From 23f0b751b57b2dd9f6e912cec92364ff59b864b2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 9 Sep 2021 22:24:07 +0300 Subject: fix for a crappy ::GetCurrentThread call that breaks all Wait* functions --- plugins/Console/src/Console.cpp | 7 +++---- plugins/KeyboardNotify/src/main.cpp | 4 ++-- plugins/NotifyAnything/NotifyAnything.vcxproj | 5 +++++ plugins/NotifyAnything/src/main.cpp | 6 +++--- plugins/Ping/src/pingthread.cpp | 4 ++-- plugins/Popup/src/popup_thread.cpp | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/Console/src/Console.cpp b/plugins/Console/src/Console.cpp index a874f8c4cd..d6c3d5dc6e 100644 --- a/plugins/Console/src/Console.cpp +++ b/plugins/Console/src/Console.cpp @@ -891,10 +891,9 @@ static INT_PTR CALLBACK ConsoleDlgProc(HWND hwndDlg, UINT message, WPARAM wParam //////////////////////////////////////////////////////////////////////////////// - -void __cdecl ConsoleThread(void*) +static void __cdecl ConsoleThread(void*) { - MThreadHandle threadLock(g_plugin.hConsoleThread); + MThreadLock threadLock(g_plugin.hConsoleThread); CoInitialize(nullptr); HWND hwnd = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONSOLE), nullptr, ConsoleDlgProc); @@ -1210,7 +1209,7 @@ void InitConsole() LoadSettings(); - mir_forkthread(ConsoleThread); + g_plugin.hConsoleThread = mir_forkthread(ConsoleThread); HookEvent(ME_SYSTEM_PRESHUTDOWN, PreshutdownConsole); HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded); diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 321aa68a9e..322ba0ec93 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -266,7 +266,7 @@ static void __cdecl FlashThreadFunction(void*) BYTE data, unchangedLeds; Thread_SetName("KeyboardNotify: FlashThreadFunction"); - MThreadHandle threadLock(hThread); + MThreadLock threadLock(hThread); while (true) { unchangedLeds = (BYTE)(LedState(VK_PAUSE) * !bFlashLed[2] + ((LedState(VK_NUMLOCK) * !bFlashLed[0]) << 1) + ((LedState(VK_CAPITAL) * !bFlashLed[1]) << 2)); @@ -903,7 +903,7 @@ static int ModulesLoaded(WPARAM, LPARAM) mir_snwprintf(eventName, L"%s/ExitEvent", eventPrefix); hExitEvent = CreateEvent(nullptr, FALSE, FALSE, eventName); - mir_forkthread(FlashThreadFunction); + hThread = mir_forkthread(FlashThreadFunction); CreateServiceFunction(MS_KBDNOTIFY_ENABLE, EnableService); CreateServiceFunction(MS_KBDNOTIFY_DISABLE, DisableService); diff --git a/plugins/NotifyAnything/NotifyAnything.vcxproj b/plugins/NotifyAnything/NotifyAnything.vcxproj index 991f77c9a7..16d172e8cc 100644 --- a/plugins/NotifyAnything/NotifyAnything.vcxproj +++ b/plugins/NotifyAnything/NotifyAnything.vcxproj @@ -39,4 +39,9 @@ + + + Sync + + \ No newline at end of file diff --git a/plugins/NotifyAnything/src/main.cpp b/plugins/NotifyAnything/src/main.cpp index 6c0c7fb9ae..bcfee4a9b3 100644 --- a/plugins/NotifyAnything/src/main.cpp +++ b/plugins/NotifyAnything/src/main.cpp @@ -837,7 +837,7 @@ void initWinsock() void __cdecl udptcpThreadFunc(void *useUdp) { - MThreadHandle threadLock(useUdp ? g_udp_thread : g_tcp_thread); + MThreadLock threadLock(useUdp ? g_udp_thread : g_tcp_thread); try { @@ -948,8 +948,8 @@ void __cdecl udptcpThreadFunc(void *useUdp) void start_threads() { g_exit_threads = false; - mir_forkthread(udptcpThreadFunc, (void *)1); - mir_forkthread(udptcpThreadFunc); + g_udp_thread = mir_forkthread(udptcpThreadFunc, (void *)1); + g_tcp_thread = mir_forkthread(udptcpThreadFunc); } void stop_threads() diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index a57266e6f1..9921eff5d2 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -74,7 +74,7 @@ void SetProtoStatus(wchar_t *pszLabel, char *pszProto, int if_status, int new_st void __cdecl sttCheckStatusThreadProc(void*) { - MThreadHandle threadLock(status_update_thread); + MThreadLock threadLock(status_update_thread); clock_t start_t = clock(), end_t; while (!get_thread_finished()) { @@ -904,7 +904,7 @@ void InitList() ReloadFont(0, 0); - mir_forkthread(sttCheckStatusThreadProc); + status_update_thread = mir_forkthread(sttCheckStatusThreadProc); } void DeinitList() diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 76113d68ec..01eab8dbeb 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -210,7 +210,7 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA static unsigned __stdcall PopupThread(void *) { Thread_SetName("Popup: PopupThread"); - MThreadHandle threadLock(hThread); + MThreadLock threadLock(hThread); // Create manager window WNDCLASSEX wcl; -- cgit v1.2.3