Guest User

Untitled

a guest
May 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. /* First we are going to start off with our Includes:
  2. iostream - Predeclarations for the STD in and out functions
  3. Windows.h - Predeclarations for the windows API calls
  4. TlHelp32 - Predeclarations for our Toolhelp32 management
  5. */
  6.  
  7. #include <iostream>
  8. #include <Windows.h>
  9. #include <TlHelp32.h>
  10.  
  11. //This is the pointer offset for the OnGround variable. Good luck trying to find it.
  12. const LPCVOID OnGroundOffset = PUT THE OFFSET HERE;
  13.  
  14. // Generic opening of a namespace
  15. using namespace std;
  16.  
  17. //Predeclare our actual function for the bhopping
  18. int startBot(DWORD PID, HWND hWnd);
  19.  
  20. //Entry point
  21. int main(void)
  22. {
  23. SetConsoleTitle(L"TraptCode's Bhop Bot");
  24.  
  25. //Creates an infinite loop checking to see when Counter-Strike: Source is opened
  26. while(true)
  27. {
  28. cout << "Waiting for Window..." << endl;
  29. DWORD procID;
  30. HWND hWnd;
  31. //Here we are trying to find our window handle, if it doesn't exist, hWnd will equal 0.
  32. hWnd = FindWindow(L"Valve001", L"Counter-Strike Source");
  33. while (hWnd==0)
  34. {
  35. hWnd = FindWindow(L"Valve001", L"Counter-Strike Source");
  36. Sleep(200);
  37. }
  38. //When the window is found, t will get the process ID from its handle and start the bot.
  39. GetWindowThreadProcessId(hWnd, &procID);
  40. startBot(procID, hWnd);
  41. }
  42. }
  43.  
  44. int startBot(DWORD PID, HWND hWnd)
  45. {
  46. cout << "Window Found." << endl;
  47. HANDLE modSnap;
  48. MODULEENTRY32 modEntry;
  49. BOOL allowJump;
  50. INT OnGround;
  51. LPCVOID hModule;
  52. LPCVOID OnGroundAddress;
  53. LPCVOID OnGroundPointer;
  54. HANDLE pHandle;
  55. //Opening the process with Read-Only protections
  56. pHandle = OpenProcess(0x0010, false, PID);
  57. //Getting our processes structure
  58. modSnap = CreateToolhelp32Snapshot(8, PID);
  59. modEntry.dwSize = sizeof(modEntry);
  60. //Enumerating each module in search for client.dll
  61. Module32First(modSnap, &modEntry);
  62. hModule = NULL;
  63. do
  64. {
  65. if(wcscmp(modEntry.szModule,L"client.dll")==0)
  66. {
  67. //Once it is found, we get the address of our OnGroundOffset
  68. hModule = modEntry.hModule;
  69. OnGroundPointer = (LPCVOID)((DWORD)hModule + (DWORD)OnGroundOffset);
  70. ReadProcessMemory(pHandle, OnGroundPointer, &OnGroundAddress, sizeof(OnGroundOffset), NULL);
  71. }
  72. }while (Module32Next(modSnap, &modEntry));
  73.  
  74. allowJump = TRUE;
  75.  
  76. //Makes sure our value exists
  77. if(OnGroundAddress!=NULL)
  78. {
  79. //Make sure the window is still open
  80. while(FindWindow(L"Valve001", L"Counter-Strike Source")==hWnd)
  81. {
  82. //Checks if Counter-Strike: Source is in focus
  83. if(GetForegroundWindow()==hWnd)
  84. {
  85. //Checks to see if the toggle key is pressed. If so, it will allow/disallow the bot to work
  86. //accordingly
  87. if(GetAsyncKeyState(VK_MULTIPLY))
  88. {
  89. //Switches between our variable
  90. allowJump = !allowJump;
  91. while(GetAsyncKeyState(VK_MULTIPLY))
  92. {
  93. //Just wait until they let go of the key
  94. Sleep(20);
  95. }
  96. }
  97.  
  98. //Makes sure we are enabled first
  99. if(allowJump)
  100. {
  101. //If the user is holding down space, we will check to see if we are on the ground
  102. if(GetAsyncKeyState(VK_SPACE))
  103. {
  104. //Reads our address to get the value
  105. ReadProcessMemory(pHandle, OnGroundAddress, &OnGround, sizeof(OnGround), NULL);
  106. //checks if we are on the ground
  107. if(OnGround==1)
  108. {
  109. //Since we are on the ground, we will send a quick key down then key up of the
  110. //space key
  111. SendMessage(hWnd, WM_KEYDOWN, VK_SPACE, 0x390000);
  112. SendMessage(hWnd, WM_KEYUP, VK_SPACE, 0x390000);
  113. }
  114. else
  115. {
  116. //Since we are in air and still holding space, we want to make sure CS:S thinks
  117. //the space key is up
  118. SendMessage(hWnd, WM_KEYUP, VK_SPACE, 0x390000);
  119. }
  120. }
  121. }
  122. }
  123. //Take a little nap to prevent overusage of the CPU
  124. Sleep(1);
  125. }
  126. }
  127. //Self explanitory
  128. cout << "Window Exited. Starting Over." << endl;
  129. return 0;
  130. }
Add Comment
Please, Sign In to add comment