Injecting DLL into a running thread
Posted on 2004-04-12
(C# code calling C++ dll that uses Assembly instructions, which hooks directly into the Win32 API...Yup, I'm going to hell). Ok, Dr. Ryan wants to work on a live patient. I know that SetWindowsHookEx will let me throw a dll into a live thread.
1.) Is this correct:
public static extern IntPtr SetWindowsHookEx(int idHook, HOOKPROC callback, IntPtr hMod, IntPtr dwThreadId);
2.) How do I get info I need to attach to a process, say Notepad.exe. (ThreadID, hMod).
3.) How do I call functions for the dll that is attached to the process? (call it normally....or).
Code that needs for the hook to work properly (called once per thread):
IntPtr hook = PaintHook.CreatePaintHook();
Code that should be called at my leisure (repeatedly):
I cannot call this dll with hWnd of the process externally. It needs to be called internally. Something about GDI not liking process boundries.