Can I use SendIPCMessage from the DLLMain initialization?

c++ / delphi package - dll injection and api hooking
Post Reply
JanDoggen
Posts: 30
Joined: Thu Nov 26, 2009 11:23 am
Location: Netherlands

Can I use SendIPCMessage from the DLLMain initialization?

Post by JanDoggen »

I see no messages coming through....

procedure DllMain(reason: Integer);
begin
case reason of
DLL_PROCESS_ATTACH:
begin
// ODS('creating thread');
RegNotifyThread := TRegNotifyThread.Create(False);
RegNotifyThread.Priority := tpHigher;
RegNotifyThread.FreeOnTerminate := True;
// ODS('starting thread');
RegNotifyThread.Resume;
end;

The RegNotifyThread in its Execute method calls SendIPCMessage

Thx
Jan
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

It's a bad idea creating a thread in a hook dll. I'd strongly recommend against that. Still, of course IPC messages could come through. I can't tell why it's not working for you. Might have multiple causes. Make sure that the IPC names perfectly match.
mikec
Posts: 166
Joined: Sun Jul 16, 2006 9:01 pm
Location: UK

Post by mikec »

Hay JanDoggen,

As you still having issues with this? If so, can you post your exact SendIPCMessage code? If your making IPC calls from within DLLMain, you need to make sure you are setting the last parameter of the SendIPCMessage() function to false.

Also, as Madshi has pointed out - all documentation suggests it is a bad idea to create a thread from within DLLMain - although this mainly relates to what exactly your thread is doing and more importantly what it is loading.

HTH Mike C
Post Reply