ReadProcessMemeory Errors

Posts 1–3 of 3 · Page 1 of 1
ReadProcessMemeory Errors
Code:
[DllImport("kernel32.dll")]
        public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);

int LocalPlayer = ReadProcessMemory(ClientDLL + m_dwLocalPlayer);
        int LocalTeam = ReadProcessMemory(LocalPlayer + m_iTeamNum);
        int CrossHairID = ReadProcessMemory(LocalPlayer + m_iCrossHairID);
        int EmemyinCrossHair = ReadProcessMemory(ClientDLL + m_dwEntityList + ((CrossHairID - 1) * EntLoopDist));
        int EnemyTeam = ReadProcessMemory(EmemyinCrossHair + m_iTeamNum);
        int EnemyHealth = ReadProcessMemory(EmemyinCrossHair + m_iHealth);
I keep coming up with the error :
Error CS7036 There is no argument given that corresponds to the required formal parameter 'lpBaseAddress' of 'Program.ReadProcessMemory(IntPtr, IntPtr, byte[], uint, out IntPtr)'
That's not how rpm works. p.s. I written this in browser.

Code:
byte[] outBuffer = new byte[4];
uint numBytesRead = 0;
if(!ReadProcessMemory(pHandel, ClientDLL + m_dwLocalPlayer, outBuffer, outBuffer.Length, out numBytesRead)){
     //failed
}

//Converting the bytes to a int
if(outBuffer == null){
     throw new Exception("out bytes null");
}

int yourValue = BitConverter.ToInt33(outBuffer, 0);
Also, feel free to use my memory class. http://www.mpgh.net/forum/showthread.php?t=1217360
ReadProcessMemory returns TRUE or FALSE for success.
You send your byte array to it, as well as hProcess,lpBaseAddress,nSize,lpNumberOfBytesRead. The last one (lpNumberOfBytesRead) can set to NULL.
If true, it puts the bytes of memory into byte[] to sent.
Then, you can cast the byte[] into an int.
People generally create memory classes to handle all the different they might want to read, instead of just byte[].

Casting isn't limited to integers either. If you have a class identical to the one in the game, you can read the byte[] from the game and cast it into a class object.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us