1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Workaround for VirtualizeDesktopPainting shim

This commit is contained in:
narzoul 2018-12-30 12:23:21 +01:00
parent 403037c0da
commit c1b35e0434
4 changed files with 12 additions and 14 deletions

View File

@ -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;
}

View File

@ -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<decltype(GetDC)*>(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);
}

View File

@ -132,15 +132,6 @@ namespace
LRESULT WINAPI defWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (WM_CREATE == msg)
{
auto className = reinterpret_cast<CREATESTRUCTW*>(lParam)->lpszClass;
if (reinterpret_cast<DWORD>(className) > 0xFFFF &&
0 == lstrcmpW(className, L"CompatWindowDesktopReplacement"))
{
return -1;
}
}
return defPaintProc(hwnd, msg, wParam, lParam, CALL_ORIG_FUNC(DefWindowProcW), "defWindowProcW");
}

View File

@ -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);
}