From c48f616991d20f00cae528910a1cac83b9069504 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 3 May 2017 21:10:19 +0300 Subject: [PATCH] perfect FakeName --- src/hack.cpp | 6 ++++ src/hooks.cpp | 1 + src/hooks.h | 2 ++ src/hooks/hookedmethods.h | 4 +++ src/hooks/others.cpp | 62 +++++---------------------------------- src/interfaces.cpp | 5 +++- 6 files changed, 24 insertions(+), 56 deletions(-) diff --git a/src/hack.cpp b/src/hack.cpp index 46685ebd..a737ab69 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -167,10 +167,16 @@ void hack::Initialize() { hooks::hkInput->Init((void*)g_IInput, 0); hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd); hooks::hkInput->Apply(); + logging::Info("Before hacking: %s", g_ISteamFriends->GetPersonaName()); hooks::hkIVModelRender = new hooks::VMTHook(); hooks::hkIVModelRender->Init(g_IVModelRender, 0); hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); hooks::hkIVModelRender->Apply(); + hooks::hkSteamFriends = new hooks::VMTHook(); + hooks::hkSteamFriends->Init(g_ISteamFriends, 0); + hooks::hkSteamFriends->HookMethod((void*)GetFriendPersonaName_hook, hooks::offGetFriendPersonaName); + hooks::hkSteamFriends->Apply(); + logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName()); // Sadly, it doesn't work as expected :( /*hooks::hkBaseClientState = new hooks::VMTHook(); hooks::hkBaseClientState->Init((void*)g_IBaseClientState, 0); diff --git a/src/hooks.cpp b/src/hooks.cpp index e1011122..1c3c0fce 100644 --- a/src/hooks.cpp +++ b/src/hooks.cpp @@ -74,6 +74,7 @@ void hooks::VMTHook::Apply() { //hooks::VMTHook* hooks::hkCTFPlayer = nullptr; hooks::VMTHook* hooks::hkInput = nullptr; +hooks::VMTHook* hooks::hkSteamFriends = nullptr; hooks::VMTHook* hooks::hkBaseClientState = nullptr; hooks::VMTHook* hooks::hkBaseClientState8 = nullptr; hooks::VMTHook* hooks::hkClientMode = 0; diff --git a/src/hooks.h b/src/hooks.h index c5f3257e..1a75bfdb 100644 --- a/src/hooks.h +++ b/src/hooks.h @@ -43,6 +43,7 @@ extern VMTHook* hkInput; extern VMTHook* hkIVModelRender; extern VMTHook* hkBaseClientState; extern VMTHook* hkBaseClientState8; +extern VMTHook* hkSteamFriends; constexpr unsigned int offGetUserCmd = 8; constexpr unsigned int offShouldDraw = 136; @@ -50,6 +51,7 @@ constexpr unsigned int offDrawModelExecute = 19; constexpr unsigned int offGetClientName = 44; constexpr unsigned int offProcessSetConVar = 4; constexpr unsigned int offProcessGetCvarValue = 29; +constexpr unsigned int offGetFriendPersonaName = 7; extern unsigned int offHandleInputEvent; extern unsigned int offPaintTraverse; extern unsigned int offCreateMove; diff --git a/src/hooks/hookedmethods.h b/src/hooks/hookedmethods.h index 9838cf9a..c93787d4 100644 --- a/src/hooks/hookedmethods.h +++ b/src/hooks/hookedmethods.h @@ -35,6 +35,10 @@ bool ProcessGetCvarValue_hook(CBaseClientState* _this, SVC_GetCvarValue* msg); //void CInput__CreateMove_hook(void*, int sequence_number, float input_sample_frametime, bool active); bool CanInspect_hook(IClientEntity*); const unsigned int offCanInspect = 512; + +typedef const char*(GetFriendPersonaName_t)(ISteamFriends*, CSteamID); +const char* GetFriendPersonaName_hook(ISteamFriends* _this, CSteamID steamID); + void BeginFrame_hook(IStudioRender*); CUserCmd* GetUserCmd_hook(IInput*, int); void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix); diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index a5f4f0bb..da3e17bb 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -166,6 +166,13 @@ static CatVar glow_enabled(CV_SWITCH, "glow_old_enabled", "0", "Enable", "Make s static CatVar glow_alpha(CV_FLOAT, "glow_old_alpha", "1", "Alpha", "Glow Transparency", 0.0f, 1.0f); static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles"); +const char* GetFriendPersonaName_hook(ISteamFriends* _this, CSteamID steamID) { + if ((force_name.convar->m_StringLength > 2) && steamID == g_ISteamUser->GetSteamID()) { + return force_name.GetString(); + } + return ((GetFriendPersonaName_t*)(hooks::hkSteamFriends->GetMethod(hooks::offGetFriendPersonaName)))(_this, steamID); +} + void FrameStageNotify_hook(void* thisptr, int stage) { SEGV_BEGIN; if (!g_IEngine->IsInGame()) g_Settings.bInvalid = true; @@ -183,29 +190,6 @@ void FrameStageNotify_hook(void* thisptr, int stage) { } } } - if (stage == FRAME_NET_UPDATE_START) { - static int next_name_change = 0; - if (next_name_change <= 0 || need_name_change) { - need_name_change = true; - next_name_change = 0; - } else next_name_change--; - if (force_name.convar->m_StringLength > 2 && need_name_change) { - INetChannel* ch = (INetChannel*)g_IEngine->GetNetChannelInfo(); - if (ch) { - logging::Info("Sending new name"); - NET_SetConVar setname("name", force_name.GetString()); - setname.SetNetChannel(ch); - setname.SetReliable(false); - ch->SendNetMsg(setname, false); - need_name_change = false; - } - next_name_change = 60 * 100; - } - static ConVar* name_cv = g_ICvar->FindVar("name"); - //name_cv->SetValue(force_name.GetString()); - name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); - name_cv->m_StringLength = strlen(force_name.GetString()) + 1; - } if (TF && cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { if (glow_enabled) { for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.m_Size; i++) { @@ -328,22 +312,6 @@ void LevelInit_hook(void* thisptr, const char* newmap) { //if (TF) LEVEL_INIT(SpyAlert); chat_stack::Reset(); hacks::shared::spam::Reset(); - need_name_change = true; - if (force_name.convar->m_StringLength > 2) { - //static ConVar* name_cv = g_ICvar->FindVar("name"); - INetChannel* ch = (INetChannel*)g_IEngine->GetNetChannelInfo(); - if (ch) { - logging::Info("Sending new name"); - NET_SetConVar setname("name", force_name.GetString()); - setname.SetNetChannel(ch); - setname.SetReliable(false); - ch->SendNetMsg(setname, false); - //name_cv->m_pszString = strfmt("%s", force_name.GetString()); - } - static ConVar* name_cv = g_ICvar->FindVar("name"); - name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); - name_cv->m_StringLength = strlen(force_name.GetString()) + 1; - } } bool CanInspect_hook(IClientEntity*) { return true; } @@ -356,21 +324,5 @@ void LevelShutdown_hook(void* thisptr) { hacks::shared::aimbot::Reset(); chat_stack::Reset(); hacks::shared::spam::Reset(); - need_name_change = true; - if (force_name.convar->m_StringLength > 2) { - //static ConVar* name_cv = g_ICvar->FindVar("name"); - INetChannel* ch = (INetChannel*)g_IEngine->GetNetChannelInfo(); - if (ch) { - logging::Info("Sending new name"); - NET_SetConVar setname("name", force_name.GetString()); - setname.SetNetChannel(ch); - setname.SetReliable(false); - ch->SendNetMsg(setname, false); - //name_cv->m_pszString = strfmt("%s", force_name.GetString()); - } - static ConVar* name_cv = g_ICvar->FindVar("name"); - name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); - name_cv->m_StringLength = strlen(force_name.GetString()) + 1; - } } diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 57e2e666..c8b0dbe2 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -87,7 +87,10 @@ void CreateInterfaces() { HSteamPipe sp = g_ISteamClient->CreateSteamPipe(); HSteamUser su = g_ISteamClient->ConnectToGlobalUser(sp); g_IVModelRender = BruteforceInterface("VEngineModel", sharedobj::engine, 16); - g_ISteamFriends = g_ISteamClient->GetISteamFriends(su, sp, "SteamFriends002"); + uintptr_t sig_steamapi = gSignatures.GetEngineSignature("55 0F 57 C0 89 E5 83 EC 18 F3 0F 11 05 ? ? ? ? F3 0F 11 05 ? ? ? ? F3 0F 10 05 ? ? ? ? C7 04 24 ? ? ? ? F3 0F 11 05 ? ? ? ? F3 0F 11 05 ? ? ? ? E8 ? ? ? ? C7 44 24 08 ? ? ? ? C7 44 24 04 ? ? ? ? C7 04 24 ? ? ? ? E8 ? ? ? ? C9 C3"); + logging::Info("SteamAPI: 0x%08x", sig_steamapi); + void** SteamAPI_engine = *reinterpret_cast(sig_steamapi + 36); + g_ISteamFriends = (ISteamFriends*)(SteamAPI_engine[1]);//g_ISteamClient->GetISteamFriends(su, sp, "SteamFriends002"); g_GlobalVars = **(reinterpret_cast((uintptr_t)11 + gSignatures.GetClientSignature("55 89 E5 83 EC ? 8B 45 08 8B 15 ? ? ? ? F3 0F 10"))); g_IPrediction = BruteforceInterface("VClientPrediction", sharedobj::client); g_IGameMovement = BruteforceInterface("GameMovement", sharedobj::client);