在自己的应用程序中使用通过作弊引擎获得的多级指针

逆向工程 视窗 调试 工具
2021-06-19 12:37:38

所以我已经完成了 Cheat Engine 教程的第 8 步,并获得了一个带有相应偏移量的静态地址来操作一个值,该值应该在教程中进行更改。我得到的表达式看起来像这样

[[[[[00645390]+C]+14]+0]+18]

我想更进一步,编写一个简单的(C++ 或 C#)程序,该程序将访问存储在该位置的值,并从内存中读取和写入。我还不确定的是如何特别访问它。我想它不像直接访问00645390内存中的地址那么容易- 我是否必须将它添加到应用程序本身的基地址中?如果是,我如何获取地址以开始处理所有这些指针?

1个回答

你需要 OpenProcess()->ReadprocessMemory() 和或 QueryVirtualEx()

您可以使用 lkd 或 livekd 来实现结果

livekd.exe
kd> !process 0 0
................
PROCESS 89d1d328  SessionId: 0  Cid: 0238    Peb: 7ffde000  ParentCid: 075c
    DirBase: 14980320  ObjectTable: e14106f0  HandleCount:  23.
    Image: Tutorial-i386.exe
........................
kd> .process /p /r 89d1d328
Implicit process is now 89d1d328
Loading User Symbols
.................
kd> ? poi(poi(poi(poi(poi(645390)+c)+14)+0)+18)
Evaluate expression: 1666 = 00000682]

[1]

这是一个使用dbgeng functionswindbg sdk
错误检查的示例代码为简洁起见删除dbg打印
假定模块地址空间是not randomised / rebased (因此使用645390原样)
否则您可能需要从Ce中找到模块基础,VA from address (645390 -modbase)
在您的代码中计算R找到modbase和将计算的RVA读指针
if modbase在你的代码是400000rva1390使用401390的,而不是645390

#include <stdio.h>
#include <engextcpp.hpp>
int __cdecl main( void  ){
    IDebugClient*     g_Client      = NULL;
    IDebugControl*    g_Control     = NULL;
    IDebugSymbols*    g_Symbols     = NULL;
    IDebugDataSpaces* g_Data        = NULL;
    ULONG             Pid           = NULL;
    ULONG             bytesread     = NULL;
    ULONG             ptr           = NULL;
    DebugCreate( __uuidof(IDebugClient), (void**)&g_Client );
    g_Client->QueryInterface( __uuidof(IDebugControl), (void**)&g_Control );
    g_Client->QueryInterface( __uuidof(IDebugSymbols), (void**)&g_Symbols );
    g_Client->QueryInterface( __uuidof(IDebugDataSpaces), (void**)&g_Data );
    g_Client->GetRunningProcessSystemIdByExecutableName(
        0,"Tutorial-i386.exe",DEBUG_GET_PROC_ONLY_MATCH,&Pid);
    g_Client->AttachProcess(0,Pid,DEBUG_ATTACH_NONINVASIVE);
    g_Control->WaitForEvent( 0, INFINITE );
    g_Data->ReadVirtualUncached(0x645390,&ptr,sizeof(ptr),&bytesread);
    g_Data->ReadVirtualUncached((ptr+0xc),&ptr,sizeof(ptr),&bytesread);
    g_Data->ReadVirtualUncached((ptr+0x14),&ptr,sizeof(ptr),&bytesread);
    g_Data->ReadVirtualUncached((ptr+0x0),&ptr,sizeof(ptr),&bytesread);
    g_Data->ReadVirtualUncached((ptr+0x18),&ptr,sizeof(ptr),&bytesread);
    printf("%-15s%d\n","5th lvl ptr =", ptr);
    g_Client->DetachProcesses();
    return 0;
}

在此处输入图片说明