1

静的アドレスとオフセットを使用して、C# で新しいメモリ アドレスを見つける方法を教えてください。

ベース: 0x1023469C

オフセット: 1E8

関数内のベースにオフセットを追加しようとしましたreadprocessmemoryが、まったく機能しませんでした:(私はこのアドレスからメモリを読み取ろうとしています.2低くなります。事前にご協力いただきありがとうございます:D

これは私がこれまでに得たものです:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
    //variabeln JC2
    //Pointer
    const int Offset = 0x1E8; // offset
    const int Base = 0x1023469C; // base
    const string Game = "The Game you don't know"; //Name

   

    //permission to read process memory
    const int PROCESS_WM_READ = 0x0010; //needed for reading memory


    [DllImport("kernel32.dll")]
    public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);

    [DllImport("kernel32.dll", SetLastError = true)]
    static extern bool ReadProcessMemory(
    IntPtr hProcess,
    IntPtr lpBaseAddress,
    [Out] byte[] lpBuffer,
    int dwSize,
    out int lpNumberOfBytesRead);


    public Form1()
    {
        InitializeComponent();
    }

    private void BTcheck_Click(object sender, EventArgs e)
    {
        if (Process.GetProcessesByName(Game).Length > 0)
        {
            Process process = Process.GetProcessesByName(Game)[0];
            IntPtr procHandle = OpenProcess(PROCESS_WM_READ, false, process.Id);

            IntPtr baseAddress = new IntPtr(Base); //whatever address you wish
            int offset = Offset; //whatever offset you wish
            baseAddress += offset;
            byte[] buffer = new byte[sizeof(int)]; //select a proper buffer size
            int read = -1;

            ReadProcessMemory(procHandle, baseAddress, buffer, buffer.Length, out read); 

                            if (read == buffer.Length)
            {
                int value = BitConverter.ToInt32(buffer, 0);
                //do something with it
                
                LBcurrent.Text = Convert.ToString(value); //display the value
            }
        }

        else
        { LBcurrent.Text = "Error!"; }
    }
}
}
4

1 に答える 1