Read Memory String/Char(?)

07/29/2015 09:40 Xonivion#1
Solved.
07/29/2015 13:52 warfley#2
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
07/29/2015 22:03 Shawak#3
You may use my lib for this: [Only registered and activated users can see links. Click Here To Register...]

Code:
var mem = new Memory(123123) // process id
var value = mem.Read<string>(0x2342342);