From ecd73aa670d5df58f06c216ca50bad77bed80c8f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 11 Aug 2020 13:07:23 +1000 Subject: [PATCH] [host] windows: fix linux crosscompile --- host/platform/Windows/src/platform.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/host/platform/Windows/src/platform.c b/host/platform/Windows/src/platform.c index 3f7a870a..72d2a6a5 100644 --- a/host/platform/Windows/src/platform.c +++ b/host/platform/Windows/src/platform.c @@ -57,6 +57,10 @@ HWND MessageHWND; typedef NTSTATUS (__stdcall *ZwSetTimerResolution_t)(ULONG RequestedResolution, BOOLEAN Set, PULONG ActualResolution); static ZwSetTimerResolution_t ZwSetTimerResolution = NULL; +// linux mingw64 is missing this +typedef WINBOOL WINAPI (*PChangeWindowMessageFilterEx)(HWND hwnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); +PChangeWindowMessageFilterEx _ChangeWindowMessageFilterEx = NULL; + static void RegisterTrayIcon() { // register our TrayIcon @@ -232,7 +236,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine app.trayRestartMsg = RegisterWindowMessage("TaskbarCreated"); app.messageWnd = CreateWindowEx(0, MAKEINTATOM(class), NULL, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); - ChangeWindowMessageFilterEx(app.messageWnd, app.trayRestartMsg, MSGFLT_ALLOW, NULL); + + // this is needed so that unprivileged processes can send us this message + HMODULE user32 = GetModuleHandle("user32.dll"); + _ChangeWindowMessageFilterEx = (PChangeWindowMessageFilterEx)GetProcAddress(user32, "ChangeWindowMessageFilterEx"); + if (_ChangeWindowMessageFilterEx) + _ChangeWindowMessageFilterEx(app.messageWnd, app.trayRestartMsg, MSGFLT_ALLOW, NULL); // set the global MessageHWND = app.messageWnd;