gpt4 book ai didi

c - Pin 工具 - 通过地址拦截指令以转储寄存器值

转载 作者:太空宇宙 更新时间:2023-11-04 02:22:25 24 4
gpt4 key购买 nike

我正在尝试将寄存器值转储到二进制文件中的给定位置。我通过逆向工程知道了正确的地址,但我没有使用 Pin 工具的 API 来指示我想检测给定的指令

有没有办法在给定地址上调用 INS_InsertCall(..),这样我就可以从那里转储寄存器的值?

非常感谢

最佳答案

在您的情况下,最简单的做法就是检查指令地址(使用 INS_Address )并使用您的检测例程中的条件调节 INS_INsertCall:

if(INS_Address(ins) == 0xdeadbeef) { // just check for your hard-coded address here.
INS_InsertCall(...)
}

在我想到的其他可能性中(但对于如此简单的事情我不会尝试):

[编辑]

至于转储上下文,像这样(没有测试或编译,但你明白了):

// in instrumentation
if(INS_Address(ins) == 0x1cafe /* whatever */) {
INS_InsertPredicatedCall(ins,
IPOINT_BEFORE, // decide if you want to point before or IPOINT_AFTER
(AFUNPTR)AnalyzeContext, // analysis routine
IARG_INST_PTR, // address of the ins
IARG_CONST_CONTEXT, // the const context (DO NOT MODIFY it in the analysis!)
IARG_END);
}

参见 IARG_CONST_CONTEXT在文档中。

以及分析例程:

VOID AnalyzeContext (ADDRINT ip, CONTEXT *ctxt){ 
PIN_REGISTER reg_val;
PIN_GetContextRegval(ctxt, LEVEL_BASE::REG_RAX, reinterpret_cast<UINT8 *>(&reg_val));
std::cout << std::hex << "REG_RAX: 0x" << reg_val << std::endl;
}

参见 PIN_GetContextRegval了解 API 概览。

关于c - Pin 工具 - 通过地址拦截指令以转储寄存器值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55797900/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com