I know this has been asked before but I can't find a similar example...
I want to hook an exe (not my own) to see when the WM_MOUSEMOVE message is processed. I know I need a dll but I don't know the right API calls in the dll or my own exe.
Printable View
I know this has been asked before but I can't find a similar example...
I want to hook an exe (not my own) to see when the WM_MOUSEMOVE message is processed. I know I need a dll but I don't know the right API calls in the dll or my own exe.
The right API calls?
Well let's look at the DLL file first. The heart of it lies in the MouseProc function. In addition to the callback, you need to speicfy it for export.
In Visual C++, I use:
Next, you create your EXE project. Use LoadLibrary() to load your newly created DLL, and use GetProcAddress() to obtain a pointer to your callback function. Now the tricky part, here, is getting the "true" name of the callback after the DLL has been compiled. Usually it's similar to _MouseProc@12 . Use Dependancy Walker to get this name.Code:extern "C" __declspec(dllexport) LRESULT CALLBACK MouseProc(.......)
Once you obtain the function pointer, simply pass it to SetWindowsHookEx and you're set.
Give that a shot, and let me know if you run into any problemsCode:SetWindowsHookEx(WH_MOUSE, lpfnCallback, hModule, 0)