From 9ced91af14c6f627d58341f5bd01cacf2ea890d5 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 27 May 2024 01:15:30 +0200 Subject: [PATCH] add experimental wing32 hooks --- inc/winapi_hooks.h | 6 ++++++ src/hook.c | 10 ++++++++++ src/winapi_hooks.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index d7e6efe..3608cc2 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -40,6 +40,12 @@ int WINAPI fake_GetDeviceCaps(HDC hdc, int index); BOOL WINAPI fake_StretchBlt( HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop); +BOOL WINAPI fake_WinGStretchBlt( + HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc); + +BOOL WINAPI fake_WinGBitBlt( + HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1); + BOOL WINAPI fake_BitBlt( HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop); diff --git a/src/hook.c b/src/hook.c index 1b2efb3..b6653a8 100644 --- a/src/hook.c +++ b/src/hook.c @@ -138,6 +138,16 @@ HOOKLIST g_hook_hooklist[] = { "", NULL, NULL, 0 } } }, + /* + { + "WING32.DLL", + { + { "WinGBitBlt", (PROC)fake_WinGBitBlt, NULL, HOOK_SKIP_2 }, + { "WinGStretchBlt", (PROC)fake_WinGStretchBlt, NULL, HOOK_SKIP_2 }, + { "", NULL, NULL, 0 } + } + }, + */ { "kernel32.dll", { diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index c530b43..33399ac 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -823,6 +823,21 @@ BOOL WINAPI fake_StretchBlt( return real_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop); } +BOOL WINAPI fake_WinGStretchBlt( + HDC hdcDest, + int xDest, + int yDest, + int wDest, + int hDest, + HDC hdcSrc, + int xSrc, + int ySrc, + int wSrc, + int hSrc) +{ + return fake_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, SRCCOPY); +} + BOOL WINAPI fake_BitBlt( HDC hdc, int x, @@ -860,11 +875,39 @@ BOOL WINAPI fake_BitBlt( return result; } } + else if (g_ddraw.width > 0 && g_ddraw.render.hdc) + { + return real_StretchBlt( + g_ddraw.render.hdc, + x + g_ddraw.render.viewport.x, + y + g_ddraw.render.viewport.y, + (int)(cx * g_ddraw.render.scale_w), + (int)(cy * g_ddraw.render.scale_h), + hdcSrc, + x1, + y1, + cx, + cy, + rop); + } } return real_BitBlt(hdc, x, y, cx, cy, hdcSrc, x1, y1, rop); } +BOOL WINAPI fake_WinGBitBlt( + HDC hdc, + int x, + int y, + int cx, + int cy, + HDC hdcSrc, + int x1, + int y1) +{ + return fake_BitBlt(hdc, x, y, cx, cy, hdcSrc, x1, y1, SRCCOPY); +} + int WINAPI fake_SetDIBitsToDevice( HDC hdc, int xDest,