Also habe ich versucht, Variablen mit ReadProcessMemory zu lesen und das Finden der Adressen in der Cheat-Engine hat perfekt funktioniert, aber sobald ich zur Programmierung kam, stieß ich auf einige Probleme. Ich suchte nach den Munitions- und Gesundheitsadressen in der Cheatmaschine und der Gesundheit war ein einstufiger Zeiger und die Munition war ein dreistufiger Zeiger. Ich habe versucht, die Gesundheit zu lesen, aber jedes Mal habe ich es gelesen, es 0.Wie benutze ich ReadProcessMemory?
namespace AssaultCubeTrainer
{
public partial class MainWindow : Window
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(IntPtr pHandle, IntPtr Address, byte[] Buffer, int Size, IntPtr NumberofBytesRead);
public static Process myProc;
public static Player p1;
public MainWindow()
{
InitializeComponent();
p1 = new Player();
MessageBox.Show("Please press the attach button as soon as the game has started", " Information",MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
}
private void AttachProcButton_Click(object sender, RoutedEventArgs e)
{
try
{
myProc = Process.GetProcessesByName("ac_client")[0];
if (myProc.Handle != null)
{
MessageBox.Show("Process successfully attached", "Success", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
}
}
catch
{
MessageBox.Show("The process was not found","Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
}
}
private void ButtonTest_Click(object sender, RoutedEventArgs e)
{
lbHealthInfo.Content = p1.GetHealthInfo();
}
}
}
namespace AssaultCubeTrainer
{
public class Player
{
private byte[] buffer;
public bool ReadSuccess;
public int HealthAddress;
public int HealthOffset;
public int AmmoAddress;
public int AmmoOffset;
public int Health;
public int Ammo;
public IntPtr bytesRead;
public Player()
{
HealthAddress = 0x00509B74;
HealthOffset = 0xF8;
AmmoAddress = 0x00509B74;
AmmoOffset = 0x374;
Health = HealthAddress + HealthOffset;
Ammo = AmmoAddress + AmmoOffset;
}
//Here I have the problem when reading variable
public int GetHealthInfo()
{
**buffer = new byte[4];
ReadSuccess = MainWindow.ReadProcessMemory(MainWindow.myProc.Handle, (IntPtr)Health, buffer, buffer.Length, bytesRead);
return BitConverter.ToInt32(buffer, 0);**
}
}
}
Heres die Links zu den Adressen in Cheat Engine liefert Couldnt sie hochladen hier: P
Wie verwende ich Pointer und Offsets der Cheat-Engine in meinem Code und wie implementiere ich mehrstufige Pointer in meinen Code? Bitte entschuldigen Sie mein beschissenes Englisch.
Ich fürchte, Sie müssen Prozess öffnen 'OpenProcess' API - check [diese] (https://stackoverflow.com/questions/34467311/c-sharp-readprocessmemory Wie zu lesen ist eine 64-Bit-Speicheradresse. – vasek