
Originally Posted by
fiqhpratama
wow, its work, i just convert Unicode to AnsiString.
Thanks for your Reply, your code is very helpfull...

I'm writing a Wrapper Class at the Moment for the Memory Stuff, if you want to play arround with that you can contact me on Skype or by PM.
If i penetrate it enough, i will make it public anyway.
It can already handle to read and write nearly all basic types, AOB Pattern Scan and dll Injection.
And i found out if you use my example you can only read 4 or 8 bytes depending on WOW or / and Plattform (64 Bit = 8 byte, 32 Bit = 4 byte) because the
sizeof() return only the Size of the type, you should use Magic Function
Length() for it.
Anyway, if you read a String from Memory, but you don't know how big it will be, you read more then you have to.
If you do that your String will maybe have "cryptic Characters" at the end, because a String in Delphi isn't NULL Terminated.
You can Trim it after it by yourself or you use a workarround with PChar, because PChar is what "Char*" in C is (Pointer to array of Char) and this is NULL Terminated:
Code:
var
BytesRead: SIZE_T;
Str: string; // Here we want the Memory Read Output as clean String
Buffer: array of char; // This we use to read the bytes, you could use
//Buffer: array of byte; // You can switch this line with the above, we don't care
StrBuffer: PChar absolute Buffer; // this PChar points already to Buffer now
len: integer; // How many we want to read
begin
len := 255;
SetLength(Buffer, len); // set the char array length
ReadProcessMemory(ProccessHandle, Pointer(addr), @ Buffer[0], len, BytesRead);
Str := AnsiString(StrBuffer); // PChar to String
SetLength(Buffer, 0); // clean up, after we filled our String
end;