Modifying instruction arguments to reference names via IDAPython

140 views
Skip to first unread message

Dick Wartell

unread,
Sep 25, 2013, 7:07:31 PM9/25/13
to idap...@googlegroups.com
I have an IDAPython script that is modifying a lot of the data in an IDB, and I'm having problems with name references. For example, I have a binary with an encoded string in it. My script would do the following:

1) Decode the encoded bytes and overwrite the bytes in the idb with the decoded string
2) Make sure IDA recognizes it as a string (by calling idautils.Strings()), and name the address the string is at accordingly

However, in IDA after the script has run, references to this string will not have been fixed in instruction operands. For example, after the script has run, the following is in the IDB:

0x402030 strBlahBlah <string bytes> Blahblah
...
0x404063 mov eax, ds:0x402030

Normally IDA would have a reference to a string look like the following:

0x404063 mov eax, aBlahblah

which is what I would like. Is there a way to force IDA to do this via IDAPython? I couldn't find a specific function that does this, and I know it exists because if I manually right click on the operand 0x402030 and choose "offset <string name>" it will switch to what I want. 

Thank you in advance for any help.
-Richard

Dick W

unread,
Sep 26, 2013, 1:54:12 PM9/26/13
to idap...@googlegroups.com
Found the solution, use idc.OpOff(ea, operand_number, offset)
Reply all
Reply to author
Forward
0 new messages