mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-14 22:03:27 +01:00
add separate GetDeviceCaps hook for system dlls
This commit is contained in:
parent
c5058f8371
commit
07aab3b8d2
@ -7,6 +7,7 @@
|
||||
|
||||
#define HOOK_SKIP_2 0x00000001l
|
||||
#define HOOK_LOCAL_ONLY 0x00000002l
|
||||
#define HOOK_SYSTEM_ONLY 0x00000004l
|
||||
|
||||
typedef struct HOOKLISTDATA {
|
||||
char function_name[32];
|
||||
|
@ -41,6 +41,7 @@ LRESULT WINAPI fake_DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
|
||||
SHORT WINAPI fake_GetKeyState(int nVirtKey);
|
||||
SHORT WINAPI fake_GetAsyncKeyState(int vKey);
|
||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||
int WINAPI fake_GetDeviceCaps_system(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);
|
||||
|
@ -174,6 +174,7 @@ HOOKLIST g_hook_hooklist[] =
|
||||
{ "SetDIBitsToDevice", (PROC)fake_SetDIBitsToDevice, (PROC*)&real_SetDIBitsToDevice, HOOK_SKIP_2 },
|
||||
{ "StretchDIBits", (PROC)fake_StretchDIBits, (PROC*)&real_StretchDIBits, HOOK_SKIP_2 },
|
||||
{ "GetDeviceCaps", (PROC)fake_GetDeviceCaps, (PROC*)&real_GetDeviceCaps, HOOK_LOCAL_ONLY },
|
||||
{ "GetDeviceCaps", (PROC)fake_GetDeviceCaps_system, NULL, HOOK_SYSTEM_ONLY },
|
||||
{ "CreateFontA", (PROC)fake_CreateFontA, (PROC*)&real_CreateFontA, 0 },
|
||||
{ "GetSystemPaletteEntries", (PROC)fake_GetSystemPaletteEntries, (PROC*)&real_GetSystemPaletteEntries, 0 },
|
||||
{ "SelectPalette", (PROC)fake_SelectPalette, (PROC*)&real_SelectPalette, 0 },
|
||||
@ -289,6 +290,9 @@ void hook_patch_obfuscated_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks,
|
||||
if (!is_local && (hooks[i].data[x].flags & HOOK_LOCAL_ONLY))
|
||||
continue;
|
||||
|
||||
if (is_local && (hooks[i].data[x].flags & HOOK_SYSTEM_ONLY))
|
||||
continue;
|
||||
|
||||
if (unhook)
|
||||
{
|
||||
if (first_thunk->u1.Function == (DWORD)hooks[i].data[x].new_function)
|
||||
@ -407,6 +411,9 @@ void hook_patch_iat_list(HMODULE hmod, BOOL unhook, HOOKLIST* hooks, BOOL is_loc
|
||||
if (!is_local && (hooks[i].data[x].flags & HOOK_LOCAL_ONLY))
|
||||
continue;
|
||||
|
||||
if (is_local && (hooks[i].data[x].flags & HOOK_SYSTEM_ONLY))
|
||||
continue;
|
||||
|
||||
#if defined(__GNUC__)
|
||||
if (util_is_bad_read_ptr((void*)import->Name))
|
||||
continue;
|
||||
|
@ -956,6 +956,21 @@ int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
|
||||
return real_GetDeviceCaps(hdc, index);
|
||||
}
|
||||
|
||||
int WINAPI fake_GetDeviceCaps_system(HDC hdc, int index)
|
||||
{
|
||||
if (g_ddraw.ref &&
|
||||
g_ddraw.bpp == 8 &&
|
||||
((g_ddraw.hwnd && WindowFromDC(hdc) == g_ddraw.hwnd) || WindowFromDC(hdc) == GetDesktopWindow()))
|
||||
{
|
||||
if (index == RASTERCAPS)
|
||||
{
|
||||
return RC_PALETTE | real_GetDeviceCaps(hdc, index);
|
||||
}
|
||||
}
|
||||
|
||||
return real_GetDeviceCaps(hdc, index);
|
||||
}
|
||||
|
||||
BOOL WINAPI fake_StretchBlt(
|
||||
HDC hdcDest,
|
||||
int xDest,
|
||||
|
Loading…
x
Reference in New Issue
Block a user