Advertisement
Guest User

main.cpp

a guest
Nov 13th, 2015
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.74 KB | None | 0 0
  1. /*
  2. This code allows us to create a bunny hop hack for CSS,
  3. in theory this will work for most games.
  4. Especially source based like TF2 all Counter-strikes etc.
  5.  
  6. Credits to ExcidiumDubstep for external base tutorial and Nubtik for certain code sections
  7.  
  8. Written by Fleep at http://guidedhacking.com/, feel free to check us out for many tutorials
  9. on cheating and join our friendly hacking community
  10. If you end up releasing any hacks from this code they would be greatly appreciated on our GuidedHacking.
  11. */
  12.  
  13. #include <Windows.h>
  14. #include <iostream>
  15. #include "HackProcess.h"
  16.  
  17. //Create our 'hooking' and process managing object
  18. CHackProcess fProcess;
  19. using namespace std;
  20.  
  21. //The player base is VERY important so we know where our player info is at
  22. //including current jump status so we can use force jumping making our bHop
  23. const DWORD Player_Base = 0x60DC98;//0x00574560;
  24. //BY WRITTING 1 BYTE TO JUMP WE ARE PERFORMING THE ACTION + JUMP
  25. //FOUND BY SEARCHING FOR 5 WHEN ENTERING + JUMP AND 4 WHEN - JUMP
  26. const DWORD dw_Jump = 0x692364;//client.dll
  27. //Read the current jump status
  28. const DWORD dw_JumpOffset = 0x350;
  29.  
  30. //Variables required for bunny hop
  31. //is our player on the ground?
  32. #define FL_ONGROUND 257
  33. //0x20 represents space see http://msdn.microsoft.com/en-us/library/ms927178.aspx
  34. #define SPACE_BAR 0x20
  35. //We use F6 to exit the hack
  36. #define F6_Key 0x75
  37. //We write this into Dw_Jump this value to say +Jump
  38. bool b_True = true;
  39. //Or if false -Jump
  40. bool b_False = false;
  41. //Used to set bHop on/off
  42. bool BunnyHopStatus = false;
  43.  
  44. //We will use this struct throughout all other tutorials adding more variables every time
  45. struct MyPlayer_t
  46. {
  47.     DWORD CLocalPlayer;
  48.     int m_fFlags;
  49.     void ReadInformation()
  50.     {
  51.         // Reading CLocalPlayer Pointer to our "CLocalPlayer" DWORD.
  52.         ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + Player_Base), &CLocalPlayer, sizeof(DWORD), 0);
  53.         //Read BHop status
  54.         //Got this by scanning for 0 jumping 1 as a BYTE on ground
  55.         //also checking for different states i n integers, scanned them all and with the results
  56.         //saw the closest one to our base address and added the offset different after comparing in data dissect
  57.         ReadProcessMemory (fProcess.__HandleProcess, (PBYTE*)(CLocalPlayer + dw_JumpOffset), &m_fFlags, sizeof(int), NULL);  //CLocalPlayer + 0x22C
  58.     }
  59. }MyPlayer;
  60.  
  61.  
  62. void BunnyHop()
  63. {
  64.     if(GetAsyncKeyState(SPACE_BAR))
  65.     {
  66.         BunnyHopStatus = !BunnyHopStatus;
  67.         //Normally I would use a timer but because this is very simple we put Sleep for 250ms here
  68.         //so that once we press SPACE then it turns bunny hop On or Off just once
  69.         //If you don't have this here it will switch off/on BHop many times in a second
  70.         Sleep(250);
  71.     }
  72.  
  73.     //If bunny hop is off leave function
  74.     if(!BunnyHopStatus)
  75.         return;
  76.  
  77.     //if space is pressed and we are on the ground then JUMP
  78.     if(MyPlayer.m_fFlags ==  FL_ONGROUND)
  79.     {
  80.         //bHOP bay bay
  81.         WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + dw_Jump), &b_True, sizeof(bool), NULL);
  82.     }
  83.     //If we are in the air reset the flag so we can jump again after
  84.     else if(MyPlayer.m_fFlags != FL_ONGROUND)
  85.     {
  86.         //bHOP bay bay, SWITCH off jump
  87.         WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(fProcess.__dwordClient + dw_Jump), &b_False, sizeof(bool), NULL);
  88.     }
  89. }
  90.  
  91.  
  92. //Our main loop
  93. int main()
  94. {
  95.     fProcess.RunProcess(); // Waiting for CSS......
  96.     cout << "Game found! Running Bunny Hop..." << endl;
  97.  
  98.     //Exit if the F6 key is pressed
  99.     while (!GetAsyncKeyState(F6_Key)) // or for(;;)
  100.     {
  101.         //Read player information into our struct so we know the player
  102.         //base and the bunny hop addresses
  103.         MyPlayer.ReadInformation();
  104.         //std::cout << (int)MyPlayer.f_Flags << std::endl;
  105.  
  106.         //Perform our bunny hop
  107.         BunnyHop();
  108.     }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement