Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* First we are going to start off with our Includes:
- iostream - Predeclarations for the STD in and out functions
- Windows.h - Predeclarations for the windows API calls
- TlHelp32 - Predeclarations for our Toolhelp32 management
- */
- #include <iostream>
- #include <Windows.h>
- #include <TlHelp32.h>
- //This is the pointer offset for the OnGround variable. Good luck trying to find it.
- const LPCVOID OnGroundOffset = PUT THE OFFSET HERE;
- // Generic opening of a namespace
- using namespace std;
- //Predeclare our actual function for the bhopping
- int startBot(DWORD PID, HWND hWnd);
- //Entry point
- int main(void)
- {
- SetConsoleTitle(L"TraptCode's Bhop Bot");
- //Creates an infinite loop checking to see when Counter-Strike: Source is opened
- while(true)
- {
- cout << "Waiting for Window..." << endl;
- DWORD procID;
- HWND hWnd;
- //Here we are trying to find our window handle, if it doesn't exist, hWnd will equal 0.
- hWnd = FindWindow(L"Valve001", L"Counter-Strike Source");
- while (hWnd==0)
- {
- hWnd = FindWindow(L"Valve001", L"Counter-Strike Source");
- Sleep(200);
- }
- //When the window is found, t will get the process ID from its handle and start the bot.
- GetWindowThreadProcessId(hWnd, &procID);
- startBot(procID, hWnd);
- }
- }
- int startBot(DWORD PID, HWND hWnd)
- {
- cout << "Window Found." << endl;
- HANDLE modSnap;
- MODULEENTRY32 modEntry;
- BOOL allowJump;
- INT OnGround;
- LPCVOID hModule;
- LPCVOID OnGroundAddress;
- LPCVOID OnGroundPointer;
- HANDLE pHandle;
- //Opening the process with Read-Only protections
- pHandle = OpenProcess(0x0010, false, PID);
- //Getting our processes structure
- modSnap = CreateToolhelp32Snapshot(8, PID);
- modEntry.dwSize = sizeof(modEntry);
- //Enumerating each module in search for client.dll
- Module32First(modSnap, &modEntry);
- hModule = NULL;
- do
- {
- if(wcscmp(modEntry.szModule,L"client.dll")==0)
- {
- //Once it is found, we get the address of our OnGroundOffset
- hModule = modEntry.hModule;
- OnGroundPointer = (LPCVOID)((DWORD)hModule + (DWORD)OnGroundOffset);
- ReadProcessMemory(pHandle, OnGroundPointer, &OnGroundAddress, sizeof(OnGroundOffset), NULL);
- }
- }while (Module32Next(modSnap, &modEntry));
- allowJump = TRUE;
- //Makes sure our value exists
- if(OnGroundAddress!=NULL)
- {
- //Make sure the window is still open
- while(FindWindow(L"Valve001", L"Counter-Strike Source")==hWnd)
- {
- //Checks if Counter-Strike: Source is in focus
- if(GetForegroundWindow()==hWnd)
- {
- //Checks to see if the toggle key is pressed. If so, it will allow/disallow the bot to work
- //accordingly
- if(GetAsyncKeyState(VK_MULTIPLY))
- {
- //Switches between our variable
- allowJump = !allowJump;
- while(GetAsyncKeyState(VK_MULTIPLY))
- {
- //Just wait until they let go of the key
- Sleep(20);
- }
- }
- //Makes sure we are enabled first
- if(allowJump)
- {
- //If the user is holding down space, we will check to see if we are on the ground
- if(GetAsyncKeyState(VK_SPACE))
- {
- //Reads our address to get the value
- ReadProcessMemory(pHandle, OnGroundAddress, &OnGround, sizeof(OnGround), NULL);
- //checks if we are on the ground
- if(OnGround==1)
- {
- //Since we are on the ground, we will send a quick key down then key up of the
- //space key
- SendMessage(hWnd, WM_KEYDOWN, VK_SPACE, 0x390000);
- SendMessage(hWnd, WM_KEYUP, VK_SPACE, 0x390000);
- }
- else
- {
- //Since we are in air and still holding space, we want to make sure CS:S thinks
- //the space key is up
- SendMessage(hWnd, WM_KEYUP, VK_SPACE, 0x390000);
- }
- }
- }
- }
- //Take a little nap to prevent overusage of the CPU
- Sleep(1);
- }
- }
- //Self explanitory
- cout << "Window Exited. Starting Over." << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment