【问题标题】:Reading Memory with DLL base address使用 DLL 基地址读取内存
【发布时间】:2013-08-28 04:35:43
【问题描述】:

我正在尝试在进程(游戏)中读取float

查看作弊引擎我可以找到我需要的地址,但它位于wow64cpu.dll + 4720,偏移量为 34。

因此,我尝试在该过程中找到 wow64cpu.dll 的基地址,但这就是我感到困惑的地方。

我现在不明白如何使用这个地址,因为我所有的尝试似乎都失败了。

        Process[] processes = Process.GetProcessesByName("Napoleon");
        Process process = processes[0];

        ProcessModuleCollection modules = process.Modules;
        ProcessModule dllBaseAdress = null;
        foreach (ProcessModule i in modules)
        {
            if (i.ModuleName == "wow64cpu.dll")
            {
                dllBaseAdress = i;
                break;
            }
        }

        IntPtr dllPtr = dllBaseAdress.BaseAddress;
        int pointer = dllPtr.ToInt32() + 0x4720;
        int offset = 34;

        IntPtr hProc = OpenProcess(ProcessAccessFlags.All, false, process.Id);

        int bytesRead;
        byte[] buffer = new byte[4];

        ReadProcessMemory(hProc, new IntPtr(pointer + offset), buffer, 4, out bytesRead);

        float lightColourScale = BitConverter.ToSingle(buffer, 0);

我的问题是我在使用 DLL 的基地址时哪里出错了,或者可能在其他地方,我不确定如何使用它来查找我的地址?

我还在 x64 中编译了该程序,否则它将找不到 wow64cpu.dll。

谢谢

【问题讨论】:

  • 投反对票,不评论为什么。太棒了,谢谢。
  • 魔兽世界机器人摧毁了游戏......

标签: c# winforms memory dll readprocessmemory


【解决方案1】:

您的偏移量必须添加到在位置wow64cpu.dll + 4720 处读取的指针,因此如果您的地址正确,则您的浮动位置位于[wow64cpu.dll + 4720] + 30

你的代码是

// Set the addresses to read
var pointer = dllPtr.ToInt32() + 0x4720;
var offset = 34;
// Initialize the buffers
var buffer = new byte[4];

// Find the pointer
ReadProcessMemory(hProc, new IntPtr(pointer), buffer, 4, out bytesRead);
pointer = BitConverter.ToInt32(buffer, 0);
// Add the offset to the value previously found
ReadProcessMemory(hProc, new IntPtr(pointer + offset), buffer, 4, out bytesRead);
var lightColourScale = BitConverter.ToSingle(buffer, 0);

尽管如此,手动调用所有这些函数确实很痛苦。我强烈建议你使用一个注入库,它为你包装了所有这些调用。

图书馆MemorySharp 适合你(我是作者)。在您的情况下,您可以编写以下代码。

using (var memory = new MemorySharp(ApplicationFinder.FromProcessName("Napoleon").First()))
{
    var myValue = memory.Read<float>(memory["wow64cpu.dll"].Read<IntPtr>(4720) + 34, false);
}

作弊引擎以十六进制给出其值。您在使用它们之前是否将它们转换为 dec ?

另外,还有一个问题和你的类似:Find address using pointer and offset C#

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-05
    • 1970-01-01
    • 2017-05-16
    • 2014-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多