Siema.
Ktoś mi pomoże ogarnąć pointery? Chcę tylko przeczytać jego zawartość.
Kod wygląda tak:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace TestApp
{
class Program
{
[DllImport("kernel32.dll")]
public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
[In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
public static byte[] ReadBytes(IntPtr Handle, Int64 Address, uint BytesToRead)
{
IntPtr ptrBytesRead;
byte[] buffer = new byte[BytesToRead];
ReadProcessMemory(Handle, new IntPtr(Address), buffer, BytesToRead, out ptrBytesRead);
return buffer;
}
public static int ReadInt32(long Address, uint length = 4, IntPtr? Handle = null)
{
return BitConverter.ToInt32(ReadBytes((IntPtr)Handle, Address, length), 0);
}
public static string ReadString(long Address, uint length = 32, IntPtr? Handle = null)
{
string temp3 = ASCIIEncoding.Default.GetString(ReadBytes((IntPtr)Handle, Address, length));
string[] temp3str = temp3.Split('\0');
return temp3str[0];
}
static void Main(string[] args)
{
UInt32 Address = 0x2410E0;
// get process
Process Okno = Process.GetProcessesByName("Client")[0];
// dump base
Console.WriteLine("Base Address : " + Okno.MainModule.BaseAddress.ToString());
UInt32 Base = (UInt32)Okno.MainModule.BaseAddress.ToInt32();
// read pointer
UInt32 Ptr1 = (UInt32)ReadInt32(Address + Base, 8, Okno.Handle);
Console.WriteLine("Pointer 1 : " + Ptr1.ToString());
UInt32 Ptr2 = (UInt32)ReadInt32(Ptr1 + 0x8, 8, Okno.Handle);
Console.WriteLine("Pointer 2 : " + Ptr2.ToString());
UInt32 Ptr3 = (UInt32)ReadInt32(Ptr2 + 0xb8, 8, Okno.Handle);
Console.WriteLine("Pointer 3 : " + Ptr3.ToString());
UInt32 Ptr4 = (UInt32)ReadInt32(Ptr3 + 0x0, 8, Okno.Handle);
Console.WriteLine("Pointer 4 : " + Ptr4.ToString());
UInt32 Ptr5 = (UInt32)ReadInt32(Ptr4 + 0x798, 8, Okno.Handle);
Console.WriteLine("Pointer 5 : " + Ptr5.ToString());
UInt32 Ptr6 = (UInt32)ReadInt32(Ptr5 + 0x750, 8, Okno.Handle);
Console.WriteLine("Pointer 6 : " + Ptr6.ToString());
// read memory pointer points to
string PtrRead = ReadString(Ptr6, 255, Okno.Handle);
Console.WriteLine("Pointer Value is : " + PtrRead);
Console.ReadLine();
}
}
}
Powinna to być wartość double... numer. Wiem że mam nawalone coś w kodzie. Jak robiłem to na "4 bytach" to śmigało. Gdy staram się to zrobić na "double" to już nie chce działać.
Proszę o pomoc. Dzięki.