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;