hooked program + DLL
A client program
I want to share data, when a winsock function run, I want to give some data to the client.
Code: Select all
The DLL:
Var
l_TestCallfromExe : pointer;
procedure Init (TestCallfromExe: pointer);
begin
l_TestCallfromExe:= TestCallfromExe;
end;
function mioAccept (s: TSocket; addr: PSockAddr; addrlen: PInteger): TSocket; stdcall;
begin
[b]l_TestCallfromExe ('dalksdasld'); // this is when I want to notice something to the controller program. And this pointer remains 12345678 instead of the set pointed value![/b]
Result := acceptNextHook(s, addr, addrlen);
end;
exports
Init;
begin
integer(@l_TestCallfromExe):= 12345678;
LoadLibrary ('wsock32.dll');
LoadLibrary ('WS2_32.dll');
CollectHooks;
HookAPI ('wsock32.dll', 'accept', @mioAccept, @acceptNextHook, 0);
.... other hooks, all returns TRUE
FlushHooks;
end.
Code: Select all
LoadLibrary ('x.dll');
@l_Init := GetProcAddress (dll, 'Init');
CreateProcessEx (nil, 'target program exe', nil, nil, false, 0, nil, nil, si, pi, 'x.dll');
l_Init (@prodecureToNotifyMe);
How to work this around? Init surely runs sooner than the hooked "accept"