I took a break for a year, now I'm back to writing my Radar hack. I upgraded to Windows 10 and Visual Studio 2015 Community, and now the program is broken.
I created a simple test program to see what I'm doing wrong on the simplest level, but I can't debug it. I'm not getting any error messages, and except for the values being wrong, everything seems to be OK.
Code:
#include "stdafx.h"
#include <psapi.h>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
#define LOCAL_PLAYER 0x169DF10
#define DESCRIPTORS 0x08
#define UNIT_HEALTH 0x0F0
#define UNIT_LEVEL 0x160
int main()
{
CString message;
DWORD PID;
DWORD_PTR address_base;
HANDLE phandle;
HWND w_handle = ::FindWindow(NULL, L"World of Warcraft");
if (!w_handle)
{
cout << "WoW isn't running." << endl;
return 1;
}
GetWindowThreadProcessId(w_handle, &PID);
phandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, PID);
if (phandle == NULL)
{
cout << "DEBUG: Phandle bad." << endl;
return 1;
}
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
HMODULE *moduleArray;
LPBYTE moduleArrayBytes;
DWORD bytesRequired;
if (processHandle)
{
if (EnumProcessModules(processHandle, NULL, 0, &bytesRequired)) {
if (bytesRequired) {
moduleArrayBytes = (LPBYTE)LocalAlloc(LPTR, bytesRequired);
if (moduleArrayBytes) {
unsigned int moduleCount;
moduleCount = bytesRequired / sizeof(HMODULE);
moduleArray = (HMODULE *)moduleArrayBytes;
if (EnumProcessModules(processHandle, moduleArray, bytesRequired, &bytesRequired))
address_base = (DWORD_PTR)moduleArray[0];
LocalFree(moduleArrayBytes);
}
}
}
CloseHandle(processHandle);
}
cout << "PID: " << PID << endl;
cout << "Base: 0x" << std::hex << address_base << std::dec << endl << endl;
DWORD_PTR first_object = NULL, object = NULL, descriptors = NULL, offset = NULL, offset1 = NULL, offset2 = NULL;
int returncode;
unsigned int player_level = 0;
unsigned int player_health = 0;
SIZE_T lpNumberOfBytesRead;
returncode = ReadProcessMemory(phandle, (LPVOID)(address_base + LOCAL_PLAYER), &offset1, 8, &lpNumberOfBytesRead);
cout << "Return 1: " << returncode << " read " << lpNumberOfBytesRead << endl;
returncode = ReadProcessMemory(phandle, (LPVOID)(offset1 + DESCRIPTORS), &descriptors, 8, &lpNumberOfBytesRead);
cout << "Return 2: " << returncode << " read " << lpNumberOfBytesRead << endl;
returncode = ReadProcessMemory(phandle, (LPVOID)(descriptors + UNIT_LEVEL), &player_level, sizeof(int), &lpNumberOfBytesRead);
cout << "Return 3: " << returncode << " read " << lpNumberOfBytesRead << " intsize " << sizeof(int) << endl;
returncode = ReadProcessMemory(phandle, (LPVOID)(descriptors + UNIT_HEALTH), &player_health, sizeof(int), &lpNumberOfBytesRead);
cout << "Return 4: " << returncode << " read " << lpNumberOfBytesRead << " intsize " << sizeof(int) << endl;
cout << endl;
cout << "Level: " << player_level << endl;
cout << "Health: " << player_health << endl;
return 0;
}
Output:
Code:
PID: 10984
Base: 0x7ff6add30000
Return 1: 1 read 8
Return 2: 1 read 8
Return 3: 1 read 4 intsize 4
Return 4: 1 read 4 intsize 4
Level: 0
Health: 4278190080
The PID is correct, and the return codes aren't zero, but It should show level 1 and 151 hp.
I can't figure out what might have changed, and I don't want to have to downgrade to Win7 where all this was all working. I downgraded to VS 2013 but the problem still exists there.
Thoughts?