Say given the following line in Ida Pro:
mov [rsp+3F8h+var_3F8], 0
How can I parse and access the items inside the [ ]
?
What I tried:
idc.GetOpnd(addr, n)
# returns a string '[rsp+3F8h+var_3F8]
'idc.GetOperandValue(addr, n)
# returns4
, which is explained in the idc.py file as follows
def GetOperandValue(ea, n): """
Get number used in the operandThis function returns an immediate number used in the operand
@param ea: linear address of instruction @param n: the operand number
@return:
value operand is an immediate value => immediate value
operand has a displacement => displacement
operand is a direct memory ref => memory address
operand is a register => register number
operand is a register phrase => phrase number
otherwise => -1
"""
How can I access the elements of the 'phrase', i.e. the rsp
, 3F8h
, and var_3F8
? I am looking for something like this:
my_op_phrase = idc.ParseOperandPhrase(ea, n)
my_op_phrase[0] #-> 'rsp'
my_op_phrase[0].type #-> idaapi.o_reg
my_op_phrase[1] #-> 0x3F8h
my_op_phrase[1].type #-> idaapi.o_imm
my_op_phrase[2] #-> 'var_3F8'
…
Is this even possible or am I misunderstanding something?