diff --git a/DDrawCompat/Gdi/Dc.cpp b/DDrawCompat/Gdi/Dc.cpp index 5a1d164..b74e7b4 100644 --- a/DDrawCompat/Gdi/Dc.cpp +++ b/DDrawCompat/Gdi/Dc.cpp @@ -178,7 +178,7 @@ namespace Gdi HDC getDc(HDC origDc, bool useMetaRgn) { - if (!origDc || OBJ_DC != GetObjectType(origDc) || DT_RASDISPLAY != GetDeviceCaps(origDc, TECHNOLOGY)) + if (!isDisplayDc(origDc)) { return nullptr; } diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp index 13af1c8..dede8c4 100644 --- a/DDrawCompat/Gdi/Gdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -47,7 +47,14 @@ namespace Gdi void installHooks() { - g_screenDc = GetDC(nullptr); + // Workaround for VirtualizeDesktopPainting shim, which doesn't seem to handle BitBlt + // from screen DC to screen DC correctly + auto getDc = reinterpret_cast(Compat::getProcAddress(GetModuleHandle("user32"), "GetDC")); + if (!getDc) + { + getDc = &GetDC; + } + g_screenDc = getDc(nullptr); DcFunctions::installHooks(); PaintHandlers::installHooks(); @@ -60,7 +67,7 @@ namespace Gdi bool isDisplayDc(HDC dc) { - return dc && OBJ_DC == GetObjectType(dc) && DT_RASDISPLAY == GetDeviceCaps(dc, TECHNOLOGY) && + return dc && OBJ_DC == GetObjectType(dc) && DT_RASDISPLAY == CALL_ORIG_FUNC(GetDeviceCaps)(dc, TECHNOLOGY) && !(GetWindowLongPtr(CALL_ORIG_FUNC(WindowFromDC)(dc), GWL_EXSTYLE) & WS_EX_LAYERED); } diff --git a/DDrawCompat/Gdi/PaintHandlers.cpp b/DDrawCompat/Gdi/PaintHandlers.cpp index 4bc9836..0af46ea 100644 --- a/DDrawCompat/Gdi/PaintHandlers.cpp +++ b/DDrawCompat/Gdi/PaintHandlers.cpp @@ -132,15 +132,6 @@ namespace LRESULT WINAPI defWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - if (WM_CREATE == msg) - { - auto className = reinterpret_cast(lParam)->lpszClass; - if (reinterpret_cast(className) > 0xFFFF && - 0 == lstrcmpW(className, L"CompatWindowDesktopReplacement")) - { - return -1; - } - } return defPaintProc(hwnd, msg, wParam, lParam, CALL_ORIG_FUNC(DefWindowProcW), "defWindowProcW"); } diff --git a/DDrawCompat/Win32/DisplayMode.cpp b/DDrawCompat/Win32/DisplayMode.cpp index 7f35518..c10b082 100644 --- a/DDrawCompat/Win32/DisplayMode.cpp +++ b/DDrawCompat/Win32/DisplayMode.cpp @@ -5,6 +5,7 @@ #include "Common/Hook.h" #include "DDraw/DirectDraw.h" #include "DDraw/ScopedThreadLock.h" +#include "Gdi/Gdi.h" #include "Win32/DisplayMode.h" BOOL WINAPI DWM8And16Bit_IsShimApplied_CallOut() { return FALSE; }; @@ -279,8 +280,7 @@ namespace int WINAPI getDeviceCaps(HDC hdc, int nIndex) { LOG_FUNC("GetDeviceCaps", hdc, nIndex); - if (hdc && BITSPIXEL == nIndex && - DT_RASDISPLAY == GetDeviceCaps(hdc, TECHNOLOGY) && OBJ_DC == GetObjectType(hdc)) + if (BITSPIXEL == nIndex && Gdi::isDisplayDc(hdc)) { return LOG_RESULT(g_currentBpp); }