Guest User

Untitled

a guest
Feb 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.68 KB | None | 0 0
  1. #include "Hooks.h"
  2. #include "Hacks.h"
  3. #include "Chams.h"
  4. #include "Menu.h"
  5. #include "Interfaces.h"
  6. #include "RenderManager.h"
  7. #include "MiscHacks.h"
  8.  
  9. float rainbowx = 1;
  10.  
  11. // Funtion Typedefs
  12. typedef void(__thiscall* DrawModelEx_)(void*, void*, void*, const ModelRenderInfo_t&, matrix3x4*);
  13. typedef void(__thiscall* PaintTraverse_)(PVOID, unsigned int, bool, bool);
  14. typedef bool(__thiscall* InPrediction_)(PVOID);
  15. typedef void(__stdcall *FrameStageNotifyFn)(ClientFrameStage_t);
  16.  
  17. // Function Pointers to the originals
  18. PaintTraverse_ oPaintTraverse;
  19. DrawModelEx_ oDrawModelExecute;
  20. FrameStageNotifyFn oFrameStageNotify;
  21. Vector aathird;
  22. // Hook function prototypes
  23. void __fastcall PaintTraverse_Hooked(PVOID pPanels, int edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce);
  24. bool __stdcall Hooked_InPrediction();
  25. void __fastcall Hooked_DrawModelExecute(void* thisptr, int edx, void* ctx, void* state, const ModelRenderInfo_t &pInfo, matrix3x4 *pCustomBoneToWorld);
  26. bool __stdcall CreateMoveClient_Hooked(/*void* self, int edx,*/ float frametime, CUserCmd* pCmd);
  27. void __stdcall Hooked_FrameStageNotify(ClientFrameStage_t curStage);
  28.  
  29. // VMT Managers
  30. namespace Hooks
  31. {
  32. // VMT Managers
  33. Utilities::Memory::CVMTHookManager VMTPanel; // Hooking drawing functions
  34. Utilities::Memory::CVMTHookManager VMTClient; // Maybe CreateMove
  35. Utilities::Memory::CVMTHookManager VMTClientMode; // CreateMove for functionality
  36. Utilities::Memory::CVMTHookManager VMTModelRender; // DrawModelEx for chams
  37. Utilities::Memory::CVMTHookManager VMTPrediction; // InPrediction for no vis recoil
  38. };
  39.  
  40. // Initialise all our hooks
  41. void Hooks::Initialise()
  42. {
  43.  
  44.  
  45. // Panel hooks for drawing to the screen via surface functions
  46. VMTPanel.bInitialize((PDWORD*)Interfaces::Panels);
  47. oPaintTraverse = (PaintTraverse_)VMTPanel.dwHookMethod((DWORD)PaintTraverse_Hooked, Offsets::VMT::Panel_PaintTraverse);
  48. VMTPanel.ReHook();
  49. //Utilities::Log("Paint Traverse Hooked");
  50.  
  51. // No Visual Recoil
  52. VMTPrediction.bInitialize((PDWORD*)Interfaces::Prediction);
  53. VMTPrediction.dwHookMethod((DWORD)Hooked_InPrediction, 14);
  54. VMTPrediction.ReHook();
  55. //Utilities::Log("InPrediction Hooked");
  56.  
  57. // Chams
  58. VMTModelRender.bInitialize((PDWORD*)Interfaces::ModelRender);
  59. oDrawModelExecute = (DrawModelEx_)VMTModelRender.dwHookMethod((DWORD)Hooked_DrawModelExecute, Offsets::VMT::ModelRender_DrawModelExecute);
  60. VMTModelRender.ReHook();
  61. //Utilities::Log("DrawModelExecute Hooked");
  62.  
  63. // Setup ClientMode Hooks
  64. VMTClientMode.bInitialize((PDWORD*)Interfaces::ClientMode);
  65. VMTClientMode.dwHookMethod((DWORD)CreateMoveClient_Hooked, 24);
  66. VMTClient.ReHook();
  67. //Utilities::Log("ClientMode CreateMove Hooked");
  68.  
  69. // Setup client hooks
  70. VMTClient.bInitialize((PDWORD*)Interfaces::Client);
  71. oFrameStageNotify = (FrameStageNotifyFn)VMTClient.dwHookMethod((DWORD)&Hooked_FrameStageNotify, 36);
  72. }
  73.  
  74. // Undo our hooks
  75. void Hooks::UndoHooks()
  76. {
  77. VMTPanel.UnHook();
  78. VMTPrediction.UnHook();
  79. VMTModelRender.UnHook();
  80. VMTClientMode.UnHook();
  81. }
  82.  
  83. void MovementCorrection(CUserCmd* pCmd)
  84. {
  85.  
  86. }
  87.  
  88. //---------------------------------------------------------------------------------------------------------
  89. // Hooked Functions
  90. //---------------------------------------------------------------------------------------------------------
  91.  
  92. // Paint Traverse Hooked function
  93. void __fastcall PaintTraverse_Hooked(PVOID pPanels, int edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce)
  94. {
  95. oPaintTraverse(pPanels, vguiPanel, forceRepaint, allowForce);
  96.  
  97. static unsigned int FocusOverlayPanel = 0;
  98. static bool FoundPanel = false;
  99.  
  100. if (!FoundPanel)
  101. {
  102. PCHAR szPanelName = (PCHAR)Interfaces::Panels->GetName(vguiPanel);
  103. if (strstr(szPanelName, "MatSystemTopPanel"))
  104. {
  105. FocusOverlayPanel = vguiPanel;
  106. FoundPanel = true;
  107. }
  108. }
  109. else if (FocusOverlayPanel == vguiPanel)
  110. {
  111. //Render::GradientV(8, 8, 160, 18, Color(0, 0, 0, 0), Color(7, 39, 17, 255));
  112. Render::Text(10, 10, Color(0, 0, 0, 255), Render::Fonts::Menu, "FÜR DIE FAMILIE");
  113.  
  114. if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame())
  115. Hacks::DrawHacks();
  116.  
  117. // Update and draw the menu
  118. Menu::DoUIFrame();
  119. }
  120. }
  121.  
  122. // InPrediction Hooked Function
  123. bool __stdcall Hooked_InPrediction()
  124. {
  125. bool result;
  126. static InPrediction_ origFunc = (InPrediction_)Hooks::VMTPrediction.dwGetMethodAddress(14);
  127. static DWORD *ecxVal = Interfaces::Prediction;
  128. result = origFunc(ecxVal);
  129.  
  130. // If we are in the right place where the player view is calculated
  131. // Calculate the change in the view and get rid of it
  132. if (Menu::Window.VisualsTab.OtherNoVisualRecoil.GetState() && (DWORD)(_ReturnAddress()) == Offsets::Functions::dwCalcPlayerView)
  133. {
  134. IClientEntity* pLocalEntity = NULL;
  135.  
  136. float* m_LocalViewAngles = NULL;
  137.  
  138. __asm
  139. {
  140. MOV pLocalEntity, ESI
  141. MOV m_LocalViewAngles, EBX
  142. }
  143.  
  144. Vector viewPunch = pLocalEntity->localPlayerExclusive()->GetViewPunchAngle();
  145. Vector aimPunch = pLocalEntity->localPlayerExclusive()->GetAimPunchAngle();
  146.  
  147. m_LocalViewAngles[0] -= (viewPunch[0] + (aimPunch[0] * 2 * 0.4499999f));
  148. m_LocalViewAngles[1] -= (viewPunch[1] + (aimPunch[1] * 2 * 0.4499999f));
  149. m_LocalViewAngles[2] -= (viewPunch[2] + (aimPunch[2] * 2 * 0.4499999f));
  150. return true;
  151. }
  152.  
  153. return result;
  154. }
  155.  
  156. // DrawModelExec for chams and shit
  157. void __fastcall Hooked_DrawModelExecute(void* thisptr, int edx, void* ctx, void* state, const ModelRenderInfo_t &pInfo, matrix3x4 *pCustomBoneToWorld)
  158. {
  159. Color color;
  160. float flColor[3] = { 0.f };
  161. static IMaterial* CoveredLit = CreateMaterial(true);
  162. static IMaterial* OpenLit = CreateMaterial(false);
  163. static IMaterial* CoveredFlat = CreateMaterial(true, false);
  164. static IMaterial* OpenFlat = CreateMaterial(false, false);
  165. static IMaterial* Chrome = CreateMaterial("$envmap env_cube");
  166. bool DontDraw = false;
  167.  
  168. const char* ModelName = Interfaces::ModelInfo->GetModelName((model_t*)pInfo.pModel);
  169. IClientEntity* pModelEntity = (IClientEntity*)Interfaces::EntList->GetClientEntity(pInfo.entity_index);
  170. IClientEntity* pLocal = (IClientEntity*)Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  171.  
  172. if (Menu::Window.VisualsTab.Active.GetState())
  173. {
  174. // Player Chams
  175. int ChamsStyle = Menu::Window.VisualsTab.OptionsChams.GetIndex();
  176. int HandsStyle = Menu::Window.VisualsTab.OtherNoHands.GetIndex();
  177. if (ChamsStyle != 0 && Menu::Window.VisualsTab.FiltersPlayers.GetState() && strstr(ModelName, "models/player"))
  178. {
  179. if (pLocal && (!Menu::Window.VisualsTab.FiltersEnemiesOnly.GetState() ||
  180. pModelEntity->GetTeamNum() != pLocal->GetTeamNum()))
  181. {
  182. IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
  183. IMaterial *open = ChamsStyle == 1 ? OpenLit : OpenFlat;
  184.  
  185. IClientEntity* pModelEntity = (IClientEntity*)Interfaces::EntList->GetClientEntity(pInfo.entity_index);
  186. if (pModelEntity)
  187. {
  188. IClientEntity *local = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  189. if (local)
  190. {
  191. if (pModelEntity->IsAlive() && pModelEntity->GetHealth() > 0 /*&& pModelEntity->GetTeamNum() != local->GetTeamNum()*/)
  192. {
  193. float alpha = 1.f;
  194.  
  195. if (pModelEntity->HasGunGameImmunity())
  196. alpha = 0.5f;
  197.  
  198. if (pModelEntity->GetTeamNum() == 2)
  199. {
  200. flColor[0] = 255.f / 255.f;
  201. flColor[1] = 0.f / 255.f; // t invis
  202. flColor[2] = 0.f / 255.f;
  203. }
  204. else
  205. {
  206. flColor[0] = 0.f / 255.f; // ct invis
  207. flColor[1] = 0.f / 255.f;
  208. flColor[2] = 255.f / 255.f;
  209. }
  210.  
  211. Interfaces::RenderView->SetColorModulation(flColor);
  212. Interfaces::RenderView->SetBlend(alpha);
  213. Interfaces::ModelRender->ForcedMaterialOverride(covered);
  214. oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
  215.  
  216. if (pModelEntity->GetTeamNum() == 2)
  217. {
  218. flColor[0] = 255.f / 255.f; //T svis
  219. flColor[1] = 255.f / 255.f;
  220. flColor[2] = 0.f / 255.f;
  221. }
  222. else
  223. {
  224. flColor[0] = 0.f / 255.f; //Ct vis
  225. flColor[1] = 255.f / 255.f;
  226. flColor[2] = 0.f / 255.f;
  227. }
  228.  
  229. Interfaces::RenderView->SetColorModulation(flColor);
  230. Interfaces::RenderView->SetBlend(alpha);
  231. Interfaces::ModelRender->ForcedMaterialOverride(open);
  232. }
  233. else
  234. {
  235. color.SetColor(255, 255, 255, 255);
  236. ForceMaterial(color, open);
  237. }
  238. }
  239. }
  240. }
  241. }
  242. else if (HandsStyle != 0 && strstr(ModelName, "arms"))
  243. {
  244. if (HandsStyle == 1)
  245. {
  246. DontDraw = true;
  247. }
  248. else if (HandsStyle == 2)
  249. {
  250. Interfaces::RenderView->SetBlend(0.3);
  251. }
  252. else if (HandsStyle == 5)
  253. {
  254. static IMaterial* wire = CreateMaterial(true, false, true);
  255. IMaterial *handy = wire;
  256. Interfaces::RenderView->SetBlend(0.3);
  257. handy->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, true);
  258. Interfaces::ModelRender->ForcedMaterialOverride(handy);
  259. }
  260. else if (HandsStyle == 3)
  261. {
  262. IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
  263. IMaterial *open = ChamsStyle == 1 ? OpenLit : OpenFlat;
  264. if (pLocal)
  265. {
  266. if (pLocal->IsAlive())
  267. {
  268. int alpha = pLocal->HasGunGameImmunity() ? 255 : 255;
  269.  
  270. if (pLocal->GetTeamNum() == 2)
  271. color.SetColor(255, 120, 0, alpha); //t
  272. else
  273. color.SetColor(255, 120, 0, alpha); // ct
  274.  
  275. ForceMaterial(color, covered);
  276. oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
  277.  
  278. if (pLocal->GetTeamNum() == 2)
  279. color.SetColor(0, 0, 255, alpha); //visible t
  280. else
  281. color.SetColor(0, 0, 255, alpha); //visible ct
  282. }
  283. else
  284. {
  285. color.SetColor(0, 0, 0, 255);
  286. }
  287.  
  288. ForceMaterial(color, open);
  289. }
  290. }
  291. else
  292. {
  293. static int counter = 0;
  294. static float colors[3] = { 1.f, 0.f, 0.f };
  295.  
  296. if (colors[counter] >= 1.0f)
  297. {
  298. colors[counter] = 1.0f;
  299. counter += 1;
  300. if (counter > 2)
  301. counter = 0;
  302. }
  303. else
  304. {
  305. int prev = counter - 1;
  306. if (prev < 0) prev = 2;
  307. colors[prev] -= 0.05f;
  308. colors[counter] += 0.05f;
  309. }
  310.  
  311. Interfaces::RenderView->SetColorModulation(colors);
  312. Interfaces::RenderView->SetBlend(0.3);
  313. Interfaces::ModelRender->ForcedMaterialOverride(OpenLit);
  314. }
  315. }
  316. else if (ChamsStyle != 0 && Menu::Window.VisualsTab.FiltersWeapons.GetState() && strstr(ModelName, "_dropped.mdl"))
  317. {
  318. IMaterial *covered = ChamsStyle == 1 ? CoveredLit : CoveredFlat;
  319. color.SetColor(0, 0, 0, 255);
  320. ForceMaterial(color, covered);
  321. }
  322. }
  323.  
  324. if (!DontDraw)
  325. oDrawModelExecute(thisptr, ctx, state, pInfo, pCustomBoneToWorld);
  326. Interfaces::ModelRender->ForcedMaterialOverride(NULL);
  327. }
  328.  
  329. /*bool __fastcall CreateMoveClient_Hooked(void* self, int edx, float frametime, CUserCmd* pCmd)
  330. {
  331. void* pEbp;
  332. __asm mov pEbp, ebp;
  333.  
  334. bool* pSendPacket = (bool*)*(DWORD*)pEbp - 0x1c;
  335. if (*pSendPacket != 0x1)
  336. {
  337. pSendPacket = nullptr;
  338. }
  339.  
  340. if (*pSendPacket)
  341. {
  342. pSendPacket = false;
  343. }
  344. }*/
  345.  
  346. // ClientMode CreateMove
  347. bool __stdcall CreateMoveClient_Hooked(/*void* self, int edx,*/ float frametime, CUserCmd* pCmd)
  348. {
  349. // Choke packet memes
  350.  
  351. if (!pCmd->command_number)
  352. return true;
  353.  
  354. if (Interfaces::Engine->IsConnected() || Interfaces::Engine->IsInGame())
  355. {
  356.  
  357. PVOID pebp;
  358.  
  359. __asm mov pebp, ebp;
  360.  
  361. bool* pbSendPacket = (bool*)(*(DWORD*)pebp - 0x1C);
  362. bool& bSendPacket = *pbSendPacket;
  363.  
  364. if (GetKeyState(VK_NUMPAD2) && !(pCmd->buttons & IN_ATTACK))
  365. {
  366. static int Ticks = 0;
  367.  
  368. if ((Ticks < 6))
  369. bSendPacket = false;
  370.  
  371. if (Ticks == (6 * 2))
  372. {
  373. bSendPacket = true;
  374.  
  375. Ticks = 0;
  376. }
  377.  
  378. Ticks++;
  379. }
  380.  
  381. // Backup for safety
  382. Vector origView = pCmd->viewangles;
  383. Vector viewforward, viewright, viewup, aimforward, aimright, aimup;
  384. Vector qAimAngles;
  385. qAimAngles.Init(0.0f, pCmd->viewangles.y, 0.0f);
  386. AngleVectors(qAimAngles, &viewforward, &viewright, &viewup);
  387.  
  388. // Do da hacks
  389. IClientEntity *pLocal = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  390. if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame() && pLocal && pLocal->IsAlive())
  391. Hacks::MoveHacks(pCmd, bSendPacket);
  392.  
  393. //Movement Fix
  394. //GameUtils::CL_FixMove(pCmd, origView);
  395. qAimAngles.Init(0.0f, GetAutostrafeView().y, 0.0f);
  396. AngleVectors(qAimAngles, &viewforward, &viewright, &viewup);
  397. qAimAngles.Init(0.0f, pCmd->viewangles.y, 0.0f);
  398. AngleVectors(qAimAngles, &aimforward, &aimright, &aimup);
  399. Vector vForwardNorm; Normalize(viewforward, vForwardNorm);
  400. Vector vRightNorm; Normalize(viewright, vRightNorm);
  401. Vector vUpNorm; Normalize(viewup, vUpNorm);
  402.  
  403. // Original shit for movement correction
  404. float forward = pCmd->forwardmove;
  405. float right = pCmd->sidemove;
  406. float up = pCmd->upmove;
  407. if (forward > 450) forward = 450;
  408. if (right > 450) right = 450;
  409. if (up > 450) up = 450;
  410. if (forward < -450) forward = -450;
  411. if (right < -450) right = -450;
  412. if (up < -450) up = -450;
  413. pCmd->forwardmove = DotProduct(forward * vForwardNorm, aimforward) + DotProduct(right * vRightNorm, aimforward) + DotProduct(up * vUpNorm, aimforward);
  414. pCmd->sidemove = DotProduct(forward * vForwardNorm, aimright) + DotProduct(right * vRightNorm, aimright) + DotProduct(up * vUpNorm, aimright);
  415. pCmd->upmove = DotProduct(forward * vForwardNorm, aimup) + DotProduct(right * vRightNorm, aimup) + DotProduct(up * vUpNorm, aimup);
  416.  
  417. // Angle normalisation
  418. if (Menu::Window.MiscTab.OtherSafeMode.GetState())
  419. {
  420. GameUtils::NormaliseViewAngle(pCmd->viewangles);
  421.  
  422. if (pCmd->viewangles.z != 0.0f)
  423. {
  424. pCmd->viewangles.z = 0.00;
  425. }
  426.  
  427. if (pCmd->viewangles.x < -89 || pCmd->viewangles.x > 89 || pCmd->viewangles.y < -180 || pCmd->viewangles.y > 180)
  428. {
  429. Utilities::Log("Having to re-normalise!");
  430. GameUtils::NormaliseViewAngle(pCmd->viewangles);
  431. Beep(750, 800);
  432. if (pCmd->viewangles.x < -89 || pCmd->viewangles.x > 89 || pCmd->viewangles.y < -180 || pCmd->viewangles.y > 180)
  433. {
  434. pCmd->viewangles = origView;
  435. pCmd->sidemove = right;
  436. pCmd->forwardmove = forward;
  437. }
  438. }
  439. }
  440. }
  441. aathird = pCmd->viewangles;
  442.  
  443. return false;
  444. }
  445.  
  446. // Hooked FrameStageNotify for removing visual recoil
  447. void __stdcall Hooked_FrameStageNotify(ClientFrameStage_t curStage)
  448. {
  449.  
  450.  
  451. if (curStage == FRAME_NET_UPDATE_POSTDATAUPDATE_START)
  452. {
  453. IClientEntity *pLocal = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  454. if (Menu::Window.MiscTab.KnifeEnable.GetState() && pLocal)
  455. {
  456. IClientEntity* WeaponEnt = Interfaces::EntList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
  457. CBaseCombatWeapon* Weapon = (CBaseCombatWeapon*)WeaponEnt;
  458. if (Weapon)
  459. {
  460. static bool LastItemWasKnife = false;
  461. if (WeaponEnt->GetClientClass()->m_ClassID == (int)CSGOClassID::CKnife)
  462. {
  463. *Weapon->FallbackStatTrak() = 1337;
  464. int Skin = Menu::Window.MiscTab.KnifeSkin.GetIndex();
  465. if (Skin == 0) *Weapon->FallbackPaintKit() = 416;
  466. if (Skin == 1) *Weapon->FallbackPaintKit() = 415;
  467. if (Skin == 3) *Weapon->FallbackPaintKit() = 409;
  468. if (Skin == 4) *Weapon->FallbackPaintKit() = 0;
  469. *Weapon->FallbackWear() = 0.0001;
  470.  
  471. //*Weapon->m_AttributeManager()->m_Item()->ItemIDHigh() = 0xFFFFF;
  472. //*Weapon->m_AttributeManager()->m_Item()->ItemIDLow() = 0xFFFFF;
  473.  
  474. if (LastItemWasKnife == false)
  475. {
  476.  
  477. //Meme->nFlags &= ~FCVAR_CHEAT;
  478. //Interfaces::Engine->ClientCmd_Unrestricted("cl_fullupdate");
  479.  
  480. //Meme->nFlags |= FCVAR_CHEAT;
  481.  
  482. LastItemWasKnife = true;
  483. }
  484.  
  485. *Weapon->m_AttributeManager()->m_Item()->ItemIDLow() = 7;
  486. int Model = Menu::Window.MiscTab.KnifeModel.GetIndex();
  487. *Weapon->m_AttributeManager()->m_Item()->ItemIDHigh() = (Model == 0) ? 507 : 500;
  488. *Weapon->m_AttributeManager()->m_Item()->ItemDefinitionIndex() = (Model == 0) ? 507 : 500;
  489.  
  490. if (GUI.GetKeyState(VK_END))
  491. ForceUpdate();
  492. }
  493. }
  494. }
  495. }
  496. if (curStage == FRAME_RENDER_START)
  497. {
  498. IClientEntity* pLocal1 = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  499. if (Interfaces::Engine->IsConnected() && Interfaces::Engine->IsInGame() && pLocal1 && pLocal1->IsAlive())
  500. {
  501. IClientEntity* pLocal = (IClientEntity*)Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
  502. //BaseEntity* localPlayer = static_cast<BaseEntity*>(g_pEntList->GetClientEntity(g_pEngine->GetLocalPlayer()));
  503. if (Menu::Window.RageBotTab.ThirdPersonAA.GetState())
  504. {
  505. *(Vector*)((DWORD)pLocal + 0x31C4 + 4) = aathird;
  506. //*(Vector*)((DWORD)pLocal + 0x31C8) = aathird; // (old) // tp aa
  507.  
  508. }
  509. }
  510. }
  511. oFrameStageNotify(curStage);
  512.  
  513. }
Add Comment
Please, Sign In to add comment