diff --git a/inc/hook.h b/inc/hook.h index 299ac75721..235d579993 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -65,6 +65,7 @@ typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int); typedef HFONT(WINAPI* CREATEFONTINDIRECTAPROC)(CONST LOGFONT*); typedef HFONT(WINAPI* CREATEFONTAPROC)(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR); typedef UINT(WINAPI* GETSYSTEMPALETTEENTRIESPROC)(HDC, UINT, UINT, LPPALETTEENTRY); +typedef HPALETTE(WINAPI* SELECTPALETTEPROC)(HDC, HPALETTE, BOOL); typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR); typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR); @@ -119,6 +120,7 @@ extern GETDEVICECAPSPROC real_GetDeviceCaps; extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA; extern CREATEFONTAPROC real_CreateFontA; extern GETSYSTEMPALETTEENTRIESPROC real_GetSystemPaletteEntries; +extern SELECTPALETTEPROC real_SelectPalette; extern LOADLIBRARYAPROC real_LoadLibraryA; extern LOADLIBRARYWPROC real_LoadLibraryW; extern LOADLIBRARYEXAPROC real_LoadLibraryExA; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index 3569abb038..ccbea4bfd6 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -59,6 +59,7 @@ int WINAPI fake_StretchDIBits( HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA*); HFONT WINAPI fake_CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR); UINT WINAPI fake_GetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY); +HPALETTE WINAPI fake_SelectPalette(HDC, HPALETTE, BOOL); HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName); HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName); diff --git a/src/hook.c b/src/hook.c index 3229a3a336..f73f31c438 100644 --- a/src/hook.c +++ b/src/hook.c @@ -58,6 +58,7 @@ GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps; CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA; CREATEFONTAPROC real_CreateFontA = CreateFontA; GETSYSTEMPALETTEENTRIESPROC real_GetSystemPaletteEntries = GetSystemPaletteEntries; +SELECTPALETTEPROC real_SelectPalette = SelectPalette; LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA; LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW; LOADLIBRARYEXAPROC real_LoadLibraryExA = LoadLibraryExA; @@ -151,6 +152,7 @@ HOOKLIST g_hook_hooklist[] = { "GetDeviceCaps", (PROC)fake_GetDeviceCaps, (PROC*)&real_GetDeviceCaps, HOOK_LOCAL_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 }, { "CreateFontIndirectA", (PROC)fake_CreateFontIndirectA, (PROC*)&real_CreateFontIndirectA, 0 }, { "", NULL, NULL, 0 } } diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index efa2daca7d..207cabbbe2 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -1385,6 +1385,24 @@ UINT WINAPI fake_GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LP return real_GetSystemPaletteEntries(hdc, iStart, cEntries, pPalEntries); } +HPALETTE WINAPI fake_SelectPalette(HDC hdc, HPALETTE hPal, BOOL bForceBkgd) +{ + if (g_ddraw.ref && g_ddraw.bpp == 8 && WindowFromDC(hdc) == g_ddraw.hwnd) + { + if (g_ddraw.primary && g_ddraw.primary->palette) + { + TRACE("%s [%p]\n", __FUNCTION__, _ReturnAddress()); + + PALETTEENTRY pal[256]; + GetPaletteEntries(hPal, 0, 256, pal); + + ddp_SetEntries(g_ddraw.primary->palette, 0, 0, 256, pal); + } + } + + return real_SelectPalette(hdc, hPal, bForceBkgd); +} + HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName) { HMODULE hmod_old = GetModuleHandleA(lpLibFileName);