From 4323f0273d8b329a2b64eb8f3da51f4de5768623 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 3 Jul 2022 11:33:42 +0200 Subject: [PATCH] Dynamically get Rui debug font face No longer hardcoded to ArameMono (default cfg's are set to ArameMono still). --- r5dev/rtech/rui/rui.cpp | 10 ++++----- r5dev/rtech/rui/rui.h | 27 ++++++++++++++++--------- r5dev/vgui/vgui_debugpanel.cpp | 11 +++++----- r5dev/vguimatsurface/MatSystemSurface.h | 4 ++-- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/r5dev/rtech/rui/rui.cpp b/r5dev/rtech/rui/rui.cpp index e95d50fe..8c402f4a 100644 --- a/r5dev/rtech/rui/rui.cpp +++ b/r5dev/rtech/rui/rui.cpp @@ -12,24 +12,24 @@ #include "tier1/cvar.h" //----------------------------------------------------------------------------- -// Purpose: Probably responsible to decide if rUI is allowed to draw. +// Purpose: draw RUI frame //----------------------------------------------------------------------------- -bool __fastcall HRuiDraw(__int64* a1, __m128* a2, const __m128i* a3, __int64 a4, __m128* a5) +bool __fastcall Rui_Draw(__int64* a1, __m128* a2, const __m128i* a3, __int64 a4, __m128* a5) { if (!rui_drawEnable->GetBool()) return false; - return v_RuiDraw(a1, a2, a3, a4, a5); + return v_Rui_Draw(a1, a2, a3, a4, a5); } void Rui_Attach() { - DetourAttach((LPVOID*)&v_RuiDraw, &HRuiDraw); + DetourAttach((LPVOID*)&v_Rui_Draw, &Rui_Draw); } void Rui_Detach() { - DetourDetach((LPVOID*)&v_RuiDraw, &HRuiDraw); + DetourDetach((LPVOID*)&v_Rui_Draw, &Rui_Draw); } #endif // !DEDICATED \ No newline at end of file diff --git a/r5dev/rtech/rui/rui.h b/r5dev/rtech/rui/rui.h index d1e9b27a..9af09047 100644 --- a/r5dev/rtech/rui/rui.h +++ b/r5dev/rtech/rui/rui.h @@ -1,11 +1,14 @@ #pragma once /* ==== RUI ====================================================================================================================================================== */ -inline CMemory p_RuiDraw; -inline auto v_RuiDraw = p_RuiDraw.RCast(); +inline CMemory p_Rui_Draw; +inline auto v_Rui_Draw = p_Rui_Draw.RCast(); -inline CMemory p_RuiLoadAsset; -inline auto v_RuiLoadAsset = p_RuiLoadAsset.RCast(); +inline CMemory p_Rui_LoadAsset; +inline auto v_Rui_LoadAsset = p_Rui_LoadAsset.RCast(); + +inline CMemory p_Rui_GetFontFace; +inline auto v_Rui_GetFontFace = p_Rui_GetFontFace.RCast(); void Rui_Attach(); void Rui_Detach(); @@ -15,17 +18,21 @@ class VRui : public IDetour { virtual void GetAdr(void) const { - spdlog::debug("| FUN: RuiDraw : {:#18x} |\n", p_RuiDraw.GetPtr()); - spdlog::debug("| FUN: RuiLoadAsset : {:#18x} |\n", p_RuiLoadAsset.GetPtr()); + spdlog::debug("| FUN: Rui_Draw : {:#18x} |\n", p_Rui_Draw.GetPtr()); + spdlog::debug("| FUN: Rui_LoadAsset : {:#18x} |\n", p_Rui_LoadAsset.GetPtr()); + spdlog::debug("| FUN: Rui_GetFontFace : {:#18x} |\n", p_Rui_GetFontFace.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { - p_RuiDraw = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x40\x4C\x8B\x5A\x18"), "xxxxxxxxxx"); - v_RuiDraw = p_RuiDraw.RCast(); /* 40 53 48 83 EC 40 4C 8B 5A 18 */ + p_Rui_Draw = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x40\x4C\x8B\x5A\x18"), "xxxxxxxxxx"); + v_Rui_Draw = p_Rui_Draw.RCast(); /* 40 53 48 83 EC 40 4C 8B 5A 18 */ - p_RuiLoadAsset = g_mGameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\xEB\x03\x49\x8B\xC6\x48\x89\x86\x00\x00\x00\x00\x8B\x86\x00\x00\x00\x00"), "x????xxxxxxxx????xx????").FollowNearCallSelf(); - v_RuiLoadAsset = p_RuiLoadAsset.RCast(); /*E8 ?? ?? ?? ?? EB 03 49 8B C6 48 89 86 ?? ?? ?? ?? 8B 86 ?? ?? ?? ??*/ + p_Rui_LoadAsset = g_mGameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\xEB\x03\x49\x8B\xC6\x48\x89\x86\x00\x00\x00\x00\x8B\x86\x00\x00\x00\x00"), "x????xxxxxxxx????xx????").FollowNearCallSelf(); + v_Rui_LoadAsset = p_Rui_LoadAsset.RCast(); /*E8 ?? ?? ?? ?? EB 03 49 8B C6 48 89 86 ?? ?? ?? ?? 8B 86 ?? ?? ?? ??*/ + + p_Rui_GetFontFace = g_mGameDll.FindPatternSIMD(reinterpret_cast("\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x74\x05\x49\x8B\xD1\xEB\x19\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x48\x58\x48\x85\xC9\x48\x0F\x45\xD1\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x75\x19\x48\x8B\x05\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x4C\x8B\x40\x58\x4D\x85\xC0\x4D\x0F\x45\xC8\x49\x8B\xC9\x48\xFF\x25\x00\x00\x00\x00"), "xx????????xxx????xxxxxxxxxx????xxx????xxxxxxxxxxxxx????????xxxxx????xxx????xxxxxxxxxxxxxxxxx????");; + v_Rui_GetFontFace = p_Rui_GetFontFace.RCast();/*F7 05 ? ? ? ? ? ? ? ? 4C 8D 0D ? ? ? ? 74 05 49 8B D1 EB 19 48 8B 05 ? ? ? ? 48 8D 15 ? ? ? ? 48 8B 48 58 48 85 C9 48 0F 45 D1 F7 05 ? ? ? ? ? ? ? ? 75 19 48 8B 05 ? ? ? ? 4C 8D 0D ? ? ? ? 4C 8B 40 58 4D 85 C0 4D 0F 45 C8 49 8B C9 48 FF 25 ? ? ? ?*/ } virtual void GetVar(void) const { } virtual void GetCon(void) const { } diff --git a/r5dev/vgui/vgui_debugpanel.cpp b/r5dev/vgui/vgui_debugpanel.cpp index 7e90bafa..8bc6ce92 100644 --- a/r5dev/vgui/vgui_debugpanel.cpp +++ b/r5dev/vgui/vgui_debugpanel.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,7 @@ void CLogSystem::DrawLog(void) y += m_nFontHeight * i; } - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, x, y, c.r(), c.g(), c.b(), alpha, m_vLogs[i].m_svMessage.c_str()); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, x, y, c.r(), c.g(), c.b(), alpha, m_vLogs[i].m_svMessage.c_str()); } else { @@ -126,7 +127,7 @@ void CLogSystem::DrawHostStats(void) const nHeight = g_nWindowHeight - nHeight; } - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)m_pszCon_NPrintf_Buf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)m_pszCon_NPrintf_Buf); } //----------------------------------------------------------------------------- @@ -151,7 +152,7 @@ void CLogSystem::DrawSimStats(void) const nHeight = g_nWindowHeight - nHeight; } - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } //----------------------------------------------------------------------------- @@ -176,7 +177,7 @@ void CLogSystem::DrawGPUStats(void) const nHeight = g_nWindowHeight - nHeight; } - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } //----------------------------------------------------------------------------- @@ -197,7 +198,7 @@ void CLogSystem::DrawCrosshairMaterial(void) const material->m_pszSurfaceName1, material->m_pszSurfaceName2, material->m_UnknownSignature); - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, cl_materialinfo_offset_x->GetInt(), cl_materialinfo_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, cl_materialinfo_offset_x->GetInt(), cl_materialinfo_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } //----------------------------------------------------------------------------- diff --git a/r5dev/vguimatsurface/MatSystemSurface.h b/r5dev/vguimatsurface/MatSystemSurface.h index efdf6b1f..fa287e7c 100644 --- a/r5dev/vguimatsurface/MatSystemSurface.h +++ b/r5dev/vguimatsurface/MatSystemSurface.h @@ -3,7 +3,7 @@ /* ==== CMATSYSTEMSURFACE =============================================================================================================================================== */ inline CMemory p_CMatSystemSurface_DrawColoredText; -inline auto CMatSystemSurface_DrawColoredText = p_CMatSystemSurface_DrawColoredText.RCast(); +inline auto CMatSystemSurface_DrawColoredText = p_CMatSystemSurface_DrawColoredText.RCast(); class CMatSystemSurface { @@ -25,7 +25,7 @@ class VMatSystemSurface : public IDetour virtual void GetFun(void) const { p_CMatSystemSurface_DrawColoredText = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x4C\x8B\xDC\x48\x83\xEC\x68\x49\x8D\x43\x58\x0F\x57\xC0"), "xxxxxxxxxxxxxx"); - CMatSystemSurface_DrawColoredText = p_CMatSystemSurface_DrawColoredText.RCast(); /*4C 8B DC 48 83 EC 68 49 8D 43 58 0F 57 C0*/ + CMatSystemSurface_DrawColoredText = p_CMatSystemSurface_DrawColoredText.RCast(); /*4C 8B DC 48 83 EC 68 49 8D 43 58 0F 57 C0*/ } virtual void GetVar(void) const {