如何获得内存地址知道指针

时间:2018-06-19 17:10:25

标签: assembly memory reverse-engineering offset cheat-engine

我应该采取什么行动才能到达该地址:0DE1AC74 知道的指针 偏移量: 194 5C 还有这个: “ bin.exe” + 0121AC10 目标是使用指针而不是在每次重新启动应用程序时搜索地址? enter image description here

2 个答案:

答案 0 :(得分:2)

从该img中,我可以看到您正在使用CE,如果我正确理解了您的问题,则只需在CE aa +脚本中执行lea ebx,[bin.exe+0121AC10],地址就会存储在ebx寄存器中(在64位进程中使用rbx)

答案 1 :(得分:1)

在作弊引擎脚本中:

[[bin.exe+0x121AC10]+14c]+194

正在组装:

lea ebx, [bin.exe+0121AC10]
add ebx, 14c
mov ebx, [ebx]
add ebx, 194

在C ++中:

您需要获取进程ID,以便可以使用OpenProcess打开句柄并开始读取内存。您需要按名称查找模块,并使用ToolHelp32Snapshot并获取模块快照的modBaseAddr成员变量来获取模块基地址。然后,您可以使用FindDMAAddy在指针中添加和取消引用每个偏移量。

DWORD GetProcId(const wchar_t* procName)
{
    DWORD procId = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hSnap != INVALID_HANDLE_VALUE)
    {
        PROCESSENTRY32 procEntry;
        procEntry.dwSize = sizeof(procEntry);

        if (Process32First(hSnap, &procEntry))
        {
            do
            {
                if (!_wcsicmp(procEntry.szExeFile, procName))
                {
                    procId = procEntry.th32ProcessID;
                    break;
                }
            } while (Process32Next(hSnap, &procEntry));

        }
    }
    CloseHandle(hSnap);
    return procId;
}

uintptr_t GetModuleBaseAddress(DWORD procId, const wchar_t* modName)
{
    uintptr_t modBaseAddr = 0;
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
    if (hSnap != INVALID_HANDLE_VALUE)
    {
        MODULEENTRY32 modEntry;
        modEntry.dwSize = sizeof(modEntry);
        if (Module32First(hSnap, &modEntry))
        {
            do
            {
                if (!_wcsicmp(modEntry.szModule, modName))
                {
                    modBaseAddr = (uintptr_t)modEntry.modBaseAddr;
                    break;
                }
            } while (Module32Next(hSnap, &modEntry));
        }
    }
    CloseHandle(hSnap);
    return modBaseAddr;
}

uintptr_t FindDMAAddy(HANDLE hProc, uintptr_t ptr, std::vector<unsigned int> offsets)
{
    uintptr_t addr = ptr;
    for (unsigned int i = 0; i < offsets.size(); ++i)
    {
        ReadProcessMemory(hProc, (BYTE*)addr, &addr, sizeof(addr), 0);
        addr += offsets[i];
    }
    return addr;
}
int main()
{
    //Get ProcId of the target process
    DWORD procId = GetProcId(L"bin.exe");

    //Getmodulebaseaddress
    uintptr_t moduleBase = GetModuleBaseAddress(procId, L"bin.exe");

    //Get Handle to Process
    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, procId);

    //Resolve base address of the pointer chain
    uintptr_t dynamicPtrBaseAddr = moduleBase + 0x121AC10;

    //Resolve the pointer chain
    std::vector<unsigned int> offsets = { 0x14c, 0x194 };

    uintptr_t addr = FindDMAAddy(hProcess, dynamicPtrBaseAddr, offsets);

    return 0;
}