From 5882ef9f9c702e3f6f536db21e65914a78fec393 Mon Sep 17 00:00:00 2001 From: narzoul Date: Mon, 15 Mar 2021 12:33:31 +0100 Subject: [PATCH] Install window hooks from presentation window thread --- DDrawCompat/Gdi/Gdi.cpp | 1 - DDrawCompat/Gdi/PresentationWindow.cpp | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp index 047c61f..1e9e9d7 100644 --- a/DDrawCompat/Gdi/Gdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -45,7 +45,6 @@ namespace Gdi PresentationWindow::installHooks(); ScrollFunctions::installHooks(); User32WndProcs::installHooks(); - WinProc::installHooks(); Caret::installHooks(); Font::installHooks(); } diff --git a/DDrawCompat/Gdi/PresentationWindow.cpp b/DDrawCompat/Gdi/PresentationWindow.cpp index f7aa5d0..3fa6b01 100644 --- a/DDrawCompat/Gdi/PresentationWindow.cpp +++ b/DDrawCompat/Gdi/PresentationWindow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace { @@ -91,9 +92,12 @@ namespace "DDrawCompatMessageWindow", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, nullptr); if (!g_messageWindow) { + Compat::Log() << "ERROR: Failed to create a message-only window"; return 0; } + Gdi::WinProc::installHooks(); + MSG msg = {}; while (GetMessage(&msg, nullptr, 0, 0)) { @@ -136,18 +140,6 @@ namespace Gdi CALL_ORIG_FUNC(RegisterClassA)(&wc); Dll::createThread(presentationWindowThreadProc, &g_presentationWindowThreadId, THREAD_PRIORITY_TIME_CRITICAL); - - int i = 0; - while (!g_messageWindow && i < 1000) - { - Sleep(1); - ++i; - } - - if (!g_messageWindow) - { - Compat::Log() << "ERROR: Failed to create a message-only window"; - } } bool isPresentationWindow(HWND hwnd)