hook stretchblt

This commit is contained in:
FunkyFr3sh 2022-10-02 18:41:06 +02:00
parent 1cbfe2d926
commit c9262a5ee9
5 changed files with 51 additions and 1 deletions

View file

@ -254,7 +254,7 @@ HRESULT dds_Blt(
}
else
{
StretchBlt(dst_dc, dst_x, dst_y, dst_w, dst_h, src_dc, src_x, src_y, src_w, src_h, SRCCOPY);
real_StretchBlt(dst_dc, dst_x, dst_y, dst_w, dst_h, src_dc, src_x, src_y, src_w, src_h, SRCCOPY);
}
/*

View file

@ -40,6 +40,7 @@ CREATEWINDOWEXAPROC real_CreateWindowExA = CreateWindowExA;
DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow;
MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints;
SHOWWINDOWPROC real_ShowWindow = ShowWindow;
STRETCHBLTPROC real_StretchBlt = StretchBlt;
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA;
@ -82,6 +83,7 @@ static HOOKLIST g_hooks[] =
{
"gdi32.dll",
{
{ "StretchBlt", (PROC)fake_StretchBlt, (PROC*)&real_StretchBlt, SKIP_HOOK2 | SKIP_HOOK3 },
{ "GetDeviceCaps", (PROC)fake_GetDeviceCaps, (PROC*)&real_GetDeviceCaps, SKIP_HOOK3 },
{ "", NULL, NULL, 0 }
}
@ -394,6 +396,7 @@ void hook_create(HOOKLIST* hooks, BOOL initial_hook)
continue;
if (_strnicmp(game_dir, mod_dir, strlen(game_dir)) == 0 ||
_strcmpi(mod_filename, "MSVFW32") == 0 ||
_strcmpi(mod_filename, "quartz") == 0 ||
_strcmpi(mod_filename, "winmm") == 0)
{
@ -470,6 +473,7 @@ void hook_revert(HOOKLIST* hooks)
_splitpath(mod_path, NULL, mod_dir, mod_filename, NULL);
if (_strnicmp(game_dir, mod_dir, strlen(game_dir)) == 0 ||
_strcmpi(mod_filename, "MSVFW32") == 0 ||
_strcmpi(mod_filename, "quartz") == 0 ||
_strcmpi(mod_filename, "winmm") == 0)
{

View file

@ -11,6 +11,7 @@
#include "mouse.h"
#include "wndproc.h"
#include "render_gdi.h"
#include "ddsurface.h"
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
@ -545,6 +546,37 @@ int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
return real_GetDeviceCaps(hdc, 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)
{
if (g_ddraw && g_ddraw->primary && WindowFromDC(hdcDest) == g_ddraw->hwnd)
{
HDC primary_dc;
dds_GetDC(g_ddraw->primary, &primary_dc);
if (primary_dc)
{
BOOL result = real_StretchBlt(primary_dc, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
dds_ReleaseDC(g_ddraw->primary, primary_dc);
return result;
}
}
return real_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
}
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName)
{
HMODULE hmod = real_LoadLibraryA(lpLibFileName);