Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <Tlhelp32.h>
- #include <tchar.h>
- #include <iostream>
- void pressSpace();
- uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName);
- int main()
- {
- DWORD processID;
- DWORD posX = 0x28BA354;
- DWORD posY = 0x28BA358;
- DWORD posZ = 0x28BA35C;
- DWORD onGround = 0x28BA3B9;
- DWORD PlayerJump = 0x28BA38C;
- float cPosX;
- bool bhop;
- HWND hWnd = FindWindowA(NULL, "AssaultCube");
- GetWindowThreadProcessId(hWnd, &processID);
- HANDLE gHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
- uintptr_t ac_client = (GetModuleBaseAddress(processID, L"ac_client.exe"));
- // Die Adresse zum LocalPlayer (pointer)
- DWORD localPlayerAddr = (ac_client + 0x10F4F4);
- // Das LocalPlayer Objekt, also das, worauf der pointer LocalPlayerAddr, zeigt
- DWORD localPlayerObject = 0x0;
- // So finden wir heraus, worauf der Pointer zeigt
- ReadProcessMemory(gHandle, (LPCVOID)localPlayerAddr, &localPlayerObject, sizeof(localPlayerObject), NULL);
- // Das Offset für Leben ist 0xF8, also vom LocalPlayer die 0xF8 dazuzählen
- DWORD healthAddr = localPlayerObject + 0xF8;
- int healthValue;
- // Schauen welche Int value an der Adresse healthAddr liegt
- ReadProcessMemory(gHandle, (LPCVOID)healthAddr, &healthValue, sizeof(healthValue), NULL);
- std::cout << "ac_client: " << healthValue << std::endl;
- if (hWnd == 0)
- {
- printf("Coulnd't find game window!\n");
- return 0;
- }
- while (1)
- {
- if (GetAsyncKeyState(VK_CONTROL))
- {
- ReadProcessMemory(gHandle, (LPVOID)onGround, &bhop, sizeof(bhop), 0);
- if (bhop == 1)
- {
- pressSpace();
- }
- }
- }
- return 0;
- }
- void pressSpace()
- {
- INPUT ip;
- ip.type = INPUT_KEYBOARD;
- ip.ki.wScan = 0;
- ip.ki.time = 0;
- ip.ki.dwExtraInfo = 0;
- ip.ki.wVk = 0x20;
- ip.ki.dwFlags = 0; //Press the key down ?
- SendInput(1, &ip, sizeof(INPUT)); //Use function
- Sleep(50); //Sleep so it doesn't spam the key press
- ip.ki.dwFlags = KEYEVENTF_KEYUP; //Release the key
- SendInput(1, &ip, sizeof(INPUT)); //Use function
- }
- uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName)
- {
- uintptr_t modBaseAddr = 0;
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
- if (hSnap != INVALID_HANDLE_VALUE)
- {
- MODULEENTRY32 modEntry;
- modEntry.dwSize = sizeof(modEntry);
- if (Module32First(hSnap, &modEntry))
- {
- do
- {
- if (!_wcsicmp(modEntry.szModule, modName))
- {
- modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
- break;
- }
- } while (Module32Next(hSnap, &modEntry));
- }
- }
- CloseHandle(hSnap);
- return modBaseAddr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement