IDA 基本块类型 fcb_cndret - 这是什么意思?

逆向工程 艾达 拆卸 蟒蛇 idapro-sdk
2021-07-09 10:03:28

idaapi.BasicBlock返回的IDA Pro对象idaapi.FlowChart()可以是以下类型(参见gdl.hppSDK 源代码):

// flow chart block types
enum fc_block_type_t
{
  fcb_normal,    // normal block
  fcb_indjump,   // block ends with indirect jump
  fcb_ret,       // return block
  fcb_cndret,    // conditional return block
  fcb_noret,     // noreturn block
  fcb_enoret,    // external noreturn block (does not belong to the function)
  fcb_extern,    // external normal block
  fcb_error,     // block passes execution past the function end
};

我能够找到所有类型的示例,除了fcb_cndret. 有什么作用

条件返回块

意思是?有人可以举个例子吗?

2个回答

我也不知道,所以我把这个小脚本放在一起,以便做一些实证分析。

import idaapi
import idc
import idautils

for f in Functions():
    fc = idaapi.FlowChart(idaapi.get_func(f))
    for bb in fc:
        if bb.type == 3:
            print "%x type: %d" % (bb.startEA, bb.type)

print "Done"

我把它扔到几个 x86 和 x86_64 二进制文件中,但没有结果

所以,可能是这样:

  • 这种块很少出现
  • 它只出现在其他架构中(我在这台计算机中没有任何 ARM 或 MIPS 来测试,抱歉)
  • 枚举字段保留供将来使用

只有我的两分钱。

更新

我用一个 ARM 二进制文件试了一下,发现了几个。显然这些是条件指令修改PC寄存器的块(见截图)

ARM 二进制文件中的 fcb_cndret 基本块

干杯

在一些指令集架构中可以找到条件返回。

例如,如果设置/清除状态标志,8085 具有将执行子程序返回的指令:

RZ   ... return if Z flag set
RC   ... return if C flag set
RNZ  ... return if Z flag clear
...