Results 1 to 2 of 2

Thread: hook another process

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question hook another process

    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.

  2. #2
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    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:
    Code:
    extern "C" __declspec(dllexport) LRESULT CALLBACK MouseProc(.......)
    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.

    Once you obtain the function pointer, simply pass it to SetWindowsHookEx and you're set.
    Code:
    SetWindowsHookEx(WH_MOUSE, lpfnCallback, hModule, 0)
    Give that a shot, and let me know if you run into any problems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width