1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

hook SetDIBitsToDevice

This commit is contained in:
FunkyFr3sh 2022-10-03 12:19:15 +02:00
parent 707239ba61
commit 2a8a5f85ec
4 changed files with 56 additions and 11 deletions

View File

@ -35,6 +35,8 @@ 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 int (WINAPI* SETDIBITSTODEVICEPROC)(
HDC, int, int, DWORD, DWORD, int, int, UINT, UINT, const VOID*, const BITMAPINFO*, UINT);
typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int);
typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR);
@ -67,6 +69,7 @@ extern DESTROYWINDOWPROC real_DestroyWindow;
extern MAPWINDOWPOINTSPROC real_MapWindowPoints;
extern SHOWWINDOWPROC real_ShowWindow;
extern STRETCHBLTPROC real_StretchBlt;
extern SETDIBITSTODEVICEPROC real_SetDIBitsToDevice;
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
extern GETDEVICECAPSPROC real_GetDeviceCaps;
extern LOADLIBRARYAPROC real_LoadLibraryA;

View File

@ -30,17 +30,9 @@ 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);
HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
int WINAPI fake_SetDIBitsToDevice(
HDC, int, int, DWORD, DWORD, int, int, UINT, UINT, const VOID*, const BITMAPINFO*, UINT);
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);

View File

@ -41,6 +41,7 @@ DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow;
MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints;
SHOWWINDOWPROC real_ShowWindow = ShowWindow;
STRETCHBLTPROC real_StretchBlt = StretchBlt;
SETDIBITSTODEVICEPROC real_SetDIBitsToDevice = SetDIBitsToDevice;
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA;
@ -84,6 +85,7 @@ static HOOKLIST g_hooks[] =
"gdi32.dll",
{
{ "StretchBlt", (PROC)fake_StretchBlt, (PROC*)&real_StretchBlt, SKIP_HOOK2 | SKIP_HOOK3 },
{ "SetDIBitsToDevice", (PROC)fake_SetDIBitsToDevice, (PROC*)&real_SetDIBitsToDevice, SKIP_HOOK2 | SKIP_HOOK3 },
{ "GetDeviceCaps", (PROC)fake_GetDeviceCaps, (PROC*)&real_GetDeviceCaps, SKIP_HOOK3 },
{ "", NULL, NULL, 0 }
}

View File

@ -598,6 +598,54 @@ BOOL WINAPI fake_StretchBlt(
return real_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
}
int WINAPI fake_SetDIBitsToDevice(
HDC hdc,
int xDest,
int yDest,
DWORD w,
DWORD h,
int xSrc,
int ySrc,
UINT StartScan,
UINT cLines,
const VOID* lpvBits,
const BITMAPINFO* lpbmi,
UINT ColorUse)
{
if (g_ddraw && WindowFromDC(hdc) == g_ddraw->hwnd)
{
if (g_ddraw->primary)
{
HDC primary_dc;
dds_GetDC(g_ddraw->primary, &primary_dc);
if (primary_dc)
{
BOOL result =
real_SetDIBitsToDevice(
primary_dc,
xDest,
yDest,
w,
h,
xSrc,
ySrc,
StartScan,
cLines,
lpvBits,
lpbmi,
ColorUse);
dds_ReleaseDC(g_ddraw->primary, primary_dc);
return result;
}
}
}
return real_SetDIBitsToDevice(hdc, xDest, yDest, w, h, xSrc, ySrc, StartScan, cLines, lpvBits, lpbmi, ColorUse);
}
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName)
{
HMODULE hmod = real_LoadLibraryA(lpLibFileName);