0

下面的代码是读取浮点数的示例,有人可以建议修改函数以读取字符串吗?

   public static float ReadPointerFloat(string EXENAME, int Pointer, int[] Offset)
 {
     float 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;
                     }
                     ReadProcessMemoryFloat((int)Handle, Pointer, ref Value, 4, ref Bytes);
                     CloseHandle(Handle);
                 }
             }
         }
         catch
         { }
     }
     return Value;
 } 

也许读取一个字节数组并应用它?

ASCIIEncoding.ASCII.GetString(variableholdingresultoffunction);
4

1 回答 1

-1
private void label2_Click(object sender, EventArgs e)
{
    Process[] test = Process.GetProcessesByName("myprocess"); //Get process base address
    int Base = test[0].MainModule.BaseAddress.ToInt32(); // ""


    int Readpointer = ReadPointerInteger("myprocess", Base, new int[3] { 0xC, 0x5, 0x6 });

    string asciiString;
    unsafe
    {
        asciiString = new string((sbyte*)Readpointer);
    }
    // use asciiString
}

正如其他人所提到的,您应该使用IntPtr而不是int指针,以便它在 32 位和 64 位系统之间交叉兼容,但这应该可以帮助您入门。

于 2012-06-15T02:38:33.920 回答