0

I'm trying to install a hook to intercept mouse and keyboard from a library to an executable. If I build the library as a Dynamically Loaded Library everything works fine, but when the I build the library as a static library it doesn't work.

To install the hook I do like this:

Get the library module handle with this function

HMODULE GetCurrentModule()
{
    return reinterpret_cast<HMODULE>(&__ImageBase);
}

Install the hook

HMODULE module = GetCurrentModule();
_windowsProcHook = SetWindowsHookEx(WH_CALLWNDPROC, WindowsProcCallback, module, NULL);

I've debugged the code and I've seen that when a build as a DLL, the module I get from GetCurrentModule is the correct one (from the DLL) but when I build as a static library GetCurrentModule returns the module of my executable.

zeb
  • 1,105
  • 2
  • 9
  • 32

0 Answers0