From 0a05ef1174b78d7fc7519b44c0892399f47ead74 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 10 Apr 2016 20:37:00 +0200 Subject: [PATCH] Call WindowFromDC through IAT GetWindowDC(GetDC(NULL)) may return a special window with a class name of "CompatWindowDesktopReplacement". Presumably the shim engine installs an IAT hook for GetWindowDC that replaces this window handle with the normal desktop window handle. CALL_ORIG_FUNC(WindowFromDC) returns with an unpatched pointer, therefore it doesn't perform the above replacement. This results in using the replacement window's clipping region (whole screen) instead of the desktop window's clipping region (empty), and things become visible that shouldn't be, e.g. some character symbols at the top left corner of the screen when launchning Diablo II. As a workaround, WindowFromDC is used without CALL_ORIG_FUNC. --- DDrawCompat/CompatGdiDc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDrawCompat/CompatGdiDc.cpp b/DDrawCompat/CompatGdiDc.cpp index 0736d7b..f6b54f3 100644 --- a/DDrawCompat/CompatGdiDc.cpp +++ b/DDrawCompat/CompatGdiDc.cpp @@ -166,7 +166,7 @@ namespace CompatGdiDc return it->second.dc; } - const HWND hwnd = CALL_ORIG_FUNC(WindowFromDC)(origDc); + const HWND hwnd = WindowFromDC(origDc); const bool isMenuWindow = hwnd && 0x8000 == GetClassLongPtr(hwnd, GCW_ATOM); if (isMenuWindow && !isMenuPaintDc) {