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?
GetSpd. – Jongware Jun 01 '15 at 15:07GetOperandValue()returns 4? Theidc.pysays: "operand is a register phrase => phrase number". I understand this as: "if there is a register 'phrase',GetOperandValue()returns the phrase number." I don't know though what is meant by this phrase number. What do you think? – langlauf.io Jun 01 '15 at 16:27register phraseis almost the same asregister name, so each processor register is assigned a number, and ida returns that number if the operand is a register name, or something similar denoting a register on exotic hardware. – Guntram Blohm Jun 01 '15 at 16:44