Это возвращает целое число из моей программы, которая вычисляет общее количество опыта в игре. Он рабочий, и он работает.
class Program
{
[DllImport("kernel32.dll")]
public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
[In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
static void Main(string[] args)
{
int add_base;
int add_player_exp = 0x3C1200;
Process p = Process.GetProcessesByName("Game")[0];
if (p != null)
{
add_base = p.MainModule.BaseAddress.ToInt32();
add_player_exp += add_base;
string output;
int exp;
exp = ReadInt32(p.Handle, add_player_exp);
output = String.Concat("Exp: ", exp.ToString());
Console.WriteLine(output);
Console.ReadKey();
}
}
private static int ReadInt32(IntPtr handle, long address)
{
return BitConverter.ToInt32(ReadBytes(handle, address, 4), 0);
}
private static byte[] ReadBytes(IntPtr handle, long address, uint bytesToRead)
{
IntPtr ptrBytesRead;
byte[] buffer = new byte[bytesToRead];
ReadProcessMemory(handle, new IntPtr(address), buffer, bytesToRead, out ptrBytesRead);
return buffer;
}
}
Каков эквивалентный код для извлечения строки из ReadProcessMemory?
Encoding.ASCII.ToString(ReadBytes(...))
- person Ben Voigt   schedule 25.02.2016