Originally Posted by
Sillyboy72
ReadProcessMemory tries to copy memory from one process space... to another. The 3rd param is the address to copy the memory to. However, you need to have some space allocated to store the memory.
I am not super familiar w/ the "string" class in c++, but I would more typically expect the buffer to be a byte array.
BYTE *ContentsOfAddress = new BYTE[BytesToRead];
actually, your BytesToRead looks weird too (always going to be 4... the sizeof a dword).
-Silly
Alright, now I've got:
Code:
char * Name = (char *)malloc(13);
~~~~~~~~~~~~~~~~~~~~
char* MemoryReadString(HANDLE Handle, DWORD ReadAddress)
{
SIZE_T BytesRead;
int BytesToRead = 13;
char * ContentsOfAddress = (char *)malloc(13);
ReadProcessMemory(Handle,(LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
return ContentsOfAddress;
}
~~~~~~~~~~~~~~~~~~~~
char * GetPlayerName(DWORD pGUID)
{
HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,HBAI.Instance[HBAI.CurrentWoWInstance].PID);
using namespace std;
Name = "";
DWORD nameStorePtr = 0x011AE3D0 + 0x8;
DWORD nameMaskOffset = 0x24;
DWORD nameBaseOffset = 0x1C;
DWORD nameStringOffset = 0x20;
DWORD Mask = MemoryRead(Handle,(nameStorePtr+nameMaskOffset));
DWORD Base = MemoryRead(Handle,(nameStorePtr+nameBaseOffset));
DWORD shortGUID = pGUID & 0xFFFFFFFF;
if (Mask == 0xFFFFFFFF)
{
Name = "";
return Name;
}
DWORD Offset = 12 *(Mask & shortGUID);
DWORD Current = MemoryRead(Handle,(Base+Offset+8));
Offset = MemoryRead(Handle,(Base+Offset));
if ((Current == 0) || (Current & 0x1))
{
Name = "";
return Name;
}
DWORD TestGUID = MemoryRead(Handle,Current);
while(TestGUID != Current)
{
Current=MemoryRead(Handle,(Current+Offset+0x4));
if ((Current == 0) || (Current & 0x1))
{
Name = "";
return Name;
}
TestGUID = MemoryRead(Handle,Current);
}
Name = MemoryReadString(Handle,(Current+nameStringOffset));
return Name;
CloseHandle(Handle);
}
Name is returning (has been for a while now) but always blank.