From 688c3f443f8dcdf794d20110459e9ec25ffe8310 Mon Sep 17 00:00:00 2001 From: Exlodium <45338028+Exlodium@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:30:36 +0100 Subject: [PATCH 1/2] Quick fix for chams --- cstrike/core/hooks.cpp | 4 +-- cstrike/core/hooks.h | 2 +- cstrike/core/menu.cpp | 2 ++ cstrike/core/variables.h | 2 ++ cstrike/features/misc/movement.cpp | 9 +++++++ cstrike/features/misc/movement.h | 1 + cstrike/sdk/interfaces/imaterialsystem.h | 34 ++++++++++++------------ 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/cstrike/core/hooks.cpp b/cstrike/core/hooks.cpp index da0d160..eef3a7d 100644 --- a/cstrike/core/hooks.cpp +++ b/cstrike/core/hooks.cpp @@ -192,10 +192,10 @@ ViewMatrix_t* CS_FASTCALL H::GetMatrixForView(CRenderGameSystem* pRenderGameSyst return matResult; } -bool CS_FASTCALL H::CreateMove(CCSGOInput* pInput, int nSlot, bool bActive, std::byte unk) +bool CS_FASTCALL H::CreateMove(CCSGOInput* pInput, int nSlot, bool bActive) { const auto oCreateMove = hkCreateMove.GetOriginal(); - const bool bResult = oCreateMove(pInput, nSlot, bActive, unk); + const bool bResult = oCreateMove(pInput, nSlot, bActive); if (!I::Engine->IsConnected() || !I::Engine->IsInGame()) return bResult; diff --git a/cstrike/core/hooks.h b/cstrike/core/hooks.h index ecb5c8d..81b8050 100644 --- a/cstrike/core/hooks.h +++ b/cstrike/core/hooks.h @@ -61,7 +61,7 @@ namespace H // game's functions ViewMatrix_t* CS_FASTCALL GetMatrixForView(CRenderGameSystem* pRenderGameSystem, IViewRender* pViewRender, ViewMatrix_t* pOutWorldToView, ViewMatrix_t* pOutViewToProjection, ViewMatrix_t* pOutWorldToProjection, ViewMatrix_t* pOutWorldToPixels); - bool CS_FASTCALL CreateMove(CCSGOInput* pInput, int nSlot, bool bActive, std::byte unk); + bool CS_FASTCALL CreateMove(CCSGOInput* pInput, int nSlot, bool bActive); bool CS_FASTCALL MouseInputEnabled(void* pThisptr); void CS_FASTCALL FrameStageNotify(void* rcx, int nFrameStage); __int64* CS_FASTCALL LevelInit(void* pClientModeShared, const char* szNewMap); diff --git a/cstrike/core/menu.cpp b/cstrike/core/menu.cpp index 4001075..a71154d 100644 --- a/cstrike/core/menu.cpp +++ b/cstrike/core/menu.cpp @@ -465,6 +465,8 @@ void T::Miscellaneous() if (C_GET(bool, Vars.bAutoBHop)) ImGui::SliderInt(CS_XOR("chance"), &C_GET(int, Vars.nAutoBHopChance), 0, 100, CS_XOR("%d%%")); + ImGui::Checkbox(CS_XOR("auto strafe"), &C_GET(bool, Vars.bAutoStrafe)); + ImGui::PopStyleVar(); } ImGui::EndChild(); diff --git a/cstrike/core/variables.h b/cstrike/core/variables.h index 67dfe2e..a0bfd64 100644 --- a/cstrike/core/variables.h +++ b/cstrike/core/variables.h @@ -70,6 +70,8 @@ struct Variables_t C_ADD_VARIABLE(bool, bAutoBHop, false); C_ADD_VARIABLE(int, nAutoBHopChance, 100); + + C_ADD_VARIABLE(bool, bAutoStrafe, false); #pragma endregion #pragma region variables_menu diff --git a/cstrike/features/misc/movement.cpp b/cstrike/features/misc/movement.cpp index acc1e00..0f9b40c 100644 --- a/cstrike/features/misc/movement.cpp +++ b/cstrike/features/misc/movement.cpp @@ -29,6 +29,7 @@ void F::MISC::MOVEMENT::OnMove(CUserCmd* pCmd, CCSPlayerController* pLocalContro return; BunnyHop(pCmd, pBaseCmd, pLocalPawn); + AutoStrafe(pBaseCmd, pLocalPawn); // loop through all tick commands //for (int nTick = 0; nTick < pBaseCmd->nTickCount; nTick++) @@ -76,6 +77,14 @@ void F::MISC::MOVEMENT::BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSP pCmd->nButtons.nValue &= ~IN_JUMP; } +void F::MISC::MOVEMENT::AutoStrafe(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn) +{ + if (!C_GET(bool, Vars.bAutoStrafe) || pLocalPawn->GetFlags() & FL_ONGROUND) + return; + + pUserCmd->flSideMove = pUserCmd->nMousedX > 0 ? -1.0f : 1.0f; // a bit yanky, but works +} + void F::MISC::MOVEMENT::ValidateUserCommand(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, CCSGOInputHistoryEntryPB* pInputEntry) { if (pUserCmd == nullptr) diff --git a/cstrike/features/misc/movement.h b/cstrike/features/misc/movement.h index 04e3661..7a33ea0 100644 --- a/cstrike/features/misc/movement.h +++ b/cstrike/features/misc/movement.h @@ -14,6 +14,7 @@ namespace F::MISC::MOVEMENT void OnMove(CUserCmd* pCmd, CCSPlayerController* pLocalController, C_CSPlayerPawn* pLocalPawn); void BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn); + void AutoStrafe(CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn); void MovementCorrection(CBaseUserCmdPB* pUserCmd, CCSGOInputHistoryEntryPB* pInputHistory, const QAngle_t& angDesiredViewPoint); // will call MovementCorrection && validate user's angView to avoid untrusted ban diff --git a/cstrike/sdk/interfaces/imaterialsystem.h b/cstrike/sdk/interfaces/imaterialsystem.h index e5b6fed..d26b632 100644 --- a/cstrike/sdk/interfaces/imaterialsystem.h +++ b/cstrike/sdk/interfaces/imaterialsystem.h @@ -38,14 +38,14 @@ struct MaterialKeyVar_t std::uint64_t FindKey(const char* szName) { using fnFindKeyVar = std::uint64_t(CS_FASTCALL*)(const char*, unsigned int, int); - static auto FindKeyVar = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 57 48 81 EC ? ? ? ? 33 C0 8B DA"))); + static auto oFindKeyVar = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 57 48 81 EC ? ? ? ? 33 C0 8B DA"))); #ifdef CS_PARANOID - CS_ASSERT(FindKeyVar != nullptr); + CS_ASSERT(oFindKeyVar != nullptr); #endif // idk those enum flags, just saw it called like that soooo yea - return FindKeyVar(szName, 0x12, 0x31415926); + return oFindKeyVar(szName, 0x12, 0x31415926); } }; @@ -57,7 +57,7 @@ class CObjectInfo class CSceneAnimatableObject { - MEM_PAD(0xA8); + MEM_PAD(0xB0); CBaseHandle hOwner; }; @@ -69,36 +69,36 @@ class CMeshData { // @ida: #STR: shader, spritecard.vfx using fnSetMaterialShaderType = void(CS_FASTCALL*)(void*, MaterialKeyVar_t, const char*, int); - static auto SetMaterialShaderType = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 4D 8B E0 4C 8B 72 ? 48 8B F9 C0 E8 ? 24 ? 3C ? 74 ? 41 B0 ? B2 ? E8 ? ? ? ? 0F B6 07 33 DB C0 E8 ? 24 ? 3C ? 75 ? 48 8B 77 ? EB ? 48 8B F3 4C 8D 44 24 ? C7 44 24 ? ? ? ? ? 48 8D 54 24 ? 89 6C 24 ? 48 8B CE 4C 89 74 24 ? E8 ? ? ? ? 8B D0 83 F8 ? 75 ? 45 33 C9 89 6C 24 ? 4C 8D 44 24 ? 4C 89 74 24 ? 48 8B D7 48 8B CE E8 ? ? ? ? 8B D0 0F B6 0F C0 E9 ? 80 E1 ? 80 F9 ? 75 ? 48 8B 4F ? EB ? 48 8B CB 8B 41 ? 85 C0 74 ? 48 8D 59 ? 83 F8 ? 76 ? 48 8B 1B 48 63 C2 4D 85 E4"))); + static auto oSetMaterialShaderType = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 4D 8B E0 4C 8B 72 ? 48 8B F9 C0 E8 ? 24 ? 3C ? 74 ? 41 B0 ? B2 ? E8 ? ? ? ? 0F B6 07 33 DB C0 E8 ? 24 ? 3C ? 75 ? 48 8B 77 ? EB ? 48 8B F3 4C 8D 44 24 ? C7 44 24 ? ? ? ? ? 48 8D 54 24 ? 89 6C 24 ? 48 8B CE 4C 89 74 24 ? E8 ? ? ? ? 8B D0 83 F8 ? 75 ? 45 33 C9 89 6C 24 ? 4C 8D 44 24 ? 4C 89 74 24 ? 48 8B D7 48 8B CE E8 ? ? ? ? 8B D0 0F B6 0F C0 E9 ? 80 E1 ? 80 F9 ? 75 ? 48 8B 4F ? EB ? 48 8B CB 8B 41 ? 85 C0 74 ? 48 8D 59 ? 83 F8 ? 76 ? 48 8B 1B 48 63 C2 4D 85 E4"))); #ifdef CS_PARANOID - CS_ASSERT(SetMaterialShaderType != nullptr); + CS_ASSERT(oSetMaterialShaderType != nullptr); #endif MaterialKeyVar_t shaderVar(0x162C1777, CS_XOR("shader")); - SetMaterialShaderType(this, shaderVar, szShaderName, 0x18); + oSetMaterialShaderType(this, shaderVar, szShaderName, 0x18); // looks like this should be 0x19u in IDA?, not sure though. Leaving it likes for maecry } void SetMaterialFunction(const char* szFunctionName, int nValue) { using fnSetMaterialFunction = void(__fastcall*)(void*, MaterialKeyVar_t, int, int); - static auto SetMaterialFunction = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 48 8B F9"))); + static auto oSetMaterialFunction = reinterpret_cast(MEM::FindPattern(PARTICLES_DLL, CS_XOR("48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 54 41 56 41 57 48 83 EC ? 0F B6 01 45 0F B6 F9 8B 2A 48 8B F9"))); #ifdef CS_PARANOID - CS_ASSERT(SetMaterialFunction != nullptr); + CS_ASSERT(oSetMaterialFunction != nullptr); #endif MaterialKeyVar_t functionVar(szFunctionName, true); - SetMaterialFunction(this, functionVar, nValue, 0x18); + oSetMaterialFunction(this, functionVar, nValue, 0x18); } - MEM_PAD(0x10); // 0x0 - CSceneAnimatableObject* pSceneAnimatableObject; // 0x10 - CMaterial2* pMaterial; // 0x18 - MEM_PAD(0x20); // 0x20 - Color_t colValue; // 0x40 - MEM_PAD(0x4); // 0x44 - CObjectInfo* pObjectInfo; // 0x48 + MEM_PAD(0x18); // 0x0 + CSceneAnimatableObject* pSceneAnimatableObject; // 0x18 + CMaterial2* pMaterial; // 0x20 + MEM_PAD(0x20); // 0x28 + Color_t colValue; // 0x48 + MEM_PAD(0x4); // 0x4C + CObjectInfo* pObjectInfo; // 0x50 }; class IMaterialSystem2 From 9108a88fedb162f3c3c76bf4fe2714dd6ec1b6a2 Mon Sep 17 00:00:00 2001 From: Exlodium <45338028+Exlodium@users.noreply.github.com> Date: Fri, 9 Feb 2024 18:59:21 +0100 Subject: [PATCH 2/2] Add back Input history --- cstrike/features/misc/movement.cpp | 20 +++++++-------- cstrike/sdk/datatypes/usercmd.h | 39 ++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/cstrike/features/misc/movement.cpp b/cstrike/features/misc/movement.cpp index 0f9b40c..6e167ca 100644 --- a/cstrike/features/misc/movement.cpp +++ b/cstrike/features/misc/movement.cpp @@ -32,18 +32,18 @@ void F::MISC::MOVEMENT::OnMove(CUserCmd* pCmd, CCSPlayerController* pLocalContro AutoStrafe(pBaseCmd, pLocalPawn); // loop through all tick commands - //for (int nTick = 0; nTick < pBaseCmd->nTickCount; nTick++) - //{ - // CCSGOInputHistoryEntryPB* pInputEntry = pCmd->cmd.inputHistoryField.pRep->tElements[nTick]; - // if (pInputEntry == nullptr) - // continue; + for (int nTick = 0; nTick < pBaseCmd->nTickCount; nTick++) + { + CCSGOInputHistoryEntryPB* pInputEntry = pCmd->csgoUserCmd.GetInputHistoryEntry(nTick); + if (pInputEntry == nullptr) + continue; - // // save view angles for movement correction - // angCorrectionView = pInputEntry->pViewCmd->angValue; + // save view angles for movement correction + angCorrectionView = pInputEntry->pViewCmd->angValue; - // // movement correction & anti-untrusted - // ValidateUserCommand(pCmd, pBaseCmd, pInputEntry); - //} + // movement correction & anti-untrusted + ValidateUserCommand(pCmd, pBaseCmd, pInputEntry); + } } void F::MISC::MOVEMENT::BunnyHop(CUserCmd* pCmd, CBaseUserCmdPB* pUserCmd, C_CSPlayerPawn* pLocalPawn) diff --git a/cstrike/sdk/datatypes/usercmd.h b/cstrike/sdk/datatypes/usercmd.h index 84aeafa..24d3aa3 100644 --- a/cstrike/sdk/datatypes/usercmd.h +++ b/cstrike/sdk/datatypes/usercmd.h @@ -82,6 +82,26 @@ class CCSGOInputHistoryEntryPB : public CBasePB int nTargetEntIndex; // 0x74 }; +class CCSGOUserCmdPB +{ +public: + int32_t nTickCount; // 0x0 + MEM_PAD(0x4); // 0x4 + void* pInputHistory; // 0x8 + + CCSGOInputHistoryEntryPB* GetInputHistoryEntry(std::int32_t nTick) + { + if (nTick < this->nTickCount) + { + CCSGOInputHistoryEntryPB** arrTickList = reinterpret_cast(reinterpret_cast(pInputHistory) + 0x8); + return arrTickList[nTick]; + } + + return nullptr; + } +}; +static_assert(sizeof(CCSGOUserCmdPB) == 0x10); + struct ButtonState_t { MEM_PAD(0x8); @@ -114,14 +134,29 @@ class CBaseUserCmdPB : public CBasePB }; static_assert(sizeof(CBaseUserCmdPB) == 0x80); - class CUserCmd { public: - MEM_PAD(0x30); + MEM_PAD(0x20); + CCSGOUserCmdPB csgoUserCmd; // 0x20 CBaseUserCmdPB* pBaseCmd; // 0x30 MEM_PAD(0x10); // 0x38 ButtonState_t nButtons; // 0x4C MEM_PAD(0x20); // 0x64 + + void SetSubTickAngle(const QAngle_t& angView) + { + for (int i = 0; i < this->csgoUserCmd.nTickCount; i++) + { + CCSGOInputHistoryEntryPB* pInputEntry = this->csgoUserCmd.GetInputHistoryEntry(i); + if (pInputEntry == nullptr) + continue; + + if (pInputEntry->pViewCmd == nullptr) + continue; + + pInputEntry->pViewCmd->angValue = angView; + } + } }; static_assert(sizeof(CUserCmd) == 0x88);