add hooks to fix blurry fonts
This commit is contained in:
parent
9b028e6376
commit
b50f9fff7b
4 changed files with 61 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue