[TextRenderer]: Added hooks for UI_GetFontHandle function

This commit is contained in:
JerryALT 2024-03-29 20:03:24 +03:00
parent f319fe20bb
commit 2c353466ef
2 changed files with 155 additions and 0 deletions

View File

@ -252,6 +252,137 @@ namespace Components
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub1()
{
const static uint32_t retn_addr = 0x410E3A;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub2()
{
const static uint32_t retn_addr = 0x41B649;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub3()
{
const static uint32_t retn_addr = 0x43A21D;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub4()
{
const static uint32_t retn_addr = 0x56DFAF;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub5()
{
const static uint32_t retn_addr = 0x56E813;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub6()
{
const static uint32_t retn_addr = 0x56ED1B;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub7()
{
const static uint32_t retn_addr = 0x56EFCF;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub8()
{
const static uint32_t retn_addr = 0x56F911;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub9()
{
const static uint32_t retn_addr = 0x57056F;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
void __declspec(naked) TextRenderer::UI_GetFontHandleStub10()
{
const static uint32_t retn_addr = 0x570805;
__asm
{
push ecx; //scrPlace
push eax; //fontEnum
call Game::UI_GetFontHandle;
add esp, 8;
jmp retn_addr;
}
}
TextRenderer::TextRenderer()
{
Utils::Hook(0x56E613, R_TextWidth_Stub01, HOOK_JUMP).install()->quick();
@ -267,5 +398,18 @@ namespace Components
// Converting a simple 'reload' text to a text with keybind localized
Utils::Hook(0x40A1EB, CG_DrawPlayerWeaponLowAmmoWarningStub, HOOK_JUMP).install()->quick();
// Replacing the original function on custom.
// P.S: Very bad hooks
Utils::Hook(0x410E35, UI_GetFontHandleStub1, HOOK_JUMP).install()->quick();
Utils::Hook(0x41B644, UI_GetFontHandleStub2, HOOK_JUMP).install()->quick();
Utils::Hook(0x43A218, UI_GetFontHandleStub3, HOOK_JUMP).install()->quick();
Utils::Hook(0x56DFAA, UI_GetFontHandleStub4, HOOK_JUMP).install()->quick();
Utils::Hook(0x56E80E, UI_GetFontHandleStub5, HOOK_JUMP).install()->quick();
Utils::Hook(0x56ED16, UI_GetFontHandleStub6, HOOK_JUMP).install()->quick();
Utils::Hook(0x56EFCA, UI_GetFontHandleStub7, HOOK_JUMP).install()->quick();
Utils::Hook(0x56F90C, UI_GetFontHandleStub8, HOOK_JUMP).install()->quick();
Utils::Hook(0x57056A, UI_GetFontHandleStub9, HOOK_JUMP).install()->quick();
Utils::Hook(0x570800, UI_GetFontHandleStub10, HOOK_JUMP).install()->quick();
}
}

View File

@ -26,6 +26,17 @@ namespace Components
static const char* CG_DrawPlayerWeaponLowAmmoKey(const char* pszInputBuffer, const char* pszMessageType, int errType);
static void UI_GetKeyBindingLocalizedStringStub();
static void UI_GetFontHandleStub1();
static void UI_GetFontHandleStub2();
static void UI_GetFontHandleStub3();
static void UI_GetFontHandleStub4();
static void UI_GetFontHandleStub5();
static void UI_GetFontHandleStub6();
static void UI_GetFontHandleStub7();
static void UI_GetFontHandleStub8();
static void UI_GetFontHandleStub9();
static void UI_GetFontHandleStub10();
static int R_TextWidth_Hk(const char* text, int maxChars, Game::Font_s* font);
static float DrawHudIcon(const char* text, const Game::Font_s* font, const float x, const float y, const float sinAngle, const float cosAngle, const float xScale, const float yScale, Game::GfxColor color);
};