Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spying on another process

Status
Not open for further replies.

phinoppix

Programmer
Jul 24, 2002
437
US
Hi all,

Am trying to build a small C# app that will allow me to hook on other processes so I can peek on any controls' properties of an open window via reflection (obviously, targeted processes must be managed apps only).

I have build almost everything I need -- managed process filters & managed wrappers for memory mapped files. Just one left: the component that will install a global hook so I can insert my spy DLL to that other process's memory space. I'm planning to use SetWindowsEx but there is a limitation.
Code:
HHOOK SetWindowsHookEx(
    int idHook,
    HOOKPROC lpfn,
    HINSTANCE hMod,
    DWORD dwThreadId
);
If dwThreadId belongs to another process, hMod must be a handle of a *native* DLL that will be inserted into the memory space of dwThreadId. (But, I'm trying to keep everything 100% managed).

I'm aware I can use C++ to build an unsafe DLL to handle the global hooks for me, but I'm hoping to use pure C# for maintenance reasons.

I'd appreciate any help or tips on how I can achieve a pure C# solution, if possible.

TIA [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top