所以我一直試圖用ReadProcessMemory讀取變量,並發現在作弊引擎中的地址工作完美,但一旦我編程,我遇到了一些問題。 我搜索了作弊引擎中的彈藥和健康地址,健康狀況是一級指針,彈藥是三級指針。 我想讀的健康,但每次我讀它,則返回0。如何使用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);**
}
}
}
繼承人的鏈接地址中作弊引擎 不可能上傳到這裏:P
如何在我的代碼中正確使用作弊引擎的指針和偏移量,以及如何在代碼中實現多級指針? 請原諒我那低劣的英語。
恐怕你需要使用'OpenProcess' API打開過程 - 檢查[這](https://stackoverflow.com/questions/34467311/c-sharp-readprocessmemory - 如何閱讀-A-64位存儲器地址)。 – vasek