diff --git a/src/Components/Modules/Colors.cpp b/src/Components/Modules/Colors.cpp index fef490fb..9fe4c4f4 100644 --- a/src/Components/Modules/Colors.cpp +++ b/src/Components/Modules/Colors.cpp @@ -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()) { @@ -244,18 +244,46 @@ namespace Components } } - return Utils::Hook::Call(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("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(0x6258D0, 0xC3); diff --git a/src/Components/Modules/Colors.hpp b/src/Components/Modules/Colors.hpp index 638ce070..bc38391a 100644 --- a/src/Components/Modules/Colors.hpp +++ b/src/Components/Modules/Colors.hpp @@ -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 ColorTable; }; }