Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include <iostream>
- #include <TlHelp32.h>
- #include <tchar.h>
- #include <vector>
- #include <fstream>
- #include <string.h>
- #include <codecvt>
- #include <locale.h>
- using namespace std;
- // addresses we read
- BYTE* healthAdress = NULL;
- // Program information
- DWORD pid; // Process ID of program
- HWND hwnd; // Handle of window
- double health;
- //window
- hwnd = FindWindow(NULL, L"AssaultCube");
- if (!hwnd) {
- cout << "window not foundn";
- cin.get();
- }
- GetWindowThreadProcessId(hwnd, &pid);
- HANDLE phandle = OpenProcess(PROCESS_VM_OPERATION, 0, pid);
- if (!phandle) {
- cout << "could not get handlen";
- cin.get();
- }
- // According to microsoft documentation you can grab a snapshot of modules of a program like this, code is pretty patched together since I was testing things here.
- HANDLE snapshot_test = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
- // Check if the handle is valid
- if (snapshot_test != INVALID_HANDLE_VALUE) {
- MODULEENTRY32 mod_entry;
- mod_entry.dwSize = sizeof(mod_entry);
- int num = 0;
- if (Module32First(snapshot_test, &mod_entry)) {
- //ofstream myfile;
- //myfile.open("D:/Users/Jack/Documents/visual studio 2015/Projects/Digging_Bot/Debug/test.txt", std::ios::binary);
- do {
- if (num == 2) {
- cout << "module base address - ";
- wcout << mod_entry.modBaseAddr << endl;
- healthAdress = mod_entry.modBaseAddr + 0x46F68;
- }
- num += 1;
- //DWORD test = (DWORD)(mod_entry.modBaseAddr + 0x46F68 + 10);
- //cout << ReadProcessMemory(phandle, (void*)(test), &health, sizeof(health), 0);
- }
- while (Module32Next(snapshot_test, &mod_entry));
- //myfile.close();
- }
- else (cout << "module32first error");
- }
- else (cout << "snapshot error");
- while (1) {
- cout << "healthadress - ";
- wcout << healthAdress << endl;
- // Address that the pointer points to
- uintptr_t pointedTo;
- cout << "void test - ";
- wcout << (void*)(healthAdress) << endl;
- ReadProcessMemory(phandle, (void*)(healthAdress), &pointedTo, sizeof(pointedTo), 0);
- cout << "pointed to adress - ";
- wcout << pointedTo;
- ReadProcessMemory(phandle, (void*)pointedTo, &health, sizeof(health), 0);
- wcout << health;
- Sleep(1000)
- }
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement