mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
hook stretchblt
This commit is contained in:
parent
1cbfe2d926
commit
c9262a5ee9
@ -34,6 +34,7 @@ typedef HWND(WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int
|
||||
typedef BOOL(WINAPI* DESTROYWINDOWPROC)(HWND);
|
||||
typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT);
|
||||
typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int);
|
||||
typedef BOOL(WINAPI* STRETCHBLTPROC)(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
|
||||
typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
|
||||
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
|
||||
typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR);
|
||||
@ -65,6 +66,7 @@ extern CREATEWINDOWEXAPROC real_CreateWindowExA;
|
||||
extern DESTROYWINDOWPROC real_DestroyWindow;
|
||||
extern MAPWINDOWPOINTSPROC real_MapWindowPoints;
|
||||
extern SHOWWINDOWPROC real_ShowWindow;
|
||||
extern STRETCHBLTPROC real_StretchBlt;
|
||||
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
|
||||
extern GETDEVICECAPSPROC real_GetDeviceCaps;
|
||||
extern LOADLIBRARYAPROC real_LoadLibraryA;
|
||||
|
@ -29,6 +29,18 @@ int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UI
|
||||
BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow);
|
||||
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
|
||||
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);
|
||||
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user