Memhacking Problem
here is the code i use to read the memory, when i try it on some things, it says access violation very often, and is quite unreliable, i was wondering if anyone can refine it, or tell me what im doing wrong..
float CMemHax::ReadFloat( DWORD address )
{
if(!readytouse) { return 0.0f; }
float retvalx;
ReadProcessMemory( game, (LPCVOID) address, &retvalx, sizeof(float), NULL );
return retvalx;
}
playptr = memory.ReadLong(0xB6F5F0);
pointer = memory.ReadLong(playptr + 0x14);
x = memory.ReadFloat(pointer + 0x30);
y = memory.ReadFloat(pointer + 0x34);
z = memory.ReadFloat(pointer + 56);
Are you sure your sending valid memory addresses to it? I'd imagine if you sent stack addresses that could cause an exception of some sort...What exactly are you doing this for anyway?
[EDIT]
Here is something I found on MSDN about the function
Are you sure the handle fits these criteria?
[EDIT]
Here is something I found on MSDN about the function
Quote:
BOOL ReadProcessMemory(
HANDLE hProcess,
LPCVOID lpBaseAddress,
LPVOID lpBuffer,
SIZE_T nSize,
SIZE_T* lpNumberOfBytesRead
);
hProcess
[in] A handle to the process with memory that is being read. The handle must have PROCESS_VM_READ access to the process.
Are you sure the handle fits these criteria?
Well, lets see.
Lets take a look at this line:
playptr = memory.ReadLong(0xB6F5F0);
lets say the memory at that location gave you the value 8. That value is now stored in playptr.
in the next line, you have:
pointer = memory.ReadLong(playptr + 0x14);
This would try to get the value of the memory at 8 +0x14, which is not the desired thing to do. What you want to do is have playptr set to the address, not the value at the address.
Later.
Lets take a look at this line:
playptr = memory.ReadLong(0xB6F5F0);
lets say the memory at that location gave you the value 8. That value is now stored in playptr.
in the next line, you have:
pointer = memory.ReadLong(playptr + 0x14);
This would try to get the value of the memory at 8 +0x14, which is not the desired thing to do. What you want to do is have playptr set to the address, not the value at the address.
Later.
Quote:Original post by Lord Hen
Well, lets see.
Lets take a look at this line:
playptr = memory.ReadLong(0xB6F5F0);
lets say the memory at that location gave you the value 8. That value is now stored in playptr.
in the next line, you have:
pointer = memory.ReadLong(playptr + 0x14);
This would try to get the value of the memory at 8 +0x14, which is not the desired thing to do. What you want to do is have playptr set to the address, not the value at the address.
Later.
If the memory at 0xB6F5F0 is a pointer then it will have an address in it. I think you are confused. That code isn't dereferencing the pointer, it is finding what address the pointer is pointing to.
Unless the value at 0xB6F5F0 was in fact a pointer to a memory address, which seems to be a valid assumption.
Edit: Beaten.
Edit: Beaten.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement