I guess you mean ReadProcessMemory right?
The problem is that String isn't an ordinal type like int, bool, etc. The second problem is that the string can have different Encodings. I wrote you an example to read an C/C++ PChar in UTF8 encoding from the adress of the first char:
Code:
String ReadUTF8String(IntPtr Address, IntPtr ProcHandle) {
int i = 0;
Byte buff = 255;
Byte[] Str;
int BytesRead;
for (i = 0; buff!=0; i++) // Counting till 0 (String Terminating Byte)
if (!ReadProcessMemory(ProcHandle, Adress+i, buff, 1, ref BytesRead))
break;
Str = new Byte[i]; // Create Array with the Size of the String
if (!ReadProcessMemory(ProcHandle, Adress, Str, Str.Length, ref BytesRead)) //Read the Buffer
return null;
return Encoding.UTF8.GetString(Str); // Return the Buffer as String
}
Well i am not a C# Developer and haven't tested it, so i have no guarantee that this code will work without changes