question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Repeatable comments on non-function symbols from a Ghidra script

See original GitHub issue

Hey guys,

In the user interface it is possible to add a repeatable comment to a symbol that is not a function (i.e. a global variable/memory reference, etc). However I didn’t find an API that would allow me to do the same from a Ghidra script. Here’s all the API functions currently available from the top level Python script environment as far as I can tell: setPlateComment, setPreComment, setPostComment, setEOLComment. I expected something like setRepeatableComment to exist, but it unfortunately does not. 😢

The closest thing I have found was the setRepeatableComment method in the ghidra.program.model.listing.Function class, but that is obviously only available for functions.

I tried to find examples from the built-in Ghidra scripts (e.g. Ghidra/Features/Base/ghidra_scripts/ReplaceInComments.java), but it seems that repeatable comments are only supported for functions.

Is there something I’m missing here, or is really not supported yet?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ebfe2326commented, Nov 15, 2019

the scripting takes some getting use to in order to find the right API. Try the code below and I think it will do what you’re asking.

currentProgram.getListing().setComment(currentAddress, ghidra.program.model.listing.CodeUnit.REPEATABLE_COMMENT, 'test repeatable comment')

0reactions
ryanmkurtzcommented, Dec 20, 2019

You can ignore my last message…I saw this ticket got updated, read your Python comment (which I thought was new), thought it was you saying you were going to make an additional pull request specifically for Python, and got confused. I think I need a coffee.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatProgramAPI - Ghidra
Modifier and Type Method Description void addEntryPoint​(Address address) Adds an entry point at th... AddressSet createAddressSet() Creates a new mutable... Data createAsciiString​(Address address, int length) Create...
Read more >
Ghidra Cheat Sheet
Repeat Define Data, Y, ❖ → Data → Last Used: type ... Rerun Script, Ctrl + Shift + R ... Next Non-function Instruction,...
Read more >
Comments - Fossies
Comments ; Plate, Displayed as a block header above the instruction. Plate comments are automatically surrounded by '*'s ; Repeatable, Displayed to the...
Read more >
ghidra scripting: how to distinguish between function and ...
The Symbol object has a couple different ways you could go about this. Here are a few options. symbols = set(currentProgram.
Read more >
The Hacker's Guide to Reverse Engineering
III, to Mike Van Emmerik for his review of the decompilation chapter, and to ... The user can then execute the next line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found