mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
add hooks to fix blurry fonts
This commit is contained in:
parent
9b028e6376
commit
b50f9fff7b
@ -37,6 +37,8 @@ typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int);
|
||||
typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd);
|
||||
typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD);
|
||||
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 HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR);
|
||||
typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR);
|
||||
typedef HMODULE(WINAPI* LOADLIBRARYEXAPROC)(LPCSTR, HANDLE, DWORD);
|
||||
@ -69,6 +71,8 @@ extern SHOWWINDOWPROC real_ShowWindow;
|
||||
extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow;
|
||||
extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA;
|
||||
extern GETDEVICECAPSPROC real_GetDeviceCaps;
|
||||
extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA;
|
||||
extern CREATEFONTAPROC real_CreateFontA;
|
||||
extern LOADLIBRARYAPROC real_LoadLibraryA;
|
||||
extern LOADLIBRARYWPROC real_LoadLibraryW;
|
||||
extern LOADLIBRARYEXAPROC real_LoadLibraryExA;
|
||||
|
@ -30,6 +30,12 @@ BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow);
|
||||
BOOL WINAPI fake_SetForegroundWindow(HWND hWnd);
|
||||
HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);
|
||||
int WINAPI fake_GetDeviceCaps(HDC hdc, int index);
|
||||
HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA* lplf);
|
||||
HFONT WINAPI fake_CreateFontA(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight,
|
||||
DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet,
|
||||
DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality, DWORD fdwPitchAndFamily,
|
||||
LPCTSTR lpszFace);
|
||||
|
||||
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName);
|
||||
HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
|
||||
|
27
src/hook.c
27
src/hook.c
@ -43,12 +43,15 @@ SHOWWINDOWPROC real_ShowWindow = ShowWindow;
|
||||
SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow;
|
||||
SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA;
|
||||
GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps;
|
||||
CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA;
|
||||
CREATEFONTAPROC real_CreateFontA = CreateFontA;
|
||||
LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA;
|
||||
LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW;
|
||||
LOADLIBRARYEXAPROC real_LoadLibraryExA = LoadLibraryExA;
|
||||
LOADLIBRARYEXWPROC real_LoadLibraryExW = LoadLibraryExW;
|
||||
COCREATEINSTANCEPROC real_CoCreateInstance = CoCreateInstance;
|
||||
|
||||
|
||||
static HOOKLIST g_hooks[] =
|
||||
{
|
||||
{
|
||||
@ -497,6 +500,20 @@ void hook_init()
|
||||
{
|
||||
BOOL initial_hook = !g_hook_active;
|
||||
|
||||
if (initial_hook)
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach((PVOID*)&real_CreateFontIndirectA, (PVOID)fake_CreateFontIndirectA);
|
||||
DetourTransactionCommit();
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach((PVOID*)&real_CreateFontA, (PVOID)fake_CreateFontA);
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (initial_hook && g_hook_dinput)
|
||||
{
|
||||
@ -577,6 +594,16 @@ void hook_exit()
|
||||
{
|
||||
g_hook_active = FALSE;
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach((PVOID*)&real_CreateFontIndirectA, (PVOID)fake_CreateFontIndirectA);
|
||||
DetourTransactionCommit();
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach((PVOID*)&real_CreateFontA, (PVOID)fake_CreateFontA);
|
||||
DetourTransactionCommit();
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (g_hook_dinput)
|
||||
{
|
||||
|
@ -560,6 +560,30 @@ int WINAPI fake_GetDeviceCaps(HDC hdc, int index)
|
||||
return real_GetDeviceCaps(hdc, index);
|
||||
}
|
||||
|
||||
HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA* lplf)
|
||||
{
|
||||
LOGFONTA lf;
|
||||
memcpy(&lf, lplf, sizeof(lf));
|
||||
lf.lfQuality = NONANTIALIASED_QUALITY;
|
||||
|
||||
return real_CreateFontIndirectA(&lf);
|
||||
}
|
||||
|
||||
HFONT WINAPI fake_CreateFontA(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight,
|
||||
DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet,
|
||||
DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality, DWORD fdwPitchAndFamily,
|
||||
LPCTSTR lpszFace)
|
||||
{
|
||||
fdwQuality = NONANTIALIASED_QUALITY;
|
||||
|
||||
return
|
||||
real_CreateFontA(
|
||||
nHeight, nWidth, nEscapement, nOrientation, fnWeight,
|
||||
fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet,
|
||||
fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily,
|
||||
lpszFace);
|
||||
}
|
||||
|
||||
HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName)
|
||||
{
|
||||
HMODULE hmod = real_LoadLibraryA(lpLibFileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user