I have set up EasyHook to hook DrawText successfully and am having no trouble snooping the text output and sending it to my application.
Ideally, I would like to know the coordinates of where these items are destined to be printed. Granted, I'm not very good at debugging the injection DLL so I'm looking for suggestions on better debugging techniques and also possibly better ways to
look up the coordinates.
I'm not 100% sure how lpRect works. Does it provide the rectangle for the string being passed in? Or does it provide the rectangle for the entire box in which the text is to be formatted (say a listView, for example).
I used the ProcMon example as a frame to get my DrawText hook working.... this is my run function:
public void Run(RemoteHooking.IContext InContext, String InArg1)
DrawTextHook = LocalHook.Create(LocalHook.GetProcAddress("user32.dll", "DrawTextW"), new DDrawText(DrawText_Hooked), this);
* Don't forget that all hooks will start deaktivated...
* The following ensures that all threads are intercepted:
catch (Exception e)
Now we should notice our host process about this error...
// wait for host process termination...
// transmit newly monitored file accesses...
if (Queue.Count > 0)
String Package = null;
Package = Queue.ToArray();
// NET Remoting will raise an exception if host is unreachable
I've even tried declaring a local variable int i = 0, and then replacing Interface.OnDrawText(RemoteHooking.GetCurrentProcessId(), Package); with
Interface.OnDrawText(RemoteHooking.GetCurrentProcessId(), Package, i); and of course changing the subsequent OnDrawText(Int32 PID, String string) function in my application's code to OnDrawText(Int32 PID, String string, int i). This makes
my text hooking cease to work.
Basically I want to see the output of lpRect but do not know how to do this without creating local variables. I think I get what's going on in the example code, since the String class can dynamically allocate, do I need to make some functions for RECT
that can do the same? But at least, I'd like to start with passing a local variable through the Interface.
Thanks in advance!