Hello Folks,
iam very new to memory editing (and also c++) and currently trying to write a programm, which reads x,y,z coords from the local player.
i red some of the guides in this section, but iam at a point where i cant get any further. iam relatively sure, that it is an logical problem and any advanced person in wow memory editing can easily figuring out what iam doing wrong, so iam asking:
Where is the mistake in my code? The 'tempbuf' variable which sould be filled by ReadProcessMemory in the 'readDWORD' or 'readFLOAT' function is ALWAYS zero (contains nothing), so i think i give the wrong memoryaddress to it...
here's my code snippet ( i know the base-address of wow.exe is normally not hardcoded)
Code:
int main(void)
{
const UINT u32WowBase = 0x00390000;
const UINT u32ClientConnection = 0x8BF1A8; // Object Manager Pointer
const UINT u32CurMgrOffset = 0x462C; // Offset to Object Manager
const UINT u32FirstObjectOffset = 0xB4; // First Object from Object Manager
const UINT u32NextObjectOffset = 0x3C; // Next Object
const UINT u32GameObjTypeOffset = 0x14;
const UINT u32GameObjGUIDOffset = 0x30;
const UINT u32PlayerGUID = 0xB8; // Local GUID
UINT u32CurrMgr_pre = 0x0;
UINT u32CurrMgr = 0x0;
UINT u32pGUID = 0x0;
const UINT u32UnitPosXOffset = 0x898;
const UINT u32UnitPosYOffset = u32UnitPosXOffset + 0x4;
const UINT u32UnitPosZOffset = u32UnitPosXOffset + 0x8;
UINT u32NextObject = 0x0;
UINT u32ObjectType = 0x0;
UINT u32PlayerObject = 0x0;
float X = 0.;
float Y = 0.;
float Z = 0.;
HANDLE hWow = NULL;
DWORD dwWowPid = 0;
if (!GetWowProc(dwWowPid)) // get wow PID
printError ( TEXT("GetWowProc FALSE") );
if( ( hWow = OpenProcess ( PROCESS_ALL_ACCESS, FALSE, dwWowPid )) == NULL)
printError ( TEXT("OpenProcess Failed due to open WoW process") );
u32CurrMgr_pre = readDWORD ( hWow, (u32WowBase + u32ClientConnection));
u32CurrMgr = readDWORD ( hWow, (u32CurrMgr_pre + u32CurMgrOffset));
u32pGUID = readDWORD ( hWow, (u32CurrMgr + u32PlayerGUID ) ); // UINT64?
u32NextObject = readDWORD ( hWow, (u32CurrMgr + u32FirstObjectOffset) );
u32ObjectType = readDWORD ( hWow, (u32NextObject + u32GameObjTypeOffset));
while ( u32ObjectType <= 7 && u32ObjectType > 0)
{
cout << "Valid Object Found!\n";
if ( readDWORD( hWow, (u32NextObject + u32GameObjGUIDOffset)) == u32pGUID )
{
cout <<"Mem Location by Player GUID found!!!\n";
u32PlayerObject = u32NextObject;
break;
}
u32NextObject = readDWORD (hWow, (u32NextObject + u32NextObjectOffset));
u32ObjectType = readDWORD ( hWow, (u32NextObject + u32GameObjTypeOffset));
}
X = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosXOffset));
Y = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosYOffset));
Z = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosZOffset));
}
my readDWORD function:
Code:
DWORD readDWORD ( HANDLE hWow, DWORD dwAddr )
{
DWORD tempbuf = 0;
unsigned int bytes_read = 0;
if (ReadProcessMemory ( hWow, &dwAddr, &tempbuf, sizeof(DWORD), (DWORD*)&bytes_read ) == 0)
{
printError ( TEXT("ReadProcessMemory DWORD failed!") );
}
_tprintf ( TEXT("read %u Bytes\n "),bytes_read );
cout << "tempbuf:" << tempbuf << "\n"; // HERE IS THE MISTAKE, tempbuf is always 0
return tempbuf;
}
and my readFLOAT function (similar to readDWORD)
Code:
float readFLOAT ( HANDLE hWow, DWORD dwAddr )
{
float tempbuf = 0.;
unsigned int bytes_read = 0;
if (ReadProcessMemory ( hWow, &dwAddr, &tempbuf, sizeof(FLOAT), (DWORD*)&bytes_read ) == 0)
{
printError ( TEXT("ReadProcessMemory FLOAT Failed!") );
}
cout << "tempbuf:" << tempbuf << "\n"; // HERE IS THE MISTAKE, tempbuf is always 0
_tprintf( TEXT("read %u Bytes\n "),bytes_read );
return tempbuf;
}
so finding the PID and creating the Handle is working correctly, but it starts to fails at this point :
Code:
u32CurrMgr_pre = readDWORD ( hWow, (u32WowBase + u32ClientConnection));
as mentioned above the tempbuf in 'readDWORD' is always zero, so of course 'u32CurrMgr_pre' and everything else is empty too.
iam wondering why 'tempbuf' is empty and not giving some random numbers stored in the memory!
thanks to everyone reading this and thanks for every help ! iam very happy about this forum and all the helpful skilled people around here.
greetings,
sixpounder