Page 1 of 1

Start process with SetWindowsHookEx

Posted: Wed May 12, 2004 11:46 am
by nildo
Hello Mathias!
Is there a way to start a process with a single SetWindowsHookEx DLL kind, injected?

Like the CreateProcessEx, but with not a MadCodeHook DLL. Thank you!

Posted: Wed May 12, 2004 5:57 pm
by madshi
I'm sorry but I don't understand what you mean... :confused:

Posted: Wed May 12, 2004 6:19 pm
by nildo
FOr example:

I have a DLL witch has a Windows Hook to catch WH_GETMESSAGE (just for example). And this hook is instaled by SetWindowsHookEX. Is there a way to start a new process, that will get started with my hook installed?

Posted: Wed May 12, 2004 7:19 pm
by madshi
Ehm, just call CreateProcess? I'm still not sure what you mean...

Posted: Wed May 12, 2004 7:34 pm
by nildo
Erm, lemme try to explain...

My program has a menu: "INJECT INTO PROCESS ->", that will inject my DLL into an openned process. BUt this DLL is a single HW_GETMESSAGE hook. So I inject it using SetWindowsHookEx. Right?

But I wish to have a manu like: "INJECT INTO NEW PROCESS..." and the user will choose the EXE that he would like to start, and this process will open with my hook alread installed, like if the first line of the program is to load my HOok. :confused:

Understand?

Posted: Wed May 12, 2004 8:12 pm
by madshi
Well, you can start the process by using CreateProcess, then call WaitForInputIdle, then call SetWindowsHookEx. I guess that should work. But why don't you simply use madCodeHook? :o

Posted: Wed May 12, 2004 8:30 pm
by nildo
WaitForInputIdle -> If this process is a console application or does not have a message queue, WaitForInputIdle returns immediately. (by MSDN)

Is there a way to do for all kind of applications?

I can not use "in this case" MadCodeHook for injection, its a KeyBoardHook, and I have to keep compatibilities with some other codes. Thats because I need iimediatly, but I will port them to MadCodeHook as I will have a time

Posted: Thu May 13, 2004 6:45 am
by madshi
SetWindowsHookEx works only on GUI processes, I believe. I'm not sure whether it works with console only processes. And it definately doesn't work with "all kind of applications".

Posted: Thu May 13, 2004 11:13 am
by nildo
Thank you!!! :D