diff --git a/inc/hook.h b/inc/hook.h index 219361c..bbab6da 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -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]; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index 3d2cbae..6c6cbb1 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -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); diff --git a/src/hook.c b/src/hook.c index 7d90641..1e4bf14 100644 --- a/src/hook.c +++ b/src/hook.c @@ -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; diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index fb27c02..50551a3 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -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,