diff --git a/src/Components/Modules/Ceg.cpp b/src/Components/Modules/Ceg.cpp index 907a9e20..4941656c 100644 --- a/src/Components/Modules/Ceg.cpp +++ b/src/Components/Modules/Ceg.cpp @@ -4,7 +4,7 @@ namespace Components { Ceg::Ceg() { - Utils::Hook::Signature signature(0x401000, 0x740000); + Utils::Hook::Signature signature(0x401000, 0x340000); // Generic killer caller. signature.add({ @@ -45,5 +45,11 @@ namespace Components Utils::Hook::Set(0x4F4CF0, 0xC3); Utils::Hook::Set(0x432180, 0xC3); Utils::Hook::Set(0x461930, 0xC3); + + // Looking for stuff in the registry + Utils::Hook::Nop(0x4826F8, 5); + + // Live_Init + Utils::Hook::Nop(0x420937, 5); } } diff --git a/src/Components/Modules/Debug.cpp b/src/Components/Modules/Debug.cpp index 2821d58c..9a2fc119 100644 --- a/src/Components/Modules/Debug.cpp +++ b/src/Components/Modules/Debug.cpp @@ -213,6 +213,11 @@ namespace Components } } + void Debug::Com_Assert_f() + { + assert(("a", false)); + } + void Debug::CL_InitDebugDvars() { static const char* debugOverlayNames_0[] = @@ -236,5 +241,7 @@ namespace Components // Hook end of CG_DrawDebugOverlays (This is to ensure some checks are done before our hook is executed). Utils::Hook(0x49CB0A, CG_DrawDebugOverlays_Hk, HOOK_JUMP).install()->quick(); + + Utils::Hook::Set(0x60BCEA, Com_Assert_f); } } diff --git a/src/Components/Modules/Debug.hpp b/src/Components/Modules/Debug.hpp index 5f031cfe..a3d9dfcf 100644 --- a/src/Components/Modules/Debug.hpp +++ b/src/Components/Modules/Debug.hpp @@ -31,6 +31,8 @@ namespace Components static void CG_DrawDebugOverlays_Hk(int localClientNum); + static void Com_Assert_f(); + static void CL_InitDebugDvars(); }; } diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 19f29235..0c5ee6cf 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -26,25 +26,33 @@ namespace Components void Logger::MessagePrint(const int channel, const std::string& msg) { + std::string out = msg; + + // Filter out coloured strings + if (out[0] == '^' && out[1] != '\0') + { + out = out.substr(2); + } + if (Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests()) { - printf("%s", msg.data()); + printf("%s", out.data()); fflush(stdout); return; } if (!Logger::IsConsoleReady()) { - OutputDebugStringA(msg.data()); + OutputDebugStringA(out.data()); } if (!Game::Sys_IsMainThread()) { - Logger::EnqueueMessage(msg); + Logger::EnqueueMessage(out); } else { - Game::Com_PrintMessage(channel, msg.data(), 0); + Game::Com_PrintMessage(channel, out.data(), 0); } } @@ -54,7 +62,8 @@ namespace Components const auto msg = std::vformat(fmt, args); const auto out = std::format("Debug:\n {}\nFile: {}\nLine: {}\n", msg, loc.file_name(), loc.line()); #else - const auto out = "^2" + std::vformat(fmt, args); + const auto msg = std::vformat(fmt, args); + const auto out = std::format("^2{}\n", msg); #endif Logger::MessagePrint(Game::CON_CHANNEL_DONT_FILTER, out); diff --git a/src/Components/Modules/Logger.hpp b/src/Components/Modules/Logger.hpp index 88f9f1da..cd281624 100644 --- a/src/Components/Modules/Logger.hpp +++ b/src/Components/Modules/Logger.hpp @@ -16,7 +16,6 @@ namespace Components static void Flush(); - static void MessagePrint(int channel, const std::string& msg); static void PrintInternal(int channel, std::string_view fmt, std::format_args&& args); static void ErrorInternal(Game::errorParm_t error, std::string_view fmt, std::format_args&& args); static void PrintErrorInternal(int channel, std::string_view fmt, std::format_args&& args); @@ -99,6 +98,7 @@ namespace Components static std::vector LoggingAddresses[2]; static void(*PipeCallback)(const std::string&); + static void MessagePrint(int channel, const std::string& msg); static void Frame(); static void G_LogPrintfStub(const char* fmt, ...); static void PrintMessageStub(); diff --git a/src/Components/Modules/PlayerName.cpp b/src/Components/Modules/PlayerName.cpp index 3233c279..74d02168 100644 --- a/src/Components/Modules/PlayerName.cpp +++ b/src/Components/Modules/PlayerName.cpp @@ -2,57 +2,57 @@ namespace Components { - Dvar::Var PlayerName::sv_allowColoredNames; + Dvar::Var PlayerName::sv_allowColoredNames; - void PlayerName::UserInfoCopy(char* buffer, const char* name, const size_t size) - { - if (!sv_allowColoredNames.get()) - { - char nameBuffer[64] = {0}; - TextRenderer::StripColors(name, nameBuffer, sizeof(nameBuffer)); - TextRenderer::StripAllTextIcons(nameBuffer, buffer, size); - } - else - { - TextRenderer::StripAllTextIcons(name, buffer, size); - } + void PlayerName::UserInfoCopy(char* buffer, const char* name, const size_t size) + { + if (!sv_allowColoredNames.get()) + { + char nameBuffer[64] = {0}; + TextRenderer::StripColors(name, nameBuffer, sizeof(nameBuffer)); + TextRenderer::StripAllTextIcons(nameBuffer, buffer, size); + } + else + { + TextRenderer::StripAllTextIcons(name, buffer, size); + } - std::string readablePlayerName(buffer); - readablePlayerName = Utils::String::Trim(readablePlayerName); + std::string readablePlayerName(buffer); + readablePlayerName = Utils::String::Trim(readablePlayerName); - if (readablePlayerName.size() < 3) - { - strncpy(buffer, "Unknown Soldier", size); - } - } + if (readablePlayerName.size() < 3) + { + strncpy(buffer, "Unknown Soldier", size); + } + } - __declspec(naked) void PlayerName::ClientCleanName() - { - __asm - { - mov eax, [esp + 4h] // length + __declspec(naked) void PlayerName::ClientCleanName() + { + __asm + { + mov eax, [esp + 4h] // length - push eax + push eax - push ecx // name - push edx // buffer + push ecx // name + push edx // buffer - call UserInfoCopy + call UserInfoCopy - add esp, 0Ch - retn - } - } + add esp, 0Ch + retn + } + } - char* PlayerName::GetClientName(int localClientNum, int index, char* buf, size_t size) - { - Game::CL_GetClientName(localClientNum, index, buf, size); + char* PlayerName::GetClientName(int localClientNum, int index, char* buf, size_t size) + { + Game::CL_GetClientName(localClientNum, index, buf, size); - // Append clantag to username & remove the colors - strncpy_s(buf, size, TextRenderer::StripColors(ClanTags::GetUserClantag(index, buf)).data(), size); + // Append clantag to username & remove the colors + strncpy_s(buf, size, TextRenderer::StripColors(ClanTags::GetUserClantag(index, buf)).data(), size); - return buf; - } + return buf; + } char* PlayerName::CleanStrStub(char* string) { diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 007c39e5..aaa59f7a 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -7070,6 +7070,8 @@ namespace Game entityState_s noDeltaEntities[1024]; }; + static_assert(sizeof(clientStatic_t) == 0xA7AEC); + struct ConDrawInputGlob { char autoCompleteChoice[64]; diff --git a/src/Utils/Hooking.cpp b/src/Utils/Hooking.cpp index e996e4f7..3b2f4544 100644 --- a/src/Utils/Hooking.cpp +++ b/src/Utils/Hooking.cpp @@ -9,7 +9,7 @@ namespace Utils { if (this->signatures.empty()) return; - char* _start = reinterpret_cast(this->start); + char* _start = static_cast(this->start); unsigned int sigCount = this->signatures.size(); Hook::Signature::Container* containers = this->signatures.data();