1

I am using Ghidra and when clicking for example in the decompile window on a specific raw, it change the cursor in the assembly window to the exact location in the assembly. Is there any option to do this using Ghidra scripting ?

Thanks

  • Can you give an example for what you mean ? I need to decompile the code using "getDecompiledFunction" and then i can use this function "getReferencesFrom" ? – Logan Apr 28 at 19:09
  • @R4444 - forgot to tag you – Logan Apr 28 at 19:17
  • Do you mean you have a list of addresses that you want to change the location in the assembly (listing) window to? If so, you can just use the GhidraScript method setCurrentLocation – genghiskhan May 1 at 23:33
  • @DanielDan You could write a comment under the specific answer (R4444's one, in this case), to ask follow up questions on it. – auspicious99 May 25 at 6:55
1

If you want instruction access references to a particular variable, then first define the reference manager:

refmanager = program.referenceManager

Then lets say you get all the local variables of a particular function - using -

vars = function.getLocalVariables()

You can get references to a particular variable:

for var in vars:
    for ref in refmanager.getReferencesTo(var):
        print(ref)

In this case ref will be of type Reference. The you can get particular references using this api. Also check this for other options.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.