PDA

View Full Version : IDAPython simulating UI actions?


LaBBa
December 10th, 2015, 07:33
hi,
i have a line that looks like this in IDA (ARM):

Code:
0F941DF4 MOV R0, #0xFA15A40


the address #0xFA15A40 can be resolved to a string by pressing 'O' or 'Ctrl+O' and the line looking like this after i have pressed:
Code:
0F941DF4 MOV R0, #aDisplayInitFail_0


i have already created a scripts that add ref to the string location and it shows me now the line like this:
Code:
0F941DF4 MOV R1, #0xFA15A40 ; "Display init fail.."


but this is not good because when i want to use the decompiler option it doesn't understand this reference. the decompiler only understand the address reference after i press 'O' or 'Ctrl+O'

and from some reason IDA doesn't do it automatically (even after re-analyze), so how can i simulate the key pressing by executing a command of IDAPython ?

Kayaker
December 10th, 2015, 16:23
It appears you could use Class UI_Hooks
https://www.hex-rays.com/products/ida/support/idapython_docs/idaapi.UI_Hooks-class.html

name - ui command name (these names can be looked up in ida[tg]ui.cfg)
"OpOffsetCs" = "Ctrl-O"

Though just issuing OpOffsetCs might not work as well?
https://www.hex-rays.com/products/ida/support/idadoc/468.shtml

LaBBa
December 14th, 2015, 06:23
this works just need to put the correct "n" value:

OpOff(ea, n, BADADDR);


Parameters:
ea - linear address
n - number of operand
0 - the first operand
1 - the second, third and all other operands
-1 - all operands

base - base of the offset as a linear address If base == BADADDR then the current operand becomes non-offset