Jump to content
  • Advertisement
Sign in to follow this  
TonyB

Memhacking Problem

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
Advertisement
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
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.




Share this post


Link to post
Share on other sites
Unless the value at 0xB6F5F0 was in fact a pointer to a memory address, which seems to be a valid assumption.

Edit: Beaten.

Share this post


Link to post
Share on other sites
i should have been more specific, it reads the coordanites X and Y fine, but around the 5th time around i usually get some kind of error when it trys to read Z (which is also read fine untill the 5th time or so)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!