Access Violations?

Need Help With an Existing Feature in Memory Hacking Software? Ask Here

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

Access Violations?

Postby A_Republican » Fri Aug 11, 2006 9:40 am

My question isn't about your program, but correlates very closesly.

I'm trying to read a memory location using the API call ReadProcessMemory. However I get an access violation error and crashes my application and my vb6 development enviroment. I can understand some what on why I might be getting this. My conclusion is because the game is running and it has locked out any access to it for what ever reason. Although that doesn't hold water, because your program can read the memory location just fine.

Any thoughts on how to get around this?

Regards
A_Republican
I Have A Few Questions
 
Posts: 5
Joined: Fri Aug 11, 2006 9:35 am

Postby L. Spiro » Fri Aug 11, 2006 9:52 am

Ensure that you are passing a valid buffer to ReadProcessMemory(), and referencing it correctly.


I don’t use Visual Basic, but the C++ code should be:

Code: Select all
// Read arbitrary bytes.
BYTE bBuffer[32];
ReadProcessMemory( hProc, (LPVOID)0x00400000, bBuffer, 32, NULL );

// Read a DWORD.
DWORD dwReturn;
ReadProcessMemory( hProc, (LPVOID)0x00400000, &dwReturn, sizeof( dwReturn ), NULL );



The access violation is happening in your program, not theirs, so you need to be sure you are correctly passing the return pointer to ReadProcessMemory(), and ensure you are passing the correct buffer size.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby A_Republican » Fri Aug 11, 2006 10:09 am

Thanks for the input.

I'm trying to retrieve a string from the location. I'm using a template that I think I got from you when GameHacking.com was still up (whatever happen to that site btw, I miss it). My code looks like this:

'-------------------------------------------------
'- Name: ReadString
'- Abstract: Reads a string
'-------------------------------------------------
Public Sub ReadString(ptrAddress As Long, lngReturnValue As String)
Dim hProcess As Long
hProcess = GetProcessHandle
ReadProcessMemory hProcess, ptrAddress, lngReturnValue, 32, 0&
CloseHandle hProcess
'// Empty Window Name / EXE Name Variables (Needed!)
sWindowName = ""
sProcessName = ""
End Sub

I would imagine that I'm not passing the right size. Is there an easy way to calculate the size needed?
A_Republican
I Have A Few Questions
 
Posts: 5
Joined: Fri Aug 11, 2006 9:35 am

Postby A_Republican » Fri Aug 11, 2006 10:12 am

Oh and if you could please move this to the correct forum. I just realized I put it into the wrong one.

Sorry

Regards,
Shaun
A_Republican
I Have A Few Questions
 
Posts: 5
Joined: Fri Aug 11, 2006 9:35 am

Postby L. Spiro » Fri Aug 11, 2006 10:18 am

What is GetProcessHandle()?

If it is returning your system handle for the target process, you should not CloseHandle() it until you are done with it.


If you can use String type here, pas the length of the string to ReadString().
That is how you know how much to read.


However, my suspicion is that you can’t pass a String type to that function.
Pass a byte-array buffer and then convert to a string.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby A_Republican » Fri Aug 11, 2006 10:52 am

I just figured it out. I took the advice of your last post and I got what I needed.

You're brillant!

Regards,
Shaun
A_Republican
I Have A Few Questions
 
Posts: 5
Joined: Fri Aug 11, 2006 9:35 am


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests

cron