【问题标题】:Pin Tool - intercepting an instruction by its address to dump the registers valuePin Tool - 通过地址拦截指令以转储寄存器值
【发布时间】:2019-09-11 20:28:18
【问题描述】:

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

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

非常感谢

【问题讨论】:

    标签: c intel-pin


    【解决方案1】:

    在您的情况下,最简单的做法就是检查指令地址(使用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;
    }
    

    有关 API 的概述,请参阅 PIN_GetContextRegval

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-02
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 2014-09-11
      • 1970-01-01
      • 2011-09-12
      相关资源
      最近更新 更多