Will global interceptors work through x86 and x64

I tried to inject everything into one COM library. Currently, I have connected WH_GETMESSAGE and WH_CBT, as shown below:

BOOL TouchDetector::SetMessageHook(BOOL Install)
{
if (Install)
{
    return ((mHookMessage = ::SetWindowsHookEx(WH_GETMESSAGE, MessageHookProc, mDll, 0)) != NULL)
         && ((mHookWin = ::SetWindowsHookEx(WH_CBT, WinHookProc, mDll, 0)) != NULL);
}
else
{
    return UnhookWindowsHookEx(mHookMessage)
        && UnhookWindowsHookEx(mHookWin);
}
};

I also added generic variables as follows:

#pragma data_seg(".shared")
TouchDetector*   pTouch = nullptr;
HHOOK            mHookMessage = NULL;
HHOOK            mHookWin = NULL;
#pragma data_seg()
#pragma comment(linker,"/section:.shared,rws")

By joining explorer.exe, I see that interceptors work, but not global. I also tried SetWinEventHook, but the same result: only respond to the window I created or explorer.exe.

COM dll it self is x64, since explorer is x64. Could this be a problem?

What I was trying to archive was updating the configuration of my application when the foreground window changed. I know that I can just start another thread to follow it. But I don’t like it, at present the program only passively responds to user input or calls callbacks.

+4
1

SetWindowsHookEx :

SetWindowsHookEx DLL . 32- DLL 64- , 64- DLL 32- . , , 32- SetWindowsHookEx 32- DLL 32- 64- SetWindowsHookEx 64- DLL 64- . 32- 64- DLL .

64- Windows, 32- 64- , , .

- , , .

, DLL, 32- 64-. , WH_MOUSE, WH_KEYBOARD, WH_JOURNAL* WH_SHELL:

, WH_MOUSE, WH_KEYBOARD, WH_JOURNAL *, WH_SHELL , , , . , 32-, 64- , 32- 64- .

WH_GETMESSAGE WH_CBT DLL.

+5

Source: https://habr.com/ru/post/1535175/


All Articles