Solved ReadProcessMemory AccessViolationException

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

Darth Revan

Newbie
Full Member
Oct 21, 2015
13
107
1
Alright, so I've been trying to reverse this game Build And Shoot, and I've gotten far enough so that I can start reading information from the game,- I've run into a problem though.

The problem is that when I try to read memory using a byte array as the buffer, I get an AccessViolationException.... I can read a vector3 without any errors or problems.

As far as I can gather, it's a problem with my buffer.

This is the code I'm using:
C#:
        Dim MemoryHolder(12) As Byte
        WinAPI.ReadProcessMemory(ProcessInformation.Handle, EBx + ProcessInformation.BaseAddress + &H7CE10, MemoryHolder, 12, 0)
By the way, the syntax highlighting color for VB code is a bit weird, it's supposed to be blue, not red.

Thanks for your time!
 
Last edited:

Darth Revan

Newbie
Full Member
Oct 21, 2015
13
107
1
Just wanted to post the answer for this.

It turns out that my RPM signature was lacking an "<(Out)>" in front of the buffer. Seems that the documentation on pinvoke.net has been changed since I first got the signature from them.

So this is what it looked like, when it didn't work:
C++:
    <DllImport("kernel32.dll")> _
    Public Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal u32BaseAddress As UInteger, ByRef u32Buffer As Byte(), ByVal u32Size As UInteger, ByRef u32NumberOfBytesRead As UInteger) As Boolean
    End Function
And this is what it should look like:
Code:
    <DllImport("kernel32.dll")> _
    Public Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal u32BaseAddress As UInteger, <Out()> ByVal u32Buffer As Byte(), ByVal u32Size As UInteger, ByRef u32NumberOfBytesRead As UInteger) As Boolean
    End Function
This can be marked as solved.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
I'm going to xxxume the one broken is the first one. I don't know a thing about VB Syntax but RPM asks for a pointer to a buffer to return the value to you. Now, you're declaring EBx as an integer and just pxxxing that directly, like i said idk if thats valid in VB, but i think you'd probably get better mileage out of pxxxing the address of that. A quick google shows there's an AddressOf function or macro or operator or whatever, so try that
 

Darth Revan

Newbie
Full Member
Oct 21, 2015
13
107
1
I'm going to xxxume the one broken is the first one. I don't know a thing about VB Syntax but RPM asks for a pointer to a buffer to return the value to you. Now, you're declaring EBx as an integer and just pxxxing that directly, like i said idk if thats valid in VB, but i think you'd probably get better mileage out of pxxxing the address of that. A quick google shows there's an AddressOf function or macro or operator or whatever, so try that

First, thanks for posting :) - Second, sorry about that, I did not notice that I included the EBx part. What I'm having issues with is the second one, the one reading a byte array. The ReadProcessMemory definition I use is perfectly valid,- I could even exchange the Byte() parameter with a Vec3 parameter. The AddressOf keyword does not do what you might think it does.
 
Last edited:

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
Eh, like i said i know jackxxxx about vb.net , hopefully someone else can chime in
 
Status
Not open for further replies.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods