Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include <iostream>
- #include <Tlhelp32.h>
- using namespace std;
- HMODULE Clientdll = NULL;
- /*HWND hwnd;
- HANDLE phandle;
- DWORD pid;*/
- DWORD GetProcessIDFromName(LPSTR szProcName) //this function gets the id of a process using a name (hl2.exe for instance)
- {
- PROCESSENTRY32 procEntry;
- HANDLE hSnapshot;
- BOOL bFound;
- if(!(hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0))) return 0;
- procEntry.dwSize = sizeof(PROCESSENTRY32);
- bFound = Process32First(hSnapshot, &procEntry);
- while(bFound)
- {
- if(!lstrcmp(procEntry.szExeFile, szProcName))
- {
- CloseHandle(hSnapshot);
- return procEntry.th32ProcessID;
- }
- bFound = Process32Next(hSnapshot, &procEntry);
- }
- CloseHandle(hSnapshot);
- return 0;
- }
- HMODULE GetModuleHandleExtern( char *szModuleName, DWORD dwProcessId ) //GetMoguleHandle recode for external processes
- {
- if( !szModuleName || !dwProcessId ) { return NULL; } //invalid input
- HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwProcessId );
- if( hSnap == INVALID_HANDLE_VALUE ) { return NULL; }
- MODULEENTRY32 me;
- me.dwSize = sizeof( MODULEENTRY32 );
- if( Module32First( hSnap, &me ) ) //we go now
- {
- while( Module32Next( hSnap, &me ) ) //through all modules in the target process
- {
- if( !strcmp( me.szModule, szModuleName ) ) //is this the model we are looking for?
- {
- CloseHandle( hSnap );
- return me.hModule; //this is our module, return it.
- }
- }
- }
- CloseHandle( hSnap );
- return NULL; //counldn't find module
- }
- int main ()
- {
- cout << "waiting for counter strike source...\n";
- while( FindWindowA( "Valve001", NULL ) == NULL ) //before getting the module handle i wait for css
- {
- Sleep( 100 );
- }
- /*
- while (!hwnd) //this is a test trying to fix the actual issue
- {
- hwnd = FindWindowA( "Valve001", NULL );
- }
- GetWindowThreadProcessId(hwnd, &pid);
- phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
- */
- cout << "found the game!\n";
- cout << "the id of process is: " << GetProcessIDFromName("hl2.exe") << "\n"; //showing the id to debug better
- cout << "getting the module handle of client.dll\n";
- do
- {
- Clientdll = GetModuleHandleExtern("client.dll", GetProcessIDFromName("hl2.exe")); //at this point we get the module handle from an ext process
- Sleep(20); //thanks a lot to mencore
- }
- while(Clientdll == NULL); //just looping it until we get it even if this shouldn't be needed
- cout << "got the module handle!!!";
- cout << "the base is: " << Clientdll << "\n"; //showing it to debug it
- while (!GetAsyncKeyState(VK_F10)) //loops the bhop code untill f10 is pressed
- {
- if( (*(int*)((DWORD)Clientdll + 0x590A0C) == 0) && (GetAsyncKeyState(VK_MENU)<0) ) //checks for OnGround->yes and ALT->pressed
- {
- keybd_event(VK_SPACE, 0x39, 0, 0); //simulates jump...
- Sleep(60);
- keybd_event(VK_SPACE, 0x39, KEYEVENTF_KEYUP, 0);
- }
- Sleep(1); //this value could be changed to a greater one to fit slower pc's
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment