Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Hooks.h"
- #include "Hacks.h"
- #include "Chams.h"
- #include "Menu.h"
- #include "Interfaces.h"
- #include "RenderManager.h"
- #include "MiscHacks.h"
- float rainbowx = 1;
- // Funtion Typedefs
- typedef void(__thiscall* DrawModelEx_)(void*, void*, void*, const ModelRenderInfo_t&, matrix3x4*);
- typedef void(__thiscall* PaintTraverse_)(PVOID, unsigned int, bool, bool);
- typedef bool(__thiscall* InPrediction_)(PVOID);
- typedef void(__stdcall *FrameStageNotifyFn)(ClientFrameStage_t);
- // Function Pointers to the originals
- PaintTraverse_ oPaintTraverse;
- DrawModelEx_ oDrawModelExecute;
- FrameStageNotifyFn oFrameStageNotify;
- Vector aathird;
- // Hook function prototypes
- void __fastcall PaintTraverse_Hooked(PVOID pPanels, int edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce);
- bool __stdcall Hooked_InPrediction();
- void __fastcall Hooked_DrawModelExecute(void* thisptr, int edx, void* ctx, void* state, const ModelRenderInfo_t &pInfo, matrix3x4 *pCustomBoneToWorld);
- bool __stdcall CreateMoveClient_Hooked(/*void* self, int edx,*/ float frametime, CUserCmd* pCmd);
- void __stdcall Hooked_FrameStageNotify(ClientFrameStage_t curStage);
- // VMT Managers
- namespace Hooks
- {
- // VMT Managers
- Utilities::Memory::CVMTHookManager VMTPanel; // Hooking drawing functions
- Utilities::Memory::CVMTHookManager VMTClient; // Maybe CreateMove
- Utilities::Memory::CVMTHookManager VMTClientMode; // CreateMove for functionality
- Utilities::Memory::CVMTHookManager VMTModelRender; // DrawModelEx for chams
- Utilities::Memory::CVMTHookManager VMTPrediction; // InPrediction for no vis recoil
- };
- // Initialise all our hooks
- void Hooks::Initialise()
- {
- // Panel hooks for drawing to the screen via surface functions
- VMTPanel.bInitialize((PDWORD*)Interfaces::Panels);
- oPaintTraverse = (PaintTraverse_)VMTPanel.dwHookMethod((DWORD)PaintTraverse_Hooked, Offsets::VMT::Panel_PaintTraverse);
- VMTPanel.ReHook();
- //Utilities::Log("Paint Traverse Hooked");
- // No Visual Recoil
- VMTPrediction.bInitialize((PDWORD*)Interfaces::Prediction);
- VMTPrediction.dwHookMethod((DWORD)Hooked_InPrediction, 14);
- VMTPrediction.ReHook();
- //Utilities::Log("InPrediction Hooked");
- // Chams
- VMTModelRender.bInitialize((PDWORD*)Interfaces::ModelRender);
- oDrawModelExecute = (DrawModelEx_)VMTModelRender.dwHookMethod((DWORD)Hooked_DrawModelExecute, Offsets::VMT::ModelRender_DrawModelExecute);
- VMTModelRender.ReHook();
- //Utilities::Log("DrawModelExecute Hooked");
- // Setup ClientMode Hooks
- VMTClientMode.bInitialize((PDWORD*)Interfaces::ClientMode);
- VMTClientMode.dwHookMethod((DWORD)CreateMoveClient_Hooked, 24);
- VMTClient.ReHook();
- //Utilities::Log("ClientMode CreateMove Hooked");
- // Setup client hooks
- VMTClient.bInitialize((PDWORD*)Interfaces::Client);
- oFrameStageNotify = (FrameStageNotifyFn)VMTClient.dwHookMethod((DWORD)&Hooked_FrameStageNotify, 36);
- }
- // Undo our hooks
- void Hooks::UndoHooks()
- {
- VMTPanel.UnHook();
- VMTPrediction.UnHook();
- VMTModelRender.UnHook();
- VMTClientMode.UnHook();
- }
- void MovementCorrection(CUserCmd* pCmd)
- {
- }
- //---------------------------------------------------------------------------------------------------------
- // Hooked Functions
- //---------------------------------------------------------------------------------------------------------
- // Paint Traverse Hooked function
- void __fastcall PaintTraverse_Hooked(PVOID pPanels, int edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce)
- {
- oPaintTraverse(pPanels, vguiPanel, forceRepaint, allowForce);
- static unsigned int FocusOverlayPanel = 0;
- static bool FoundPanel = false;
- if (!FoundPanel)
- {
- PCHAR szPanelName = (PCHAR)Interfaces::Panels->GetName(vguiPanel);
- if (strstr(szPanelName, "MatSystemTopPanel"))
- {
- FocusOverlayPanel = vguiPanel;
- FoundPanel = true;
- }
- }
- else if (FocusOverlayPanel == vguiPanel)
- {
- //Render::GradientV(8, 8, 160, 18, Color(0, 0, 0, 0), Color(7, 39, 17, 255));
- Render::Text(10, 10, Color(0, 0, 0, 255), Render::Fonts::Menu, "FÜR DIE FAMILIE");
- if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame())
- Hacks::DrawHacks();
- // Update and draw the menu
- Menu::DoUIFrame();
- }
- }
- // InPrediction Hooked Function
- bool __stdcall Hooked_InPrediction()
- {
- bool result;
- static InPrediction_ origFunc = (InPrediction_)Hooks::VMTPrediction.dwGetMethodAddress(14);
- static DWORD *ecxVal = Interfaces::Prediction;
- result = origFunc(ecxVal);
- // If we are in the right place where the player view is calculated
- // Calculate the change in the view and get rid of it
- if (Menu::Window.VisualsTab.OtherNoVisualRecoil.GetState() && (DWORD)(_ReturnAddress()) == Offsets::Functions::dwCalcPlayerView)
- {
- IClientEntity* pLocalEntity = NULL;
- float* m_LocalViewAngles = NULL;
- __asm
- {
- MOV pLocalEntity, ESI
- MOV m_LocalViewAngles, EBX
- }
- Vector viewPunch = pLocalEntity->localPlayerExclusive()->GetViewPunchAngle();
- Vector aimPunch = pLocalEntity->localPlayerExclusive()->GetAimPunchAngle();
- m_LocalViewAngles[0] -= (viewPunch[0] + (aimPunch[0] * 2 * 0.4499999f));
- m_LocalViewAngles[1] -= (viewPunch[1] + (aimPunch[1] * 2 * 0.4499999f));
- m_LocalViewAngles[2] -= (viewPunch[2] + (aimPunch[2] * 2 * 0.4499999f));
- return true;
- }
- return result;
- }
- // DrawModelExec for chams and shit
- void __fastcall Hooked_DrawModelExecute(void* thisptr, int edx, void* ctx, void* state, const ModelRenderInfo_t &pInfo, matrix3x4 *pCustomBoneToWorld)
- {
- Color color;
- float flColor[3] = { 0.f };
- static IMaterial* CoveredLit = CreateMaterial(true);
- static IMaterial* OpenLit = CreateMaterial(false);
- static IMaterial* CoveredFlat = CreateMaterial(true, false);
- static IMaterial* OpenFlat = CreateMaterial(false, false);
- static IMaterial* Chrome = CreateMaterial("$envmap env_cube");
- bool DontDraw = false;
- const char* ModelName = Interfaces::ModelInfo->GetModelName((model_t*)pInfo.pModel);
- IClientEntity* pModelEntity = (IClientEntity*)Interfaces::EntList->GetClientEntity(pInfo.entity_index);
- IClientEntity* pLocal = (IClientEntity*)Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- if (Menu::Window.VisualsTab.Active.GetState())
- {
- // Player Chams
- int ChamsStyle = Menu::Window.VisualsTab.OptionsChams.GetIndex();
- int HandsStyle = Menu::Window.VisualsTab.OtherNoHands.GetIndex();
- if (ChamsStyle != 0 && Menu::Window.VisualsTab.FiltersPlayers.GetState() && strstr(ModelName, "models/player"))
- {
- if (pLocal && (!Menu::Window.VisualsTab.FiltersEnemiesOnly.GetState() ||
- pModelEntity->GetTeamNum() != pLocal->GetTeamNum()))
- {
- IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
- IMaterial *open = ChamsStyle == 1 ? OpenLit : OpenFlat;
- IClientEntity* pModelEntity = (IClientEntity*)Interfaces::EntList->GetClientEntity(pInfo.entity_index);
- if (pModelEntity)
- {
- IClientEntity *local = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- if (local)
- {
- if (pModelEntity->IsAlive() && pModelEntity->GetHealth() > 0 /*&& pModelEntity->GetTeamNum() != local->GetTeamNum()*/)
- {
- float alpha = 1.f;
- if (pModelEntity->HasGunGameImmunity())
- alpha = 0.5f;
- if (pModelEntity->GetTeamNum() == 2)
- {
- flColor[0] = 255.f / 255.f;
- flColor[1] = 0.f / 255.f; // t invis
- flColor[2] = 0.f / 255.f;
- }
- else
- {
- flColor[0] = 0.f / 255.f; // ct invis
- flColor[1] = 0.f / 255.f;
- flColor[2] = 255.f / 255.f;
- }
- Interfaces::RenderView->SetColorModulation(flColor);
- Interfaces::RenderView->SetBlend(alpha);
- Interfaces::ModelRender->ForcedMaterialOverride(covered);
- oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
- if (pModelEntity->GetTeamNum() == 2)
- {
- flColor[0] = 255.f / 255.f; //T svis
- flColor[1] = 255.f / 255.f;
- flColor[2] = 0.f / 255.f;
- }
- else
- {
- flColor[0] = 0.f / 255.f; //Ct vis
- flColor[1] = 255.f / 255.f;
- flColor[2] = 0.f / 255.f;
- }
- Interfaces::RenderView->SetColorModulation(flColor);
- Interfaces::RenderView->SetBlend(alpha);
- Interfaces::ModelRender->ForcedMaterialOverride(open);
- }
- else
- {
- color.SetColor(255, 255, 255, 255);
- ForceMaterial(color, open);
- }
- }
- }
- }
- }
- else if (HandsStyle != 0 && strstr(ModelName, "arms"))
- {
- if (HandsStyle == 1)
- {
- DontDraw = true;
- }
- else if (HandsStyle == 2)
- {
- Interfaces::RenderView->SetBlend(0.3);
- }
- else if (HandsStyle == 5)
- {
- static IMaterial* wire = CreateMaterial(true, false, true);
- IMaterial *handy = wire;
- Interfaces::RenderView->SetBlend(0.3);
- handy->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, true);
- Interfaces::ModelRender->ForcedMaterialOverride(handy);
- }
- else if (HandsStyle == 3)
- {
- IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
- IMaterial *open = ChamsStyle == 1 ? OpenLit : OpenFlat;
- if (pLocal)
- {
- if (pLocal->IsAlive())
- {
- int alpha = pLocal->HasGunGameImmunity() ? 255 : 255;
- if (pLocal->GetTeamNum() == 2)
- color.SetColor(255, 120, 0, alpha); //t
- else
- color.SetColor(255, 120, 0, alpha); // ct
- ForceMaterial(color, covered);
- oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
- if (pLocal->GetTeamNum() == 2)
- color.SetColor(0, 0, 255, alpha); //visible t
- else
- color.SetColor(0, 0, 255, alpha); //visible ct
- }
- else
- {
- color.SetColor(0, 0, 0, 255);
- }
- ForceMaterial(color, open);
- }
- }
- else
- {
- static int counter = 0;
- static float colors[3] = { 1.f, 0.f, 0.f };
- if (colors[counter] >= 1.0f)
- {
- colors[counter] = 1.0f;
- counter += 1;
- if (counter > 2)
- counter = 0;
- }
- else
- {
- int prev = counter - 1;
- if (prev < 0) prev = 2;
- colors[prev] -= 0.05f;
- colors[counter] += 0.05f;
- }
- Interfaces::RenderView->SetColorModulation(colors);
- Interfaces::RenderView->SetBlend(0.3);
- Interfaces::ModelRender->ForcedMaterialOverride(OpenLit);
- }
- }
- else if (ChamsStyle != 0 && Menu::Window.VisualsTab.FiltersWeapons.GetState() && strstr(ModelName, "_dropped.mdl"))
- {
- IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
- color.SetColor(0, 0, 0, 255);
- ForceMaterial(color, covered);
- }
- }
- if (!DontDraw)
- oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
- Interfaces::ModelRender->ForcedMaterialOverride(NULL);
- }
- /*bool __fastcall CreateMoveClient_Hooked(void* self, int edx, float frametime, CUserCmd* pCmd)
- {
- void* pEbp;
- __asm mov pEbp, ebp;
- bool* pSendPacket = (bool*)*(DWORD*)pEbp - 0x1c;
- if (*pSendPacket != 0x1)
- {
- pSendPacket = nullptr;
- }
- if (*pSendPacket)
- {
- pSendPacket = false;
- }
- }*/
- // ClientMode CreateMove
- bool __stdcall CreateMoveClient_Hooked(/*void* self, int edx,*/ float frametime, CUserCmd* pCmd)
- {
- // Choke packet memes
- if (!pCmd->command_number)
- return true;
- if (Interfaces::Engine->IsConnected() || Interfaces::Engine->IsInGame())
- {
- PVOID pebp;
- __asm mov pebp, ebp;
- bool* pbSendPacket = (bool*)(*(DWORD*)pebp - 0x1C);
- bool& bSendPacket = *pbSendPacket;
- if (GetKeyState(VK_NUMPAD2) && !(pCmd->buttons & IN_ATTACK))
- {
- static int Ticks = 0;
- if ((Ticks < 6))
- bSendPacket = false;
- if (Ticks == (6 * 2))
- {
- bSendPacket = true;
- Ticks = 0;
- }
- Ticks++;
- }
- // Backup for safety
- Vector origView = pCmd->viewangles;
- Vector viewforward, viewright, viewup, aimforward, aimright, aimup;
- Vector qAimAngles;
- qAimAngles.Init(0.0f, pCmd->viewangles.y, 0.0f);
- AngleVectors(qAimAngles, &viewforward, &viewright, &viewup);
- // Do da hacks
- IClientEntity *pLocal = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame() && pLocal && pLocal->IsAlive())
- Hacks::MoveHacks(pCmd, bSendPacket);
- //Movement Fix
- //GameUtils::CL_FixMove(pCmd, origView);
- qAimAngles.Init(0.0f, GetAutostrafeView().y, 0.0f);
- AngleVectors(qAimAngles, &viewforward, &viewright, &viewup);
- qAimAngles.Init(0.0f, pCmd->viewangles.y, 0.0f);
- AngleVectors(qAimAngles, &aimforward, &aimright, &aimup);
- Vector vForwardNorm; Normalize(viewforward, vForwardNorm);
- Vector vRightNorm; Normalize(viewright, vRightNorm);
- Vector vUpNorm; Normalize(viewup, vUpNorm);
- // Original shit for movement correction
- float forward = pCmd->forwardmove;
- float right = pCmd->sidemove;
- float up = pCmd->upmove;
- if (forward > 450) forward = 450;
- if (right > 450) right = 450;
- if (up > 450) up = 450;
- if (forward < -450) forward = -450;
- if (right < -450) right = -450;
- if (up < -450) up = -450;
- pCmd->forwardmove = DotProduct(forward * vForwardNorm, aimforward) + DotProduct(right * vRightNorm, aimforward) + DotProduct(up * vUpNorm, aimforward);
- pCmd->sidemove = DotProduct(forward * vForwardNorm, aimright) + DotProduct(right * vRightNorm, aimright) + DotProduct(up * vUpNorm, aimright);
- pCmd->upmove = DotProduct(forward * vForwardNorm, aimup) + DotProduct(right * vRightNorm, aimup) + DotProduct(up * vUpNorm, aimup);
- // Angle normalisation
- if (Menu::Window.MiscTab.OtherSafeMode.GetState())
- {
- GameUtils::NormaliseViewAngle(pCmd->viewangles);
- if (pCmd->viewangles.z != 0.0f)
- {
- pCmd->viewangles.z = 0.00;
- }
- if (pCmd->viewangles.x < -89 || pCmd->viewangles.x > 89 || pCmd->viewangles.y < -180 || pCmd->viewangles.y > 180)
- {
- Utilities::Log("Having to re-normalise!");
- GameUtils::NormaliseViewAngle(pCmd->viewangles);
- Beep(750, 800);
- if (pCmd->viewangles.x < -89 || pCmd->viewangles.x > 89 || pCmd->viewangles.y < -180 || pCmd->viewangles.y > 180)
- {
- pCmd->viewangles = origView;
- pCmd->sidemove = right;
- pCmd->forwardmove = forward;
- }
- }
- }
- }
- aathird = pCmd->viewangles;
- return false;
- }
- // Hooked FrameStageNotify for removing visual recoil
- void __stdcall Hooked_FrameStageNotify(ClientFrameStage_t curStage)
- {
- if (curStage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
- {
- IClientEntity *pLocal = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- if (Menu::Window.MiscTab.KnifeEnable.GetState() && pLocal)
- {
- IClientEntity* WeaponEnt = Interfaces::EntList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
- CBaseCombatWeapon* Weapon = (CBaseCombatWeapon*)WeaponEnt;
- if (Weapon)
- {
- static bool LastItemWasKnife = false;
- if (WeaponEnt->GetClientClass()->m_ClassID == (int)CSGOClassID::CKnife)
- {
- *Weapon->FallbackStatTrak() = 1337;
- int Skin = Menu::Window.MiscTab.KnifeSkin.GetIndex();
- if (Skin == 0) *Weapon->FallbackPaintKit() = 416;
- if (Skin == 1) *Weapon->FallbackPaintKit() = 415;
- if (Skin == 3) *Weapon->FallbackPaintKit() = 409;
- if (Skin == 4) *Weapon->FallbackPaintKit() = 0;
- *Weapon->FallbackWear() = 0.0001;
- //*Weapon->m_AttributeManager()->m_Item()->ItemIDHigh() = 0xFFFFF;
- //*Weapon->m_AttributeManager()->m_Item()->ItemIDLow() = 0xFFFFF;
- if (LastItemWasKnife == false)
- {
- //Meme->nFlags &= ~FCVAR_CHEAT;
- //Interfaces::Engine->ClientCmd_Unrestricted("cl_fullupdate");
- //Meme->nFlags |= FCVAR_CHEAT;
- LastItemWasKnife = true;
- }
- *Weapon->m_AttributeManager()->m_Item()->ItemIDLow() = 7;
- int Model = Menu::Window.MiscTab.KnifeModel.GetIndex();
- *Weapon->m_AttributeManager()->m_Item()->ItemIDHigh() = (Model == 0) ? 507 : 500;
- *Weapon->m_AttributeManager()->m_Item()->ItemDefinitionIndex() = (Model == 0) ? 507 : 500;
- if (GUI.GetKeyState(VK_END))
- ForceUpdate();
- }
- }
- }
- }
- if (curStage == FRAME_RENDER_START)
- {
- IClientEntity* pLocal1 = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame() && pLocal1 && pLocal1->IsAlive())
- {
- IClientEntity* pLocal = (IClientEntity*)Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
- //BaseEntity* localPlayer = static_cast<BaseEntity*>(g_pEntList->GetClientEntity(g_pEngine->GetLocalPlayer()));
- if (Menu::Window.RageBotTab.ThirdPersonAA.GetState())
- {
- *(Vector*)((DWORD)pLocal + 0x31C4 + 4) = aathird;
- //*(Vector*)((DWORD)pLocal + 0x31C8) = aathird; // (old) // tp aa
- }
- }
- }
- oFrameStageNotify(curStage);
- }
Add Comment
Please, Sign In to add comment