TransWikia.com

Accessing Call String of CALLOTHER Pcode Instruction via Java API?

Reverse Engineering Asked on February 25, 2021

Is there a way to access the call string of a CALLOTHER Pcode instruction when iterating over the Pcode in Java? The listing below shows an example of what I mean:

048
                             LAB_0001b034                                    XREF[1]:     0001b024(j)  
        0001b034 36 7f ff e6     rbit       r7,r6
                                                      r7 = CALLOTHER "ReverseBitOrder", r6

In this example, I’d like to get the string "ReverseBitOrder".
Unfortunately, there is no hint in the instruction info except for this input object:

const:0x3c

Which does not translate into the given string and I also cannot click on the string to find a location in memory.
I also looked through the API docs of Pcode, Instruction etc., but did not find anything useful.

One Answer

There is a ghidra_script that current does this, see https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Base/ghidra_scripts/MarkCallOtherPcode.java

basically:

op = getInstructionAt(toAddr(0x1b034)).getPcode()[0]
currentProgram.getLanguage().getUserDefinedOpName(op.getInput(0).getOffset()))

Correct answer by mumbel on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP