我正在使用一个readprocessmemory
类,并让它用于读取多级指针并在 label2.text 的最终地址处显示整数。
这适用于我指定基地址的地方(如下所示的“0x40000”):
private void label2_Click(object sender, EventArgs e)
{
int Readpointer = Trainer.ReadPointerInteger("runningprocess", 0x40000, new int[3] { 0x3, 0x4, 0x10 });
string converted = Readpointer.ToString();
label2.Text = converted;
现在,我不想指定基地址“40000”,而是想使用一个函数来“找出”进程的基地址并将其存储在一个变量中并将其作为参数传递。这是第一部分:
Process[] test = Process.GetProcessesByName("runningprocess"); //Get process base address
int Base = test[0].MainModule.BaseAddress.ToInt32(); // ""
不幸的是,该"Trainer.ReadPointerInteger"
函数需要“0x40000”形式的基地址参数。所以我这样做了:
string BaseAddress = "0x" + Addr.ToHex(Base); // addr.ToHex is just another function which converts the int to hex.
现在我想将变量传递给ReadPointerInteger's
第二个参数,我尝试了这个:
int Readpointer = Trainer.ReadPointerInteger("runningprocess", BaseAddress, new int[3] { 0x3, 0x4, 0x10 });
string converted = Readpointer.ToString();
label2.Text = converted;
看起来这应该可行,但问题(错误)是“Trainer”函数的第二个参数是一个 Int,这对我的新手来说很奇怪,因为我不直观地拥有一个包含的输入参数字母作为 Int。无论如何,我被困在这里,想知道是否有人可以指出如何解决 Int/String 问题?
仅供参考,ReadPointerInteger
课程是:
public static int ReadPointerInteger(string EXENAME, int Pointer, int[] Offset)
{
int Value = 0;
checked
{
try
{
Process[] Proc = Process.GetProcessesByName(EXENAME);
if (Proc.Length != 0)
{
int Bytes = 0;
int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc[0].Id);
if (Handle != 0)
{
foreach (int i in Offset)
{
ReadProcessMemoryInteger((int)Handle, Pointer, ref Pointer, 4, ref Bytes);
Pointer += i;
}
ReadProcessMemoryInteger((int)Handle, Pointer, ref Value, 4, ref Bytes);
CloseHandle(Handle);
}
}
}
catch
{ }
}
return Value;
}