操作符类型是常用的,因此了解所有类型是有益的。
如前所述,我们可以使用 idc.get_operand_type(ea,n) 来获取操作数类型。
操作数类型有八种。
指令没有任何操作数,该方法会返回0,比如 ret 指令。
CODE:0040101C C3 retn
执行下面的脚本:
from idc import *
ea = here()
op1_type = get_operand_type(ea, 0)
print(op1_type)
0
print(o_void)
0
操作数是通用寄存器。
CODE:00401051 50 push eax
print(get_operand_type(here(), 0))
1
内存地址。
CODE:0040101D C7 05 64 20 40 00 03 40 00 00 mov ds:WndClass.style, 4003h
print(get_operand_type(here(), 0))
2