Annotations

Annotations are a method for embedding display markup in Ghidra fields, such as comments. An annotation is written with a strict syntax, which when rendered will have a display value as defined by the particular annotation used. Furthermore, some annotations add functionality, such as making the display text a hyperlink.

The following text shows the syntax of the URL annotation:


{@url "http://www.google.com"}

The bold text is required for all annotations. The italicized text is required but is specific to the annotation being used (see the table below).

Examples


URL Annotation Example

The image above shows a URL annotation in its text form as entered into the EOL Comment tab of the Comments dialog.

The image below shows how the annotation is rendered in Ghidra.


Rendered URL Annotation Example

When the URL text (e.g., "http://www.google.com") in the above image is clicked from within Ghidra, a web browser is launched and attempts to load the corresponding web page. If the URL text is of the form ghidra://<host>[:<port>]/<repository-name>/<program-path>[#<address-or-symbol-ref>] an attempt will be made to open the corresponding program from the referenced Ghidra Server (e.g., ghidra://myserver/Repo/notepad.exe#entry).

Valid Annotations

The following is a table of supported annotations:

Name
Description
Parameter List
Accepted Keywords Examples
Symbol
Displays the text of the given symbol or the current name of the primary symbol for a given address as a hyperlink.


Notes:
  • If you provide a symbol name and not an address, then you will need to fully-qualify the symbol name if it is not in the global namespace (e.g., FunctionFoo::param1 to link to a specific function parameter).
  • If you specify a symbol name instead of an address, then the text of the comment will be changed to use the address of that symbol.
  1. address or symbol name
  • @symbol
  • @sym
  • {@symbol "0x1001004a"}
  • {@symbol "fred"}
  • {@sym "100100fe"}
Address
Displays the given address value as a hyperlink.
  1. address
  2. [display text]
  • @address
  • @addr
  • {@address "1001004a"}
  • {@addr "0x0100100c"}
  • {@address "01001004a" "my special address"}
URL
Displays the given URL has a hyperlink. This annotation optionally takes display text so that the hyperlink may be displayed with text other than that of the URL.

References to ghidra://, which refer to a program within a Ghidra Server repository, will be opened within the Listing display, while all other URL protocols (e.g., http://, https://, file://, etc.) will be launched via an external web browser (see command configuration for Processor Manuals).
  1. URL
  2. [display text]
  • @url
  • @hyperlink
  • @href
  • @link
  • {@url "http://www.google.com"}
  • {@url "http://www.google.com" "google"}
  • {@url "http://www.google.com" "click here for google"}
  • {@url "ghidra://myserver/Repo/notepad.exe"}
  • {@url "ghidra://myserver/Repo/notepad.exe#entry"}
  • {@url "ghidra://myserver/Repo/notepad.exe" "see notepad.exe"}
Program
Displays a hyperlink to the given Ghidra program name that will open that program in a new Listing tab when clicked.
You may optionally provide an address or symbol to be displayed when the program is opened by appending to the program name an '@' character, followed by an address or symbol name.
  1. program name (with optional address or symbol)
  2. [display text]
  • @program
  • {@program "WinHelloCPP.exe"}
  • {@program "WinHelloCPP.exe@01001234"}
  • {@program "WinHelloCPP.exe@some_label"}
  • {@program "WinHelloCPP.exe@SomeFunction::some_label"}
  • {@program "WinHelloCPP.exe" "Click here to open WinHelloCPP"}
  • {@program "subfolder/WinHelloCPP.exe"}
  • {@program "subfolder1/subfolder2/WinHelloCPP.exe"}
Execute
Launches the specified executable with given optional parameters.
  1. "executable path"
OR
  1. "executable path"
  2. "parameter list" (may be empty quotes)
  3. "display text" (may be empty quotes)
  • @execute
  • {@execute "C:\Program Files\Mozilla Firefox\firefox.exe"}
  • {@execute "C:\Program Files\Mozilla Firefox\firefox.exe" "http://my.website.com" "Opens a web browser to Website"}
  • {@execute "C:\Program Files\Mozilla Firefox\firefox.exe" "" "My display text"}
  • {@execute "C:\Path\To\Some\executable.exe" "arg1 arg2" ""}
Note: quotes are required for this annotation
Discovered Annotations
Ghidra may discover new annotations that are provided by Ghidra plugins. Consult the documentation of the respective plugins for more information regarding the discovered annotations.



Note All annotations support double quotes (") around content inside of the annotation tag, excluding the @name part of the tag. Further, some annotations require quotes, as listed in the table above (e.g., the Execute annotation requires quotes). It is considered good practice to quote all annotation parameter values.

Errors

If there is a problem parsing an annotation then an error message will be printed in place of the annotations.


Invalid Annotation Text Entry


Rendered Invalid Annotation Example



Related Topics: