How to remake this in C#...  
Author Message
deodorant2





PostPosted: Visual C# Language, How to remake this in C#... Top

Below is code from C++ file i'm trying to convert to C#:

DWORD playerUnit[25];
DWORD addr;

ReadProcessMemory (pD2, (VOID *)0x6FBCC1E0, &addr, sizeof(addr), &read);
ReadProcessMemory (pD2, (VOID *)addr, playerUnit, sizeof(playerUnit), &read);

This is my code:

byte[] playerUnit = new byte[25];
byte[] bMemory = new byte[100];
IntPtr ptrReaded;

ReadProcessMemory(pD2[0].Handle, (IntPtr)0x6FBCC1E0, bMemory, sizeof(byte), out ptrReaded);
ReadProcessMemory(pD2[0].Handle, (IntPtr)bMemory, playerUnit, sizeof(byte), out ptrReaded);

In the C++ code, I can see that the information read from "0x6FBCC1E0" is stored in "addr." I've been able to write that much, but now I'm stuck.

Next, In the C++ code he reads from "addr" and stores the newly collected info "playerUnit." I cannot get this to work, "bMemory" throws errors and when I try to do stuff like, "bMemory[1]," nothing gets read.

So, what would I do to get the second line of my code to read correctly



Visual C#6  
 
 
Peter Ritchie





PostPosted: Visual C# Language, How to remake this in C#... Top

I would suggest reading http://blogs.msdn.com/joshwil/archive/2005/08/10/450200.aspx and http://www.pinvoke.net/default.aspx/kernel32/ReadProcessMemory.html