I'm trying to call some code inside an exe from another exe via a LoadLibrary call, all of this in Delphi.
I've had a look at the following discussion on experts-exchange :
http://www.experts-exchange.com/Program ... 63413.html
and it seems it's quite possible to call _InitLib, provided one finds a way to pass the proper parameters.
Here is what I have written so far, in the loaded Exe:
TInitProc = procedure;
function GetInitLibAddr: TInitProc;
mov eax, offset SysInit.@InitLib
add eax, $007A0000
procedure Init; stdcall;
InitProc := GetInitLibAddr();
push 0 // Reserved
mov ebp, esp
mov eax, $004537E8
With this I can call the Init exported procedure from another exe which loads the one above via LoadLibrary.
However, it does not work as expected because it gives me an access violation. Value "$007A0000" is taken from the EE discussion mentioned above and the "$004537E8" value is taken from a disassembly that I made myself.
However, this does not work at all.
I know that I could create a true DLL called by both exes, but I'm still curious as to how I could achieve the above in Delphi. I know it can be done with a very basic C program, but then again, I want to use Delphi.
Any help greatly appreciated.