Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Global hook giving memory error

146 views
Skip to first unread message

-h-

unread,
Aug 20, 2004, 4:01:39 AM8/20/04
to
Hi.

I have a following problem.

I have installed a mouse hook for a application opened by my app. Lets say,
for WinAmp. When WinAmp receives any mouse events, a memory error occurs
(The instruction at "0x..." referenced memory at "0x....". The memory could
not be "written").

I have my hooks set in a dll file like "SetWindowsHookEx(WH_MOUSE,MouseProc,
hInstance,processThreadId);". The hInstance is received GetWindowInstance
and processThreadId by GetWindowThreadProcessId. The WinAmp window handle is
used for both.

I think this problem is in my dll file. It seems like the dll is trying to
write something to a place where it is not allowed. The hooking works for my
application window, but the hooking the opened applications will crash.

Any ideas? Thanks.

-h-

Google....@email.com

unread,
Mar 15, 2013, 11:55:30 AM3/15/13
to
The hInstance should be the hInstance of the DLL. Don't set the hook from your application, but from a procedure in your DLL and use the hInstance of the DLL, that is how to inject DLL into foreign process.
0 new messages