Jump hook

This commit is contained in:
Diavolo 2021-07-28 13:48:46 +02:00
parent ff50ecfddf
commit ecf44c8580
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 37 additions and 8 deletions

View File

@ -221,7 +221,7 @@ namespace Components
// Patches team overhead normally
signed int __cdecl Colors::Dvar_GetUnpackedColorByName(const char* name, float* color)
int Colors::Dvar_GetUnpackedColorByName(const char* name, float* color)
{
if (Colors::ColorBlind.get<bool>())
{
@ -244,18 +244,46 @@ namespace Components
}
}
return Utils::Hook::Call<signed int(const char*, float*)>(0x406530)(name, color);
return 1;
}
__declspec(naked) void Colors::GetUnpackedColorByNameStub()
{
__asm
{
push eax
pushad
push [esp + 2Ch]
push [esp + 2Ch];
call Colors::Dvar_GetUnpackedColorByName
add esp, 8h
mov [esp + 20h], eax
popad
pop eax
test eax, eax
jnz continue
xor eax, eax
retn
continue:
push edi
mov edi, dword ptr[esp + 4h]
push 406535h
retn
}
}
Colors::Colors()
{
// Add a colorblind mode for team colors
Colors::ColorBlind = Dvar::Register<bool>("r_colorBlindTeams", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use color-blindness-friendly colors for ingame team names");
Utils::Hook(0x4C09BE, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick();
Utils::Hook(0x583661, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick();
Utils::Hook(0x5836A5, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick();
Utils::Hook(0x4264FC, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick();
Utils::Hook(0x4264E5, Colors::Dvar_GetUnpackedColorByName, HOOK_CALL).install()->quick();
Utils::Hook(0x406530, Colors::GetUnpackedColorByNameStub, HOOK_JUMP).install()->quick();
// Disable SV_UpdateUserinfo_f, to block changing the name ingame
Utils::Hook::Set<BYTE>(0x6258D0, 0xC3);

View File

@ -36,7 +36,8 @@ namespace Components
static void LookupColor(DWORD* color, char index);
static void LookupColorStub();
static char* CleanStrStub(char* string);
static signed int Dvar_GetUnpackedColorByName(const char* name, float* color);
static int Dvar_GetUnpackedColorByName(const char* name, float* color);
static void GetUnpackedColorByNameStub();
static std::vector<DWORD> ColorTable;
};
}