Some time ago, I was doing myself a windows hook with Object Pascal (Delphi) and it worked correctly, but now, I've been working on a hook that doesn't work at all. In the hook procedure, in the dynamic library
i put this little code in the header file :
extern "C" {
HOOKDLL_API LRESULT CALLBACK WndHKK(int code, WPARAM _key, LPARAM _other);
}
and in the source file i put this one :
__declspec(dllexport) LRESULT CALLBACK hookproc(int code, WPARAM _key, LPARAM _other)
{
return CallNextHookEx(_h, code, _key, _other);
}
Then, for the test program I wrote the following code :
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG m;
HHOOK hook;
HMODULE lib = LoadLibrary("HookDLL.dll");
HOOKPROC proc = (HOOKPROC)GetProcAddress(lib, "LInit"); // It returned the
if (!(hook = SetWindowsHookEx(WH_KEYBOARD, proc, lib, 0)))
{
HOOKERROR;
return 0;
}
SendMessage((HWND)hInstance, WM_KEYDOWN, 98, 0);
while (GetMessage(&m, 0, 0, 0))
{
TranslateMessage(&m);
DispatchMessage(&m);
}
UnhookWindowsHookEx(hook);
return 0;
}
And the GetProcAddress didn't gave me the value I had expected ...
Later I tried loading the library implicitly with the process, and it work
correctly creating the HOOK but when I test it debbuging from the DLL I realised
that it didn't passing through the code in the DLL. Please , help me quickly