Skip to content

Ghidra is a software reverse engineering (SRE) framework

Installation of Decompiler help

caheckman09fe23bfa497
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java
index efd41356ab..c9839d408a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java
@@ -71,6 +71,11 @@ public interface HelpTopics {
*/
public final static String DATA_TYPE_EDITORS = "DataTypeEditors";
+ /**
+ * Help Topic for the decompiler
+ */
+ public final static String DECOMPILER = "DecompilePlugin";
+
/**
* Help Topic for doing diffs between programs.
*/
diff --git a/Ghidra/Features/Decompiler/build.gradle b/Ghidra/Features/Decompiler/build.gradle
index 9e43eee56b..e84cca09d2 100644
--- a/Ghidra/Features/Decompiler/build.gradle
+++ b/Ghidra/Features/Decompiler/build.gradle
@@ -68,6 +68,62 @@ def buildDir = "../../../build" // Relative to the 'workingDir' Exec task proper
def installPoint = "$rootDir/GhidraDocs/languages/html"
+def installHelpPoint = "../help/help"
+
+task buildDecompilerHelpHtml(type: Exec) {
+
+ workingDir 'src/main/doc'
+
+ // 'which' returns the number of failed arguments
+ // Using the 'which' command first will allow the task to fail if the required
+ // executables are not installed.
+ //
+ // The bash commands end with "2>&1" to redirect stderr to stdout and have all
+ // messages print in sequence
+ //
+ // 'commandLine' takes one command, so wrap multiple commands in bash.
+ commandLine 'bash', '-e', '-c', """
+ echo '** Checking if required executables are installed. **'
+ which xsltproc
+ which sed
+
+ echo '** Removing older html files installed under '$installPoint' **'
+ rm -f $installPoint/topics/DecompilePlugin/*.html
+
+ echo '** Building html files **'
+ xsltproc --output $buildDir/decomp_noscaling.xml --stringparam profile.condition "noscaling" /usr/share/sgml/docbook/xsl-stylesheets/profiling/profile.xsl decompileplugin.xml 2>&1
+ xsltproc --stringparam base.dir ${installHelpPoint}/topics/DecompilePlugin/ --stringparam root.filename Decompiler decompileplugin_html.xsl $buildDir/decomp_noscaling.xml 2>&1
+ sed -i -e '/Frontpage.css/ { p; s/Frontpage.css/languages.css/; }' ${installHelpPoint}/topics/DecompilePlugin/*.html
+
+ echo '** Done. **'
+ """
+
+ // Allows doLast block regardless of exit value.
+ ignoreExitValue true
+
+ // Store the output instead of printing to the console.
+ standardOutput = new ByteArrayOutputStream()
+ ext.output = { standardOutput.toString() }
+ ext.errorOutput = { standardOutput.toString() }
+
+ // Check the OS before executing command.
+ doFirst {
+ if (!getCurrentPlatformName().startsWith("linux")) {
+ throw new TaskExecutionException( it, new Exception("The '$it.name' task only works on Linux."))
+ }
+ }
+
+ // Print the output of the commands and check the return value.
+ doLast {
+ println output()
+ if (execResult.exitValue) {
+ logger.error("$it.name: An error occurred. Here is the output:\n" + output())
+ throw new TaskExecutionException( it, new Exception("'$it.name': The command: '${commandLine.join(' ')}'" +
+ " task \nfailed with exit code $execResult.exitValue; see task output for details."))
+ }
+ }
+}
+
/**
* Build the pdfs docs for the decompiler and place them in the '$buildDir' directory.
* A build (ex: 'gradle buildGhidra') will place the pdfs in the distribution zip file.
diff --git a/Ghidra/Features/Decompiler/certification.manifest b/Ghidra/Features/Decompiler/certification.manifest
index b6e0e2d458..3328c543bc 100644
--- a/Ghidra/Features/Decompiler/certification.manifest
+++ b/Ghidra/Features/Decompiler/certification.manifest
@@ -37,7 +37,12 @@ src/main/help/help/shared/redo.png||GHIDRA||||END|
src/main/help/help/shared/tip.png||Oxygen Icons - LGPL 3.0||||END|
src/main/help/help/shared/undo.png||GHIDRA||||END|
src/main/help/help/shared/warning.png||Oxygen Icons - LGPL 3.0||||END|
-src/main/help/help/topics/DecompilePlugin/Decompiler.htm||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/Decompiler.html||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/DecompilerAnnotations.html||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/DecompilerConcepts.html||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/DecompilerIntro.html||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/DecompilerOptions.html||GHIDRA||||END|
+src/main/help/help/topics/DecompilePlugin/DecompilerWindow.html||GHIDRA||||END|
src/main/help/help/topics/DecompilePlugin/images/BackwardSlice.png||GHIDRA||||END|
src/main/help/help/topics/DecompilePlugin/images/DecompWindow.png||GHIDRA||||END|
src/main/help/help/topics/DecompilePlugin/images/Defuse.png||GHIDRA||||END|
diff --git a/Ghidra/Features/Decompiler/src/main/doc/decompileplugin.xml b/Ghidra/Features/Decompiler/src/main/doc/decompileplugin.xml
index 84a9fab409..d732acd4c7 100644
--- a/Ghidra/Features/Decompiler/src/main/doc/decompileplugin.xml
+++ b/Ghidra/Features/Decompiler/src/main/doc/decompileplugin.xml
@@ -26,7 +26,7 @@
and navigation between C language expressions and their
corresponding assembly instructions.
</para>
-<sect2>
+<sect2 id="EnablePlugin">
<title>Enabling the Plug-in</title>
<para>
The Decompiler is a full Plug-in within Ghidra and can be configured to be enabled or
@@ -42,7 +42,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ShowWindow">
<title>Showing the Decompiler Window</title>
<para>
From the Code Browser, either:
@@ -282,7 +282,7 @@
</sect2>
- <sect2>
+ <sect2 id="ConceptPcodeOps">
<title>P-code Operations</title>
<para>
A <emphasis role="bold">p-code operation</emphasis> is defined as a formal operator,
@@ -367,7 +367,7 @@
</informalexample>
</para>
- <sect3>
+ <sect3 id="ConceptOperatorTokens">
<title>Operator Tokens</title>
<para>
Most opcodes naturally correspond to a particular C operator token,
@@ -906,7 +906,7 @@
<emphasis>HighSymbol</emphasis> refer to this decompiler specific view of the function.
</para>
- <sect2>
+ <sect2 id="ConceptHighSymbol">
<title>HighSymbol</title>
<para>
A <emphasis role="bold">HighSymbol</emphasis> is one of the explicit symbols recovered by the
@@ -1021,7 +1021,7 @@
is no corresponding HighVariable.
</para>
- <sect3>
+ <sect3 id="ConceptMerging">
<title>Merging</title>
<para>
<emphasis role="bold">Merging</emphasis> is the part of the analysis process where
@@ -1071,7 +1071,7 @@
A prototype model is typically used as a whole and is assigned by name to individual functions. But some of
the sub-concepts of the model may be relevant to reverse engineers.
</para>
- <sect3>
+ <sect3 id="ConceptPrototypeStorage">
<title>Incoming and Outgoing Storage Locations</title>
<para>
A formal input parameter is always assigned a specific memory location to hold its value coming into the function.
@@ -1091,7 +1091,7 @@
points, but they all share the same return value storage location.
</para>
</sect3>
- <sect3>
+ <sect3 id="ConceptPrototypeUnaffected">
<title>Unaffected</title>
<para>
Prototype models can specify a set of <emphasis role="bold">unaffected</emphasis>memory locations,
@@ -1104,7 +1104,7 @@
a sub-function.
</para>
</sect3>
- <sect3>
+ <sect3 id="ConceptPrototypeKilledByCall">
<title>Killed by Call</title>
<para>
In constrast to <emphasis>unaffected</emphasis> memory locations, a prototype model may specify
@@ -1150,7 +1150,7 @@
A <emphasis role="bold">function body</emphasis> is the set of addresses reached by control-flow
analysis (and the machine instructions at those addresses).
</para>
- <sect2>
+ <sect2 id="ConceptEntryPoint">
<title>Entry Point</title>
<para>
The <emphasis>entry point</emphasis> address for a function plays a pivotal role for
@@ -1171,7 +1171,7 @@
(See <link xlink:href="help/topics/FunctionPlugin/Functions.htm#Create_Function">Create Function</link>)
</para>
</sect2>
- <sect2>
+ <sect2 id="ConceptFunctionBody">
<title>Formal Function Body</title>
<para>
When a function is created, Ghidra stores its function body as a set of addresses in the
@@ -1191,7 +1191,7 @@
</note>
</sect2>
- <sect2>
+ <sect2 id="ConceptFlowOverride">
<title>Flow Overrides</title>
<para>
Control-flow behavior for machine instructions is generally determined by the underlying
@@ -1307,7 +1307,7 @@
<link xlink:href="help/topics/CommentsPlugin/Comments.htm">Comments</link>.
</para>
- <sect2>
+ <sect2 id="CommentDisplay">
<title>Display</title>
<para>
The decompiler collects and displays comments associated with any address in the
@@ -1347,7 +1347,7 @@
</note>
</sect2>
- <sect2>
+ <sect2 id="CommentUnreachable">
<title>Unreachable Blocks</title>
<para>
The decompiler may decide as part of its analysis that individual
@@ -1357,7 +1357,7 @@
</para>
</sect2>
- <sect2 id="AnnoteWarnings">
+ <sect2 id="CommentWarnings">
<title>Warning Comments</title>
<para>
The decompiler can generate internal warnings during its analysis and will incorporate
@@ -1399,7 +1399,7 @@
</informalexample>
</para>
- <sect2>
+ <sect2 id="VariableCreate">
<title>Creating Variable Annotations</title>
<para>
Ghidra provides various ways that a name and other attributes can be ascribed
@@ -1458,7 +1458,7 @@
</para>
</sect2>
- <sect2>
+ <sect2 id="VariableSymbol">
<title>Variable Symbols</title>
<para>
Ghidra maintains its own symbol table that supports namespaces and function
@@ -1493,7 +1493,7 @@
</informalexample>
</para>
- <sect3>
+ <sect3 id="SymbolScope">
<title>Variable Scope</title>
<para>
All variables belong either to a <emphasis>global</emphasis> or <emphasis>local</emphasis>
@@ -1537,7 +1537,7 @@
are, to the extent possible, automatically incorporated
into the decompiler's analysis.
</para>
- <sect3>
+ <sect3 id="DecompilerDataTypes">
<title>Data-types Supported by the Decompiler</title>
<para>
The decompiler understands traditional primitive data-types, in all their various sizes,
@@ -1550,7 +1550,7 @@
or simply as an array of bytes.
</para>
- <sect4>
+ <sect4 id="TypeUndefined">
<title>Undefined</title>
<para>
The <emphasis>undefined</emphasis> data-types are supported, in their various sizes:
@@ -1565,7 +1565,7 @@
output for the variable (See <xref linkend="AnnoteForcing"/> below).
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeVoid">
<title>Void</title>
<para>
The <emphasis role="bold">void</emphasis> data-type is supported but treated specially by
@@ -1575,7 +1575,7 @@
is possible; the decompiler treats it as a pointer to an unknown data-type.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeInteger">
<title>Integer</title>
<para>
Integer data-types, both signed and unsigned, are supported up to a size of 8 bytes. Larger
@@ -1588,13 +1588,13 @@
based on the processor and compiler selected when importing the Program.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeBoolean">
<title>Boolean</title>
<para>
A 1-byte boolean data-type is supported.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeFloat">
<title>Floating-point</title>
<para>
Floating-point sizes of 4, 8, 10, and 16 are supported, mapping in all cases currently to the
@@ -1604,7 +1604,7 @@
that are bigger than 8 bytes.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeChar">
<title>Character</title>
<para>
ASCII or unicode encoded character data-types are supported for sizes of 1, 2, and 4. The size affectively
@@ -1614,7 +1614,7 @@
processor and compiler selected when importing the Program.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeString">
<title>String</title>
<para>
Terminated strings, encoded either in ASCII or Unicode, are supported. The decompiler converts
@@ -1641,7 +1641,7 @@
escape sequences like '\xFF'.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypePointer">
<title>Pointer</title>
<para>
Pointer data-types are fully supported. A pointer to any other supported data-type is
@@ -1664,14 +1664,14 @@
determine the correct address space from the context of its use within the function.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeArray">
<title>Array</title>
<para>
Array data-types are fully supported. The array element can be any other supported data-type
with a fixed size.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeStructure">
<title>Structure</title>
<para>
Structured data-types are fully supported. The decompiler does not automatically infer structures
@@ -1680,7 +1680,7 @@
structures can be triggered by the user, see <xref linkend="ActionAutoStructure"/>.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeEnum">
<title>Enumeration</title>
<para>
Enumerations are fully supported. The decompiler can propagate enumerations from explicitly
@@ -1692,7 +1692,7 @@
for instance, by labeling individal bit values within an enumeration.
</para>
</sect4>
- <sect4>
+ <sect4 id="TypeFunction">
<title>Function Definition</title>
<para>
A <emphasis role="bold">Function Definition</emphasis> in Ghidra is a data-type that encodes
@@ -1830,7 +1830,7 @@
<emphasis role="bold">scope</emphasis>; this is distinct from (but influenced by) the scope of the
variable itself. The different types of storage location are listed below.
</para>
- <sect3>
+ <sect3 id="VariableStorageImage">
<title>Load-image Address</title>
<para>
A <emphasis role="bold">load-image address</emphasis> is a concrete address in the load image of the Program,
@@ -1853,7 +1853,7 @@
the variable in decompiler output.
</para>
</sect3>
- <sect3>
+ <sect3 id="VariableStorageStack">
<title>Stack Address</title>
<para>
A <emphasis role="bold">stack address</emphasis> is an address in the <emphasis>stack frame</emphasis>
@@ -1884,7 +1884,7 @@
<emphasis>propagated through</emphasis> to another expression.
</para>
</sect3>
- <sect3>
+ <sect3 id="VariableStorageRegister">
<title>Register</title>
<para>
A variable annotation can refer to a specific <emphasis>register</emphasis> for the processor associated
@@ -1909,7 +1909,7 @@
<emphasis>merging</emphasis> process, but the full extent is not stored in the annotation.
</para>
</sect3>
- <sect3>
+ <sect3 id="VariableStorageTemp">
<title>Temporary Registers</title>
<para>
Variable annotations can have a <emphasis>temporary register</emphasis> as a storage location.
@@ -2048,7 +2048,7 @@
</variablelist>
</informalexample>
</para>
- <sect2>
+ <sect2 id="PrototypeDiscover">
<title>Discovering Parameters</title>
<para>
The input parameter and return value annotations of the function prototype, like
@@ -2067,7 +2067,7 @@
dictates which storage locations can be considered as parameters and their formal ordering.
</para>
</sect2>
- <sect2>
+ <sect2 id="PrototypeCustom">
<title>Custom Storage</title>
<para>
If there are parameter or return value annotations that do not agree with the calling convention that
@@ -2106,11 +2106,11 @@
</para>
<para>
Mutability can be set on an entire block of memory in the Program, typically from the
- <link xlink:href="help/topics/MemoryMapPlugin/Memory_map.htm#View_Memory_Map">Memory Map</link>.
+ <link xlink:href="help/topics/MemoryMapPlugin/Memory_Map.htm#View_Memory_Map">Memory Map</link>.
It can also be set as part of a single Variable Annotation. From the Listing Window for instance,
use the <link xlink:href="help/topics/DataPlugin/Data.htm#Data_Settings">Settings</link> dialog.
</para>
- <sect2>
+ <sect2 id="MutabilityReadOnly">
<title>Read-only</title>
<para>
The <emphasis role="bold">constant</emphasis> mutability setting indicates that values within
@@ -2121,7 +2121,7 @@
can have a substantial impact on the final output.
</para>
</sect2>
- <sect2>
+ <sect2 id="MutabilityVolatile">
<title>Volatile</title>
<para>
The <emphasis role="bold">volatile</emphasis> mutability setting indicates that values within
@@ -2161,7 +2161,7 @@
</itemizedlist>
</informalexample>
</para>
- <sect2>
+ <sect2 id="ConstantEquates">
<title>Equates</title>
<para>
Ghidra can create an association between a name and a constant, called an <emphasis role="bold">equate</emphasis>.
@@ -2180,7 +2180,7 @@
symbol (representing the original constant).
</para>
</sect2>
- <sect2>
+ <sect2 id="ConstantConversions">
<title>Format Conversions</title>
<para>
Ghidra can apply a <emphasis role="bold">format conversion</emphasis> to override how an integer operand
@@ -2645,7 +2645,7 @@
<para>
Toggle whether decompiler generated <emphasis>WARNING</emphasis> comments are displayed as part
of the output. The decompiler generates these comments, independent of those layed down by users, to
- indicate unusual conditions or possible errors (See <xref linkend="AnnoteWarnings"/>).
+ indicate unusual conditions or possible errors (See <xref linkend="CommentWarnings"/>).
</para>
</listitem>
</varlistentry>
@@ -2823,7 +2823,7 @@
one or more warnings during the process. These warnings are integrated into the output as
source code comments starting with label <code>WARNING:</code>. They occur either at the
beginning of the function as part of the function header or at the point in the code directly
- associated with the warning. (See <xref linkend="AnnoteWarnings"/>)
+ associated with the warning. (See <xref linkend="CommentWarnings"/>)
</para>
</section>
@@ -2831,7 +2831,7 @@
<title>Main Window</title>
<para>
Initially pushing <guiicon><inlinegraphic fileref="images/decompileFunction.gif"/></guiicon> or selecting
- <emphasis role="bold">Decompile</emphasis> from <emphasis role="bold">Window</emphasis> menu in the tool
+ <emphasis role="bold">Decompile</emphasis> from the <emphasis role="bold">Window</emphasis> menu in the tool
brings up the <emphasis>main</emphasis> window. The main window always displays the function
at the <emphasis>current address</emphasis> within the Code Browser and follows as the user navigates
within the Program. Any mouse click, menu option, or other action causing the cursor to move to a new
@@ -2915,7 +2915,7 @@
<emphasis>Snapshot</emphasis>. The action applies to the function and decompiler results
displayed in that particular window.
</para>
-<sect2>
+<sect2 id="ToolBarExport">
<title>Export to C</title>
<para>
<guiicon><inlinegraphic fileref="images/page_edit.png"/></guiicon> - button
@@ -2928,7 +2928,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ToolBarSnapshot">
<title>Snapshot</title>
<para>
<guiicon><inlinegraphic fileref="images/camera-photo.png"/></guiicon> - button
@@ -2941,7 +2941,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ToolBarRedecompile">
<title>Re-decompile</title>
<para>
<guiicon><inlinegraphic fileref="images/reload3.png"/></guiicon> - button
@@ -2959,7 +2959,7 @@
</note>
</sect2>
-<sect2>
+<sect2 id="ToolBarCopy">
<title>Copy</title>
<para>
<guiicon><inlinegraphic fileref="images/page_white_copy.png"/></guiicon> - button
@@ -2969,7 +2969,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ToolBarDebug">
<title>Debug Function Decompilation</title>
<para>
This action is located in the drop-down menu on the right side of the decompiler
@@ -2990,7 +2990,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ToolBarGraph">
<title>Graph AST Control Flow</title>
<para>
Generate a control-flow graph based upon the results in the active Decompiler Window,
@@ -3005,7 +3005,7 @@
<section id="MouseActions">
<title>Mouse Actions</title>
-<sect2>
+<sect2 id="MouseLeft">
<title>Left Click</title>
<para>
Moves the decompiler window cursor and highlights the token. Within the
@@ -3024,7 +3024,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="MouseRight">
<title>Right Click</title>
<para>
Moves the decompiler window cursor, highlights the token, and brings up the menu of
@@ -3034,7 +3034,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="MouseDouble">
<title>Double Click</title>
<para>
Navigates based on the selected symbol or other token (See below). If the selected token represents a formal symbol,
@@ -3089,7 +3089,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="MouseControlDouble">
<title>Control Double Click</title>
<para>
Opens a new <emphasis>Snapshot</emphasis> window, navigating it to the selected symbol.
@@ -3100,7 +3100,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="MouseControlShift">
<title>Control Shift Click</title>
<para>
Generates a navigation event to the address, within the current function, associated with
@@ -3111,7 +3111,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="MouseMiddle">
<title>Middle Click</title>
<para>
Highlights every occurrence of a variable, constant, or operator under the current
@@ -3177,7 +3177,7 @@
</informalexample>
</sect2>
-<sect2>
+<sect2 id="ActionComments">
<title>Comments</title>
<para>Set or change a comment at the address of the selected token.
</para>
@@ -3212,7 +3212,7 @@
</sect2>
<sect2 id="ActionCommitLocals">
- <title>Commit Local Names></title>
+ <title>Commit Local Names</title>
<para>
Commit the names of any local variables discovered during the decompiler's analysis
to the Program database as new Variable Annotations. The recovered data-type is
@@ -3260,7 +3260,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionCopy">
<title>Copy/Copy Special ...</title>
<para>
Copy selected code from the decompiler window into the clipboard.
@@ -3272,7 +3272,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionEditDataType">
<title>Edit Data Type</title>
<para>
Bring up a dialog for editing the definition of the data-type under the cursor.
@@ -3291,7 +3291,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionEditSignature">
<title>Edit Function Signature</title>
<para>
Bring up a dialog for editing the <emphasis>prototype</emphasis> of a selected function and other
@@ -3347,7 +3347,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionHighlight">
<title>Highlight</title>
<para>
All these actions highlight a specific set of variable tokens tracing the data-flow
@@ -3420,7 +3420,7 @@
</informalexample>
</sect2>
-<sect2>
+<sect2 id="ActionSecondaryHighlight">
<title>Secondary Highlight</title>
<para>
A <emphasis>secondary highlight</emphasis> is a semi-permanent token highlight in the decompiler
@@ -3496,9 +3496,9 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionReference">
<title>Reference ...</title>
- <sect3>
+ <sect3 id="ActionFindUses">
<title>Find Uses of &lt;data-type&gt;</title>
<para>
Calculate locations in the Program that reference the <emphasis role="bold">data-type</emphasis>
@@ -3515,7 +3515,7 @@
variables as well.
</para>
</sect3>
- <sect3>
+ <sect3 id="ActionFindReferences">
<title>Find References to &lt;function&gt;</title>
<para>
Display locations in the Program that reference the <emphasis role="bold">function</emphasis>
@@ -3528,7 +3528,7 @@
address of the function.
</para>
</sect3>
- <sect3>
+ <sect3 id="ActionShowReferences">
<title>Show References to Address</title>
<para>
Display locations in the Program that reference the <emphasis role="bold">address</emphasis>
@@ -3543,7 +3543,7 @@
</sect3>
</sect2>
-<sect2>
+<sect2 id="ActionRemoveOverride">
<title>Remove Signature Override</title>
<para>
Remove the overriding function prototype applied previously to the sub-function under the cursor.
@@ -3558,7 +3558,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionRenameFunction">
<title>Rename Function</title>
<para>
Rename the function corresponding to the token under the cursor.
@@ -3587,7 +3587,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionRenameField">
<title>Rename Field</title>
<para>
Rename the field currently under the cursor within its <emphasis>structure</emphasis>
@@ -3617,7 +3617,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionRenameGlobal">
<title>Rename Global</title>
<para>
Rename the global variable corresponding to the token under the cursor.
@@ -3699,7 +3699,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionRetypeGlobal">
<title>Retype Global</title>
<para>
Change the data-type of the global variable currently under the cursor.
@@ -3719,7 +3719,7 @@
</para>
</sect2>
-<sect2>
+<sect2 id="ActionRetypeReturn">
<title>Retype Return</title>
<para>
Change the data-type of the current function's <emphasis>return value</emphasis>.
diff --git a/Ghidra/Features/Decompiler/src/main/doc/decompileplugin_html.xsl b/Ghidra/Features/Decompiler/src/main/doc/decompileplugin_html.xsl
index 4b1e388948..ac7773d335 100644
--- a/Ghidra/Features/Decompiler/src/main/doc/decompileplugin_html.xsl
+++ b/Ghidra/Features/Decompiler/src/main/doc/decompileplugin_html.xsl
@@ -42,7 +42,7 @@
<xsl:param name="use.id.as.filename" select="1"/> <!-- Split up into files based on id attribute -->
-<xsl:param name="html.stylesheet" select="'Frontpage.css'"/> <!-- Use our custom cascading style sheet -->
+<xsl:param name="html.stylesheet" select="'../../shared/Frontpage.css'"/> <!-- Use our custom cascading style sheet -->
<xsl:param name="chunk.section.depth" select="0"/>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/TOC_Source.xml b/Ghidra/Features/Decompiler/src/main/help/help/TOC_Source.xml
index eecad1417f..a5b016054e 100644
--- a/Ghidra/Features/Decompiler/src/main/help/help/TOC_Source.xml
+++ b/Ghidra/Features/Decompiler/src/main/help/help/TOC_Source.xml
@@ -54,108 +54,48 @@
<tocdef id="Decompiler"
text="Decompiler"
- target="help/topics/DecompilePlugin/Decompiler.htm" >
+ target="help/topics/DecompilePlugin/DecompilerIntro.html" >
- <tocdef id="Decompiler Capabilities"
+ <tocdef id="Decompiler Concepts"
sortgroup="a"
- text="Decompiler Capabilities"
- target="help/topics/DecompilePlugin/Decompiler.htm#Capabilities" />
- <tocdef id="Variables"
+ text="Decompiler Concepts"
+ target="help/topics/DecompilePlugin/DecompilerConcepts.html">
+ <tocdef id="ConceptPcode" sortgroup="a" text="P-code" target="help/topics/DecompilePlugin/DecompilerConcepts.html#ConceptPcode"/>
+ <tocdef id="ConceptHighFunction" sortgroup="b" text="The HighFunction" target="help/topics/DecompilePlugin/DecompilerConcepts.html#ConceptHighFunction"/>
+ </tocdef>
+ <tocdef id="Program Annotations Affecting the Decompiler"
sortgroup="b"
- text="Variables"
- target="help/topics/DecompilePlugin/Decompiler.htm#Variables" />
- <tocdef id="Parameter Variables"
+ text="Program Annotations Affecting the Decompiler"
+ target="help/topics/DecompilePlugin/DecompilerAnnotations.html">
+ <tocdef id="AnnoteFunctionBody" sortgroup="a" text="Machine Instructions" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteFunctionBody"/>
+ <tocdef id="AnnoteComments" sortgroup="b" text="Comments" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteComments"/>
+ <tocdef id="AnnoteVariables" sortgroup="c" text="Variable Annotations" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteVariables"/>
+ <tocdef id="AnnotePrototype" sortgroup="d" text="Function Prototypes" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnotePrototype"/>
+ <tocdef id="AnnoteMutability" sortgroup="e" text="Data Mutability" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteMutability"/>
+ <tocdef id="AnnoteConstants" sortgroup="f" text="Constant Annotations" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteConstants"/>
+ <tocdef id="AnnoteRegister" sortgroup="g" text="Register Values" target="help/topics/DecompilePlugin/DecompilerAnnotations.html#AnnoteRegister"/>
+ </tocdef>
+ <tocdef id="Decompiler Options"
sortgroup="c"
- text="Parameter Variables"
- target="help/topics/DecompilePlugin/Decompiler.htm#Parameter_Variables" />
- <tocdef id="Internal Decompiler Functions"
- sortgroup="d"
- text="Internal Decompiler Functions"
- target="help/topics/DecompilePlugin/Decompiler.htm#Internal_Decompiler_Functions" />
- <tocdef id="Register Settings"
- sortgroup="e"
- text="Register Settings"
- target="help/topics/DecompilePlugin/Decompiler.htm#Register_Settings" />
- <tocdef id="Decompiler Options"
- sortgroup="f"
text="Decompiler Options"
- target="help/topics/DecompilePlugin/Decompiler.htm#DecompileOptions" />
- <tocdef id="Data Mutability"
- sortgroup="g"
- text="Data Mutability"
- target="help/topics/DecompilePlugin/Decompiler.htm#Data_Mutability" />
- <tocdef id="Decompiler Window Commands"
- sortgroup="h"
- text="Decompiler Window Commands"
- target="help/topics/DecompilePlugin/Decompiler.htm#Decompiler_Window" >
-
- <tocdef id="Copy/Copy Special"
- sortgroup="a"
- text="Copy/Copy Special"
- target="help/topics/DecompilePlugin/Decompiler.htm#Copy" />
- <tocdef id="Set Comments"
- sortgroup="b"
- text="Set Comments"
- target="help/topics/DecompilePlugin/Decompiler.htm#Comments" />
- <tocdef id="Saving decompiler parameters to database"
- sortgroup="c"
- text="Saving decompiler parameters to database"
- target="help/topics/DecompilePlugin/Decompiler.htm#Commit_Params_Return" />
- <tocdef id="Saving decompiler local variables to database"
- sortgroup="d"
- text="Saving decompiler local variables to database"
- target="help/topics/DecompilePlugin/Decompiler.htm#Commit_Locals" />
- <tocdef id="Highlighting all places a value is used"
- sortgroup="e"
- text="Highlighting all places a value is used"
- target="help/topics/DecompilePlugin/Decompiler.htm#Highlight_Defined_Use" />
- <tocdef id="Highlighting Forward Slice"
- sortgroup="f"
- text="Highlighting Forward Slice"
- target="help/topics/DecompilePlugin/Decompiler.htm#Highlight_Forward_Slice" />
- <tocdef id="Highlighting Backward Slice"
- sortgroup="g"
- text="Highlighting Backward Slice"
- target="help/topics/DecompilePlugin/Decompiler.htm#Highlight_Backward_Slice" />
- <tocdef id="Highlighting Forward Instruction Slice"
- sortgroup="f"
- text="Highlighting Forward Instruction Slice"
- target="help/topics/DecompilePlugin/Decompiler.htm#Highlight_Forward_Inst_Slice" />
- <tocdef id="Highlighting Backward Instruction Slice"
- sortgroup="g"
- text="Highlighting Backward Instruction Slice"
- target="help/topics/DecompilePlugin/Decompiler.htm#Highlight_Backward_Inst_Slice" />
- <tocdef id="Renaming Variables"
- sortgroup="h"
- text="Renaming Variables"
- target="help/topics/DecompilePlugin/Decompiler.htm#Rename_Variable" />
- <tocdef id="Retyping Variables"
- sortgroup="i"
- text="Retyping Variables"
- target="help/topics/DecompilePlugin/Decompiler.htm#Retype_Variable" />
- <tocdef id="Editing Function Signatures"
- sortgroup="j"
- text="Editing Function Signatures"
- target="help/topics/DecompilePlugin/Decompiler.htm#Edit_Function_Signature" />
- <tocdef id="Searching for text in decompiled functions"
- sortgroup="j"
- text="Searching for text in decompiled functions"
- target="help/topics/DecompilePlugin/Decompiler.htm#Find" />
- <tocdef id="Debugging Function Decompilation"
- sortgroup="k"
- text="Debugging Function Decompilation"
- target="help/topics/DecompilePlugin/Decompiler.htm#Debug_Function_Decompilation" />
- <tocdef id="Exporting to C"
- sortgroup="m"
- text="Exporting to C"
- target="help/topics/DecompilePlugin/Decompiler.htm#Export_to_C" />
- <tocdef id="Changing appearance of Decompiler window"
- sortgroup="n"
- text="Changing appearance of Decompiler window"
- target="help/topics/DecompilePlugin/Decompiler.htm#DecompilerProperties" />
- </tocdef>
- </tocdef>
-
- </tocref>
+ target="help/topics/DecompilePlugin/DecompilerOptions.html">
+ <tocdef id="GeneralOptions" sortgroup="a" text="General Options" target="help/topics/DecompilePlugin/DecompilerOptions.html#GeneralOptions"/>
+ <tocdef id="AnalysisOptions" sortgroup="b" text="Analysis Options" target="help/topics/DecompilePlugin/DecompilerOptions.html#AnalysisOptions"/>
+ <tocdef id="DisplayOptions" sortgroup="c" text="Display Options" target="help/topics/DecompilePlugin/DecompilerOptions.html#DisplayOptions"/>
+ <tocdef id="ProgramOptions" sortgroup="d" text="Program Options" target="help/topics/DecompilePlugin/DecompilerOptions.html#ProgramOptions"/>
+ </tocdef>
+ <tocdef id="Decompiler Window"
+ sortgroup="d"
+ text="Decompiler Window"
+ target="help/topics/DecompilePlugin/DecompilerWindow.html">
+ <tocdef id="DecompilerDisplay" sortgroup="a" text="Display" target="help/topics/DecompilePlugin/DecompilerWindow.html#DecompilerDisplay"/>
+ <tocdef id="MainWindow" sortgroup="b" text="Main Window" target="help/topics/DecompilePlugin/DecompilerWindow.html#MainWindow"/>
+ <tocdef id="Snapshot" sortgroup="c" text="Snapshot Windows" target="help/topics/DecompilePlugin/DecompilerWindow.html#Snapshot"/>
+ <tocdef id="ToolBar" sortgroup="d" text="Tool Bar" target="help/topics/DecompilePlugin/DecompilerWindow.html#ToolBar"/>
+ <tocdef id="MouseActions" sortgroup="e" text="Mouse Actions" target="help/topics/DecompilePlugin/DecompilerWindow.html#MouseActions"/>
+ <tocdef id="MenuActions" sortgroup="f" text="Pop-up Menu Actions" target="help/topics/DecompilePlugin/DecompilerWindow.html#MenuActions"/>
+ </tocdef>
+ </tocdef>
+ </tocref>
</tocroot>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.htm b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.htm
deleted file mode 100644
index 3d9ed92987..0000000000
--- a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.htm
+++ /dev/null
@@ -1,1090 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<HTML>
- <HEAD>
- <META name="generator" content=
- "HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net">
- <META http-equiv="Content-Language" content="en-us">
- <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
- <META name="GENERATOR" content="Microsoft FrontPage 4.0">
- <META name="ProgId" content="FrontPage.Editor.Document">
-
- <TITLE>Decompiler</TITLE>
- <LINK rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
- </HEAD>
-
- <BODY>
- <H1><A name="Decompile_Function"></A>Decompiler</H1>
-
- <BLOCKQUOTE>
- <P>The Decompiler plugin is a sophisticated transformation engine which automatically
- converts the binary representation of individual functions into a high-level C
- representation. The Decompiler presents a view of a program which is interactive and
- dynamically updated as the user adds or makes changes to the annotations associated with the
- program. A Decompiler window maintains the correspondence between the C representation and
- the assembly representation displayed in the Code Browser window, to the extent possible. The
- window allows instant visual association and navigation between C language expressions and
- their corresponding assembly instructions.</P>
-
- <P>To display the decompiler window, position the cursor on a function in the Code Browser,
- then select the <IMG alt="" src="images/decompileFunction.gif" border="0"> icon from the tool
- bar, or the <B>Decompile</B> option from the <B>Window</B> menu in the tool.</P>
-
- <CENTER style="margin-top:50px; margin-bottom:25px">
- <P><IMG alt="" src="images/DecompWindow.png" border="0"></P>
- </CENTER>
-
- <P><A name="Capabilities"></A>Some of the primary capabilities of the decompiler include:</P>
-
- <UL>
- <LI><I><B>Recovers Expressions</B></I>: The decompiler does full dataflow analysis which
- allows it to perform slicing on functions. The most tangible benefit to the user is that
- complicated expressions, which have been split into distinct operations/instructions and
- then mixed together with other instructions by the compiling/optimizing process, are
- reconstituted into a single expression again by the decompiler.</LI>
-
- <LI><I><B>Recovers High-Level Scoped Variables</B></I>: The decompiler understands how
- compilers use processor stacks and registers to implement variables with different scopes
- within a function. Data-flow allows it to follow what was originally a single variable as it
- moves from the stack, into a register, into a different register, etc. Thus it can
- effectively recover the original programs concept of a variable, minimizing the need to
- introduce artificial variables in the output.</LI>
-
- <LI><I><B>Recovers Function Parameters</B></I>: The decompiler understands the parameter
- passing conventions of the compiler and can reconstruct the form of the original function
- call.</LI>
-
- <LI><I><B>Uses Data type, Name, and Signature Annotations</B></I>: The decompiler
- automatically pulls in all the different data types and variable names that the user has
- applied to functions, and the C output is altered to reflect this. High-level variables are
- appropriately named, structure fields and array indices are calculated and displayed with
- correct syntax, constant char pointers are replaced with appropriate quoted strings,
- etc.</LI>
-
- <LI><I><B>Performs Local Type Propagation</B></I>: In the absence of information, the
- decompiler does its best to fill in information from what it does know. Variables whose
- data type has not been explicitly labeled by the user can often by recovered by seeing how
- the variable is used or by allowing the known data types to propagate.</LI>
-
- <LI><SPAN style="font-weight: bold; font-style: italic;">Can be used to Automatically
- Recover Structure Fields</SPAN>:&nbsp; The decompiler can be leveraged to recover
- references to a structure.<BR>
- </LI>
- </UL>
-
- <H3><A name="Variables"></A>Variables</H3>
-
- <BLOCKQUOTE>
- <P>The decompiler will attempt to combine different locations (stack, memory, register) for
- variables within a function. Data type information for variables is gathered automatically
- from several sources. Any annotated function signatures, both of the function and of any
- sub-functions it calls, provide type information. If the function contains references to
- global memory locations that have a data type applied to them, these will also be used, and
- any local variables of the function can be annotated directly with data types. The user can
- provide data type information to the decompiler by annotating all these sources. The more
- information that can be provided the better the produced C-code will be.</P>
-
- <P>Variables not labeled directly are assigned types by analyzing local type propagation.
- Typically, assigning data types to a few key variables dramatically improves the
- readability of the C-code, as propagation will accurately fill in all the other data types.
- Assigning types in function signatures and to global variables is particularly effective
- because of their effect across multiple functions simultaneously.</P>
-
- <P><IMG alt="" src="../../shared/note.png" border="0">If you have C-header files for an API
- a program is using, there is a prototype C-Code parser than can extract the Data Type
- information from C-Code and create a <A href=
- "help/topics/DataTypeManagerPlugin/data_type_manager_description.htm#Archives"><FONT color=
- "#ff0000">Ghidra Data Type Archive (.gdt)</FONT></A>. The interface is currently fairly
- crude, but it handles most C syntax including macro expansion. The function signatures and
- data types extracted can be applied to the program. Just <A href=
- "help/topics/DataTypeManagerPlugin/data_type_manager_description.htm#Open_File_Data_Type_Archive">open
- the archive</A> in the <I>Data Type Manager</I> window, select the archive, right mouse
- click, and select <B><A href=
- "help/topics/DataTypeManagerPlugin/data_type_manager_window.html#Apply_All">Apply
- Function DataTypes</A></B>. Ghidra currently provides definitions for the majority of
- windows API functions and data types automatically.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Parameter_Variables"></A>Parameter Variables</H3>
-
- <BLOCKQUOTE>
- <P>Specifying data types for function parameters is especially useful. A function that has
- data types defined for its parameters will propagate these types into the variables of any
- calling functions.</P>
-
- <P>C variable argument conventions, or varargs, are are also supported. For instance, if
- the user has identified the standard C library routine <I>printf</I>, the signature can be
- defined to be void printf (char *, ...). Now whenever printf() is called, the decompiler
- will display the correct number of variable arguments.</P>
-
- <P>Function signatures can be applied from a Ghidra data type database. Windows data types
- and standard C library function signatures are included with the standard distribution.
- More definitions will be added in the future.<BR>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Internal_Decompiler_Functions"></A>Internal Decompiler Functions</H3>
-
- <BLOCKQUOTE>
- <P>Occasionally, the decompiler may use one of several internal decompiler functions that
- don't get transformed into more 'C'-like expressions. Use of these can indicate that the
- pcode is incorrect or needs to be "Tuned" to make the decompiler output better. It can also
- mean that the decompiler needs an additional simplification rule to take care of that
- particular situation.<BR>
- </P>
-
- <UL>
- <LI><FONT color="#333399">SUB41(x,c)</FONT> - truncation operation</LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 4 is the size of the input operand (x) in bytes.</LI>
- </UL>
- </DIV>
-
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 1 is the size of the output value in bytes.</LI>
-
- <LI>The x is the thing being truncated</LI>
-
- <LI>The c is the number of least significant bytes being truncated<BR>
- </LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P><FONT color="#009900">SUB42(0xaabbccdd,1) = 0xbbcc</FONT></P>
-
- <P>When "c" is 0, the operation is almost always a cast between integer sizes, where
- the decompiler didn't quite figure it out. Usually the decompiler didn't figure out
- that "x" was an integer type or was forced to assume otherwise.</P>
-
- <P>SUB41(x,0) is usually a cast from "int" to "char".<BR>
- SUB42(x,0) is a cast from "int" to "short" and so on.<BR>
- SUB84(x,4) is probably part of an extended precision multiplication but also turns up
- in other things like division strength reduction.<BR>
- </P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <UL>
- <LI><FONT color="#333399">CONCAT31(x,y)</FONT> - concatenates two operands together into
- a larger size object</LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The "3" is the size of x in bytes.</LI>
-
- <LI>The "1" is the size of y in bytes.</LI>
-
- <LI>The result is the 4-byte concatenation of the bits in "x" with the bits<BR>
- in "y". The "x" forms the most signifigant part of the result, "y" the<BR>
- least.</LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P><FONT color="#009900">CONCAT31(0xaabbcc,0xdd) = 0xaabbccdd<BR>
- </FONT></P>
-
- <P>This usually crops up when a 1-byte sized (char) variable is being stored in a
- 4-byte register. All the basic arithmetic/logical ops on the 4-byte register give the
- correct result for doing the operation on a 1-byte variable; the compiler just has to
- make sure to ignore the 3 most significant bytes of the register. The CONCAT31 is the
- decompiler keeping track of these most significant bytes that the compiler was ignoring
- because it is mistakenly interpreting the register variable as being a 4-byte variable.
- In many cases the decompiler can figure this out, but especially in looping constructs,
- it cannot. This is really a dead code issue. The decompiler currently makes judgements
- about dead code for entire varnodes. A full fix of this problem would require a dead
- code elimination algorithm that could decide if part of a varnode were dead.<BR>
- </P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <UL>
- <LI><FONT color="#333399">ZEXT14(x)</FONT> - zero extension</LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 1 is the size of the operand x</LI>
-
- <LI>The 4 is the size of the output in bytes</LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P>This is almost always a cast from small integer types to big unsigned types.</P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <UL>
- <LI><FONT color="#333399">SEXT14(x)</FONT> - signed extension</LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 1 is the size of the operand x</LI>
-
- <LI>The 4 is the size of the output in bytes</LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P>This is probably a cast from a small signed integer into a big signed integer.</P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <UL>
- <LI><FONT color="#333399">SBORROW4(x,y)</FONT> - true if subtracting the signed numbers
- would cause a borrow</LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 4 is the size of both x and y in bytes</LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P>Returns "true" if there is an arithmetic overflow when subtracting "y" from "x" as
- signed integers. These are generated particularly by signed integer comparisons. There
- are rules in place for recovering the original comparison, but this is a missed one
- special case. These could also conceivably be generated in extended precision
- subtraction.<BR>
- </P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <UL>
- <LI><FONT color="#333399">CARRY4(x,y)</FONT> - true if there would be a carry adding x to
- y</LI>
-
- <LI><FONT color="#333399">SCARRY4(x,y)</FONT> - true if there would be a signed overflow
- adding x to y<BR>
- </LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <DIV style="margin-left: 2em;">
- <UL>
- <LI>The 4 is the size of both x and y in bytes</LI>
- </UL>
- </DIV>
- </LI>
- </UL>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P>Returns "true" if there would be a carry adding x to y.</P>
-
- <P>If these are turning up everywhere in a particular binary, it could be a missed
- simplification that could be easily fixed.<BR>
- </P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <H3><A name="Register_Settings"></A>Register Settings</H3>
-
- <BLOCKQUOTE>
- <P>Occasionally a program will use a register to store a global constant. By using the
- <FONT color="#ff0000">&lt;Set Register&gt;</FONT> function on the right mouse pop-up menu,
- the user can specify this value to the decompiler. The constant will be propagated
- automatically throughout the function, and the resulting code may be greatly
- simplified.</P>
- </BLOCKQUOTE>
-
- <H3><A name="DecompileOptions"></A>Decompiler Options</H3>
-
- <BLOCKQUOTE>
- <P>The following Decompiler Analysis Options are available ( Edit-&gt;Options
- Decompiler/Analysis ):</P>
-
- <UL>
- <LI><SPAN style="font-weight: bold;">Eliminate unreachable code</SPAN> - causes the
- decompiler to eliminate branch paths which it considers unreachable as a result of
- constant propagation.<BR>
- <BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Ignore unimplemented instructions</SPAN> - causes
- the decompiler to ignore instructions whose semantics have been marked as
- unimplemented.&nbsp; Otherwise a <SPAN style=
- "font-style: italic;">halt_unimplemented</SPAN> call will appear in the decompilation for
- such cases.<BR>
- <BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Infer constant pointers</SPAN> - allows the decompiler
- to infer a data type for constants it determines are likely pointers. In the basic heuristic,
- each constant is treated as an address, and if that address starts a known data or function element
- in the program, the constant is assumed to be a pointer.<BR>
- <BR>
- </LI>
-
- <LI><B>Respect read-only flags</B> - causes the decompiler to treat any values in memory
- or blocks of memory marked read-only as constant values. Normally global memory is
- considered public writable, meaning you cannot depend on the initial value at a location.
- Any global value could be changed by another function.&nbsp; For areas of memory that are
- really read-only and never change their statically initialized value, mark the memory
- area as read only in the <I>Memory Manager</I> or specific Data locations as <SPAN style=
- "font-style: italic;">Constant</SPAN> (see Data Mutability below).<BR>
- <BR>
- Typically as part of the import process, memory blocks are marked as read-only if the
- memory block is tagged as such in the imported binary.<BR>
- <BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Simplify predication</SPAN> - causes the decompiler
- to simplify code that employs conditional (predicated) instructions,
- merging <SPAN style="font-style: italic;">if/else</SPAN> blocks of
- code that share the same condition.<BR>
- <BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Simplify extended integer operations</SPAN> - causes
- the decompiler to simplify integer operations, where a single logical value is split into
- high and low pieces that are acted on in multiple stages. The decompiler tries to identify
- these constructions and replaces the multiple stages with a single operation.<BR>
- <BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Use in-place assignment operators</SPAN> - causes the
- decompiler to employ in-place C assignment operators such as += in the decompiled
- syntax.<BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Decompiler Timeout (seconds)</SPAN> - the number
- of seconds to allow the decompiler to run before terminating the decompiler.
-
- Currently this does not affect the UI, which will run indefinitely.
- This setting currently only affects background analysis that uses the decompiler.
- syntax.<BR>
- </LI>
-
- </UL><BR>
- </BLOCKQUOTE>
-
- <H3><A name="Data_Mutability"></A>Data Mutability<BR>
- </H3>
-
- <BLOCKQUOTE>
- <P>Decompiler output can be influenced by the mutability of data locations within
- memory.&nbsp; Supported mutability settings include:<BR>
- </P>
-
- <UL>
- <LI><SPAN style="font-weight: bold;">Read-only/Constant</SPAN> - indicates that a memory
- locations value never changes and the currently stored value can be treated as a
- constant.<BR>
- </LI>
-
- <LI><SPAN style="font-weight: bold;">Volatile</SPAN> - indicates that a memory location's
- value may change asynchronously between reads.&nbsp; Reads and writes to such locations
- are never simplified by the decompiler and are wrapped with specially named function
- calls (e.g., volatile_read, volatile_write).&nbsp; The language definition and compiler
- specification may predefine specific volatile regions of memory and may also override the
- default volatile read/write function names.</LI>
- </UL>
-
- <P>Data mutability may be controlled by the user in one of two ways:<BR>
- </P>
-
- <OL>
- <LI><A href="help/topics/MemoryMapPlugin/Memory_Map.htm">Memory Block Settings</A></LI>
-
- <LI><A href="help/topics/DataPlugin/Data.htm#Data_Settings">Data Settings</A><BR>
- </LI>
- </OL>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <H2>Tips:</H2>
-
- <BLOCKQUOTE>
- <BLOCKQUOTE>
- <P><IMG alt="" src="../../shared/note.png" border="0"> It is important to note that the
- decompiler is only as good as the definition of the the underlying assembly language code.
- Each assembly instruction has an associated PCODE definition that describes what the
- instruction does, essentially an RTL (Register Transfer Language). For example, the
- following MOV instruction which moves a value into an offset onto the stack also has a
- PCODE definition.</P>
-
- <BLOCKQUOTE>
- <P>MOV local_1c[ESP], 0x804aac8</P>
-
- <BLOCKQUOTE>
- <P><FONT color="#008000">temp1</FONT> = INT_ADD 0x4, ESP<BR>
- <FONT color="#008000">temp2</FONT> = COPY 0x804aac8<BR>
- STORE ram(<FONT color="#008000">temp1</FONT>), <FONT color="#008000">temp2</FONT></P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <P>Irregularities in the produced C-code can often be attributed to errors in this
- underlying definition. Such errors can usually be fixed quickly. <FONT color="red">Please
- feedback any problems or issues you find.</FONT></P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <BLOCKQUOTE>
- <UL>
- <LI>A good way to start using the decompiler is by defining the parameters to functions
- that are obviously "char *" string references. This allows the decompiler to discover and
- display any static strings referenced anywhere the function is called.<BR>
- </LI>
-
- <LI style="list-style-type: none; list-style-image: none; list-style-position: outside;">
- <UL>
- <LI>The decompiler can work out references to fields of a data structure and figure out
- array indexing given enough information about data types. Building these data type
- definitions greatly enhances readability of the C-code and is a natural way to
- encapsulate reverse engineering knowledge. If you notice many offset references from a
- base value other than the frame or stack pointer, that value is probably pointing to a
- structure or an array. Notice psParm1 in the code below. There are several different
- references off of it. The parameter can be annotated to point to a structure. The user
- can create a new structure or use one from a Ghidra data type library.</LI>
- </UL>
-
- <BLOCKQUOTE>
- <P>Without knowing the data type, the decompiler produces the following C-code.</P>
-
- <P><IMG alt="" src="images/Structnotapplied.png" border="0"></P>
-
- <P>After applying the appropriate structure, the code becomes:</P>
-
- <P><IMG alt="" src="images/StructApplied.png" border="0"></P>
- </BLOCKQUOTE>
-
- <UL>
- <LI>
- The parameters shown where a function is called may not agree with the
- parameters where the function is defined. This can be caused by several
- things:
-
- <UL>
- <LI>The function takes variable arguments.</LI>
-
- <LI>The parameters are not actually referenced (used) by the function.</LI>
-
- <LI>The decompiler does not see the parameter location being filled.</LI>
- </UL>
-
- <P>Parameters determined from the function definition are more likely to be correct.</P>
- </LI>
- </UL>
- </LI>
- </UL>
- </BLOCKQUOTE>
-
- <H1><A name="Decompiler_Window"></A>Decompiler Window</H1>
-
- <P>To display the decompiler window, position the cursor on a function in the Code Browser,
- then select the <IMG alt="" src="images/decompileFunction.gif" border="0"> icon from the tool
- bar, or the <B>Decompile</B> option from the <B>Window</B> menu in the tool.</P>
-
- <P>Errors from the decompiler process are reported in the status area of the tool and sometimes
- at the end of the C code in the decompiler window.<BR>
- </P>
-
- <H2>Mouse Actions</H2>
-
- <BLOCKQUOTE>
- <UL>
- <LI><B>Double-click</B> - Navigates to the symbol that was clicked.</LI>
-
- <LI><B>Control-double-click</B> - Navigates to the symbol that was clicked, opening the
- results in a new window.</LI>
-
- <LI><B>Control-shift-click</B> - Triggers the Listing in a <A href=
- "help/topics/Snapshots/Snapshots.html">Snapshots</A> view to navigate to the address
- denoted by the symbol that was clicked.</LI>
-
- <LI><B>Middle-mouse</B> - If you press the middle mouse
- button the decompiler will highlight every occurrence of a variable or constant
- under the current cursor location (the button changed in the tool options under
- <B>Browser Field-&gt;Cursor Text Highlight</B>).</LI>
- </UL>
-
- <BLOCKQUOTE>
- <P><IMG alt="" src="../../shared/tip.png" border="0">You can navigate to the target
- of a <code>goto</code> statement by double-clicking its label (you can also double-click
- a brace to navigate to the matching brace).<BR>
- </P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
- <BR>
- <BR>
-
-
- <P>Other actions available in the decompiler are described in the following paragraphs.<BR>
- </P>
-
- <H3 style="margin-left: 40px;"><A name="Copy"></A>Copy/Copy Special...<BR>
- </H3>
-
- <BLOCKQUOTE>
- <P style="margin-left: 40px;">C Code from the decompiler window can be copied and pasted into
- any other system text window. Select the text to copy, and then choose <B>Copy</B> from the
- popup menu.<BR>
- </P>
- </BLOCKQUOTE>
-
- <H3 style="margin-left: 40px;"><A name="Comments"></A>Comments-&gt;Set...<BR>
- </H3>
-
- <P style="margin-left: 80px;">Set a comment on a line of C-Code.&nbsp; The comment will be
- stored in the program database at the closest assembly line associated with the generated
- C-Code.&nbsp; Any type of comment (EOL, Post, Pre, Plate) can be attached to the representative
- C-Code.&nbsp; When this function is re-displayed at some later point, the comment will
- persist.<BR>
- </P>
-
- <H3 style="margin-left: 40px;"><A name="Commit_Params_Return"></A>Commit Params/Return<BR>
- </H3>
-
- <P style="margin-left: 80px;">By default, the decompiler will analyze the code to try to
- discover function parameters, return type, and local variables. Each time the decompiler
- displays C-code for a function it does this analysis again. <SPAN style=
- "font-weight: bold;">Commit Params/Return</SPAN> causes any parameter names and types and
- return type to be saved in the program database so that next time the function is decompiled
- the current definitions will be used. This is useful for "syncing" the function signature with
- the disassembly display. This causes the names and types of parameters and returns in the
- disassembly to agree with the decompiler names and types.</P>
-
- <P style="margin-left: 80px;">Ghidra will do stack analysis that will recover parameters and
- return types, but for many programs, the analysis the decompiler does is better.</P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0">The
- Decompiler Parameter ID analyzer automatically pulls in the decompiler derived
- information and applies it to each function as the function is created.</P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0"> If a variable
- displayed in the assembly window has an undefined type, the decompiler will still respect the
- name of the variable.<BR>
- </P>
-
- <H3 style="margin-left: 40px;"><A name="Commit_Locals"></A>Commit Locals<BR>
- </H3>
-
- <P style="margin-left: 80px;">By default, the decompiler will analyze the code to try to
- discover function parameters, return type, and local variables. Each time the decompiler
- displays C-code for a function it does this analysis again. <SPAN style=
- "font-weight: bold;">Commit Locals</SPAN> causes any local variable names and types to be saved
- in the program database so that next time the function is decompiled the current local variable
- definitions will be used. This is useful for "syncing" the local variable definitions with the
- disassembly display. This causes the names and types of locals in the disassembly to agree with
- the decompiler names and types.</P>
-
- <P style="margin-left: 80px;">Ghidra will do stack analysis that will recover local variables
- on the stack, but for many programs, the analysis the decompiler does is better.<BR>
- </P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0">
- The Decompiler Parameter ID analyzer automatically pulls in the decompiler derived
- information and applies it to each function as the function is created. The analyzer by default
- will not commit local variable definitions, either stack or register locals.
- Committing locals automatically
- can be turned on by changing the Decompiler Parameter ID analysis options.
- In most cases it is better to commit locals only for certain functions that you really care
- about, or after the data type definitions (structures, etc...) have settled down for the
- program you are Reverse Engineering.<BR>
- </P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0"> If a variable
- displayed in the assembly window has an undefined type, the decompiler will still respect the
- name of the variable.<BR>
- </P>
-
- <H3 style="margin-left: 40px;"><A name="Recover_Structure_Variable"></A>Auto Create Structure /
- Auto Fill in Structure<BR>
- </H3>
-
- <P style="margin-left: 80px;">Automatically creates a structure definition for the pointed to
- structure, and fills it out based on the references found by the decompiler.</P>
-
- <P style="margin-left: 80px;">To use this, place the cursor on a function parameter variable,
- or any variable within a function that is a pointer to a structure.&nbsp; It could currently
- have a data type of undefined, int, void *, char *, etc...&nbsp; For example:&nbsp; func(int
- *this), (for a C++ this call function).</P>
-
- <P style="margin-left: 80px;">If the variable is already a structure pointer, any new
- references found will be added to the structure, even if the structure must grow in size.&nbsp;
- This is very useful as you find more places the structure is used.&nbsp; If you have already
- started recovering a portion of a structure and find it used in another function.&nbsp; Retype
- the variable to be the structure, and then use <SPAN style="font-weight: bold;">Auto Fill in
- Structure</SPAN> to add any new fields recovered for the structure.<BR>
- </P>
-
- <P style="margin-left: 80px;">This feature is also available in the assembly listing when the
- cursor is placed on a defined parameter or return variable.<BR>
- </P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0">Currently this
- only recovers the structure by following the structure pointer through the current function and
- any function the structure is passed into within the current function.&nbsp; Eventually this
- will be put into a global type analyzer, but for now it is most useful interactively.<BR>
- </P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0">For best
- results, the function should be well formed with good flow, and all the switch statements
- should be recoverable.</P>
-
- <P style="margin-left: 80px;"><IMG alt="" src="../../shared/note.png" border="0">There is also
- a script called <SPAN style="font-weight: bold;">CreateStructure</SPAN> that you can use for
- automated structure recovery.&nbsp; For instance if you have a set of ThisCall routines where
- the first parameter to all the routines is a pointer to a shared class structure, the script
- could be modified to recover the structure for each this parameter.</P>
-
- <BLOCKQUOTE>
- <H3><A name="Highlight_Defined_Use"></A>Highlight Def-Use</H3>
-
- <BLOCKQUOTE>
- <P>Highlights all places a value is used, starting at the place it is first written, and
- including all the places where that one value is read. This is usually a proper subset of
- all the places a variable appears in the function Place the cursor over a variable you
- would like to highlight and select Highlight Def-Use from the pop-up menu.</P>
-
- <P>As an example the <I>a</I> at the top of the function is under the cursor when Highlight
- Def-Use is chosen.</P>
-
- <CENTER>
- <P><IMG alt="" src="images/Defuse.png" border="0"></P>
- </CENTER>
-
- <P>Notice that the first three references to <I>a</I> are highlighted but the final use of
- <I>a</I> is not because the value might have changed in the <I>else</I> clause.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Highlight_Forward_Slice"></A>Highlight Forward Slice</H3>
-
- <BLOCKQUOTE>
- <P>Highlight Forward Slice highlights each variable whose value may be affected by the
- value in the variable under the cursor.</P>
-
- <P>As an example, <I>b</I>, the output of <I>max_alpha</I>, is under the cursor when
- Highlight Forward Slice is chosen.</P>
-
- <CENTER>
- <P><IMG alt="" src="images/ForwardSlice.png" border="0"></P>
- </CENTER>
-
- <P>We can see that <I>c</I> is tainted by the value of <I>b</I> all the way through to the
- bottom of the function.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Highlight_Backward_Slice"></A>Highlight Backward Slice</H3>
-
- <BLOCKQUOTE>
- <P>Highlight Backward Slice highlights all points in the function that contain a value
- involved in the creation of the value in the variable under the cursor.</P>
-
- <P>As an example the final <I>a</I> of the function is under the cursor when Highlight
- Backward Slice is chosen.</P>
-
- <CENTER>
- <P><IMG alt="" src="images/BackwardSlice.png" border="0"></P>
- </CENTER>
-
- <P>We can see that the final value of <I>a</I> is affected by the loop and by the input
- parameter but never by <I>b</I> and <I>c</I>.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Highlight_Forward_Inst_Slice"></A>Highlight Forward Instruction Slice</H3>
-
- <BLOCKQUOTE>
- <P>Highlight Forward Inst Slice highlights each instruction whose value may be affected by
- the value in the variable under the cursor, rather than the values themselves.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Highlight_Backward_Inst_Slice"></A>Highlight Backward Instruction Slice</H3>
-
- <BLOCKQUOTE>
- <P>Highlight Backward Inst Slice highlights all instructions in the function that
- contribute to the creation of the value in the variable under the cursor.</P>
- </BLOCKQUOTE>
-
- <BR>
- <BR>
- <BR>
- <!-- Secondary Highlights -->
- <BLOCKQUOTE>
-
- <H2>Secondary Highlights</H2>
- <BLOCKQUOTE>
- <P>
- Secondary highlights are highlights that you can apply to text that will
- stay until you remove them (this is in contrast to normal highlights, which go
- away whenever you click in the Decompiler). Further, each secondary highlight will get a
- different color (chosen randomly or by the user). The Decompiler will remember
- the color previously used for a particular highlighted piece of text <b>for a
- given Ghidra session</b>. Use the actions listed below to add and remove
- secondary highlights.
- </P>
-
- <H3><A name="Set_Secondary_Highlight"></A>Set Secondary Highlight</H3>
-
- <BLOCKQUOTE>
- <P>
- Use this action to apply a secondary highlight to all text matching the text of the
- token under the cursor. This action will reuse the previously applied color for
- that text or choose a new color randomly. This action is accessible from the
- context menu via
- <b>Secondary Highlight<img border="0" src="../../shared/arrow.gif">Set Highlight</b>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Set_Secondary_Highlight_With_Color"></A>Set Secondary Highlight With Color</H3>
-
- <BLOCKQUOTE>
- <P>
- Use this action to apply a secondary highlight to all text matching the text of the
- token under the cursor. This action will show a Color Chooser dialog initialized with
- the previously applied color for
- that text or choose a new color randomly. This action is accessible from the
- context menu via
- <b>Secondary Highlight<img border="0" src="../../shared/arrow.gif">Set Highlight...</b>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Remove_Secondary_Highlight"></A>Remove Secondary Highlight</H3>
-
- <BLOCKQUOTE>
- <P>
- Use this action to remove an existing secondary highlight under the cursor.
- This action is accessible from the context menu via
- <b>Secondary Highlight<img border="0" src="../../shared/arrow.gif">Remove Highlight</b>
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Remove_All_Secondary_Highlights"></A>Remove All Secondary Highlights</H3>
-
- <BLOCKQUOTE>
- <P>
- Use this action to remove all existing secondary highlights.
- This action is accessible from the context menu via
- <b>Secondary Highlight<img border="0" src="../../shared/arrow.gif">Remove All Highlights</b>
- </P>
- </BLOCKQUOTE>
-
-
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <!-- End Secondary Highlights -->
- <BR>
- <BR>
- <BR>
-
-
- <H3><A name="Rename_Field"></A>Rename Field</H3>
-
- <BLOCKQUOTE>
- <P>
- Action triggered from a specific token in the decompiler window to rename a field within
- a structure data type. If the field already exists within the specific structure, it is
- simply renamed. Otherwise, if the decompiler has discovered an undefined structure offset, a new
- field is added to the structure with this offset and the user selected name. In either case,
- the altered structure is committed permanently to the program's database.
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Rename_Variable"></A>Rename Variable</H3>
-
- <BLOCKQUOTE>
- <P>Any parameter or local variable can be renamed. Just place the
- cursor over a variable definition, or any use of the variable and choose <B>Rename
- Variable</B> from the popup menu. The name will now be saved for this function, so the next
- time the decompiler displays the code for the function, the same name is used.</P>
- <P>
- If a matching variable in the database already exists, it is simply renamed. Otherwise
- a new variable is added to the database. In this case the new variable is assigned
- an "undefined" datatype, which leaves it un-typelocked, and the decompiler will take
- the name but lets the data type continue to "float" and can speculatively merge the
- variable with others.
- </P>
- <P>
- If the selected variable is an input parameter, other input parameters within the decompiler
- model will need to be committed, if they do not already exist in the database, as any parameters
- committed to the database are forcing on the decompiler. Any new parameters committed this way
- inherit their name from the decompiler model, but the parameters will not be type-locked, allowing
- their data type to "float".
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Rename_Global"></A>Rename Global</H3>
-
- <BLOCKQUOTE>
- <P>
- Action triggered from a specific token in the decompiler window to rename a global variable.
- The variable is associated with an address. There may already be a symbol in the database
- there, in which case the symbol is simply renamed. Otherwise a new symbol is added.
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Rename_Function"></A>Rename Function</H3>
-
- <BLOCKQUOTE>
- <P>A shortcut for renaming the function from within the decompiler window.</P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Retype_Field"></A>Retype Field</H3>
-
- <BLOCKQUOTE>
- <P>
- Changes the data type of the selected field within a structure data type. The field must
- already exist, except in the case of a completely undefined structure. The data type of the
- field is changed according to the user selection. If the size of the selected data type
- is bigger, this can trigger other fields in the structure to be removed and may change
- the size of the structure. The modified data type is permanently committed to the
- program's database.
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Retype_Variable"></A>Retype Variable</H3>
-
- <BLOCKQUOTE>
- <P>The decompiler does its best to recover the type of a variable automatically but often
- only has limited information for analysis. Explicitly changing the type of a variable can
- dramatically improve the C-code produced. This is especially true for structures. Changing
- the type of a parameter variable will affect the display for every place the function is
- called.</P>
-
- <P>To change a variable's data type; place the cursor over the variable definition or use of
- the variable, select <B>Retype Variable</B> from the popup menu, and then enter the name of
- the type. The name of any data type known to the program can be used.</P>
-
- <P>A simple code improvement is to locate any functions with obvious string parameters and
- re-type the parameter to be a "char *". Any references to defined memory will now display
- the passed parameter as a character "string".</P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Retype_Return"></A>Retype Return</H3>
-
- <BLOCKQUOTE>
- <P>
- Action triggered from a specific token in the decompiler window to change the return type of
- the function. The user selected data type is permanently set as the return type. As the
- return type is part of the function prototype and is forcing on the decompiler,
- this action may trigger input parameters to be committed to the database as well. This situation
- currently triggers a confirmation dialog. If new input parameters need to be committed, their
- name and data-type are taken from the decompiler model.
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Retype_Global"></A>Retype Global</H3>
-
- <BLOCKQUOTE>
- <P>
- Action triggered from a specific token in the decompiler window to change the data type
- associated with a global variable. If the variable does not already exist in the program
- database, it will be created using storage address the decompiler has assigned to the
- variable within its model. In either case, there is a preexisting notion of variable
- storage. This action may allow the newly selected data type to be of a different size
- relative to this preexisting storage, constrained by other global variables that might
- already consume storage.
- </P>
- </BLOCKQUOTE>
-
-
- <H3><A name="Edit_Data_Type"></A>Edit Data Type of Variable<BR>
- </H3>
-
- <BLOCKQUOTE>
- <P>Only structure, union, and enum data types can be edited. If a variable's data type is
- one of these it can be edited. Also, if the data type is a type definition, array, or
- pointer based on an editable data type, then the base data type can be edited. For example,
- if you have a structure pointer for a variable then you can edit the structure. To edit a
- variable's data type; place the cursor over the variable definition or use of the variable
- and select <B>Edit Data Type...</B> from the popup menu. For structures and unions, the <A
- href="help/topics/DataTypeEditors/StructureEditor.htm"><FONT color="#0000ff">structure
- editor</FONT></A> will appear, and for enums the <A href=
- "help/topics/DataTypeEditors/EnumEditor.htm">enum editor</A> will appear. If the data type
- for a variable can't be edited, the action will be disabled in the popup.&nbsp;</P>
- </BLOCKQUOTE>
-
- <H3><A name="Edit_Function_Signature"></A>Edit Function Signature</H3>
-
- <BLOCKQUOTE>
- <P>The <B>Edit Function Signature</B> dialog allows you to change the function's signature,
- the calling convention, whether the function is inline and whether the function has no
- return.<BR>
- <BR>
- </P>
-
- <DIV align="center">
- <IMG src="images/EditFunctionSignature.png" alt=""><BR>
- </DIV>
-
- <P>The function signature includes</P>
-
- <UL>
- <LI>function name</LI>
-
- <LI>return type</LI>
-
- <LI>number of parameters</LI>
-
- <LI>parameter names</LI>
-
- <LI>parameter type</LI>
-
- <LI>varargs (variable arguments)</LI>
- </UL>
-
- <P>This features allows you to edit a function signature text string to change any of
- these.<BR>
- For example if a function is actually printf(), instead of changing the name, return type,
- and parameters individually, the entire function signature can be changed all at once. To
- do this you could enter<BR>
- &nbsp;&nbsp;&nbsp; <I>void printf( char *fmt, ...)</I><BR>
- within the <B>Signature</B> field and then select the OK button.<BR>
- </P>
-
- <P>In addition, you can select the <B>Calling Convention</B> for this function from a list
- of available calling conventions as determined by the program's language. Selecting the
- <B>Inline</B> checkbox indicates that the function is in-lined. Selecting the <B>No
- Return</B> checkbox indicates that the function does not return.<BR>
- </P>
-
- <P><IMG src="../../shared/note.png" alt="">The signature of the current function, or any
- called function can be changed.</P>
-
- <P>To edit a function's signature from the <B>Decompile</B> window. Just place the cursor
- over any function name, select <B>Edit Function Signature</B> from the popup menu, and the
- dialog will appear with the function's current information.<BR>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Override_Signature"></A>Override Signature</H3>
-
- <BLOCKQUOTE>
- <P>Overrides the signature of a called function at the point it is called. This allows you
- to set the parameter values for a particular call.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Remove_Signature_Override"></A>Remove Signature Override</H3>
-
- <BLOCKQUOTE>
- <P>This action allows you to remove a previously added function signature override.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Split_Out_As_New_Variable"></A>Split Out As High Variable</H3>
-
- <BLOCKQUOTE>
- <P>Create multiple variables from the selected variable. If a
- <CODE>HighVariable</CODE> consists of
- more than one (forced) merge group, split out the group
- that contains <CODE>varnode</CODE> as a separate <CODE>HighVariable</CODE>. </P>
- </BLOCKQUOTE>
-
- <H3><A name="Find"></A>Find...</H3>
-
- <BLOCKQUOTE>
- <P>Find any string of text within the currently decompiled function.<BR>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Debug_Function_Decompilation"></A>Debug Function Decompilation</H3>
-
- <BLOCKQUOTE>
- <P>For certain functions, the decompiler may produce an error message, produce incorrect
- code, or simply exit without producing results. Selecting <B><IMG alt="\/" src=
- "../../shared/menu16.gif"> Debug Function Decompilation</B>, from the decompiler provider
- window toolbar, will run the decompiler again, and save all relevant information to an XML
- file. Instead of submitting the entire program to be analyzed to discover the problem, only
- a small XML file is needed.<BR>
- </P>
- </BLOCKQUOTE>
-
- <H3><A name="Graph_AST_Control_Flow"></A>Graph AST Control Flow</H3>
-
- <BLOCKQUOTE>
- <P>Selecting <B><IMG alt="" src="../../shared/menu16.gif">Graph AST Control Flow</B>,
- from the decompiler provider window toolbar, will generate an abstract syntax tree (AST)
- control flow graph based upon the decompiler results and render the graph within the
- current Graph Service.</P>
-
- <BLOCKQUOTE>
- <P><IMG alt="" src="../../shared/note.yellow.png" border="0">If no Graph Service is
- available then this action will not be present.
- </P>
- </BLOCKQUOTE>
-
- </BLOCKQUOTE>
-
- <H3><A name="Export_to_C"></A>Export to C <IMG alt="" src="images/page_edit.png" border=
- "0"></H3>
-
- <BLOCKQUOTE>
- <P>You can export the current decompiled function to a file by selecting the <IMG alt=""
- src="images/page_edit.png" border="0"> icon in the local tool bar of the decompiler window.
- A file chooser dialog is displayed for you to select the name of the output file. If you do
- not specify a file extension, ".c" is appended to the filename.</P>
- </BLOCKQUOTE>
-
- <H3><A name="Snapshot"></A>Snapshot <IMG alt="" src="images/camera-photo.png" border=
- "0"></H3>
-
- <BLOCKQUOTE>
- <P>Creates a <A href="help/topics/Snapshots/Snapshots.html">Snapshot</A> of the current
- decompiler window, which allows you to leave the current decompiled function in place while
- navigating to other functions.</P>
- </BLOCKQUOTE>
-
- <H3><A name="DecompilerProperties"></A>Properties</H3>
-
- <BLOCKQUOTE>
- <P>The colors used in the decompiler window can be changed by editing the C Display Options
- through the <I>Edit Options</I> dialog. To edit the options, choose <B>Edit</B><IMG alt=""
- src="../../shared/arrow.gif" border="0"> <B>Tool Options...</B> from the tool menu. Click
- on the <I>C Display node</I> in the Options tree. A panel shows the colors that can be
- customized. Click on the color bar to bring up the color chooser to change the color.</P>
-
- <P>The other options allow you to change the maximum characters in a line displayed in the
- decompiler window, and the number of characters for indenting in the code.</P>
- </BLOCKQUOTE>
- </BLOCKQUOTE>
-
- <H2>Mouse Hovers</H2>
-
- <BLOCKQUOTE>
- <P>These function similarly to <A href=
- "help/topics/CodeBrowserPlugin/CodeBrowser.htm#MouseHover">Code Browser Mouse Hovers</A></P>
- </BLOCKQUOTE>
-
- <P class="providedbyplugin">Provided by: <I>Decompiler Plugin</I></P>
-
- <P class="relatedtopic">Related Topics:</P>
-
- <UL>
- <LI><A href="help/topics/CodeBrowserPlugin/CodeBrowser.htm">Code Browser</A></LI>
-
- <LI><A href="help/topics/Snapshots/Snapshots.html">Snapshots</A></LI>
- </UL>
- </BODY>
-</HTML>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.html
new file mode 100644
index 0000000000..e4ca3b09aa
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/Decompiler.html
@@ -0,0 +1,59 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Decompiler</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="next" href="DecompilerIntro.html" title="Decompiler">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Decompiler</th></tr>
+<tr>
+<td width="20%" align="left">�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�<a accesskey="n" href="DecompilerIntro.html">Next</a>
+</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="book">
+<div class="titlepage">
+<div><div><h1 class="title">
+<a name="idm140185515313584"></a>Decompiler</h1></div></div>
+<hr>
+</div>
+
+
+
+
+
+
+
+
+
+
+
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�<a accesskey="n" href="DecompilerIntro.html">Next</a>
+</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right" valign="top">�Decompiler</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerAnnotations.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerAnnotations.html
new file mode 100644
index 0000000000..4f613be70c
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerAnnotations.html
@@ -0,0 +1,1290 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Program Annotations Affecting the Decompiler</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="up" href="Decompiler.html" title="Decompiler">
+<link rel="prev" href="DecompilerConcepts.html" title="Decompiler Concepts">
+<link rel="next" href="DecompilerOptions.html" title="Decompiler Options">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Program Annotations Affecting the Decompiler</th></tr>
+<tr>
+<td width="20%" align="left">
+<a accesskey="p" href="DecompilerConcepts.html">Prev</a>�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�<a accesskey="n" href="DecompilerOptions.html">Next</a>
+</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="DecompilerAnnotations"></a>Program Annotations Affecting the Decompiler</h1></div></div></div>
+
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteFunctionBody"></a>Machine Instructions</h2></div></div></div>
+
+ <p>
+ Individual <span class="bold"><strong>machine instructions</strong></span>
+ make up the biggest source of information when the
+ decompiler analyzes a function. Instructions are translated from their
+ processor specific form into Ghidra's IR language (see <a class="xref" href="DecompilerConcepts.html#ConceptPcode" title="P-code">&#8220;P-code&#8221;</a>),
+ which provides both the control-flow behavior of the instruction and the detailed
+ semantics describing how the processor and memory state is affected. The translation is controlled by
+ the underlying processor model and cannot be directly altered from the tool. Users
+ <span class="emphasis"><em>can</em></span> modify the model specification itself, however.
+ See the document "SLEIGH: A Language for Rapid Processor Specification".
+ </p>
+ <p>
+ Decompiling a function starts by analyzing control-flow starting from the function's
+ first instruction. Control-flow is traced to additional instructions using flow information
+ from the underlying processor model. All paths are traced through instructions with
+ <span class="emphasis"><em>fall through</em></span>, <span class="emphasis"><em>conditional jump</em></span>, and other
+ semantics until an instruction with <span class="emphasis"><em>terminator</em></span> semantics is
+ reached, which is usually a "return from subroutine"
+ instruction. Flow is not traced into subfunctions, in this situation. Instructions
+ with <span class="emphasis"><em>call</em></span> semantics are treated only as if they fall through.
+ </p>
+ <p>
+ An <span class="bold"><strong>entry point</strong></span> is the address of the function's first instruction.
+ </p>
+ <p>
+ A <span class="bold"><strong>function body</strong></span> is the set of addresses reached by control-flow
+ analysis (and the machine instructions at those addresses).
+ </p>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptEntryPoint"></a>Entry Point</h3></div></div></div>
+
+ <p>
+ The <span class="emphasis"><em>entry point</em></span> address for a function plays a pivotal role for
+ analysis using the Ghidra decompiler. Ghidra generally associates
+ a formal <span class="emphasis"><em>Function Symbol</em></span> and an underlying
+ <span class="emphasis"><em>Function</em></span> object at this address, which are the key elements that
+ need to be present to trigger decompilation.
+ (See <a class="ulink" href="help/topics/FunctionPlugin/Functions.htm" target="_top">Functions</a>)
+ The Function object stores the function body, parameters, local variables, and
+ other information critical to the decompilation process.
+ </p>
+ <p>
+ Function Symbols and Function objects are generally created automatically by a Ghidra
+ analyzer when initially importing a binary executable and running auto-analysis.
+ If necessary however, a user can manually create a Function object from the Listing window
+ by using <span class="emphasis"><em>Create Function</em></span> command (pressing the 'f' key), when the cursor
+ is placed on the function's entry point.
+ (See <a class="ulink" href="help/topics/FunctionPlugin/Functions.htm#Create_Function" target="_top">Create Function</a>)
+ </p>
+ </div>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptFunctionBody"></a>Formal Function Body</h3></div></div></div>
+
+ <p>
+ When a function is created, Ghidra stores its function body as a set of addresses in the
+ Program database. This <span class="emphasis"><em>formal</em></span> function body delineates the function
+ from all the other kinds of data within the Program and lets Ghidra immediately link addresses
+ in the middle of the function to the entry point and the Function object. Decompiler windows
+ in particular use the formal function body to know which function to decompile in response
+ to a navigation event to an arbitrary address.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ The decompiler does <span class="emphasis"><em>not</em></span> use the formal function body when it computes
+ control-flow; it recomputes its own idea of the function body starting from the entry point
+ it is handed. If the formal function body was created manually, using a selection for instance,
+ or in other extreme circumstances, the decompiler's view of the function body may not match
+ the formal view. This can lead to confusing behavior, where clicking in a decompiler window
+ may unexpectedly navigate the window away from the function.
+ </td></tr>
+</table></div>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptFlowOverride"></a>Flow Overrides</h3></div></div></div>
+
+ <p>
+ Control-flow behavior for machine instructions is generally determined by the underlying
+ Processor model. But this flow can be overridden for individual instructions by various
+ Analyzers or manually by the user. The decompiler incorporates these overrides into its
+ analysis, and they can have a significant impact on results. Current
+ <span class="emphasis"><em>flow overrides</em></span> include:
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>BRANCH Override</strong></span></span></dt>
+<dd>
+ <p>
+ Treats the primary <span class="emphasis"><em>CALL</em></span> or <span class="emphasis"><em>RETURN</em></span>
+ behavior of the instruction as if it were a <span class="emphasis"><em>BRANCH</em></span>
+ within the function. For <span class="emphasis"><em>CALL</em></span> instructions,
+ the call target becomes the branch destination,
+ and the instruction is no longer assumed
+ to fall through. <span class="emphasis"><em>RETURN</em></span> instructions become an
+ indirect branch, and the decompiler will attempt to recover branch
+ destinations using <span class="emphasis"><em>switch</em></span> analysis.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>CALL Override</strong></span></span></dt>
+<dd>
+ <p>
+ Treats the primary <span class="emphasis"><em>BRANCH</em></span> or <span class="emphasis"><em>RETURN</em></span>
+ behavior of the instruction as if it were a <span class="emphasis"><em>CALL</em></span>.
+ A <span class="emphasis"><em>BRANCH</em></span> becomes a fall through instruction, and the destination address becomes
+ the call target, which may no longer be considered part of the function. The computed
+ address for an indirect <span class="emphasis"><em>BRANCH</em></span> or <span class="emphasis"><em>RETURN</em></span> instruction becomes
+ the target address of an indirect <span class="emphasis"><em>CALL</em></span>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>CALL_RETURN Override</strong></span></span></dt>
+<dd>
+ <p>
+ Treats the primary <span class="emphasis"><em>BRANCH</em></span> or <span class="emphasis"><em>RETURN</em></span>
+ behavior of the instruction as if it executed a <span class="emphasis"><em>CALL</em></span> followed
+ by a <span class="emphasis"><em>RETURN</em></span> operation.
+ The destination address of a <span class="emphasis"><em>BRANCH</em></span> becomes the call target,
+ which may no longer be considered part of the function. The computed address for
+ an indirect <span class="emphasis"><em>BRANCH</em></span> or <span class="emphasis"><em>RETURN</em></span> instruction becomes
+ the target address of an indirect <span class="emphasis"><em>CALL</em></span>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>RETURN Override</strong></span></span></dt>
+<dd>
+ <p>
+ Treats an indirect <span class="emphasis"><em>BRANCH</em></span> or <span class="emphasis"><em>CALL</em></span>
+ instruction as if it were a <span class="emphasis"><em>RETURN</em></span> instruction, terminating
+ the control-flow path within the function. The computed destination address is
+ considered part of the return mechanism of the function and may no longer be
+ explicitly displayed in the output.
+ An indirect <span class="emphasis"><em>BRANCH</em></span> no longer invokes switch analysis during
+ decompilation.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteComments"></a>Comments</h2></div></div></div>
+
+ <p>
+ The decompiler automatically incorporates comments from the Program database into its
+ output. Comments in Ghidra are centralized and can be created and displayed by multiple
+ Program views, including the decompiler. Comments created from a decompiler window will
+ show up in the Listing window for instance, and vice versa.
+ </p>
+ <p>
+ For the purposes of understanding comments within the decompiler, keep in mind that:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ An individual comment is associated with a specific <span class="emphasis"><em>address</em></span> in the Program.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ There are 5 different kinds of comments.
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
+<li class="listitem" style="list-style-type: circle">
+ <span class="emphasis"><em>Plate</em></span>
+ </li>
+<li class="listitem" style="list-style-type: circle">
+ <span class="emphasis"><em>Pre</em></span>
+ </li>
+<li class="listitem" style="list-style-type: circle">
+ <span class="emphasis"><em>Post</em></span>
+ </li>
+<li class="listitem" style="list-style-type: circle">
+ <span class="emphasis"><em>End-of-line (EOL)</em></span>
+ </li>
+<li class="listitem" style="list-style-type: circle">
+ <span class="emphasis"><em>Repeatable</em></span>
+ </li>
+</ul></div>
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ For general documentation on creating and editing comments within Ghidra, see
+ <a class="ulink" href="help/topics/CommentsPlugin/Comments.htm" target="_top">Comments</a>.
+ </p>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="CommentDisplay"></a>Display</h3></div></div></div>
+
+ <p>
+ The decompiler collects and displays comments associated with any address in the
+ formal <span class="emphasis"><em>function body</em></span> currently decompiling.
+ The comments are integrated line by line into the decompiled code, and an
+ individual comment is displayed on the line <span class="emphasis"><em>before</em></span> the
+ line of code incorporating the instruction associated with the comment's
+ address.
+ </p>
+ <p>
+ Because a single line of code typically encompasses multiple machine instructions,
+ there is a possibility that multiple comments at different addresses apply to
+ the same line. In this case, the decompiler displays each comment on its
+ own line, in address order, directly before the line of code.
+ </p>
+ <p>
+ Because the output of the decompiler can be a heavily transformed version compared
+ to the original machine instructions, its possible that individual instructions
+ no longer have explicit tokens representing them in the output. Comments attached
+ to these instruction will still be displayed in the decompiler output with the
+ closest associated line of code, usually within the same basic block.
+ </p>
+ <p>
+ By default, the decompiler displays only the <span class="emphasis"><em>Pre</em></span> comments
+ within the body of the function. It also displays <span class="emphasis"><em>Plate</em></span>
+ comments, but only if they are attached to the <span class="emphasis"><em>entry point</em></span>
+ of the function. In this case, they are displayed first in the decompiler output,
+ along with WARNING comments, before the function declaration. Other comment
+ types can be configured to display in decompiler output, by changing the
+ decompiler Display options (See <a class="xref" href="DecompilerOptions.html#CommentOptions"><span class="bold"><strong>Display &lt;kind-of&gt; Comments</strong></span></a>).
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ Unlike the Listing window, the decompiler does not alter how a comment is
+ displayed based on its type.
+ All enabled types of comment are displayed in the same way, on
+ a separate line before the line of code associated with the address.
+ </td></tr>
+</table></div>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="CommentUnreachable"></a>Unreachable Blocks</h3></div></div></div>
+
+ <p>
+ The decompiler may decide as part of its analysis that individual
+ <span class="emphasis"><em>basic blocks</em></span> are unreachable and not display them in the output.
+ In this case, any comments associated with addresses in the unreachable block
+ will also not be displayed.
+ </p>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="CommentWarnings"></a>Warning Comments</h3></div></div></div>
+
+ <p>
+ The decompiler can generate internal warnings during its analysis and will incorporate
+ them into the output as comments in the same way as the user defined
+ comments described above. They are not part of Ghidra's comment system however and
+ cannot be edited. They can be distinguished from normal comments by the word
+ 'WARNING' at the beginning of the comment.
+ </p>
+<div class="informalexample">
+ <code class="code">/* WARNING: ... */</code>
+ </div>
+<p>
+ </p>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteVariables"></a>Variable Annotations</h2></div></div></div>
+
+ <p>
+ Variable annotations are the most important way to get names and data-types
+ that are meaningful to the user incorporated into the decompiler's output.
+ A <span class="bold"><strong>variable</strong></span> in this context is loosely defined
+ as any piece of memory that code in the Program treats as a logical entity.
+ The decompiler works to incorporate all forms of annotation into its output
+ for any variable pertinent to the function being analyzed.
+ </p>
+ <p>
+ At a minimum, a variable annotation in Ghidra provides a:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Symbol name</strong></span>,
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Data-type</strong></span>, and
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Storage location</strong></span>.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="VariableCreate"></a>Creating Variable Annotations</h3></div></div></div>
+
+ <p>
+ Ghidra provides various ways that a name and other attributes can be ascribed
+ to a variable. These break up roughly into <span class="emphasis"><em>global</em></span> variables,
+ defined directly on memory in the Program image, and variables that are
+ <span class="emphasis"><em>local</em></span> to a function.
+ </p>
+ <p>
+ Global variables annotations are created from the tool by applying a data-type to a memory
+ location in the Listing window, either by invoking a command from the <span class="emphasis"><em>Data</em></span>
+ pop-up menu, or dragging a data-type from the <span class="emphasis"><em>Data Type Manager</em></span>
+ window directly onto the memory location. Refer to the documentation:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; "><li class="listitem" style="list-style-type: none">
+ <a class="ulink" href="help/topics/DataPlugin/Data.htm#ApplyDataType" target="_top">Applying Data Type</a>
+ </li></ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ Local variables annotations are created from the Listing from various editor dialogs. See in particular:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <a class="ulink" href="help/topics/FunctionPlugin/Variables.htm#Edit_Function" target="_top">Function Signature Dialog</a>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <a class="ulink" href="help/topics/StackEditor/StackEditor.html" target="_top">Stack Frame Editor</a>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <a class="ulink" href="help/topics/ReferencesPlugin/References_from.htm#Create_Default_Reference" target="_top">Creating a Default Reference</a>
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The <span class="emphasis"><em>Decompiler</em></span> window also provides numerous ways of annotating variables, both local and global. In particular,
+ see the commands:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <a class="xref" href="DecompilerWindow.html#ActionRenameVariable" title="Rename Variable">&#8220;Rename Variable&#8221;</a>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <a class="xref" href="DecompilerWindow.html#ActionRetypeVariable" title="Retype Variable">&#8220;Retype Variable&#8221;</a>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <a class="xref" href="DecompilerWindow.html#ActionCommitParams" title="Commit Params/Return">&#8220;Commit Params/Return&#8221;</a>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <a class="xref" href="DecompilerWindow.html#ActionCommitLocals" title="Commit Local Names">&#8220;Commit Local Names&#8221;</a>
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="VariableSymbol"></a>Variable Symbols</h3></div></div></div>
+
+ <p>
+ Ghidra maintains its own symbol table that supports namespaces and function
+ scopes, and variable names are automatically incorporated into this.
+ In order to widely accommodate different use cases, Ghidra's symbol
+ table has extremely lax naming rules. Ghidra
+ may allow names that conflict with the stricter rules of the language
+ the decompiler is attempting to produce. The decompiler does not currently
+ have an option that checks for this. Users should be aware of:
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term">Illegal Characters</span></dt>
+<dd>
+ <p>
+ Ghidra symbols allow almost every printable character except
+ a space in a symbol name; punctuation and keywords can be incorporated.
+ </p>
+ </dd>
+<dt><span class="term">Duplicate Symbols</span></dt>
+<dd>
+ <p>
+ Ghidra allows duplicate symbols, including duplicate function names, in
+ any scope higher than a function.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="SymbolScope"></a>Variable Scope</h4></div></div></div>
+
+ <p>
+ All variables belong either to a <span class="emphasis"><em>global</em></span> or <span class="emphasis"><em>local</em></span>
+ scope, which directly affects how the variable is treated in the decompiler's data-flow
+ analysis.
+ Annotations created by applying a data-type directly to a memory location in the listing
+ are automatically added to the formal <span class="emphasis"><em>global</em></span> namespace.
+ Ghidra can create other custom namespaces that are considered global in this sense, and
+ renaming actions provide options that let individual global annotations be moved into
+ these namespaces.
+ Dialogs that are brought up in the context of a function, like the Function Signature Editor,
+ create variable annotations that are local to that function.
+ </p>
+ <p>
+ A global variable annotation forces the decompiler to treat the memory location as if its value
+ persists beyond the end of the function. The variable must <span class="emphasis"><em>exist</em></span>
+ at all points of the function body, generally at the same memory location.
+ </p>
+ <p>
+ Local variables,
+ in constrast, do not generally exist across the whole function, but come into scope
+ at the instruction that first writes to them, and then exist only up to the last
+ instruction that reads them. The memory location storing a local variable
+ at one point of the function may be reused for different variables at other points.
+ This can cause ambiguity in how the decompiler should treat a given memory location used
+ for storing local variables, which the user may want to steer. See the discussion
+ in <a class="xref" href="DecompilerAnnotations.html#AnnoteStorage" title="Variable Storage">&#8220;Variable Storage&#8221;</a>.
+ </p>
+ <p>
+ </p>
+ </div>
+
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="AnnoteDatatype"></a>Variable Data-types</h3></div></div></div>
+
+ <p>
+ Ghidra provides extensive support for naming and describing
+ <span class="bold"><strong>data-types</strong></span> that are tailored for the Program
+ being analyzed. Data-types that are explicitly part of a variable annotation
+ are, to the extent possible, automatically incorporated
+ into the decompiler's analysis.
+ </p>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="DecompilerDataTypes"></a>Data-types Supported by the Decompiler</h4></div></div></div>
+
+ <p>
+ The decompiler understands traditional primitive data-types, in all their various sizes,
+ like integers, floating-point numbers, booleans, and characters. It also understands
+ pointers, structures, and arrays, letting it support
+ arbitrarily complicated composite data-types. Ghidra provides
+ some data-types with specialized display capabilities that don't have a natural representation
+ in the high-level language output by the decompiler. The decompiler treats these as
+ black-box data-types, preserving the name, but treating the underlying data either as an integer
+ or simply as an array of bytes.
+ </p>
+
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeUndefined"></a>Undefined</h5></div></div></div>
+
+ <p>
+ The <span class="emphasis"><em>undefined</em></span> data-types are supported, in their various sizes:
+ <span class="bold"><strong>undefined1</strong></span>, <span class="bold"><strong>undefined2</strong></span>,
+ <span class="bold"><strong>undefined4</strong></span>, etc. In Ghidra, the undefined
+ data-types, let the user specify the size of a variable, while formally declaring that
+ other details about the data-type are unknown.
+ </p>
+ <p>
+ For the decompiler, undefined data-types as an annotation have the important special meaning
+ that the decompiler should let its analysis determine the final data-type presented in the
+ output for the variable (See <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a> below).
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeVoid"></a>Void</h5></div></div></div>
+
+ <p>
+ The <span class="bold"><strong>void</strong></span> data-type is supported but treated specially by
+ the decompiler, as does Ghidra in general. A <span class="bold"><strong>void</strong></span> can be
+ used to indicate the absence of a return value in function prototypes, but cannot be used
+ as a general annotation on variables. A void pointer, <span class="bold"><strong>void *</strong></span>,
+ is possible; the decompiler treats it as a pointer to an unknown data-type.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeInteger"></a>Integer</h5></div></div></div>
+
+ <p>
+ Integer data-types, both signed and unsigned, are supported up to a size of 8 bytes. Larger
+ sizes are supported internally but are generally represented as an array of bytes in
+ decompiler output. Odd integer sizes are also supported.
+ </p>
+ <p>
+ The standard C data-type names: <span class="bold"><strong>int</strong></span>, <span class="bold"><strong>short</strong></span>,
+ <span class="bold"><strong>long</strong></span>, and <span class="bold"><strong>long long</strong></span> are mapped to specific sizes
+ based on the processor and compiler selected when importing the Program.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeBoolean"></a>Boolean</h5></div></div></div>
+
+ <p>
+ A 1-byte boolean data-type is supported.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeFloat"></a>Floating-point</h5></div></div></div>
+
+ <p>
+ Floating-point sizes of 4, 8, 10, and 16 are supported, mapping in all cases currently to the
+ <span class="bold"><strong>float</strong></span>, <span class="bold"><strong>double</strong></span>,
+ <span class="bold"><strong>float10</strong></span>, and <span class="bold"><strong>float16</strong></span>
+ data-types respectively. The decompiler currently cannot display floating-point constants
+ that are bigger than 8 bytes.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeChar"></a>Character</h5></div></div></div>
+
+ <p>
+ ASCII or unicode encoded character data-types are supported for sizes of 1, 2, and 4. The size affectively
+ chooses between the UTF8, UTF16, and UTF32 character encodings respectively. The standard
+ C data-type names <span class="bold"><strong>char</strong></span> and <span class="bold"><strong>wchar_t</strong></span> are
+ mapped to one of these sizes based on the
+ processor and compiler selected when importing the Program.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeString"></a>String</h5></div></div></div>
+
+ <p>
+ Terminated strings, encoded either in ASCII or Unicode, are supported. The decompiler converts
+ Ghidra's dedicated string data-types like <span class="bold"><strong>string</strong></span> to
+ an "array of characters" data-type, such as <span class="bold"><strong>char[]</strong></span>,
+ where the character size matches the encoding.
+ A "pointer to character" data-type like
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <code class="code">char *</code> or
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">wchar_t *</code>
+ </li>
+</ul></div>
+ </div>
+<p>
+ is also treated as a potential string reference. The decompiler can infer terminated strings if this
+ kind of data-type propagates to constant values during its analysis.
+ </p>
+ <p>
+ Strings should be fully rendered in decompiler output,
+ with non-printable characters escaped using either traditional sequences like '\r', '\n' or using unicode
+ escape sequences like '\xFF'.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypePointer"></a>Pointer</h5></div></div></div>
+
+ <p>
+ Pointer data-types are fully supported. A pointer to any other supported data-type is
+ possible. The data-type being pointed to, whether its a primitive, structure, or another pointer,
+ informs how the decompiler renders a dereferenced pointer.
+ The decompiler assumes that a pointer variable may refer to an array of
+ the underlying data-type and will use array notation if there is evidence of more than
+ one element.
+ </p>
+ <p>
+ The default pointer size is set based on the processor and compiler selected when the Program is
+ imported and generally matches the size of the <span class="bold"><strong>ram</strong></span> (or equivalent)
+ address space. Different pointer sizes within the same Program are possible. The decompiler generally
+ expects the pointer size to match the size of the address space being pointed to, but individual
+ architectures can model different size pointers into the space (such as <span class="emphasis"><em>near</em></span> pointers).
+ </p>
+ <p>
+ For processors with more than one memory address space, pointer data-types currently cannot be directly
+ annotated to indicate a preferred address space. Where there is ambiguity, the decompiler attempts to
+ determine the correct address space from the context of its use within the function.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeArray"></a>Array</h5></div></div></div>
+
+ <p>
+ Array data-types are fully supported. The array element can be any other supported data-type
+ with a fixed size.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeStructure"></a>Structure</h5></div></div></div>
+
+ <p>
+ Structured data-types are fully supported. The decompiler does not automatically infer structures
+ when analyzing a function; it propagates structured data-types into the function from explicitly
+ annotated sources, like input parameters or global variables. Decompiler directed creation of
+ structures can be triggered by the user, see <a class="xref" href="DecompilerWindow.html#ActionAutoStructure" title="Auto Create Structure">&#8220;Auto Create Structure&#8221;</a>.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeEnum"></a>Enumeration</h5></div></div></div>
+
+ <p>
+ Enumerations are fully supported. The decompiler can propagate enumerations from explicitly
+ annotated sources throughout a function onto constants, which are then displayed with the
+ appropriate label from the definition of the enumeration. If the constant does not match a
+ single value in the enumeration definition, the decompiler attempts to build a matching
+ value by <span class="emphasis"><em>or</em></span>-ing together multiple labels.
+ The decompiler can be made to break out constants representing packed <span class="emphasis"><em>flags</em></span>,
+ for instance, by labeling individal bit values within an enumeration.
+ </p>
+ </div>
+ <div class="sect4">
+<div class="titlepage"><div><div><h5 class="title">
+<a name="TypeFunction"></a>Function Definition</h5></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>Function Definition</strong></span> in Ghidra is a data-type that encodes
+ information about the parameters and return value for a generic/unspecified function.
+ A formal <span class="bold"><strong>function pointer</strong></span> is supported by the decompiler as a pointer
+ data-type that points to a Function Definition. A Function Definition specifically encodes:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ The name and data-type of each parameter.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ Whether the function takes a variable number of parameters.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ The data-type associated with the return value.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ An indicator of the <span class="emphasis"><em>prototype model</em></span> that should be
+ associated with the function.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The Function Definition itself does not encode any storage information. Once the Function
+ Definition is associated with a Program, the indicator maps to one of the prototype models for the
+ specific processor and compiler. A Function Definition is currently limited to a prototype model
+ with one of the following names:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ __stdcall
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ __thiscall
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ __fastcall
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ __cdecl
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ __vectorcall
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ </div>
+ </div>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="AnnoteForcing"></a>Forcing Data-types</h4></div></div></div>
+
+ <p>
+ The decompiler performs <span class="bold"><strong>type propagation</strong></span> as part of its analysis
+ on functions. Data-type information is collected from variable annotations (and other sources),
+ which is then propagated via data-flow throughout the function to other variables and
+ constants where the data-type may not be immediately apparent.
+ </p>
+ <p>
+ With few exceptions, a variable annotation is <span class="emphasis"><em>forcing</em></span> on the decompiler in the sense
+ that the storage location being annotated is considered an unalterable data-type source. During
+ type propagation, the data-type may propagate to other variables,
+ but the variable representing the storage location being annotated is guaranteed to have
+ the given name and that data-type; it will not be overridden.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ Users should be aware that variable annotations are forcing on the decompiler and may directly
+ override aspects of its analysis. Because of this, variable annotations are the most powerful way
+ for the user to affect decompiler output, but setting an incomplete (or incorrect) data-type as
+ part of an annotation may produce poorer decompiler output.
+ </td></tr>
+</table></div>
+ <p>
+ The major exception to forcing annotations is if the data-type in the annotation is <span class="emphasis"><em>undefined</em></span>.
+ Ghidra reserves the following names to represent formally undefined data-types:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>undefined1</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>undefined2</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>undefined4</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>undefined8</strong></span></li>
+<li class="listitem" style="list-style-type: disc">...</li>
+</ul></div>
+ </div>
+<p>
+ These allow annotations to be made even when the user doesn't have information about a variable's data-type.
+ The number in the name only specifies the number of bytes in the variable.
+ </p>
+ <p>
+ The decompiler views a variable annotation with an undefined data-type only as an indication of what name
+ should be used if a variable at that storage address exists. The data-type for the variable is filled in,
+ using type propagation from other sources.
+ </p>
+ <p>
+ For annotations that specifically label a function's formal parameters or return value,
+ the <span class="emphasis"><em>Signature Source-Type</em></span> also affects how they're treated by the decompiler.
+ If the Source-Type is set to anything other than <span class="emphasis"><em>DEFAULT</em></span>, there is a forced
+ one-to-one correspondence between variable annotations and actual parameters in the decompiler's
+ view of the function. This is stronger than just forcing the data-type; the existence (or not) of
+ the variable itself is forced by the annotation in this case. If the Source-Type is forcing and
+ there are no parameter annotations, a <span class="emphasis"><em>void</em></span> prototype is forced on the function.
+ </p>
+ <p>
+ A forcing Source-Type, with a value other than
+ <span class="emphasis"><em>DEFAULT</em></span>, is set typically if debug symbols for the function are read in during
+ Program import (<span class="emphasis"><em>IMPORTED</em></span>), or if the user manually edits the function prototype
+ directly (<span class="emphasis"><em>USER_DEFINED</em></span>).
+ </p>
+ <p>
+ If an annotation and the Signature Source-Type force a parameter to exist, specifying an
+ <span class="emphasis"><em>undefined</em></span> data-type in the annotation still directs the decompiler to fill in
+ the variable's data-type using type propagation. The same holds true for the return value; an
+ <span class="emphasis"><em>undefined</em></span> annotation fixes the size of the return value, but the decompiler
+ fills in its own data-type.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ The decompiler may still use an <span class="emphasis"><em>undefined</em></span> data-type to label a variable,
+ even after type propagation. If a variable is simply copied around within a function and there
+ are no other substantive operations or annotations on the variable, the decompiler may decide the undefined
+ data-type is appropriate.
+ </td></tr>
+</table></div>
+ </div>
+
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="AnnoteStorage"></a>Variable Storage</h3></div></div></div>
+
+ <p>
+ Every variable annotation is associated with a single <span class="emphasis"><em>storage location</em></span>, where the
+ value of the variable is stored during execution: generally a register, stack location, or an address
+ in the load image of the Program. The storage location does not necessarily hold the value for that
+ variable at all points of execution, and its possible for the variable value to be held in
+ <span class="emphasis"><em>different</em></span> storage locations at different points of execution. The set of execution
+ points where the storage location <span class="emphasis"><em>does</em></span> hold the variable value is called the annotation
+ <span class="bold"><strong>scope</strong></span>; this is distinct from (but influenced by) the scope of the
+ variable itself. The different types of storage location are listed below.
+ </p>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="VariableStorageImage"></a>Load-image Address</h4></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>load-image address</strong></span> is a concrete address in the load image of the Program,
+ typically in the <span class="bold"><strong>ram</strong></span> address space. This kind of
+ storage must be backed by a formal memory block for the Program, which typically corresponds to a specific
+ program section (such as the <code class="code">.text</code> or <code class="code">.bss</code> section). Because it is in the
+ load image directly, an annotation with this storage shows up directly in the <span class="emphasis"><em>Listing</em></span>
+ window and can be directly manipulated there. In much of the Ghidra documentation, these annotations
+ are referred to as <span class="bold"><strong>Data</strong></span>. See the section
+ <a class="ulink" href="help/topics/DataPlugin/Data.htm" target="_top">Data</a> in particular.
+ </p>
+ <p>
+ Although specific architectures may vary, generally a storage location at a load image address
+ represents a formal <span class="emphasis"><em>global</em></span> variable, and the annotation is in scope
+ across all Program execution. For the decompiler, the storage location is treated as a
+ a single <span class="emphasis"><em>persistent</em></span> variable in all functions that reference it. Within a
+ function, all distinct references to the storage location (varnodes) are merged. The decompiler
+ expects a value at the storage location to exist from <span class="emphasis"><em>before</em></span> the start of
+ the function, and any change to the value must be explicitly represented as an assignment to
+ the variable in decompiler output.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="VariableStorageStack"></a>Stack Address</h4></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>stack address</strong></span> is an address in the <span class="emphasis"><em>stack frame</em></span>
+ of a particular function in the Program. Formally, a stack address is defined as an offset relative to the
+ incoming value of the <span class="emphasis"><em>stack pointer</em></span> and exists in the
+ <span class="bold"><strong>stack</strong></span> address space associated with the function. See the discussion
+ in <a class="xref" href="DecompilerConcepts.html#ConceptAddressSpace" title="Address Space">&#8220;Address Space&#8221;</a>. A <span class="bold"><strong>stack annotation</strong></span> then is a variable annotation
+ with a stack address as its storage location. It exists only in the scope of a
+ single function and the variable must be <span class="emphasis"><em>local</em></span> to that function.
+ </p>
+ <p>
+ Within the <span class="emphasis"><em>Listing</em></span> window, a stack annotation is displayed as part of the function header
+ (at the entry point address of the function), with a syntax similar to:
+ </p>
+<div class="informalexample">
+ <code class="code">undefined4 Stack[-0x14]:4 local_14</code>
+ </div>
+<p>
+ The middle field (the <span class="emphasis"><em>Variable Location</em></span> field) indicates that the storage location is on the
+ stack, and the value in brackets indicates the offset of the storage location, relative to the incoming
+ stack pointer. The value after the colon indicates the number of bytes in the storage location.
+ </p>
+ <p>
+ Currently, the entire body of the function is included
+ in the scope of any stack annotation, and the decompiler will allow only a single variable to exist
+ at the stack address. A stack annotation can be a formal parameter to the function, but otherwise the
+ decompiler does not expect to see a value that exists before the start of the function. Similarly,
+ because the value is not expected to persist after the function executes, a write to the stack
+ address may not show up as an explicit assignment to the variable if the value is simply
+ <span class="emphasis"><em>propagated through</em></span> to another expression.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="VariableStorageRegister"></a>Register</h4></div></div></div>
+
+ <p>
+ A variable annotation can refer to a specific <span class="emphasis"><em>register</em></span> for the processor associated
+ with the Program. In general, such an annotation will be for a variable local to a particular function.
+ Within the <span class="emphasis"><em>Listing</em></span> window, this annotation is displayed as part of the function header, with
+ syntax like:
+ </p>
+<div class="informalexample">
+ <code class="code">int EAX:4 iVar1</code>
+ </div>
+<p>
+ The <span class="emphasis"><em>Variable Location</em></span> field displays the name of the particular register attached to
+ the annotation, and the value after the colon indicates the number of bytes in the register.
+ </p>
+ <p>
+ For a local variable annotations with a register storage location, there is an expectation that the
+ register may be reused for different variables at different points of execution within the function.
+ There may be more than one annotation, for different variables, that share the same register
+ storage location.
+ An annotation is associated with a <span class="emphasis"><em>first use point</em></span> that describes where
+ the register first holds a value for the particular variable. (See the discussion - <a class="xref" href="DecompilerConcepts.html#ConceptVarnodeSSA" title="Varnodes in the Decompiler">&#8220;Varnodes in the Decompiler&#8221;</a>)
+ The entire scope of the annotation is limited to the address regions between the first use point
+ and any points where the value is read. The decompiler may extend the scope as part of its
+ <span class="emphasis"><em>merging</em></span> process, but the full extent is not stored in the annotation.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="VariableStorageTemp"></a>Temporary Registers</h4></div></div></div>
+
+ <p>
+ Variable annotations can have a <span class="emphasis"><em>temporary register</em></span> as a storage location.
+ A temporary register is not specific to a processor but is produced at various stages of
+ the decompilation process. See the discussion of the <span class="bold"><strong>unique</strong></span>
+ space in <a class="xref" href="DecompilerConcepts.html#ConceptAddressSpace" title="Address Space">&#8220;Address Space&#8221;</a>. These registers do not have a meaningful name, and
+ the specific storage address may change on successive decompilations. So within the
+ <span class="emphasis"><em>Listing</em></span> window, this annotation is displayed as part of the function header,
+ with syntax like:
+ </p>
+<div class="informalexample">
+ <code class="code">int HASH:5f96367122:4 iVar2</code>
+ </div>
+<p>
+ The <span class="emphasis"><em>Variable Location</em></span> field displays the internal hash used to uniquely
+ identify the temporary register within the data-flow of the function.
+ </p>
+ <p>
+ A temporary register annotation must be for a local variable, and as with an ordinary register,
+ the annotation is associated with a <span class="emphasis"><em>first use point</em></span> that describes
+ where the temporary register first holds a value for the variable.
+ </p>
+ </div>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnotePrototype"></a>Function Prototypes</h2></div></div></div>
+
+ <p>
+ Every formal Function in Ghidra is associated with a set of variable annotations and other properties that
+ make up the <span class="bold"><strong>function prototype</strong></span>. Due to the nature of reverse engineering,
+ the function prototype may only include partial information and may be built up over time. Individual
+ elements include:
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Input Parameters</strong></span></span></dt>
+<dd>
+ <p>
+ Each formal input to the function can have a Variable Annotation that describes its name, data-type,
+ and storage location, at the moment control-flow enters the function. If annotations exist, they are shown
+ in the Listing Window as part of the Function header, and they usually correspond directly with symbols in the
+ <span class="emphasis"><em>function declaration</em></span> produced by the decompiler.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Return Value</strong></span></span></dt>
+<dd>
+ <p>
+ The value returned by a function can have a special Variable Annotation that describes its data-type
+ and storage location, at the moment control-flow exits the function. If it exists, the annotation is shown
+ in the Listing Window as part of the Function header with the name <code class="code">&lt;RETURN&gt;</code>, and it usually
+ corresponds directly with the return value in the <span class="emphasis"><em>function declaration</em></span> produced by
+ the decompiler.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Calling Convention</strong></span></span></dt>
+<dd>
+ <p>
+ The calling convention used by the function can be specified as part of the function prototype. The convention
+ is specified by name, referring to the formal <a class="xref" href="DecompilerConcepts.html#ConceptPrototypeModel" title="Prototype Model">&#8220;Prototype Model&#8221;</a> that describes how storage
+ locations are selected for individual parameters along with other information about how the compiler treats
+ the function.
+ </p>
+ <p>
+ In the absence of parameter and return value annotations, the decompiler will use the prototype model as
+ part of its analysis to <span class="emphasis"><em>discover</em></span> the input parameters and the return value of the function.
+ </p>
+ <p>
+ The name "unknown" is reserved to indicate that nothing is known about the calling convention. If
+ set to "unknown", depending on context, the decompiler may assign the calling convention based on
+ the <span class="emphasis"><em>Prototype Evaluation</em></span> option (See <a class="xref" href="DecompilerOptions.html#OptionProtoEval"><span class="bold"><strong>Prototype Evaluation</strong></span></a>), or it
+ may use the default calling convention for the architecture.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Variable Arguments</strong></span></span></dt>
+<dd>
+ <p>
+ Functions have a boolean property called <span class="bold"><strong>variable argments</strong></span>, which can be turned on
+ if the function is capable of being passed a variable number of inputs. This property informs the decompiler that
+ the function may take additional parameters beyond any with an explicit variable annotation.
+ This affects decompilation of any function which calls the <span class="emphasis"><em>variable arguments</em></span> function, allowing
+ the decompiler to discover unlisted parameters at a given call site.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>No Return</strong></span></span></dt>
+<dd>
+ <p>
+ A function can be marked explicitly as <span class="bold"><strong>not returning</strong></span>, meaning that once
+ a call is made to the function, execution will never return to the caller. The decompiler uses this to
+ compute the correct control-flow in any calling functions.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>In-Line</strong></span></span></dt>
+<dd>
+ <p>
+ If the boolean property <span class="bold"><strong>in-line</strong></span> is turned on for a particular function,
+ it directs the decompiler to inline the effects of the function into the decompilation of any of its calling functions.
+ The function will no longer appear as a direct subfunction call in the decompilation, but all of its data-flow
+ will be incorporated into the calling function.
+ </p>
+ <p>
+ This is useful for <span class="emphasis"><em>bookkeeping</em></span> functions, where its important for the decompiler to
+ <span class="emphasis"><em>see</em></span> its effects on the calling function. Functions that set up the stack frame for a caller or
+ functions that look up or dispatch a switch destination are typical examples that should be marked <span class="emphasis"><em>in-line</em></span>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Call-fixup</strong></span></span></dt>
+<dd>
+ <p>
+ This property is similar in spirit to marking a function as <span class="emphasis"><em>in-line</em></span>.
+ A <span class="bold"><strong>call-fixup</strong></span> directs the decompiler to replace any call to the function with a specific
+ chunk of raw p-code. The decompilation of any calling function no longer shows the subfunction call, but the chunk
+ of p-code incorporates the subfunction's effects.
+ </p>
+ <p>
+ Call-fixups are more flexible than just inlining a function. The call-fixup chunk can be tailored to incorporate all of,
+ just a part of, or something different to the behavior of the function.
+ </p>
+ <p>
+ Call-fixups are specified by name. The name and associated p-code chunk are typically defined in the
+ <span class="emphasis"><em>compiler specification</em></span> for the Program.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="PrototypeDiscover"></a>Discovering Parameters</h3></div></div></div>
+
+ <p>
+ The input parameter and return value annotations of the function prototype, like
+ any variable annotations, can be forcing on the decompiler.
+ See the complete discussion in <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>.
+ But keep in mind:
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ The input parameters and return value are all forced on the decompiler as a unit based on the
+ <span class="emphasis"><em>Signature Source-Type</em></span>. They are all forced if the Source-Type is set to anything
+ other than <span class="emphasis"><em>DEFAULT</em></span>; otherwise none of them are forced.
+ </td></tr>
+</table></div>
+ <p>
+ If the function prototype's annotations are not forced, the decompiler will attempt to discover the parameters
+ and return value using the calling convention. The prototype model underlying the calling convention
+ dictates which storage locations can be considered as parameters and their formal ordering.
+ </p>
+ </div>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="PrototypeCustom"></a>Custom Storage</h3></div></div></div>
+
+ <p>
+ If there are parameter or return value annotations that do not agree with the calling convention that
+ has been set, the function prototype is said to be using <span class="bold"><strong>custom storage</strong></span>.
+ Using the <a class="ulink" href="help/topics/FunctionPlugin/Variables.htm#Edit_Function" target="_top">Function Editor Dialog</a>
+ for instance, any storage location can be specified as a parameter, and a completely custom prototype
+ can be built for the function.
+ </p>
+ <p>
+ The decompiler will disregard the calling convention's rules in this situation and use the custom storage
+ locations for parameters and the return value. Other aspects of the calling convention, like the
+ <span class="emphasis"><em>unaffected</em></span> list, will still be used.
+ </p>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteMutability"></a>Data Mutability</h2></div></div></div>
+
+ <p>
+ <span class="bold"><strong>Mutability</strong></span> is a description of how values in a specific memory region
+ (either a single variable or a larger block) can change during Program execution, based either on
+ properties or established rules. Ghidra recognizes the mutability settings:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">Normal</li>
+<li class="listitem" style="list-style-type: disc">Constant - (read-only)</li>
+<li class="listitem" style="list-style-type: disc">Volatile</li>
+</ul></div>
+ </div>
+<p>
+ Mutability affects decompiler analysis and can have a large impact the output.
+ </p>
+ <p>
+ Most memory has <span class="bold"><strong>normal</strong></span> mutability, meaning:
+ the value at the memory location may change over the course of executing the Program, but for a given
+ section of code, the value will not change unless an instruction explicitly writes to it.
+ </p>
+ <p>
+ Mutability can be set on an entire block of memory in the Program, typically from the
+ <a class="ulink" href="help/topics/MemoryMapPlugin/Memory_Map.htm#View_Memory_Map" target="_top">Memory Map</a>.
+ It can also be set as part of a single Variable Annotation. From the Listing Window for instance,
+ use the <a class="ulink" href="help/topics/DataPlugin/Data.htm#Data_Settings" target="_top">Settings</a> dialog.
+ </p>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MutabilityReadOnly"></a>Read-only</h3></div></div></div>
+
+ <p>
+ The <span class="bold"><strong>constant</strong></span> mutability setting indicates that values within
+ the memory region are read-only and don't change during Program execution. If a read-only variable is
+ accessed in a function being analyzed by the decompiler, its constant value, if present in the
+ Program's <span class="emphasis"><em>load image</em></span>, replaces the variable within data-flow for the
+ function. The decompiler may propagate the constant and fold it in to other operations, which
+ can have a substantial impact on the final output.
+ </p>
+ </div>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MutabilityVolatile"></a>Volatile</h3></div></div></div>
+
+ <p>
+ The <span class="bold"><strong>volatile</strong></span> mutability setting indicates that values within
+ the memory region may change unexpectedly, even if the code currently executing does not directly
+ write to it. If a volatile variable is accessed in a function being analyzed by the decompiler,
+ each specific access is replaced with a built-in function call, which prevents constant propagation
+ and other transforms across the access. The built-in functions are named based on
+ whether the access is a <span class="emphasis"><em>read</em></span> or <span class="emphasis"><em>write</em></span> and then the size
+ of the access. Within decompiler output, the first parameter to a built-in function is a symbol
+ indicating the volatile variable. The function returns a value in the case of a volatile read or
+ takes a second parameter in the case of a volatile write.
+ </p>
+<div class="informalexample">
+ <pre class="programlisting">
+ write_volatile_1(DAT_mem_002b,0x20);
+ X = read_volatile_2(SREG);
+ </pre>
+ </div>
+<p>
+ </p>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteConstants"></a>Constant Annotations</h2></div></div></div>
+
+ <p>
+ Ghidra provides some ways to control how specific constants shown in disassembly are formatted or displayed.
+ These annotations are attached to constants as operands of specific machine instructions. To the extent
+ possible, the decompiler applies these annotations to the matching constant in the decompiler output.
+ The constant may be transformed from its value in the original machine instruction during the decompiler's
+ analysis. The decompiler will follow the constant through simple transformations, but if the transformed
+ is too far from the original value, the annotation will not be applied. The transforms followed are:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">Signed or zero extension</li>
+<li class="listitem" style="list-style-type: disc">Bitwise negation</li>
+<li class="listitem" style="list-style-type: disc">Integer negation - Twos complement</li>
+<li class="listitem" style="list-style-type: disc">Add or subtract 1</li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConstantEquates"></a>Equates</h3></div></div></div>
+
+ <p>
+ Ghidra can create an association between a name and a constant, called an <span class="bold"><strong>equate</strong></span>.
+ The constant must be a constant operand of a specific machine instruction, and the equate
+ is applied directly to the operand from the Listing Window using the
+ <a class="ulink" href="help/topics/EquatePlugin/Equates.htm#Set_Equate" target="_top">Set Equate</a> menu.
+ Once applied, the equate's name is displayed instead of the numeric representation of the constant.
+ Equates across the entire Program can be viewed from the
+ <a class="ulink" href="help/topics/EquatePlugin/Equates.htm#Equate_Table" target="_top">Equate Table</a>.
+ </p>
+ <p>
+ When analyzing a function, the decompiler attempts to follow any constant in the function with an attached
+ equate to the matching constant in the final output. If successful, the equate's name is printed instead of
+ the numeric form of the matching constant. If the constant was transformed from its original value, the
+ matching constant is printed as an expression, where the transforming operations are applied to the equate
+ symbol (representing the original constant).
+ </p>
+ </div>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConstantConversions"></a>Format Conversions</h3></div></div></div>
+
+ <p>
+ Ghidra can apply a <span class="bold"><strong>format conversion</strong></span> to override how an integer operand
+ is displayed in a specific machine instruction. Conversions are generally applied from the Listing Window using the
+ <a class="ulink" href="help/topics/EquatePlugin/Equates.htm#Convert" target="_top">Convert</a> menu option. When analyzing a
+ function containing a machine instruction that has a format conversion applied, the decompiler will attempt
+ to trace the constant to a matching constant in the final output. If successful, the format conversion is also
+ applied to the matching constant.
+ </p>
+ <p>
+ Conversions applied by the decompiler are currently limited to:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">Binary - 0b10100111</li>
+<li class="listitem" style="list-style-type: disc">Decimal- 167</li>
+<li class="listitem" style="list-style-type: disc">Hexadecimal - 0xa7</li>
+<li class="listitem" style="list-style-type: disc">Octal - 0247</li>
+</ul></div>
+ </div>
+<p>
+ An appropriate header matching the format is prepended to the representation string, either "0b", "0x" or just
+ "0". The decompiler will not switch the signedness of the constant but preserves the signed or unsigned data-type
+ as determined by analysis.
+ </p>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnnoteRegister"></a>Register Values</h2></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>register value</strong></span> in this context is a region of code in the Program
+ where a specific register holds a known constant value. Ghidra maintains an explicit list of these values for
+ the Program (see the documentation for <a class="ulink" href="help/topics/RegisterPlugin/Registers.htm" target="_top">Register Values</a>),
+ which the decompiler can use when analyzing a function.
+ A register value benefits decompiler analysis, especially if the original compiler was aware
+ of the constant value, as the decompiler can recover address references calculated as offsets relative to the register
+ and otherwise propagate the constant.
+ </p>
+ <p>
+ A <span class="emphasis"><em>register value</em></span> is set by highlighting the region of code in the Listing Window and then invoking the
+ <a class="ulink" href="help/topics/RegisterPlugin/Registers.htm#SetRegisterValues" target="_top">Set Register Values ...</a> command
+ from the pop-up menu. The beginning and end of a region is indicated in the Listing Window with
+ <code class="code">assume</code> directives, and regions can be generally viewed from the
+ <a class="ulink" href="help/topics/RegisterPlugin/Registers.htm#Register_Manager" target="_top">Register Manager</a> window.
+ </p>
+ <p>
+ In order for a particular register value to affect decompilation, the region of code associated with the
+ value must contain the entry point of the function, and of course the function must read from the register.
+ Only the initial reads of the register are replaced with the constant value.
+ The decompiler will continue to respect later instructions that write to the register (even if the
+ instruction is inside the register value's region)
+ If a register value's region starts in the middle of a function, decompilation is <span class="emphasis"><em>not</em></span>
+ affected at all.
+ </p>
+</div>
+
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">
+<a accesskey="p" href="DecompilerConcepts.html">Prev</a>�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�<a accesskey="n" href="DecompilerOptions.html">Next</a>
+</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">Decompiler Concepts�</td>
+<td width="20%" align="center"><a accesskey="h" href="Decompiler.html">Home</a></td>
+<td width="40%" align="right" valign="top">�Decompiler Options</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerConcepts.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerConcepts.html
new file mode 100644
index 0000000000..07f0db5714
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerConcepts.html
@@ -0,0 +1,1084 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Decompiler Concepts</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="up" href="Decompiler.html" title="Decompiler">
+<link rel="prev" href="DecompilerIntro.html" title="Decompiler">
+<link rel="next" href="DecompilerAnnotations.html" title="Program Annotations Affecting the Decompiler">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Decompiler Concepts</th></tr>
+<tr>
+<td width="20%" align="left">
+<a accesskey="p" href="DecompilerIntro.html">Prev</a>�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�<a accesskey="n" href="DecompilerAnnotations.html">Next</a>
+</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="DecompilerConcepts"></a>Decompiler Concepts</h1></div></div></div>
+
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="ConceptPcode"></a>P-code</h2></div></div></div>
+
+ <p>
+ P-code is Ghidra's Intermediate Representation (IR) language. When analyzing a function,
+ the decompiler translates every machine instruction into p-code first and performs its
+ analysis directly on the operators and variables of the language. Output of the decompiler
+ is also best understood in terms of p-code. This section presents the key concepts of
+ p-code. For a more detailed discussion see the document "P-Code Reference Manual".
+ </p>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptAddressSpace"></a>Address Space</h3></div></div></div>
+
+ <p>
+ P-code defines all data in terms of an address space. An <span class="bold"><strong>address space</strong></span>
+ is defined simply as an indexed sequence of bytes that can be read and written by p-code operations.
+ For a specific byte, the unique index that labels it is called the byte's <span class="bold"><strong>address</strong></span>.
+ Each address space has a:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>name</strong></span> - a formal name for the space
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>size</strong></span> - the maximum number of bytes that can be addressed
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>endianess</strong></span> - how groups of bytes are interpreted as integers
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ For a p-code model of a specific processor, all elements of the processor state (including RAM, registers,
+ flags, etc.) must be contained in some address space. The model will define multiple address spaces
+ to accomplish this, and beyond the raw translation of machine instructions to p-code, the decompiler
+ can add additional spaces. Address space definitions that are common across many different processors include:
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>ram</strong></span></span></dt>
+<dd>
+ <p>
+ A space that models memory accessible via the processors's main data bus. Depending on
+ the architecture, different spaces might be substituted for <span class="emphasis"><em>ram</em></span>,
+ such as separate <span class="emphasis"><em>code</em></span> and <span class="emphasis"><em>data</em></span> spaces.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>register</strong></span></span></dt>
+<dd>
+ <p>
+ A space that models the processor's general purpose registers. Ghidra still uses
+ the standard names to refer to registers for the processor, but internally each register maps to a
+ specific address in this space.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>unique</strong></span></span></dt>
+<dd>
+ <p>
+ A space dedicated to <span class="emphasis"><em>temporary</em></span> registers.
+ It is used to hold intermediate values when modeling instruction behavior, and the decompiler
+ uses it to allocate space for variables that don't directly correspond to the low level
+ processor state. The name <span class="emphasis"><em>unique</em></span> is reserved for this purpose and
+ is present in all processor models.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>stack</strong></span></span></dt>
+<dd>
+ <p>
+ A space that represents bytes explicitly indexed through a <span class="emphasis"><em>stack pointer</em></span>.
+ This is an example of an address space added by the decompiler beyond what the raw processor
+ model defines. The <span class="emphasis"><em>stack</em></span> space is a logical construction representing the set of bytes a
+ single function might access through its stack pointer. Each stack address represents
+ the offset of a byte in some underlying space (usually <span class="emphasis"><em>ram</em></span>) relative
+ to the initial value of the stack pointer upon entry to the function. The stack space is
+ always referenced in the context of a single function, and in this sense, each function
+ can be viewed as having its own distinct stack space.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>constant</strong></span></span></dt>
+<dd>
+ <p>
+ A special space for encoding constants in p-code.
+ For complete generality, even constants that the processor might manipulate are
+ assigned to their own address space. For an address in the constant
+ space, the index itself represents the constant.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptVarnode"></a>Varnodes</h3></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>varnode</strong></span> is defined as a sequence of bytes in
+ an address space. It represents the storage for a single value (variable) being
+ acted on by the processor.
+ All manipulation of data by p-code operations occurs on varnodes.
+ A varnode can always be represented as the formal triple:
+ </p>
+<div class="informalexample">
+ <code class="code">(address space,offset,size)</code>
+ </div>
+<p>
+ Both <span class="emphasis"><em>offset</em></span> and <span class="emphasis"><em>size</em></span> are integer values
+ specified in terms of bytes.
+ The first two elements, address space and offset, taken together represent the
+ <span class="emphasis"><em>address</em></span> of the varnode.
+ </p>
+ <p>
+ Varnodes by themselves do not necessarily have a data-type associated with them.
+ The decompiler ultimately assigns a formal data-type, but at the lowest level of p-code,
+ varnodes inherit one the building block data-types from the p-code operations that
+ act on them:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Integer</strong></span>
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Boolean</strong></span>
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Floating Point</strong></span>
+ </li>
+</ul></div>
+ </div>
+<p>
+ The integer data-type assumes a twos complement encoding in the endianness of the
+ address space containing the varnode. Similarly, the floating point data-type assumes
+ an IEEE 754 standard encoding. The precision of the integer or floating point value is
+ determined by the varnode's size. A boolean data-type assumes the varnode has a size
+ of 1 byte and takes either a value of 0, for <span class="emphasis"><em>false</em></span>, or a value of
+ 1 for <span class="emphasis"><em>true</em></span>.
+ </p>
+
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptPcodeOps"></a>P-code Operations</h3></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>p-code operation</strong></span> is defined as a formal operator,
+ labeled by its <span class="emphasis"><em>opcode</em></span>, acting on 1 or more varnodes as input and
+ storing a result in at most 1 varnode. Each p-code operation is associated with an
+ address, which is usually the address of the machine instruction from which the p-code
+ operation was translated. As most instructions require more than one p-code operation
+ to fully model it, a separate 1-up counter is used to distinguish p-code operations
+ associated with the same address. Together the address and the counter are referred
+ to as the operation's <span class="bold"><strong>sequence number</strong></span>.
+ </p>
+ <p>
+ The formal opcodes break up into categories similar to many programming languages.
+ </p>
+<div class="informalexample">
+ <div class="table">
+<a name="ops.htmltable"></a><p class="title"><b>Table�.�P-code Operations</b></p>
+<div class="table-contents"><table width="90%" frame="box" rules="all">
+
+ <col width="40%">
+ <col width="60%">
+ <thead>
+ <tr>
+ <td><span class="bold"><strong>Category</strong></span></td>
+ <td><span class="bold"><strong>Operations</strong></span></td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Data Moving</td>
+ <td><code class="code">COPY, LOAD, STORE</code></td>
+ </tr>
+ <tr>
+ <td>Integer Arithmetic</td>
+ <td><code class="code">INT_ADD, INT_SUB,
+ INT_2COMP, INT_MULT, INT_DIV, INT_SDIV, INT_REM, INT_SREM</code></td>
+ </tr>
+ <tr>
+ <td>Integer Shifts</td>
+ <td><code class="code">INT_LEFT, INT_RIGHT, INT_SRIGHT</code></td>
+ </tr>
+ <tr>
+ <td>Integer Comparison</td>
+ <td><code class="code">INT_EQUAL, INT_NOTEQUAL, INT_SLESS, INT_SLESSEQUAL, INT_LESS, INT_LESSEQUAL</code></td>
+ </tr>
+ <tr>
+ <td>Logical</td>
+ <td><code class="code">INT_NEGATE, INT_XOR, INT_AND, INT_OR, POPCOUNT</code></td>
+ </tr>
+ <tr>
+ <td>Boolean</td>
+ <td><code class="code">BOOL_NEGATE, BOOL_XOR, BOOL_AND, BOOL_OR</code></td>
+ </tr>
+ <tr>
+ <td>Floating Point Arithmetic</td>
+ <td><code class="code">FLOAT_ADD, FLOAT_SUB, FLOAT_MULT, FLOAT_DIV, FLOAT_NEG,
+ FLOAT_ABS, FLOAT_SQRT</code></td>
+ </tr>
+ <tr>
+ <td>Floating Point Comparison</td>
+ <td><code class="code">FLOAT_EQUAL, FLOAT_NOTEQUAL, FLOAT_LESS, FLOAT_LESSEQUAL</code></td>
+ </tr>
+ <tr>
+ <td>Floating Point Conversion</td>
+ <td><code class="code">INT2FLOAT, FLOAT2FLOAT, TRUNC, CEIL, FLOOR, ROUND</code></td>
+ </tr>
+ <tr>
+ <td>Branching</td>
+ <td><code class="code">BRANCH, CBRANCH, BRANCHIND, CALL, CALLIND, RETURN</code></td>
+ </tr>
+ <tr>
+ <td>Extension/Truncation</td>
+ <td><code class="code">INT_ZEXT, INT_SEXT, PIECE, SUBPIECE</code></td>
+ </tr>
+ <tr>
+ <td>Overflow Tests</td>
+ <td><code class="code">INT_CARRY, INT_SCARRY, INT_SBORROW, FLOAT_NAN</code></td>
+ </tr>
+ <tr>
+ <td>Managed Code</td>
+ <td><code class="code">CPOOLREF, NEW</code></td>
+ </tr>
+ </tbody>
+ </table></div>
+</div>
+<br class="table-break">
+ </div>
+<p>
+ </p>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptOperatorTokens"></a>Operator Tokens</h4></div></div></div>
+
+ <p>
+ Most opcodes naturally correspond to a particular C operator token,
+ and in decompiler output, many of the operator tokens displayed correspond
+ directly to a p-code operation present in the decompiler's internal
+ representation. The biggest exception are the <span class="emphasis"><em>Branching</em></span>
+ operations; the decompiler uses standard high-level language control-flow
+ structures, like <span class="emphasis"><em>if/else</em></span>, <span class="emphasis"><em>switch</em></span>, and
+ <span class="emphasis"><em>do/while</em></span> blocks, instead of the
+ low-level branching operations. But even here, there is some correspondence
+ between operations and keywords in the high-level language.
+ </p>
+ <p>
+ Operations in the <span class="emphasis"><em>Extension/Truncation</em></span> and
+ <span class="emphasis"><em>Floating Point Conversion</em></span> categories tend to be
+ represented as <span class="emphasis"><em>cast</em></span> operations in the high-level language,
+ and so don't have an explicit operator token representing them. Many p-code
+ operations share the same operator token, such as the integer and floating-point
+ addition operations <span class="bold"><strong>INT_ADD</strong></span> and
+ <span class="bold"><strong>FLOAT_ADD</strong></span>. The high-level language distinguishes
+ between them via the underlying data-type of the variables.
+ </p>
+ <div class="informalexample">
+ <div class="table">
+<a name="ref.htmltable"></a><table width="90%" frame="box" rules="rows">
+ <col width="25%">
+ <col width="25%">
+ <col width="50%">
+ <thead>
+ <tr>
+ <td><span class="bold"><strong>Name</strong></span></td>
+ <td><span class="bold"><strong>Operator Token</strong></span></td>
+ <td><span class="bold"><strong>Description</strong></span></td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>COPY</td>
+ <td><code class="code">=</code></td>
+ <td>Copy one varnode into another.</td>
+ </tr>
+ <tr>
+ <td>LOAD</td>
+ <td>
+<code class="code">*</code> or <code class="code">-&gt;</code>
+</td>
+ <td>Dereference a pointer, or load a value from memory.</td>
+ </tr>
+ <tr>
+ <td>STORE</td>
+ <td>
+<code class="code">*</code> or <code class="code">-&gt;</code>
+</td>
+ <td>Store a value to memory, through a pointer.</td>
+ </tr>
+ <tr>
+ <td>BRANCH</td>
+ <td><code class="code">goto</code></td>
+ <td>Branch execution to a specific address.</td>
+ </tr>
+ <tr>
+ <td>CBRANCH</td>
+ <td><code class="code">if (...) goto</code></td>
+ <td>Branch execution to an address if the condition is true.</td>
+ </tr>
+ <tr>
+ <td>BRANCHIND</td>
+ <td><code class="code">switch(...)</code></td>
+ <td>Branch execution to a computed address.</td>
+ </tr>
+ <tr>
+ <td>CALL</td>
+ <td><code class="code">funcname(...)</code></td>
+ <td>Branch to a subfunction.</td>
+ </tr>
+ <tr>
+ <td>CALLIND</td>
+ <td><code class="code">(*funcptr)(...)</code></td>
+ <td>Branch through a pointer to a subfunction.</td>
+ </tr>
+ <tr>
+ <td>RETURN</td>
+ <td><code class="code">return</code></td>
+ <td>Return execution to the calling function.</td>
+ </tr>
+ <tr>
+ <td>PIECE</td>
+ <td><code class="code">CONCAT</code></td>
+ <td>Concatenate two varnodes.</td>
+ </tr>
+ <tr>
+ <td>SUBPIECE</td>
+ <td><code class="code">SUB</code></td>
+ <td>Extract a subset of bytes.</td>
+ </tr>
+ <tr>
+ <td>POPCOUNT</td>
+ <td><code class="code">POPCOUNT</code></td>
+ <td>Count the 1 bits.</td>
+ </tr>
+ <tr>
+ <td>INT_EQUAL</td>
+ <td><code class="code">==</code></td>
+ <td>True if input varnodes are equal.</td>
+ </tr>
+ <tr>
+ <td>INT_NOTEQUAL</td>
+ <td><code class="code">!=</code></td>
+ <td>True if input varnodes are not equal.</td>
+ </tr>
+ <tr>
+ <td>INT_LESS</td>
+ <td>
+<code class="code">&lt;</code> or <code class="code">&gt;</code>
+</td>
+ <td>True if one varnode is less than the other as unsigned integers.</td>
+ </tr>
+ <tr>
+ <td>INT_SLESS</td>
+ <td>
+<code class="code">&lt;</code> or <code class="code">&gt;</code>
+</td>
+ <td>True if one varnode is less than the other as signed integers.</td>
+ </tr>
+ <tr>
+ <td>INT_LESSEQUAL</td>
+ <td>
+<code class="code">&lt;=</code> or <code class="code">&gt;=</code>
+</td>
+ <td>True if one varnode is less than or equal to the other as unsigned integers.</td>
+ </tr>
+ <tr>
+ <td>INT_SLESSEQUAL</td>
+ <td>
+<code class="code">&lt;=</code> or <code class="code">&gt;=</code>
+</td>
+ <td>True if one varnode is less than or equal to the other as signed integers.</td>
+ </tr>
+ <tr>
+ <td>INT_ZEXT</td>
+ <td><code class="code">ZEXT</code></td>
+ <td>Zero extension.</td>
+ </tr>
+ <tr>
+ <td>INT_SEXT</td>
+ <td><code class="code">SEXT</code></td>
+ <td>Signed extension.</td>
+ </tr>
+ <tr>
+ <td>INT_ADD</td>
+ <td><code class="code">+</code></td>
+ <td>Add as integers.</td>
+ </tr>
+ <tr>
+ <td>INT_SUB</td>
+ <td><code class="code">-</code></td>
+ <td>Subtract as integers.</td>
+ </tr>
+ <tr>
+ <td>INT_CARRY</td>
+ <td><code class="code">CARRY</code></td>
+ <td>True if adding produces an unsigned carry.</td>
+ </tr>
+ <tr>
+ <td>INT_SCARRY</td>
+ <td><code class="code">SCARRY</code></td>
+ <td>True if adding produces a signed carry.</td>
+ </tr>
+ <tr>
+ <td>INT_SBORROW</td>
+ <td><code class="code">SBORROW</code></td>
+ <td>True if subtracting produces a signed borrow.</td>
+ </tr>
+ <tr>
+ <td>INT_2COMP</td>
+ <td><code class="code">-</code></td>
+ <td>Twos complement.</td>
+ </tr>
+ <tr>
+ <td>INT_NEGATE</td>
+ <td><code class="code">~</code></td>
+ <td>Bitwise negation.</td>
+ </tr>
+ <tr>
+ <td>INT_XOR</td>
+ <td><code class="code">^</code></td>
+ <td>Bitwise exclusive-or.</td>
+ </tr>
+ <tr>
+ <td>INT_AND</td>
+ <td><code class="code">&amp;</code></td>
+ <td>Bitwise logical-and.</td>
+ </tr>
+ <tr>
+ <td>INT_OR</td>
+ <td><code class="code">|</code></td>
+ <td>Bitwise logical-or.</td>
+ </tr>
+ <tr>
+ <td>INT_LEFT</td>
+ <td><code class="code">&lt;&lt;</code></td>
+ <td>Left shift.</td>
+ </tr>
+ <tr>
+ <td>INT_RIGHT</td>
+ <td><code class="code">&gt;&gt;</code></td>
+ <td>Unsigned (logical) right shift.</td>
+ </tr>
+ <tr>
+ <td>INT_SRIGHT</td>
+ <td><code class="code">&gt;&gt;</code></td>
+ <td>Signed (arithmetic) right shift.</td>
+ </tr>
+ <tr>
+ <td>INT_MULT</td>
+ <td><code class="code">*</code></td>
+ <td>Integer multiplication.</td>
+ </tr>
+ <tr>
+ <td>INT_DIV</td>
+ <td><code class="code">/</code></td>
+ <td>Unsigned integer division.</td>
+ </tr>
+ <tr>
+ <td>INT_REM</td>
+ <td><code class="code">%</code></td>
+ <td>Unsigned remainder.</td>
+ </tr>
+ <tr>
+ <td>INT_SDIV</td>
+ <td><code class="code">/</code></td>
+ <td>Signed division.</td>
+ </tr>
+ <tr>
+ <td>INT_SREM</td>
+ <td><code class="code">%</code></td>
+ <td>Signed remainder.</td>
+ </tr>
+ <tr>
+ <td>BOOL_NEGATE</td>
+ <td><code class="code">!</code></td>
+ <td>Boolean negation.</td>
+ </tr>
+ <tr>
+ <td>BOOL_XOR</td>
+ <td><code class="code">^^</code></td>
+ <td>Boolean exclusive-or.</td>
+ </tr>
+ <tr>
+ <td>BOOL_AND</td>
+ <td><code class="code">&amp;&amp;</code></td>
+ <td>Boolean logical-and.</td>
+ </tr>
+ <tr>
+ <td>BOOL_OR</td>
+ <td><code class="code">||</code></td>
+ <td>Boolean logical-or.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_EQUAL</td>
+ <td><code class="code">==</code></td>
+ <td>True if inputs are equal as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_NOTEQUAL</td>
+ <td><code class="code">!=</code></td>
+ <td>True if inputs are not equal as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_LESS</td>
+ <td>
+<code class="code">&lt;</code> or <code class="code">&gt;</code>
+</td>
+ <td>True if one input is less than the other as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_LESSEQUAL</td>
+ <td>
+<code class="code">&lt;=</code> or <code class="code">&gt;=</code>
+</td>
+ <td>True if one input is less than or equal to the other as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_ADD</td>
+ <td><code class="code">+</code></td>
+ <td>Add as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_SUB</td>
+ <td><code class="code">-</code></td>
+ <td>Subtract as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_MULT</td>
+ <td><code class="code">*</code></td>
+ <td>Multiply as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_DIV</td>
+ <td><code class="code">/</code></td>
+ <td>Divide as floating-point numbers.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_NEG</td>
+ <td><code class="code">-</code></td>
+ <td>Negate a floating-point number.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_ABS</td>
+ <td><code class="code">ABS</code></td>
+ <td>Absolute value of a floating-point number.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_SQRT</td>
+ <td><code class="code">SQRT</code></td>
+ <td>Square root of a floating-point number.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_CEIL</td>
+ <td><code class="code">CEIL</code></td>
+ <td>Ceiling function.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_FLOOR</td>
+ <td><code class="code">FLOOR</code></td>
+ <td>Floor function.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_ROUND</td>
+ <td><code class="code">ROUND</code></td>
+ <td>Nearest integral value.</td>
+ </tr>
+ <tr>
+ <td>FLOAT_NAN</td>
+ <td><code class="code">NAN</code></td>
+ <td>True if input is not a valid floating-point number (NaN).</td>
+ </tr>
+ <tr>
+ <td>INT2FLOAT</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Convert integer to floating-point.</td>
+ </tr>
+ <tr>
+ <td>FLOAT2FLOAT</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Convert between different floating-point precisions.</td>
+ </tr>
+ <tr>
+ <td>TRUNC</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Convert floating-point to integer.</td>
+ </tr>
+ <tr>
+ <td>CPOOLREF</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Obtain constant pool value.</td>
+ </tr>
+ <tr>
+ <td>NEW</td>
+ <td><code class="code">new</code></td>
+ <td>Allocate an object or an array of objects.</td>
+ </tr>
+ <tr>
+ <td>MULTIEQUAL</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Compiler phi-node: merge values from multiple control-flow paths.</td>
+ </tr>
+ <tr>
+ <td>INDIRECT</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Indirect effect on a varnode.</td>
+ </tr>
+ <tr>
+ <td>CAST</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Copy a value, changing its data-type.</td>
+ </tr>
+ <tr>
+ <td>PTRADD</td>
+ <td><code class="code">+</code></td>
+ <td>Add an offset to a pointer.</td>
+ </tr>
+ <tr>
+ <td>PTRSUB</td>
+ <td>
+<code class="code">.</code> or <code class="code">-&gt;</code>
+</td>
+ <td>Dereference a subfield from a pointer.</td>
+ </tr>
+ <tr>
+ <td>INSERT</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Insert a bit-range.</td>
+ </tr>
+ <tr>
+ <td>EXTRACT</td>
+ <td><code class="code">&lt;na&gt;</code></td>
+ <td>Extract a bit-range.</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+ </div>
+ </div>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptInternalFunctions"></a>Internal Decompiler Functions</h4></div></div></div>
+
+ <p>
+ Certain p-code operations can show up in decompiler output that cannot be represented
+ as either an operator token, a cast operation, or other depiction that is natural to
+ the language. The decompiler generally tries to eliminate these, but this isn't always
+ possible. The decompiler resorts to a functional syntax for these kinds
+ of p-code operations, displaying them as if they were built-in functions for the language.
+ </p>
+ <div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SUB41(x,c)</code> - Truncation operation - SUBPIECE
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of the input operand 'x' in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The digit '1' indicates the size of the output value in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The parameter 'x' is the value being truncated.</li>
+<li class="listitem" style="list-style-type: disc">The parameter 'c' is the number of least significant bytes being truncated.</li>
+</ul></div>
+ <pre class="programlisting">
+ SUB42(0xaabbccdd,1) = 0xbbcc
+ </pre>
+ <p>
+ Extract a contiguous subset of the bytes from 'x'.
+ When 'c' is 0, the operation is a simple integer truncation.
+ </p>
+ <p>
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SUB41(x,0)</code>
+ truncates from a 4-byte integer to a 1-byte (<span class="bold"><strong>char</strong></span>
+ or <span class="bold"><strong>byte</strong></span>) integer.
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SUB42(x,0)</code>
+ truncates from a 4-byte integer to a 2-byte (<span class="bold"><strong>short</strong></span>) integer.
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SUB84(x,4)</code> extracts the high 4 bytes from the 8 byte integer.
+ </li>
+</ul></div>
+<p>
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">CONCAT31(x,y)</code> - Concatenation operator - PIECE
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">The digit '3' indicates the size of the input operand 'x' in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The digit '1' indicates the size of the input operand 'y' in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The parameters 'x' and 'y' hold the values being concatenated.</li>
+</ul></div>
+ <pre class="programlisting">
+ CONCAT31(0xaabbcc,0xdd) = 0xaabbccdd
+ </pre>
+ <p>
+ Concatenate the bytes in 'x' with the bytes in 'y'. 'x' becomes the most significant
+ bytes, and 'y' the least significant bytes, in the result.
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">ZEXT14(x)</code> - Zero-extension operator - INT_ZEXT
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">The digit '1' indicates the size of the input operand 'x' in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of the output in bytes.</li>
+</ul></div>
+ <pre class="programlisting">
+ ZEXT24(0xaabb) = 0x0000aabb
+ </pre>
+ <p>
+ Extend the operand 'x' to a larger size by appending zero bytes, which become the most
+ significant bytes of the result.
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SEXT14(x)</code> - Sign-extension operator - INT_SEXT
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">The digit '1' indicates the size of the input operand 'x' in bytes.</li>
+<li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of the output in bytes.</li>
+</ul></div>
+ <pre class="programlisting">
+ SEXT48(0xaabbccdd) = 0xffffffffaabbccdd
+ </pre>
+ <p>
+ Extend the operand 'x' to a larger size by duplicating the <span class="emphasis"><em>sign</em></span>
+ bit of 'x' into the most significant bytes of the result.
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SBORROW4(x,y)</code> - Test for signed borrow operator - INT_SBORROW
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of both input operands 'x' and 'y' in bytes.</li></ul></div>
+ <p>
+ Return <span class="emphasis"><em>true</em></span> if there is an arithmetic overflow when subtracting 'y' from 'x'
+ as signed integers.
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">CARRY4(x,y)</code> - Test for unsigned overflow operator - INT_CARRY
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of both input operands 'x' and 'y' in bytes.</li></ul></div>
+ <p>
+ Return <span class="emphasis"><em>true</em></span> if there is an arithmetic overflow when adding 'x' and 'y'
+ as unsigned integers.
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <code class="code">SCARRY4(x,y)</code> - Test for signed overflow operator - INT_SCARRY
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; "><li class="listitem" style="list-style-type: disc">The digit '4' indicates the size of both input operands 'x' and 'y' in bytes.</li></ul></div>
+ <p>
+ Return <span class="emphasis"><em>true</em></span> if there is an arithmetic overflow when adding 'x' and 'y'
+ as signed integers.
+ </p>
+ </li>
+</ul></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="ConceptHighFunction"></a>The HighFunction</h2></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>HighFunction</strong></span> is the collection of specific information
+ produced by the decompiler about a function, referring to the root class in the Ghidra
+ source which holds this information.
+ The HighFunction is made up of the following explicit objects:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ A <span class="bold"><strong>control-flow</strong></span> representation of the function
+ in terms of <span class="emphasis"><em>basic blocks</em></span>.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ A <span class="bold"><strong>data-flow</strong></span> representation of the function
+ in terms of <span class="emphasis"><em>varnodes</em></span> and <span class="emphasis"><em>p-code operations</em></span>.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ A <span class="bold"><strong>symbol-table</strong></span> of variables accessed by the function.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The decompiler's output provides a standalone view of the function which is distinct
+ from any annotations about the function that are present in the Program database
+ and displayed in the Listing view (although the output may be informed by these annotations).
+ The terms <span class="emphasis"><em>HighFunction</em></span>, <span class="emphasis"><em>HighVariable</em></span>, and
+ <span class="emphasis"><em>HighSymbol</em></span> refer to this decompiler specific view of the function.
+ </p>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptHighSymbol"></a>HighSymbol</h3></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>HighSymbol</strong></span> is one of the explicit symbols recovered by the
+ decompiler. It is made up of a name and data-type and can describe either:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ a formal <span class="bold"><strong>parameter</strong></span> of the function,
+ </li>
+<li class="listitem" style="list-style-type: none">
+ a <span class="bold"><strong>local variable</strong></span> of the function, or
+ </li>
+<li class="listitem" style="list-style-type: none">
+ a <span class="bold"><strong>global variable</strong></span> accessed by the function.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ An important aspect of HighSymbols is that they are distinct from
+ the standard Ghidra symbols stored in the Program database and are part of
+ the decompiler's separate view of the function. When the decompiler displays
+ declarations for symbols in its output for instance, it is displaying
+ HighSymbols, which may not directly match up with database symbols.
+ The decompiler is generally
+ <span class="emphasis"><em>informed</em></span> by annotations in the database and may
+ copy specific symbols from the database into its view, but it is
+ generally free to invent new symbols discovered during its analysis.
+ </p>
+ <p>
+ Various actions within Ghidra allow the user to <span class="emphasis"><em>commit</em></span>
+ specific HighSymbols to the database as a permanent annotation, but this
+ does not happen by default.
+ </p>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptVarnodeSSA"></a>Varnodes in the Decompiler</h3></div></div></div>
+
+ <p>
+ Varnodes are the central <span class="emphasis"><em>variable</em></span> concept for the decompiler.
+ They form the individual nodes in the decompiler's data-flow representation
+ of functions and are used during all stages of analysis. During the initial stages
+ of analysis, varnodes simply represent specific storage locations that are accessed
+ in sequence by individual p-code operations. The decompiler immediately converts
+ the p-code into a graph based data-flow representation, called Static Single
+ Assignment (SSA) form. In this form, the varnodes take on some additional attributes.
+ </p>
+ <p>
+ In SSA form, each write of an operation to a storage location defines a new varnode.
+ Write operations at different points in the code to the same storage location, still
+ produce different varnodes. In this context, each varnode has a <span class="emphasis"><em>lifetime</em></span>
+ or <span class="emphasis"><em>scope</em></span> within the function. The scope starts at:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <p>
+ The <span class="bold"><strong>defining</strong></span> p-code operation which has the
+ varnode as its output. <span class="emphasis"><em>Or</em></span>
+ </p>
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <p>
+ The beginning of the function, if the varnode is an <span class="bold"><strong>input</strong></span>
+ to the function.
+ </p>
+ </li>
+</ul></div>
+ </div>
+<p>
+ The scope extends via control-flow to each p-code operation that <span class="emphasis"><em>reads</em></span> the
+ specific varnode as an operand. The value of the varnode between the definining p-code operation
+ and the reading operations does not change. The scope of a varnode can be thought of as a set
+ of addresses within the function's body connected by control-flow. The address of the defining
+ p-code operation is referred to as the varnode's <span class="bold"><strong>first use point</strong></span>
+ or <span class="bold"><strong>first use offset</strong></span>.
+ </p>
+ <p>
+ In the decompiler output for a specific high-level language like C or Java,
+ a varnode still has a <span class="emphasis"><em>scope</em></span> and represents a variable
+ in the high-level language only across this connected region of the code.
+ A set of varnodes, with disjoint scopes, provides a complete
+ description of a high-level variable that can be written to at more than one point
+ in the function.
+ </p>
+ </div>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptHighVariable"></a>HighVariable</h3></div></div></div>
+
+ <p>
+ A <span class="bold"><strong>HighVariable</strong></span> is a set varnodes that, taken
+ together, represent the storage of an entire variable in the high-level language
+ being output by the decompiler. Each varnode describes where the variable's
+ value is stored across some section of code.
+ </p>
+ <p>
+ There is generally a one-to-one correspondence between HighVariables and
+ HighSymbols. HighVariables can be thought of as the detailed storage description
+ of the high-level variable, while the HighSymbol provides its name and data-type.
+ However, there are some technical caveats to this correspondence to keep in mind.
+ </p>
+ <p>
+ A HighVariable always describes <span class="emphasis"><em>explicit</em></span> manipulation of
+ data by instructions in the function. In some cases, a HighVariable may only describe part
+ of the storage for a HighSymbol. Particularly for structured or composite data-types, a
+ function may operate on different parts of the variable at different points of the code,
+ so a HighVariable may only encompass one field of the structure.
+ </p>
+ <p>
+ A symbol may be referenced in a function, but the symbol's value may not be explicitly
+ manipulated. Constant pointers may refer to variables either
+ on the stack or in main memory, but the variable's value is neither read nor written
+ within the function. In this case, the HighSymbol exists, but there
+ is no corresponding HighVariable.
+ </p>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptMerging"></a>Merging</h4></div></div></div>
+
+ <p>
+ <span class="bold"><strong>Merging</strong></span> is the part of the analysis process where
+ the decompiler decides what varnodes get grouped together to create the final
+ HighVariables in the output. Each varnode's scope (see the discussion in
+ <a class="xref" href="DecompilerConcepts.html#ConceptVarnodeSSA" title="Varnodes in the Decompiler">&#8220;Varnodes in the Decompiler&#8221;</a>) provides the fundamental restriction on this process.
+ Two varnodes cannot be merged if their scopes intersect. But this leaves a lot of
+ leeway in what varnodes <span class="emphasis"><em>can</em></span> be merged.
+ </p>
+ <p>
+ Certain varnodes must be merged; if they use the same storage but in different
+ control-flow paths that come together, for instance, or if it is explicitly
+ known that the varnodes must represent the same variable. This is referred
+ to as <span class="bold"><strong>forced merging</strong></span>.
+ </p>
+ <p>
+ The decompiler may also merge varnodes that could just as easily exist as separate
+ variables. This is called <span class="bold"><strong>speculative merging</strong></span>.
+ In addition to the intersection condition on varnode scopes, the decompiler only
+ speculatively merges variables that share the same data-type. Beyond this, the decompiler
+ prioritizes variable pairs that are read and written within the same instruction and
+ then pairs that are "near" each other in the control-flow of the function.
+ To a limited extent, users are able to control this kind of merging
+ (See <a class="xref" href="DecompilerWindow.html#ActionIsolate" title="Split Out As New Variable">&#8220;Split Out As New Variable&#8221;</a>).
+ </p>
+ </div>
+ </div>
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ConceptPrototypeModel"></a>Prototype Model</h3></div></div></div>
+
+ <p>
+ Functions in high-level languages manipulate symbols like parameters and return values that
+ are implicitly stored in a way that doesn't collide with other functions and variables. To
+ actually map these symbols to physical registers and memory locations, compilers establish a
+ <span class="emphasis"><em>calling convention</em></span> for the function.
+ Loosely, this is a set of memory resources, whether it is registers or stack locations,
+ and a procedure for sequentially assigning resources to parameters based on their properties.
+ A <span class="bold"><strong>prototype model</strong></span> is the formal object in Ghidra that represents
+ a calling convention and holds its specific rules and resource details.
+ </p>
+ <p>
+ Prototype models are architecture specific, and depending on the compiler, a single Program may make
+ use of multiple models. Subsequently, each distinct model has a name like <code class="code">__stdcall</code> or
+ <code class="code">__thiscall</code>. The decompiler makes use of the prototype model, as assigned to the function by the user or
+ discovered in some other way, when performing its analysis of parameters.
+ </p>
+ <p>
+ A prototype model is typically used as a whole and is assigned by name to individual functions. But some of
+ the sub-concepts of the model may be relevant to reverse engineers.
+ </p>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptPrototypeStorage"></a>Incoming and Outgoing Storage Locations</h4></div></div></div>
+
+ <p>
+ A formal input parameter is always assigned a specific memory location to hold its value coming into the function.
+ The storage location can be a register, a stack location, or other memory location. The storage
+ location may be reused later by other variables in the function; only the incoming value stored there is guaranteed
+ to be that of input parameter.
+ </p>
+ <p>
+ If the parameter
+ is stored on the stack, the storage location is viewed as a constant offset in the <span class="bold"><strong>stack</strong></span>
+ space, where the offset is relative to the incoming value of <span class="emphasis"><em>stack pointer</em></span>
+ (See the discussion in <a class="xref" href="DecompilerConcepts.html#ConceptAddressSpace" title="Address Space">&#8220;Address Space&#8221;</a>).
+ </p>
+ <p>
+ The <span class="emphasis"><em>return value</em></span> for the function, similarly, is stored at a single memory location. It
+ is guaranteed to be at that location only at points where the function is exited. There may be multiple exit
+ points, but they all share the same return value storage location.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptPrototypeUnaffected"></a>Unaffected</h4></div></div></div>
+
+ <p>
+ Prototype models can specify a set of <span class="bold"><strong>unaffected</strong></span>memory locations,
+ whose value must be <span class="emphasis"><em>preserved</em></span> across the function. I.e. each location
+ must hold the same value at a function's exit that it held coming into the function.
+ These encompass a calling convention's <span class="emphasis"><em>saved registers</em></span>, where a calling function
+ can store values it doesn't want to change unexpectedly, but also may include other registers that are
+ known not to change, like the stack pointer.
+ The decompiler uses the information to determine which locations can be safely propagated across
+ a sub-function.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ConceptPrototypeKilledByCall"></a>Killed by Call</h4></div></div></div>
+
+ <p>
+ In constrast to <span class="emphasis"><em>unaffected</em></span> memory locations, a prototype model may specify
+ <span class="bold"><strong>killed by call</strong></span> locations that are guaranteed <span class="emphasis"><em>not</em></span>
+ to be used to hold a value across the function.
+ </p>
+ </div>
+ </div>
+</div>
+
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">
+<a accesskey="p" href="DecompilerIntro.html">Prev</a>�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�<a accesskey="n" href="DecompilerAnnotations.html">Next</a>
+</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">Decompiler�</td>
+<td width="20%" align="center"><a accesskey="h" href="Decompiler.html">Home</a></td>
+<td width="40%" align="right" valign="top">�Program Annotations Affecting the Decompiler</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerIntro.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerIntro.html
new file mode 100644
index 0000000000..8ed405d946
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerIntro.html
@@ -0,0 +1,186 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Decompiler</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="up" href="Decompiler.html" title="Decompiler">
+<link rel="prev" href="Decompiler.html" title="Decompiler">
+<link rel="next" href="DecompilerConcepts.html" title="Decompiler Concepts">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Decompiler</th></tr>
+<tr>
+<td width="20%" align="left">
+<a accesskey="p" href="Decompiler.html">Prev</a>�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�<a accesskey="n" href="DecompilerConcepts.html">Next</a>
+</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="DecompilerIntro"></a>Decompiler</h1></div></div></div>
+
+<div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="100%"><tr><td align="center"><img src="images/DecompWindow.png" align="middle" width="990" height="387"></td></tr></table></div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="Overview"></a>Overview</h2></div></div></div>
+
+ <p>
+ The Decompiler plug-in is a sophisticated transformation engine
+ which automatically converts the binary representation of
+ individual functions into a high-level C representation. The
+ Decompiler presents a view of a program which is interactive and
+ dynamically updated as the user adds or makes changes to the
+ annotations associated with the program. A Decompiler window
+ maintains the correspondence between the C representation and the
+ assembly representation displayed in the Code Browser window, to
+ the extent possible. The window allows instant visual association
+ and navigation between C language expressions and their
+ corresponding assembly instructions.
+ </p>
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="EnablePlugin"></a>Enabling the Plug-in</h3></div></div></div>
+
+ <p>
+ The Decompiler is a full Plug-in within Ghidra and can be configured to be enabled or
+ disabled within any particular tool. Default configurations will have the
+ plug-in enabled, but if its disabled for some reason, it can be enabled from within
+ a Code Browser by selecting the menu option
+ </p>
+<div class="informalexample">
+ <span class="bold"><strong>File -&gt; Configure</strong></span>
+ </div>
+<p>
+ Then click on the <span class="emphasis"><em>Configure</em></span> link under the
+ <span class="bold"><strong>Ghidra Core</strong></span> section and check the box next to
+ <span class="bold"><strong>DecompilePlugin</strong></span>.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ShowWindow"></a>Showing the Decompiler Window</h3></div></div></div>
+
+ <p>
+ From the Code Browser, either:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ Press the <span class="guiicon"><img src="images/decompileFunction.gif"></span> icon
+ in the tool bar, <span class="emphasis"><em>or</em></span>
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ Select the <span class="bold"><strong>Decompile</strong></span> option from the
+ <span class="bold"><strong>Window</strong></span> menu.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The window automatically decompiles and displays the function at the
+ <span class="emphasis"><em>current address</em></span>. The address is set typically by left-clicking in the Listing window,
+ or invoking the <span class="emphasis"><em>Goto</em></span> command (pressing the 'g' key) and manually entering
+ the address or some other label, but the Decompiler window
+ follows any type of navigation in the Code Browser. Navigating to a new address
+ or making a change to the underlying Program causes the the window to (re)decompile and display
+ the new function.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="Capabilities"></a>Capabilities</h3></div></div></div>
+
+ <p>
+ Some of the primary capabilities of the decompiler include:
+
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Recovers Expressions</strong></span>: The
+ decompiler does full data-flow analysis which allows it to
+ perform slicing on functions. The most tangible benefit to the
+ user is that complicated expressions, which have been split into
+ distinct operations/instructions and then mixed together with
+ other instructions by the compiling/optimizing process, are
+ reconstituted into a single expression again by the decompiler.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Recovers High-Level Scoped
+ Variables</strong></span>: The decompiler understands how compilers
+ use processor stacks and registers to implement variables with
+ different scopes within a function. Data-flow allows it to
+ follow what was originally a single variable as it moves from
+ the stack, into a register, into a different register, etc. Thus
+ it can effectively recover the original programs concept of a
+ variable, minimizing the need to introduce artificial variables
+ in the output.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Recovers Function Parameters</strong></span>:
+ The decompiler understands the parameter passing conventions of
+ the compiler and can reconstruct the form of the original
+ function call.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Uses Data-type, Name, and Signature
+ Annotations</strong></span>: The decompiler automatically pulls in
+ all the different data types and variable names that the user
+ has applied to functions, and the C output is altered to reflect
+ this. High-level variables are appropriately named, structure
+ fields and array indices are calculated and displayed with
+ correct syntax, constant char pointers are replaced with
+ appropriate quoted strings, etc.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Performs Local Data-type
+ Propagation</strong></span>: In the absence of information, the
+ decompiler does its best to fill in information from what it
+ does know. Variables whose data-type has not been explicitly
+ labeled by the user can often by recovered by seeing how the
+ variable is used or by allowing the known data-types to
+ propagate.
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Can be used to Automatically Recover
+ Structure Fields</strong></span>: The decompiler can be leveraged to
+ recover references to a structure.
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+</div>
+</div>
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">
+<a accesskey="p" href="Decompiler.html">Prev</a>�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�<a accesskey="n" href="DecompilerConcepts.html">Next</a>
+</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">Decompiler�</td>
+<td width="20%" align="center"><a accesskey="h" href="Decompiler.html">Home</a></td>
+<td width="40%" align="right" valign="top">�Decompiler Concepts</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerOptions.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerOptions.html
new file mode 100644
index 0000000000..efc2897d14
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerOptions.html
@@ -0,0 +1,552 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Decompiler Options</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="up" href="Decompiler.html" title="Decompiler">
+<link rel="prev" href="DecompilerAnnotations.html" title="Program Annotations Affecting the Decompiler">
+<link rel="next" href="DecompilerWindow.html" title="Decompiler Window">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Decompiler Options</th></tr>
+<tr>
+<td width="20%" align="left">
+<a accesskey="p" href="DecompilerAnnotations.html">Prev</a>�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�<a accesskey="n" href="DecompilerWindow.html">Next</a>
+</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="DecompilerOptions"></a>Decompiler Options</h1></div></div></div>
+
+<div class="simplesect">
+<div class="titlepage"></div>
+ <p>
+ This lists configuration options that explicitly affect the behavior of the decompiler or
+ its output, independent of the code that is being decompiled. The bulk of these are
+ accessible by selecting the Code Browser menu
+ </p>
+<div class="informalexample">
+ <span class="bold"><strong>Edit -&gt; Tool Options</strong></span>
+ </div>
+<p>
+ and then picking the <span class="emphasis"><em>Decompiler</em></span> sub-folder. These options are associated
+ with the particular tool (Code Browser) being used and will apply to decompilation of any Program
+ being analyzed by that tool. The three categories of options are:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+<a class="xref" href="DecompilerOptions.html#GeneralOptions" title="General Options">&#8220;General Options&#8221;</a> affecting the engine behavior</li>
+<li class="listitem" style="list-style-type: disc">
+<a class="xref" href="DecompilerOptions.html#AnalysisOptions" title="Analysis Options">&#8220;Analysis Options&#8221;</a> affecting the decompiler's transformation process</li>
+<li class="listitem" style="list-style-type: disc">
+<a class="xref" href="DecompilerOptions.html#DisplayOptions" title="Display Options">&#8220;Display Options&#8221;</a> affecting the final presentation of decompiler output</li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ Another source of options can be accessed by selecting the Code Browser menu
+ </p>
+<div class="informalexample">
+ <span class="bold"><strong>Edit -&gt; Options for &lt;Program&gt;</strong></span>
+ </div>
+<p>
+ and the picking the <span class="emphasis"><em>Decompiler</em></span> tab. These <a class="xref" href="DecompilerOptions.html#ProgramOptions" title="Program Options">&#8220;Program Options&#8221;</a>
+ are specific to the particular Program being analyzed.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="GeneralOptions"></a>General Options</h2></div></div></div>
+
+ <p>
+ These options govern what resources are available to the Plug-in and the decompiler engine but do
+ not affect how analysis is performed or results are displayed.
+ </p>
+ <p>
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Cache Size (Functions)</strong></span></span></dt>
+<dd>
+ <p>
+ Decompilation results for a single function can be compute intensive to produce.
+ This option specifies the number of functions whose decompilation results
+ can be cached simultaneously. When navigating to a function that
+ has been recently cached, as when navigating back and forth between a few functions,
+ a new decompilation is not triggered.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Decompiler Max-Payload (MBytes)</strong></span></span></dt>
+<dd>
+ <p>
+ This is a limit on the number of bytes that can be produced by the decompiler process as output
+ when decompiling a single function. A payload includes the actual characters to be displayed in
+ the window, additional token markup, symbol information, and other details of the underlying
+ syntax tree. The limit is specified in megabytes of data. If the limit is exceeded for a single
+ function, decompilation is aborted for that function, and an error message
+ "Decompiler results exceeded payload limit ..." is displayed.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Decompiler Timeout (seconds)</strong></span></span></dt>
+<dd>
+ <p>
+ This option sets an upper limit on the number of seconds the decompiler spends attempting
+ to analyze one function before aborting.
+ It is currently <span class="bold"><strong>not</strong></span> enforced for the Decompilation
+ Window. Instead it applies to the DecompilerSwitchAnalyzer, the <code class="code">analyzeHeadless</code> command, scripts, or other
+ plug-ins that make use of the decompiler service.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="AnalysisOptions"></a>Analysis Options</h2></div></div></div>
+
+ <p>
+ These options directly affect how the decompiler performs its analysis, either by
+ toggling specific analysis passes or changing how it treats various annotations.
+ </p>
+ <p>
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Alias Blocking</strong></span></span></dt>
+<dd>
+ <p>
+ When deciding if an individual stack location has become dead, the decompiler
+ must consider <span class="emphasis"><em>aliases</em></span>, pointers onto the stack that could
+ be used to modify the location within a sub-function. One strong heuristic the decompiler
+ uses is; if the user has explicitly created a variable on the stack between the
+ base location referenced by the pointer and the individual stack location, then
+ the decompiler can assume that the pointer is not an alias of the stack location.
+ The alias is <span class="emphasis"><em>blocked</em></span> by the explicit variable.
+ However, if the user's explicit variable is labeling something that isn't
+ really an explicit variable, like a field within a larger structure for instance,
+ the decompiler may incorrectly consider the stack location as dead and start removing
+ live code.
+ </p>
+ <p>
+ In order to support the exploratory labeling of stack locations, the user can use this
+ setting to specify what data-types should be considered blocking. The four options are:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>None</strong></span> - No data-type is considered blocking.</li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Structures</strong></span> - Only structured data-types are blocking.</li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Structures and Arrays</strong></span></li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>All Data-types</strong></span> - All data-types are blocking.</li>
+</ul></div>
+ </div>
+<p>
+ Selecting <span class="emphasis"><em>None</em></span> is the equivalent of turning off the heuristic. Selecting anything
+ except <span class="emphasis"><em>All Data-types</em></span> allows users to safely label small variables without
+ knowing immediately if the stack location is part of a larger structure or array.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Eliminate unreachable code</strong></span></span></dt>
+<dd>
+ <p>
+ When this is toggled <span class="emphasis"><em>on</em></span>, the decompiler eliminates code that it
+ considers unreachable. This usually happens when, due to constant propagation and other
+ analysis, the decompiler decides that a boolean value controlling a conditional branch can
+ only take one possible value and removes the branch corresponding to the other value. Toggling
+ this to <span class="emphasis"><em>off</em></span> lets the user see the dead code, which is typically demarcated
+ by the control-flow structure -- <code class="code">if (false) { ... }</code>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Ignore unimplemented instructions</strong></span></span></dt>
+<dd>
+ <p>
+ When toggled <span class="emphasis"><em>on</em></span>, the decompiler treats instructions whose semantics
+ have been formally marked <span class="bold"><strong>unimplemented</strong></span> as if they do
+ nothing (no operation). Crucially, control-flow falls through to the next instruction.
+ In this case, the decompiler inserts the warning "Control flow ignored unimplemented
+ instructions" as a comment in the function header, but the exact point at which
+ instruction was ignored may not be clear.
+ If this option is toggled <span class="emphasis"><em>off</em></span>, the decompiler inserts the built-in
+ function <code class="code">halt_unimplemented()</code> at the point of the unimplemented instruction, and
+ control-flow does not fall through.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Infer constant pointers</strong></span></span></dt>
+<dd>
+ <p>
+ When toggled <span class="emphasis"><em>on</em></span>, the decompiler infers a data-type for constants
+ it determines are likely pointers. In the basic heuristic,
+ each constant is considered as an address, and if that address starts a known data or function element
+ in the program, the constant is assumed to be a pointer. The constants are treated like
+ any other source of data-type information, and the inferred data-types are freely propagated by
+ the decompiler to other parts of the function.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Respect read-only flags</strong></span></span></dt>
+<dd>
+ <p>
+ When toggled <span class="emphasis"><em>on</em></span>, the decompiler treats any values in memory
+ marked <span class="emphasis"><em>read-only</em></span> as constant. If a read-only memory location is explicitly
+ referenced by the function being decompiled, it is considered to be unchanging, and the initial
+ value present in the Program is pulled in to the data-flow of the function as a constant.
+ Due to <span class="emphasis"><em>Constant Propagation</em></span> and other transformations, read-only memory
+ can have a large effect on decompiler output.
+ </p>
+ <p>
+ Typically as part of the import process, Ghidra marks memory blocks as read-only if they
+ are tagged as such by a section header or other meta-data in the original binary.
+ Users can actively set whether specific memory regions are considered read-only through the
+ <span class="emphasis"><em>Memory Manager</em></span>, and individual data elements can be marked
+ as <span class="emphasis"><em>constant</em></span> via the <span class="bold"><strong>Mutability</strong></span> setting
+ (See <a class="xref" href="DecompilerAnnotations.html#AnnoteMutability" title="Data Mutability">&#8220;Data Mutability&#8221;</a>).
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Simplify extended integer operations</strong></span></span></dt>
+<dd>
+ <p>
+ This toggles whether the decompiler attempts to simplify double precision arithmetic operations,
+ where a single logical operation is split into two parts, calculating the high and low pieces
+ of the result in separate instructions. Decompiler support for this kind of transform is currently
+ limited, and only certain constructions are simplified.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Simplify predication</strong></span></span></dt>
+<dd>
+ <p>
+ When this option is active, the decompiler simplifies code sequences containing
+ <span class="emphasis"><em>predicated</em></span> instructions. A predicated instruction is executed
+ conditionally based on a boolean value, the <span class="bold"><strong>predicate</strong></span>,
+ and a sequence of instructions can share the same predicate. The decompiler merges the
+ resulting <code class="code">if/else</code> blocks that share the same predicate so that the condition is only
+ printed once.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Use in-place assignment operators</strong></span></span></dt>
+<dd>
+ <p>
+ When toggled <span class="emphasis"><em>on</em></span>, the decompiler employs in-place assignment operators,
+ such as <code class="code">+=</code> and <code class="code">&lt;&lt;=</code>, in its output syntax.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="DisplayOptions"></a>Display Options</h2></div></div></div>
+
+ <p>
+ These options do not change the decompiler's analysis but only affect how the results are presented.
+ </p>
+ <p>
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Background Color</strong></span></span></dt>
+<dd>
+ <p>
+ Assign the background color for the Decompiler window.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Color for &lt;token&gt;</strong></span></span></dt>
+<dd>
+ <p>
+ Assign colors to the different types of language tokens emitted by the decompiler.
+ These include:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Comments</strong></span></li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Constants</strong></span> - including integer, floating-point, character, and string</li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Functions names</strong></span></li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Globals</strong></span> - names of variables with global scope</li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Keywords</strong></span> - reserved names in the language being emitted</li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Parameters</strong></span> - names of function input variables</li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Types</strong></span> - names of data-types in variable declarations and casts</li>
+<li class="listitem" style="list-style-type: disc">
+<span class="bold"><strong>Variables</strong></span> - names of local variables</li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Color Default</strong></span></span></dt>
+<dd>
+ <p>
+ Assign the color to any characters emitted by the decompiler that do not fall into one of token types
+ listed above. This includes delimiter characters like commas and parantheses as well as various <span class="emphasis"><em>operator</em></span>
+ characters.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Color for Current Variable Highlight</strong></span></span></dt>
+<dd>
+ <p>
+ Assign the background color used to highlight the token currently under the cursor in a Decompiler Window.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Color for Highlighting Find Matches</strong></span></span></dt>
+<dd>
+ <p>
+ Assign the background color used to highlight characters matching the current <span class="emphasis"><em>Find</em></span> pattern.
+ See <a class="xref" href="DecompilerWindow.html#ActionFind" title="Find ...">&#8220;Find ...&#8221;</a>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Comment line indent level</strong></span></span></dt>
+<dd>
+ <p>
+ Set the number of characters that comment lines are indented within decompiler output. This applies only
+ to comments within the body of the function being displayed. Comments at the head of the function
+ are not indented.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Comment style</strong></span></span></dt>
+<dd>
+ <p>
+ Set the language syntax used to delimit comments emitted as part of decompiler output. For C and Java,
+ the choices are <code class="code">/* C style comments */</code> and <code class="code">// C++ style comments</code>.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Disable printing of type casts</strong></span></span></dt>
+<dd>
+ <p>
+ Set whether the syntax for <span class="emphasis"><em>type casts</em></span> is emitted in decompiler output.
+ If this is toggled on, type cast syntax is never displayed, even when rules of the language
+ require it. So individual statements may no longer be formally accurate.
+ </p>
+ </dd>
+<dt>
+<a name="CommentOptions"></a><span class="term"><span class="bold"><strong>Display &lt;kind-of&gt; Comments</strong></span></span>
+</dt>
+<dd>
+ <p>
+ Set whether a specific kind of comment can be incorporated into decompiler output. Comments in
+ Ghidra are categorized based on their placement within the Listing Window, and the decompiler
+ in general tries to display comments where appropriate. See the discussion in <a class="xref" href="DecompilerAnnotations.html#AnnoteComments" title="Comments">&#8220;Comments&#8221;</a>.
+ Each kind of comment has its own toggle and can be individually included or excluded from decompiler output.
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>PLATE</strong></span> - Whether plate comments <span class="emphasis"><em>within the body of the function</em></span> are displayed
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>PRE</strong></span>
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>POST</strong></span>
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>EOL</strong></span>
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Display Header comment</strong></span></span></dt>
+<dd>
+ <p>
+ Toggle whether the decompiler emits comments at the head (before the beginning) of a function.
+ The header is built from Plate comments placed at the <span class="emphasis"><em>entry point</em></span> of the
+ function. See the discussion in <a class="xref" href="DecompilerAnnotations.html#AnnoteComments" title="Comments">&#8220;Comments&#8221;</a>.
+ The inclusion of other Plate comments is controlled by the <span class="bold"><strong>Display PLATE comments</strong></span> toggle, described above.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Display Line Numbers</strong></span></span></dt>
+<dd>
+ <p>
+ Toggle whether line numbers are displayed in any Decompiler Window. If toggled
+ on, each Decompiler Window reserves space to display a numbers down the left
+ side of the window, labeling each line of output produced by the decompiler.
+ Line numbers are associated with the window itself and are not formally part of
+ the decompiler's output.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Display Namespaces</strong></span></span></dt>
+<dd>
+ <p>
+ Control how the decompiler displays namespace information associated
+ with function and variable symbols. The possible settings are:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Always</strong></span> - Always display the entire namespace path
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Never</strong></span> - Never display the namespace path
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Minimally</strong></span> - Display the minimal path that distinguishes the symbol
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The <span class="bold"><strong>Minimally</strong></span> setting, which is the default, will only emit the portion
+ of the namespace path necessary to distinguish the symbol from other symbols with the same base name used
+ by the function, or if a portion of the path is completely outside the function's scope.
+ </p>
+ <p>
+ The <span class="bold"><strong>Never</strong></span> setting never displays any of the namespace path under any
+ circumstances and may produce output that is ambiguous and doesn't formally parse.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Display Warning comments</strong></span></span></dt>
+<dd>
+ <p>
+ Toggle whether decompiler generated <span class="emphasis"><em>WARNING</em></span> comments are displayed as part
+ of the output. The decompiler generates these comments, independent of those layed down by users, to
+ indicate unusual conditions or possible errors (See <a class="xref" href="DecompilerAnnotations.html#CommentWarnings" title="Warning Comments">&#8220;Warning Comments&#8221;</a>).
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Font</strong></span></span></dt>
+<dd>
+ <p>
+ Set the typeface used to render characters in any Decompiler Window. Indentation is generally clearer
+ using a monospaced (fixed width) font, but any font available to the system can be used. The size of
+ the font can also be controlled from this option.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Integer format</strong></span></span></dt>
+<dd>
+ <p>
+ Set how integer constants are formatted in the decompiler output.
+ The possible settings are:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Best Fit</strong></span> - Select the most <span class="emphasis"><em>natural</em></span> representation
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Force Decimal</strong></span> - Always use a decimal representation
+ </li>
+<li class="listitem" style="list-style-type: disc">
+ <span class="bold"><strong>Force Hexadecimal</strong></span> - Always use a hexadecimal representation
+ </li>
+</ul></div>
+ </div>
+<p>
+ For <span class="bold"><strong>Best Fit</strong></span>, a representation is selected based on how
+ close it is to either a <span class="emphasis"><em>round</em></span> decimal value (10, 100, 1000, etc.) or
+ a round hexadecimal value (0x10, 0x100, 0x1000, etc.)
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Maximum characters in a code line</strong></span></span></dt>
+<dd>
+ <p>
+ Set the maximum number of characters in a line of code emitted by the decompiler before a line break
+ is forced. The decompiler will not split an individual token across lines. So line breaks frequently
+ will come before the maximum number of characters is reached, and technically a single token can
+ extend the line beyond the maximum.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Number of characters per indent level</strong></span></span></dt>
+<dd>
+ <p>
+ Set the amount of indenting used to print statements within a nested scope in the
+ decompiler output. Each level of nesting (for function bodies,
+ loop bodies, <span class="bold"><strong>if/else</strong></span> bodies, etc.)
+ bodies adds this number characters.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Print 'NULL' for null pointers</strong></span></span></dt>
+<dd>
+ <p>
+ Set how null pointers are displayed in decompiler output. If this is toggled
+ on, the decompiler will print a constant pointer value of zero (a <span class="bold"><strong>null</strong></span> pointer)
+ using the special token <code class="code">NULL</code>. Otherwise the pointer value is represented with the '0' character,
+ which is then type cast into a pointer.
+ </p>
+ </dd>
+<dt><span class="term"><span class="bold"><strong>Print calling convention name</strong></span></span></dt>
+<dd>
+ <p>
+ Set whether the <span class="emphasis"><em>calling convention</em></span> is printed as part of the function
+ declaration in decompiler output. If this option is turned on, the name of the calling convention
+ is printed just prior to the return value data-type within the function declaration. All functions
+ in Ghidra have an associated calling convention (or prototype model) that is used during
+ decompiler analysis. See the discussion in <a class="xref" href="DecompilerConcepts.html#ConceptPrototypeModel" title="Prototype Model">&#8220;Prototype Model&#8221;</a>.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="ProgramOptions"></a>Program Options</h2></div></div></div>
+
+ <p>
+ Changes to these options affect only the current Program being analyzed.
+ </p>
+ <p>
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt>
+<a name="OptionProtoEval"></a><span class="term"><span class="bold"><strong>Prototype Evaluation</strong></span></span>
+</dt>
+<dd>
+ <p>
+ Sets the calling convention (prototype model) used when decompiling a function where
+ the convention is not known (i.e. marked as "unknown"). Many architectures have multiple
+ calling conventions, <code class="code">__stdcall</code>, <code class="code">__thiscall</code> etc. See the
+ discussion in <a class="xref" href="DecompilerConcepts.html#ConceptPrototypeModel" title="Prototype Model">&#8220;Prototype Model&#8221;</a>.
+ </p>
+ </dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+</div>
+
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">
+<a accesskey="p" href="DecompilerAnnotations.html">Prev</a>�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�<a accesskey="n" href="DecompilerWindow.html">Next</a>
+</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">Program Annotations Affecting the Decompiler�</td>
+<td width="20%" align="center"><a accesskey="h" href="Decompiler.html">Home</a></td>
+<td width="40%" align="right" valign="top">�Decompiler Window</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerWindow.html b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerWindow.html
new file mode 100644
index 0000000000..d4795ab6a3
--- /dev/null
+++ b/Ghidra/Features/Decompiler/src/main/help/help/topics/DecompilePlugin/DecompilerWindow.html
@@ -0,0 +1,1154 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Decompiler Window</title>
+<link rel="stylesheet" type="text/css" href="../../shared/Frontpage.css">
+<link rel="stylesheet" type="text/css" href="../../shared/languages.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
+<link rel="home" href="Decompiler.html" title="Decompiler">
+<link rel="up" href="Decompiler.html" title="Decompiler">
+<link rel="prev" href="DecompilerOptions.html" title="Decompiler Options">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<div class="navheader">
+<table width="100%" summary="Navigation header">
+<tr><th colspan="3" align="center">Decompiler Window</th></tr>
+<tr>
+<td width="20%" align="left">
+<a accesskey="p" href="DecompilerOptions.html">Prev</a>�</td>
+<th width="60%" align="center">�</th>
+<td width="20%" align="right">�</td>
+</tr>
+</table>
+<hr>
+</div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="DecompilerWindow"></a>Decompiler Window</h1></div></div></div>
+
+ <p>
+ To display the decompiler window, position the cursor on a
+ function in the Code Browser, then select the
+ <span class="guiicon"><img src="images/decompileFunction.gif"></span> icon from the tool bar, or the
+ <span class="bold"><strong>Decompile</strong></span> option from the
+ <span class="bold"><strong>Window</strong></span> menu in the tool.
+ </p>
+ <p>
+ A decompiler window always displays one <span class="emphasis"><em>function</em></span> at a time.
+ The initial window that comes up in the Code Browser is called the <span class="bold"><strong>Main</strong></span>
+ window (See <a class="xref" href="DecompilerWindow.html#MainWindow" title="Main Window">&#8220;Main Window&#8221;</a>), and it automatically decompiles and displays the function at the
+ <span class="emphasis"><em>current address</em></span>, following the user's navigation. Other
+ <span class="bold"><strong>Snapshot</strong></span> windows can also
+ be opened that show different functions at the same time (See <a class="xref" href="DecompilerWindow.html#Snapshot" title="Snapshot Windows">&#8220;Snapshot Windows&#8221;</a>). But any window
+ only shows one function at a time.
+ </p>
+ <p>
+ Decompilation for a window is performed "on-the-fly". It automatically
+ incorporates the most recent labels, data-types, comments, and other annotations applied by the user. Any change
+ to the Program annotations (renaming, setting data-types, etc.) automatically causes each window to redecompile
+ its function.
+ </p>
+ <p>
+ The time it takes to decompile a single function is generally proportional to the number of instructions that make
+ up the body of the function. Large functions may require a significant amount of time to decompile, and because
+ decompilation is performed on-the-fly, closing a window or navigating away from a function
+ runs the risk of losing results that took a long time to compute.
+ </p>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="DecompilerDisplay"></a>Display</h2></div></div></div>
+
+ <p>
+ The window shows the decompiled output for the function associated with the window in C or some other
+ high-level programming language. The output is tokenized following conventions of the language. Possible
+ token types include:
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist compact" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Data-type Name</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Variable Name</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Variable Sub-field Name</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Function Name</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Operator</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Label</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Comment</strong></span></li>
+<li class="listitem" style="list-style-type: disc"><span class="bold"><strong>Syntax</strong></span></li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ The type of token provides context for the pop-up menus, which can trigger
+ highlighting, navigation, renaming, and other actions within the window.
+ </p>
+
+ <p>
+ If the window starts to decompile but ultimately fails to complete the decompilation, due
+ to an error or cancellation, it displays a brief description of what caused the failure
+ instead of the normal output. Decompilation may also successfully produce output but issue
+ one or more warnings during the process. These warnings are integrated into the output as
+ source code comments starting with label <code class="code">WARNING:</code>. They occur either at the
+ beginning of the function as part of the function header or at the point in the code directly
+ associated with the warning. (See <a class="xref" href="DecompilerAnnotations.html#CommentWarnings" title="Warning Comments">&#8220;Warning Comments&#8221;</a>)
+ </p>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="MainWindow"></a>Main Window</h2></div></div></div>
+
+ <p>
+ Initially pushing <span class="guiicon"><img src="images/decompileFunction.gif"></span> or selecting
+ <span class="bold"><strong>Decompile</strong></span> from <span class="bold"><strong>Window</strong></span> menu in the tool
+ brings up the <span class="emphasis"><em>main</em></span> window. The main window always displays the function
+ at the <span class="emphasis"><em>current address</em></span> within the Code Browser and follows as the user navigates
+ within the Program. Any mouse click, menu option, or other action causing the cursor to move to a new
+ address in the Listing also causes the main window to display the function containing that address.
+ Navigation to new functions is also possible from within the window by double-clicking on function
+ tokens (See <a class="xref" href="DecompilerWindow.html#MouseActions" title="Mouse Actions">&#8220;Mouse Actions&#8221;</a>).
+ </p>
+
+ <div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="CrossHighlighting"></a>Cross Highlighting</h3></div></div></div>
+
+ <p>
+ The main window maintains a map between the individual variable and operator tokens displayed in
+ the window and the machine instructions which correspond to them. This can give the user instant
+ feedback about the correspondence between the decompiler and disassembly views of the function,
+ and it is frequently useful to have both the Listing window and the Decompiler window side
+ by side. Clicking on tokens in the Decompiler window causes the Listing window to navigate
+ to the corresponding instruction, and clicking instructions in the Listing window
+ causes the Decompiler window to navigate to the corresponding line. Highlighting a region of
+ code in either window causes the corresponding region in the other window to be highlighted.
+ </p>
+ <p>
+ <span class="emphasis"><em>Variable Name</em></span> and <span class="emphasis"><em>Variable Sub-field Name</em></span> tokens
+ map to the machine instruction which wrote to the variable at that point in function.
+ </p>
+ <p>
+ <span class="emphasis"><em>Operator</em></span> tokens map to the machine instruction which performed that operation.
+ </p>
+ <p>
+ <span class="emphasis"><em>Function Name</em></span> tokens, if they represent a call to a sub-function, map to the
+ machine instruction executing the call.
+ </p>
+ <p>
+ <span class="emphasis"><em>Comment</em></span> tokens map to the machine address associated with the comment.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ In general, the map between machine instructions and tokens is not one to one because the decompiler
+ transforms its underlying representation of the function.
+ An instruction may no longer have any operator that corresponds to it in the decompiled result.
+ Tokens may be transformed from the natural operation of the machine instruction they are associated
+ with or may represent the effect of multiple instructions.
+ </td></tr>
+</table></div>
+ </div>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="Snapshot"></a>Snapshot Windows</h2></div></div></div>
+
+ <p>
+ Pressing the <span class="guiicon"><img src="images/camera-photo.png"></span>
+ icon in another Decompiler window's toolbar causes a <span class="emphasis"><em>Snapshot</em></span> window
+ to be created, which initially shows decompilation of the same function. Multiple
+ Snapshot windows can be brought up to show decompilation of different functions
+ simultaneously. Snapshot
+ windows are visually distinguished from the <span class="emphasis"><em>main</em></span> Decompiler window
+ by their colored outline.
+ </p>
+ <p>
+ The Snapshot
+ window, unlike the <span class="emphasis"><em>main</em></span> window, is not linked to the Listing window
+ and does not change the function it displays in response to external navigation events.
+ A Snapshot window can be used to hold a function fixed while the user navigates to
+ different functions in the Listing or other windows.
+ </p>
+ <p>
+ Navigating to new functions within a Snapshot window is possible when the window is
+ <span class="emphasis"><em>active</em></span>. The window responds to the actions
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: bullet; ">
+<li class="listitem" style="list-style-type: disc">Go To ... <span class="emphasis"><em>(pressing the 'g' key)</em></span>
+</li>
+<li class="listitem" style="list-style-type: disc">Go to previous location <span class="emphasis"><em>(Back)</em></span>
+</li>
+<li class="listitem" style="list-style-type: disc">Go to next location <span class="emphasis"><em>(Forward)</em></span>
+</li>
+</ul></div>
+ </div>
+<p>
+ </p>
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="ToolBar"></a>Tool Bar</h2></div></div></div>
+
+ <p>
+ This is a group of actions that can be triggered by pressing a button in the tool/title
+ bar at the top of individual decompiler windows, both <span class="emphasis"><em>main</em></span> and
+ <span class="emphasis"><em>Snapshot</em></span>. The action applies to the function and decompiler results
+ displayed in that particular window.
+ </p>
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarExport"></a>Export to C</h3></div></div></div>
+
+ <p>
+ <span class="guiicon"><img src="images/page_edit.png"></span> - button
+ </p>
+ <p>
+ Exports the decompiled result of the current function to a file. A file chooser
+ dialog is displayed to select the name of the output file. If a file extension
+ is not specified, a ".c" is appended to the filename. If the file already exists,
+ a final dialog is presented to confirm that the file should be overwritten.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarSnapshot"></a>Snapshot</h3></div></div></div>
+
+ <p>
+ <span class="guiicon"><img src="images/camera-photo.png"></span> - button
+ </p>
+ <p>
+ Creates a new <span class="emphasis"><em>Snapshot</em></span> window. The <span class="emphasis"><em>Snapshot</em></span> window
+ initially displays the same function as the decompiler window on which the action was triggered,
+ but if that window navigates to other functions, the <span class="emphasis"><em>Snapshot</em></span> does not
+ follow and continues to display the original function. (See <a class="xref" href="DecompilerWindow.html#Snapshot" title="Snapshot Windows">&#8220;Snapshot Windows&#8221;</a>)
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarRedecompile"></a>Re-decompile</h3></div></div></div>
+
+ <p>
+ <span class="guiicon"><img src="images/reload3.png"></span> - button
+ </p>
+ <p>
+ Triggers a re-decompilation of the current function displayed in the window.
+ Any cached results are discarded, and a full decompile is performed.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ This action is <span class="bold"><strong>not</strong></span> necessary for normal reverse
+ engineering tasks. Re-decompilation is <span class="emphasis"><em>automatically</em></span> triggered for all
+ decompiler windows by any change to the Program, so the most up-to-date decompilation is
+ always available to the user without this action. This action is a primarily a debugging
+ aid for plug-in developers.
+ </td></tr>
+</table></div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarCopy"></a>Copy</h3></div></div></div>
+
+ <p>
+ <span class="guiicon"><img src="images/page_white_copy.png"></span> - button
+ </p>
+ <p>
+ Copies the currently selected text in the decompiler window to the clipboard.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarDebug"></a>Debug Function Decompilation</h3></div></div></div>
+
+ <p>
+ This action is located in the drop-down menu on the right side of the decompiler
+ window tool/title bar.
+ </p>
+ <p>
+ Information suitable for debugging the decompilation process for
+ the current function is collected and saved to an output file in
+ XML format. A file chooser dialog is presented to the user to
+ choose the output file. The file is useful when submitting bug reports
+ about the decompiler as it is generally much smaller than
+ the entire Program and only contains information specific to the
+ function. Information is generated by performing the full
+ decompilation of the function and collecting all the data and
+ annotations required during the process, including instruction
+ bytes, symbols, data-types, and other settings affecting
+ decompilation.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ToolBarGraph"></a>Graph AST Control Flow</h3></div></div></div>
+
+ <p>
+ Generate a control-flow graph based upon the results in the active Decompiler Window,
+ and render it using the current Graph Service.
+ </p>
+ <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
+<th align="left"></th>
+</tr>
+<tr><td align="left" valign="top">
+ If no Graph Service is available then this action will no be present.
+ </td></tr>
+</table></div>
+</div>
+
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="MouseActions"></a>Mouse Actions</h2></div></div></div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseLeft"></a>Left Click</h3></div></div></div>
+
+ <p>
+ Moves the decompiler window cursor and highlights the token. Within the
+ <span class="emphasis"><em>main</em></span> window, if a token has a machine address
+ associated with it, a left click generates a
+ <span class="emphasis"><em>navigation</em></span> event to that address, which may cause other
+ windows to display code near that address.
+ (See <a class="xref" href="DecompilerWindow.html#CrossHighlighting" title="Cross Highlighting">&#8220;Cross Highlighting&#8221;</a>)
+ </p>
+ <p>
+ Selecting a '(' or ')' token causes it and its matching parenthesis to be
+ highlighted along with the entire expression they surround.
+ </p>
+ <p>
+ Selecting a '{' or '}' token causes it and its matching brace to be highlighted.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseRight"></a>Right Click</h3></div></div></div>
+
+ <p>
+ Moves the decompiler window cursor, highlights the token, and brings up the menu of
+ context sensitive actions. Any highlighting and navigation is identical to a
+ left click. The menu actions presented depend primarily on the token type and
+ are tailored to the context at that point in the code.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseDouble"></a>Double Click</h3></div></div></div>
+
+ <p>
+ Navigates based on the selected symbol or other token (See below). If the selected token represents a formal symbol,
+ such as a function name or a global variable, double clicking causes a
+ <span class="emphasis"><em>navigation</em></span> event to the address associated with the symbol.
+ </p>
+<div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Sub-function Symbols</strong></span></span></dt>
+<dd><p>
+ Double clicking a sub-function name causes the
+ window itself to navigate away from its current function to the sub-function, triggering
+ a new decompilation if necessary and changing its display.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Global Variables</strong></span></span></dt>
+<dd><p>
+ Double clicking a global
+ variable name does <span class="emphasis"><em>not</em></span> have any effect on the decompiler window itself,
+ but <span class="emphasis"><em>other</em></span> windows, like the Listing window, may navigate to the
+ storage address of the global variable.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Constants</strong></span></span></dt>
+<dd><p>
+ Double clicking a token representing a constant causes the constant to be treated
+ as an address, and a navigation event to that address is generated. The decompiler
+ window itself navigates depending again on whether the address represents a new function or not.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Labels</strong></span></span></dt>
+<dd><p>
+ Double clicking the label within a <span class="emphasis"><em>goto</em></span> statement causes the window to navigate
+ to the target of the goto, within the function. The cursor is set and the window view is adjusted if
+ necessary to ensure that the target is visible.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Braces</strong></span></span></dt>
+<dd><p>
+ Double clicking a '{' or '}' token, causes the window to navigate to the <span class="emphasis"><em>matching</em></span> brace
+ within the window. The cursor is set and the window view is adjusted if
+ necessary to ensure that the matching brace is visible.
+ </p></dd>
+</dl></div>
+ </div>
+<p>
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseControlDouble"></a>Control Double Click</h3></div></div></div>
+
+ <p>
+ Opens a new <span class="emphasis"><em>Snapshot</em></span> window, navigating it to the selected symbol.
+ This is a convenience for immediately decompiling and displaying a sub-function in a
+ new window, without disturbing the active window. The behavior is similar to the
+ Double Click action, the selected token must represent a function name symbol or possibly
+ a constant address, but the navigation occurs in the new Snapshot window.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseControlShift"></a>Control Shift Click</h3></div></div></div>
+
+ <p>
+ Generates a navigation event to the address, within the current function, associated with
+ the clicked token. This allows <span class="emphasis"><em>Snapshot</em></span> windows to do basic
+ cross-highlighting in the same way as the <span class="emphasis"><em>main</em></span> decompiler window.
+ A Control double-click causes the Listing and other windows to navigate to and display the same
+ portion of code currently being displayed in the Snapshot window. (See <a class="xref" href="DecompilerWindow.html#CrossHighlighting" title="Cross Highlighting">&#8220;Cross Highlighting&#8221;</a>)
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="MouseMiddle"></a>Middle Click</h3></div></div></div>
+
+ <p>
+ Highlights every occurrence of a variable, constant, or operator under the current
+ cursor location, within the decompiler window.
+ </p>
+</div>
+
+</div>
+
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="MenuActions"></a>Pop-up Menu Actions</h2></div></div></div>
+
+ <p>
+ All the actions described in this section can be activated from the menu that pops up
+ when right-clicking on a token within the decompiler window. The pop-up menu is context sensitive and
+ the type of token in particular (See <a class="xref" href="DecompilerWindow.html#DecompilerDisplay" title="Display">&#8220;Display&#8221;</a>) determines what actions are available.
+ The token clicked provides a local context for the action and may be used to pinpoint the exact
+ variable or operation affected.
+ </p>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionAutoStructure"></a>Auto Create Structure</h3></div></div></div>
+
+ <p>
+ Automatically create a <span class="emphasis"><em>structure</em></span> data-type for a selected variable
+ based on its use within the current function and possibly child functions.
+ </p>
+ <p>
+ The <span class="emphasis"><em>structure</em></span> definition is filled in by examining how the variable
+ is used, assuming it is a pointer to the <span class="emphasis"><em>structure</em></span>, tracing
+ data-flow to all the expressions the variable is used in. LOAD and STORE operations
+ trigger new <span class="emphasis"><em>fields</em></span> and additive offsets are traced to calculate
+ the offset of the fields within the <span class="emphasis"><em>structure</em></span> definition.
+ </p>
+ <p>
+ Once the new <span class="emphasis"><em>structure</em></span> is created, the selected variable is
+ retyped to be a pointer to the <span class="emphasis"><em>structure</em></span>. Within the window,
+ the function is decompiled again and references to new fields in the structure
+ should be immediately apparent. These can be renamed or retyped from the window
+ to further refine the new <span class="emphasis"><em>structure</em></span> definition.
+ (See <a class="xref" href="DecompilerWindow.html#ActionRenameVariable" title="Rename Variable">&#8220;Rename Variable&#8221;</a>)
+ </p>
+ <div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Auto Fill in Structure</strong></span></span></dt>
+<dd><p>
+ If the selected variable is already a pointer to a <span class="emphasis"><em>structure</em></span>,
+ this action fills in new information about the structure on top of the existing
+ structure definition. Depending on how the pointer is used in the current function,
+ new fields may be added and the data-type of <span class="emphasis"><em>undefined</em></span> fields
+ may be changed, but other existing parts of the structure definition are preserved.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Auto Fill in Class Structure</strong></span></span></dt>
+<dd><p>
+ If the selected variable is the <span class="bold"><strong>this</strong></span> parameter for
+ a class method, the menu title for this action reflects this, but the action is the same.
+ The class's structure definition is filled in with any new information.
+ </p></dd>
+</dl></div>
+ </div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionComments"></a>Comments</h3></div></div></div>
+
+ <p>Set or change a comment at the address of the selected token.
+ </p>
+ <p>
+ These actions bring up the general Comment dialog (See <a class="ulink" href="help/topics/CommentsPlugin/Comments.htm" target="_top">Comments</a>),
+ which associates the comment with a specific <span class="emphasis"><em>address</em></span> in the Program. For the
+ decompiler actions, this address is of the machine instruction most closely linked to the selected token.
+ Comments will be visible in the Listing and other Ghidra windows viewing the same
+ section of code.
+ </p>
+ <p>
+ The decompiler windows can display all comment types, but this may be affected by the Display options
+ (See <a class="xref" href="DecompilerAnnotations.html#AnnoteComments" title="Comments">&#8220;Comments&#8221;</a>).
+ </p>
+ <div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Set Plate Comment ...</strong></span></span></dt>
+<dd><p>
+ Brings up the dialog for setting or editing a <span class="emphasis"><em>Plate</em></span> comment.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Set Pre Comment ...</strong></span></span></dt>
+<dd><p>
+ Brings up the dialog for setting or editing a <span class="emphasis"><em>Pre</em></span> comment.
+ </p></dd>
+</dl></div>
+ </div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionCommitLocals"></a>Commit Local Names</h3></div></div></div>
+
+ <p>
+ Commit the names of any local variables discovered during the decompiler's analysis
+ to the Program database as new Variable Annotations. The recovered data-type is
+ not committed as part of the annotation, only the name and storage location.
+ </p>
+ <p>
+ Parameters are not affected by this command, see <a class="xref" href="DecompilerWindow.html#ActionCommitParams" title="Commit Params/Return">&#8220;Commit Params/Return&#8221;</a>.
+ The purpose of the command is to synchronize the local variables in the
+ decompiler's view of a function with the formal Variable Annotations in the disassembly view,
+ without otherwise affecting the decompilation. After executing this command, additional changes
+ to local variable can be performed directly on the corresponding annotations in the Listing Window,
+ using various methods (See <a class="xref" href="DecompilerAnnotations.html#AnnoteVariables" title="Variable Annotations">&#8220;Variable Annotations&#8221;</a>).
+ Data-types are not forced for new annotations, they are created with
+ an <span class="emphasis"><em>undefined</em></span> data-type, which allows the decompiler to refine
+ its view of the variable's data-type as new information becomes available
+ (See <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>).
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionCommitParams"></a>Commit Params/Return</h3></div></div></div>
+
+ <p>
+ Commit the decompiler's analysis of the input parameters and return value of the current
+ function as annotations to the Program database.
+ </p>
+ <p>
+ In the absence of either <span class="emphasis"><em>imported</em></span> or <span class="emphasis"><em>user defined</em></span>
+ information about a function's prototype, the decompiler performs its own analysis of what
+ the prototype is, determining the storage location and data-type of all parameters and the
+ return value. This action commits this analysis permanently for the current function
+ displayed in the window, creating a matching <span class="emphasis"><em>Variable Annotation</em></span> for each input
+ parameter and the return value. The new annotations will be displayed in the
+ Listing Window as part of the function header, and the action effectively
+ <span class="emphasis"><em>synchronizes</em></span> the disassembly view and decompiler's view of the function prototype.
+ </p>
+ <p>
+ Committed prototype information is used both when decompiling the function itself and when
+ decompiling other functions that call it.
+ The committed annotations are <span class="emphasis"><em>forcing</em></span> on the decompiler, and it will
+ no longer perform prototype recovery analysis for that function. The decompiler assumes the committed parameters,
+ and only the committed parameters, exist and will not modify their data-types, with the
+ exception of parameters that are explicitly marked as having an <span class="emphasis"><em>undefined</em></span>
+ data-type. The user must manually modify individual variables or clear the entire prototype
+ if they want a change (See <a class="xref" href="DecompilerAnnotations.html#AnnoteVariables" title="Variable Annotations">&#8220;Variable Annotations&#8221;</a>).
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionCopy"></a>Copy/Copy Special ...</h3></div></div></div>
+
+ <p>
+ Copy selected code from the decompiler window into the clipboard.
+ </p>
+ <p>
+ This is part of the standard copy
+ capabilities for all Ghidra windows and is suitable for copying (sections of) decompiler output
+ into other documents.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionEditDataType"></a>Edit Data Type</h3></div></div></div>
+
+ <p>
+ Bring up a dialog for editing the definition of the data-type under the cursor.
+ </p>
+ <p>
+ The cursor must be on the data-type <span class="emphasis"><em>name</em></span> token,
+ not on a variable or other syntax. The action is only available for
+ <span class="emphasis"><em>structures</em></span> and <span class="emphasis"><em>unions</em></span>,
+ which will bring up the <a class="ulink" href="help/topics/DataTypeEditors/StructureEditor.htm" target="_top">Structure Editor</a>,
+ and for <span class="emphasis"><em>enumerations</em></span>, which will bring up the
+ <a class="ulink" href="help/topics/DataTypeEditors/EnumEditor.htm" target="_top">Enum Editor</a>.
+ </p>
+ <p>
+ Any change to the definition of the data-type is automatically incorporated by the decompiler into its output
+ (see <a class="xref" href="DecompilerAnnotations.html#AnnoteDatatype" title="Variable Data-types">&#8220;Variable Data-types&#8221;</a>).
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionEditSignature"></a>Edit Function Signature</h3></div></div></div>
+
+ <p>
+ Bring up a dialog for editing the <span class="emphasis"><em>prototype</em></span> of a selected function and other
+ details about how it passes parameters.
+ </p>
+ <p>
+ The action is available from any token in the decompiler window. Most tokens trigger editing
+ of the current function itself, but a subfunction can be edited by putting the cursor on
+ its name specifically.
+ </p>
+ <p>
+ </p>
+<div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="100%"><tr><td align="center"><img src="images/EditFunctionSignature.png" align="middle" width="681" height="529"></td></tr></table></div>
+<p>
+ The dialog provides detailed control over elements like
+ </p>
+<div class="informalexample">
+ <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: none; ">
+<li class="listitem" style="list-style-type: none">
+ <span class="bold"><strong>Parameters</strong></span> - including name, data-type, and storage
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <span class="bold"><strong>Return Type</strong></span> - including data-type and storage
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <span class="bold"><strong>Variable Arguments</strong></span> and
+ </li>
+<li class="listitem" style="list-style-type: none">
+ <span class="bold"><strong>Inlining</strong></span>
+ </li>
+</ul></div>
+ </div>
+<p>
+ </p>
+ <p>
+ See documentation for the
+ <a class="ulink" href="help/topics/FunctionPlugin/Variables.htm#Edit_Function" target="_top">Function Editor Dialog</a>.
+ The decompiler automatically incorporates any changes into its output.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionFind"></a>Find ...</h3></div></div></div>
+
+ <p>
+ Search for strings within the active window, in the current decompiler output.
+ </p>
+ <p>
+ The command brings up a dialog where a search pattern can entered as a raw string or regular expression.
+ The search is performed directly on the text of the decompiled function, from the current cursor; forward
+ each time the <span class="bold"><strong>Next</strong></span> button is hit, or backward for the
+ <span class="bold"><strong>Previous</strong></span> button. Any match is highlighted in the window,
+ and the cursor is set to the start of the match.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionHighlight"></a>Highlight</h3></div></div></div>
+
+ <p>
+ All these actions highlight a specific set of variable tokens tracing the data-flow
+ of the selected variable within the current function. Data-flow is the directed flow
+ of data from input variables through operations that manipulate their value to their
+ output variables. The operations and variables chain together to form data-flow
+ <span class="emphasis"><em>paths</em></span>.
+ </p>
+ <div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Def-Use</strong></span></span></dt>
+<dd><p>
+ Highlight the single token where the selected variable was last written (def),
+ and highlight all the tokens where that single value is read (use). The written token,
+ generally where the variable is on the left-hand side of an assignment expression,
+ is highlighted in a different color. If the variable is written on multiple merging
+ control-flow paths, no written token is highlighted.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Forward Slice</strong></span></span></dt>
+<dd>
+<p>
+ Highlight all variable tokens where the value at that point in the function is
+ directly affected by the value at the selected variable token.
+ A token is highlighted if there is a direct data-flow path
+ starting from the selected point and ending at the token.
+ </p>
+ <p>
+ In the following example, the token <span class="emphasis"><em>b</em></span>, the output of
+ <span class="emphasis"><em>max_alpha</em></span>, is selected when Forward Slice is chosen.
+ </p>
+<div class="mediaobject" align="center"><table border="0" summary="manufactured viewport for HTML img" style="cellpadding: 0; cellspacing: 0;" width="100%"><tr><td align="center"><img src="images/ForwardSlice.png" align="middle" width="433" height="242"></td></tr></table></div>
+<p>
+ </p>
+</dd>
+<dt><span class="term"><span class="bold"><strong>Backward Slice</strong></span></span></dt>
+<dd><p>
+ Highlight all variable tokens where the value at that point in the function
+ directly affects the value at the selected variable token.
+ A token is highlighted if there is a direct data-flow path
+ starting from the token and ending at the selected point.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Forward Inst Slice</strong></span></span></dt>
+<dd><p>
+ Highlight every operator token that manipulates a value directly affected by the
+ value at the selected variable token. Along each direct data-flow path that
+ <span class="emphasis"><em>starts</em></span>
+ at the selected point, each token representing an operation is highlighted, along with
+ any explicit variable it writes to.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Backward Inst Slice</strong></span></span></dt>
+<dd><p>
+ Highlight every operator token that manipulates a value that directly affects the
+ value at the selected variable token. Along each direct data-flow path that
+ <span class="emphasis"><em>ends</em></span>
+ at the selected point, each token representing an operation is highlighted, along with
+ any explicit variable it writes to.
+ </p></dd>
+</dl></div>
+ </div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionSecondaryHighlight"></a>Secondary Highlight</h3></div></div></div>
+
+ <p>
+ A <span class="emphasis"><em>secondary highlight</em></span> is a semi-permanent token highlight in the decompiler
+ window that, unlike normal highlights, will not go away as the user clicks other tokens.
+ The color and text being highlighted is controlled by the user and will persist for
+ <span class="bold"><strong>for the duration of the Ghidra session</strong></span> or until the user
+ explicitly removes the highlight.
+ </p>
+ <div class="informalexample">
+ <div class="variablelist"><dl class="variablelist">
+<dt><span class="term"><span class="bold"><strong>Set Highlight</strong></span></span></dt>
+<dd><p>
+ Apply a secondary highlight to all text matching the text of the token under
+ the cursor. A color is chosen randomly for the Ghidra session. If the same highlight
+ is removed and then reactivated later in the session, the same color will be used.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Set Highlight...</strong></span></span></dt>
+<dd><p>
+ Apply a secondary highlight to all text matching the text of the token under
+ the cursor, as in the <span class="emphasis"><em>Set Highlight</em></span> action above.
+ A Color Chooser dialog is shown allowing the user to select the specific color
+ for the highlight. The dialog is initialized with a random color or with the color
+ previously applied to the same token.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Remove Highlight</strong></span></span></dt>
+<dd><p>
+ Remove the existing secondary highlight applied to the token under the cursor.
+ Other highlights are not affected.
+ </p></dd>
+<dt><span class="term"><span class="bold"><strong>Remove All Highlights</strong></span></span></dt>
+<dd><p>
+ Remove all secondary highlights in the current function. Highlights in other
+ functions are not affected.
+ </p></dd>
+</dl></div>
+ </div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionOverrideSignature"></a>Override Signature</h3></div></div></div>
+
+ <p>
+ Override the function prototype corresponding to the sub-function under the cursor.
+ </p>
+ <p>
+ This action can be triggered at <span class="emphasis"><em>call sites</em></span>, where the function
+ being decompiled is calling into another sub-function. Users must select either the token representing
+ the sub-function's name or the tokens representing the function pointer at the call site.
+ A dialog is brought up where the a complete <span class="emphasis"><em>function declaration</em></span>, specifying
+ the return data-type along with the name and data-type for each input parameter. Additionally,
+ the "Calling Convention", "In Line", and "No Return" properties of the function prototype
+ can be set (See <a class="xref" href="DecompilerAnnotations.html#AnnotePrototype" title="Function Prototypes">&#8220;Function Prototypes&#8221;</a>).
+ </p>
+ <p>
+ Confirming the dialog forces the new function prototype on the decompiler's view of the sub-function,
+ but only for the single selected call site.
+ </p>
+ <p>
+ This action is suitable for either indirect calls or direct calls to functions taking a variable number
+ of arguments; situations where a complete description of all parameters is not available.
+ For direct calls with a fixed number of arguments, it is almost always better to provide
+ parameter information by setting the function's prototype directly. See the
+ <a class="xref" href="DecompilerWindow.html#ActionCommitParams" title="Commit Params/Return">&#8220;Commit Params/Return&#8221;</a> command for instance. In this situation, the "Override Signature"
+ command is still possible, but it will bring up a confirmation dialog.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionReference"></a>Reference ...</h3></div></div></div>
+
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ActionFindUses"></a>Find Uses of &lt;data-type&gt;</h4></div></div></div>
+
+ <p>
+ Calculate locations in the Program that reference the <span class="bold"><strong>data-type</strong></span>
+ of the token under the cursor. Results are collected in a
+ <a class="ulink" href="help/topics/LocationReferencesPlugin/Location_References.html" target="_top">Location References Dialog</a>,
+ which displays a row for each reference with its address and other context.
+ </p>
+ <p>
+ Uses (references) specifically are to <span class="emphasis"><em>variables</em></span> that have been assigned the data-type.
+ References to parameters and global variables are always listed.
+ If the <span class="emphasis"><em>Dynamic Data Type Discovery</em></span> option is on
+ (see <a class="ulink" href="help/topics/LocationReferencesPlugin/Location_References.html#Data_Types" target="_top">To Find Location References to Data Types</a>),
+ the decompiler's propagation analysis is invoked on all functions to discover local
+ variables as well.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ActionFindReferences"></a>Find References to &lt;function&gt;</h4></div></div></div>
+
+ <p>
+ Display locations in the Program that reference the <span class="bold"><strong>function</strong></span>
+ associated with the token under the cursor. Results are collected in a
+ <a class="ulink" href="help/topics/LocationReferencesPlugin/Location_References.html" target="_top">Location References Dialog</a>,
+ which displays a row for each reference with its address and other context.
+ </p>
+ <p>
+ References include both instructions and data referring to the <span class="emphasis"><em>entry point</em></span>
+ address of the function.
+ </p>
+ </div>
+ <div class="sect3">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="ActionShowReferences"></a>Show References to Address</h4></div></div></div>
+
+ <p>
+ Display locations in the Program that reference the <span class="bold"><strong>address</strong></span>
+ associated with the token under the cursor. Results are collected in a
+ <a class="ulink" href="help/topics/LocationReferencesPlugin/Location_References.html" target="_top">Location References Dialog</a>,
+ which displays a row for each reference with its address and other context.
+ </p>
+ <p>
+ The selected address is of the instruction most closely associated with the
+ variable or operator represented by the token.
+ </p>
+ </div>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRemoveOverride"></a>Remove Signature Override</h3></div></div></div>
+
+ <p>
+ Remove the overriding function prototype applied previously to the sub-function under the cursor.
+ </p>
+ <p>
+ This action can only be triggered at <span class="emphasis"><em>call sites</em></span>, where an overriding
+ prototype was previously placed by the <a class="xref" href="DecompilerWindow.html#ActionOverrideSignature" title="Override Signature">&#8220;Override Signature&#8221;</a> command. As with
+ this command, users must select either the token representing the sub-function's name or the
+ tokens representing the function pointer at the call site. The action causes the
+ override to be removed immediately. Parameter information will be drawn from the decompiler's
+ normal analysis.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRenameFunction"></a>Rename Function</h3></div></div></div>
+
+ <p>
+ Rename the function corresponding to the token under the cursor.
+ </p>
+ <p>
+ The current function can be renamed by selecting the name token within the function's
+ declaration at the top of the decompiler window, or individual subfunctions
+ can be renamed by selecting their name token within a call expression.
+ This action brings up a dialog containing a text field prepopulated with the
+ name to be changed. The current namespace (and any parent namespaces) is
+ presented in a drop-down menu. Editing the text field changes the <span class="emphasis"><em>base</em></span>
+ name of the function, and selecting within the drop-down menu allows
+ the function to be moved into a parent namespace.
+ </p>
+ <p>
+ A new or child namespace can
+ be specified by prepending the base name with the namespace using the C++ '::'
+ separator characters. Any namespace path entered this way is considered relative
+ to the namespace set in the drop-down meu, so the <span class="bold"><strong>Global</strong></span>
+ namespace may need to be selected if the user wants to specify an absolute path. If
+ any path element of the namespace does not exist, it is created.
+ </p>
+ <p>
+ The change will be immediately visible across all references to the function
+ (including in any Decompiler, Listing, and Functions windows).
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRenameField"></a>Rename Field</h3></div></div></div>
+
+ <p>
+ Rename the field currently under the cursor within its <span class="emphasis"><em>structure</em></span>
+ data-type definition.
+ </p>
+ <p>
+ The action brings up a dialog prepopulated with the
+ current name of the field. Editing and confirming this dialog immediately changes
+ field's name in its corresponding structure definition. The dialog enforces unique field names.
+ </p>
+ <p>
+ If the initial name looks like <code class="code">field_0x..</code>, it may be that the field offset was
+ discovered by the decompiler, and the field does not exist in the structure definition.
+ In this case, a new field is created at that offset, with the new name and a data-type of "undefined".
+ </p>
+ <p>
+ The change to the definition is visible globally
+ throughout the Program, anywhere the data-type is referenced. Decompilation
+ is triggered again to incorporate the new name, but the output is otherwise unaffected.
+ </p>
+ <p>
+ Within a decompiler window, field name tokens are presented <span class="emphasis"><em>in context</em></span>,
+ showing how they are used within the code flow of the current function.
+ Combined with <a class="xref" href="DecompilerWindow.html#ActionAutoStructure" title="Auto Create Structure">&#8220;Auto Create Structure&#8221;</a> and
+ <a class="xref" href="DecompilerWindow.html#ActionRetypeField" title="Retype Field">&#8220;Retype Field&#8221;</a>, this action allows a
+ <span class="emphasis"><em>structure</em></span> to be created and filled in based on this context.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRenameGlobal"></a>Rename Global</h3></div></div></div>
+
+ <p>
+ Rename the global variable corresponding to the token under the cursor.
+ </p>
+ <p>
+ This action brings up a dialog containing a text field prepopulated with the
+ current name of the variable. The current namespace (and any parent namespaces) is
+ presented in a drop-down menu. Editing the text field changes the <span class="emphasis"><em>base</em></span>
+ name of the variable, and selecting within the drop-down menu allows
+ the variable to be moved into a parent namespace.
+ </p>
+ <p>
+ A new or child namespace can
+ be specified by prepending the base name with the namespace using the C++ '::'
+ separator characters. Any namespace path entered this way is considered relative
+ to the namespace set in the drop-down meu, so the <span class="bold"><strong>Global</strong></span>
+ namespace may need to be selected if the user wants to specify an absolute path. If
+ any path element of the namespace does not exist, it is created.
+ </p>
+ <p>
+ The change will be immediately visible across all references to the variable,
+ including the Decompiler and Listing windows. A new decompilation is triggered
+ to incorporate the new name, but the output is otherwise unaffected.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRenameVariable"></a>Rename Variable</h3></div></div></div>
+
+ <p>
+ Rename the local variable or parameter currently under the cursor.
+ </p>
+ <p>
+ The action brings up a dialog prepopulated with the current name of the variable.
+ Editing and confirming this dialog immediately changes the name, unless there is a
+ conflict with another variable.
+ </p>
+ <p>
+ Decompilation is triggered again to incorporate the
+ new name, causing local variable declarations to be reordered and line breaks to
+ change, but otherwise the the output is unaffected.
+ </p>
+ <p>
+ Local variables and parameters presented by the decompiler may be invented on-the-fly
+ and don't necessarily have a formal annotation in Ghidra
+ (see <a class="xref" href="DecompilerAnnotations.html#AnnoteVariables" title="Variable Annotations">&#8220;Variable Annotations&#8221;</a>). Performing this action on
+ a variable will create an annotation if one didn't exist previously, which will
+ generally be visible as part of the function header in the Listing window.
+ A new annotation will <span class="emphasis"><em>not</em></span> commit the data-type of the variable,
+ and data-types applied later, and elsewhere in the function, can still propagate into
+ the variable.
+ </p>
+ <p>
+ Performing this action on a function parameter causes a formal annotation to be created
+ for <span class="emphasis"><em>all</em></span> parameters, although the names of any other parameters
+ will not be changed.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRetypeField"></a>Retype Field</h3></div></div></div>
+
+ <p>
+ Change the data-type of the field currently under the cursor within its
+ <span class="emphasis"><em>structure</em></span> data-type definition.
+ </p>
+ <p>
+ The action brings up a dialog prepopulated with the current data-type associated
+ with the field. The user can select any fixed length data-type in the Program,
+ although selecting a larger data-type may cause an error if there is not enough room
+ for it with other existing fields.
+ Editing and confirming this dialog immediately changes the
+ corresponding data-type definition.
+ </p>
+ <p>
+ The change to the definition is visible globally throughout the Program,
+ anywhere the data-type is referenced, and is <span class="emphasis"><em>forcing</em></span>
+ on the decompiler (see <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>). Decompilation is triggered
+ again, and the new data-type is propagated from the point of the field reference(s).
+ Changes to the output may be large and indirect.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRetypeGlobal"></a>Retype Global</h3></div></div></div>
+
+ <p>
+ Change the data-type of the global variable currently under the cursor.
+ </p>
+ <p>
+ This action brings up a dialog prepopulated with the current data-type of the variable.
+ The user can select any fixed length data-type in the Program that matches
+ the size of the variable. Editing and confirming this dialog immediately changes
+ the data-type.
+ </p>
+ <p>
+ The change is visible globally throughout the Program, anywhere the variable is
+ referenced, and is <span class="emphasis"><em>forcing</em></span> on the decompiler
+ (see <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>). Decompilation is triggered
+ again, and the new data-type is propagated from the variable reference(s).
+ Changes to the output may be large and indirect.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRetypeReturn"></a>Retype Return</h3></div></div></div>
+
+ <p>
+ Change the data-type of the current function's <span class="emphasis"><em>return value</em></span>.
+ </p>
+ <p>
+ This action is only available from the data-type token in the function declaration, at the
+ top of the decompiler's output. It brings up a dialog prepopulated with the current
+ data-type returned by the function. The user can select any fixed length data-type in the Program.
+ Editing and confirming this dialog immediately changes the data-type. If an annotation for
+ the return value (named <code class="code">&lt;RETURN&gt;</code>) did not exist previously, one is created.
+ </p>
+ <p>
+ As input parameter annotations and the return value annotation must be commited as a whole
+ (see the discussion of function prototype's in <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>), if
+ no prototype existed previously, this action also causes variable annotations for all
+ input parameters to be created as well. In this situation, the action is equivalent to
+ <a class="xref" href="DecompilerWindow.html#ActionCommitParams" title="Commit Params/Return">&#8220;Commit Params/Return&#8221;</a>, and a confirmation dialog comes up to notify the user.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionRetypeVariable"></a>Retype Variable</h3></div></div></div>
+
+ <p>
+ Change the data-type of the local variable or parameter currently under the cursor.
+ </p>
+ <p>
+ This action brings up a dialog prepopulated with the current data-type of the variable.
+ The user can select any fixed length data-type in the Program that matches
+ the size of the variable. Editing and confirming this dialog immediately changes
+ the data-type.
+ </p>
+ <p>
+ The change to the data-type is <span class="emphasis"><em>forcing</em></span> on the decompiler
+ (see <a class="xref" href="DecompilerAnnotations.html#AnnoteForcing" title="Forcing Data-types">&#8220;Forcing Data-types&#8221;</a>). Decompilation is triggered again, and the new
+ data-type is propagated from the variable reference(s). Changes to the output may be
+ large and indirect.
+ </p>
+ <p>
+ Local variables and parameters presented by the decompiler may be invented on-the-fly
+ and don't necessarily have a formal annotation in Ghidra
+ (see <a class="xref" href="DecompilerAnnotations.html#AnnoteVariables" title="Variable Annotations">&#8220;Variable Annotations&#8221;</a>). Performing this action on a variable
+ will create an annotation if one didn't exist previously, which will generally be
+ visible as part of the function header in the Listing window.
+ </p>
+ <p>
+ Performing this action on a function parameter causes a formal annotation to
+ be created for <span class="emphasis"><em>all</em></span> parameters to the function, and the number
+ of parameters and their memory locations become fixed. If the annotation of another
+ parameter did not exist previously, then its data-type is <span class="emphasis"><em>not</em></span>
+ forced by this action.
+ </p>
+</div>
+
+<div class="sect2">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="ActionIsolate"></a>Split Out As New Variable</h3></div></div></div>
+
+ <p>
+ Split a high-level variable so that the selected token becomes a new variable with the smallest
+ possible range.
+ </p>
+ <p>
+ The decompiler defines high-level variables in terms of <a class="link" href="DecompilerConcepts.html#ConceptVarnode" title="Varnodes">varnodes</a> that
+ are merged together to produce the final variable. Some merging is speculative, which reduces the
+ number of variables overall, but is not strictly necessary for valid decompilation. The merged
+ variable can be represented with two or more variables that have a smaller range. See the
+ documentation on <a class="xref" href="DecompilerConcepts.html#ConceptHighVariable" title="HighVariable">&#8220;HighVariable&#8221;</a>.
+ </p>
+ <p>
+ This command is only available if the selected token is part of a high-level variable that has
+ been speculatively merged. The part of the variable that is directly represented by the
+ token is split out as its own variable, retaining the name of the original variable.
+ Any other pieces become a separate variable with a new name.
+ </p>
+</div>
+
+</div>
+
+</div>
+<div class="navfooter">
+<hr>
+<table width="100%" summary="Navigation footer">
+<tr>
+<td width="40%" align="left">
+<a accesskey="p" href="DecompilerOptions.html">Prev</a>�</td>
+<td width="20%" align="center">�</td>
+<td width="40%" align="right">�</td>
+</tr>
+<tr>
+<td width="40%" align="left" valign="top">Decompiler Options�</td>
+<td width="20%" align="center"><a accesskey="h" href="Decompiler.html">Home</a></td>
+<td width="40%" align="right" valign="top">�</td>
+</tr>
+</table>
+</div>
+</body>
+</html>
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
index 7b779ea55d..af595de985 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/DecompilerProvider.java
@@ -34,6 +34,7 @@ import ghidra.app.decompiler.component.*;
import ghidra.app.nav.*;
import ghidra.app.plugin.core.decompile.actions.*;
import ghidra.app.services.*;
+import ghidra.app.util.HelpTopics;
import ghidra.app.util.HighlightProvider;
import ghidra.framework.model.DomainObjectChangedEvent;
import ghidra.framework.model.DomainObjectListener;
@@ -740,7 +741,8 @@ public class DecompilerProvider extends NavigatableComponentProviderAdapter
};
refreshAction.setToolBarData(new ToolBarData(REFRESH_ICON, "A" /* first on toolbar */));
refreshAction.setDescription("Push at any time to trigger a re-decompile");
- refreshAction.setHelpLocation(new HelpLocation(plugin.getName(), "Decompiler")); // just use the default
+ refreshAction
+ .setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarRedecompile")); // just use the default
//
// Below are actions along with their groups and subgroup information. The comments
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractSetSecondaryHighlightAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractSetSecondaryHighlightAction.java
index 9b66c5748f..2e818dcbd5 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractSetSecondaryHighlightAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractSetSecondaryHighlightAction.java
@@ -18,11 +18,15 @@ package ghidra.app.plugin.core.decompile.actions;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.TokenHighlights;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
+import ghidra.util.HelpLocation;
public abstract class AbstractSetSecondaryHighlightAction extends AbstractDecompilerAction {
AbstractSetSecondaryHighlightAction(String name) {
super(name);
+ setHelpLocation(
+ new HelpLocation(HelpTopics.DECOMPILER, "ActionSecondaryHighlight"));
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceAction.java
index ae3f0ebbc4..403403861a 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceAction.java
@@ -22,8 +22,10 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
+import ghidra.util.HelpLocation;
public class BackwardsSliceAction extends AbstractDecompilerAction {
@@ -31,6 +33,7 @@ public class BackwardsSliceAction extends AbstractDecompilerAction {
public BackwardsSliceAction() {
super("Highlight Backward Slice");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionHighlight"));
setPopupMenuData(new MenuData(new String[] { "Highlight", "Backward Slice" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceToPCodeOpsAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceToPCodeOpsAction.java
index fdf6321cd6..3d4b8c71cf 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceToPCodeOpsAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/BackwardsSliceToPCodeOpsAction.java
@@ -22,13 +22,16 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
+import ghidra.util.HelpLocation;
public class BackwardsSliceToPCodeOpsAction extends AbstractDecompilerAction {
public BackwardsSliceToPCodeOpsAction() {
super("Highlight Backward Inst Slice");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionHighlight"));
setPopupMenuData(
new MenuData(new String[] { "Highlight", "Backward Inst Slice" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CloneDecompilerAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CloneDecompilerAction.java
index df338e1692..51b8ee0384 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CloneDecompilerAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CloneDecompilerAction.java
@@ -23,6 +23,7 @@ import javax.swing.ImageIcon;
import docking.action.KeyBindingData;
import docking.action.ToolBarData;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.util.HelpLocation;
import resources.ResourceManager;
@@ -33,7 +34,7 @@ public class CloneDecompilerAction extends AbstractDecompilerAction {
ImageIcon image = ResourceManager.loadImage("images/camera-photo.png");
setToolBarData(new ToolBarData(image, "ZZZ"));
setDescription("Create a snapshot (disconnected) copy of this Decompiler window ");
- setHelpLocation(new HelpLocation("Snapshots", "Snapshots_Start"));
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarSnapshot"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_T,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitLocalsAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitLocalsAction.java
index b8350c6026..56a7dd317c 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitLocalsAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitLocalsAction.java
@@ -17,15 +17,18 @@ package ghidra.app.plugin.core.decompile.actions;
import docking.action.MenuData;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.HighFunction;
import ghidra.program.model.pcode.HighFunctionDBUtil;
import ghidra.program.model.symbol.SourceType;
+import ghidra.util.HelpLocation;
public class CommitLocalsAction extends AbstractDecompilerAction {
public CommitLocalsAction() {
super("Commit Locals");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionCommitLocals"));
setPopupMenuData(new MenuData(new String[] { "Commit Local Names" }, "Commit"));
setDescription(
"Save Local variable names from Decompiler window to Program");
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitParamsAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitParamsAction.java
index e956eb2c20..ea090ac2cf 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitParamsAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CommitParamsAction.java
@@ -20,10 +20,12 @@ import java.awt.event.KeyEvent;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.HighFunction;
import ghidra.program.model.pcode.HighFunctionDBUtil;
import ghidra.program.model.symbol.SourceType;
+import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.exception.*;
@@ -31,6 +33,7 @@ public class CommitParamsAction extends AbstractDecompilerAction {
public CommitParamsAction() {
super("Commit Params/Return");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionCommitParams"));
setPopupMenuData(new MenuData(new String[] { "Commit Params/Return" }, "Commit"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_P, 0));
setDescription(
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CreateStructureVariableAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CreateStructureVariableAction.java
index c3b16a0344..d5b0346ccc 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CreateStructureVariableAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/CreateStructureVariableAction.java
@@ -23,12 +23,14 @@ import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.decompiler.component.DecompilerController;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.HighParam;
import ghidra.program.model.pcode.HighVariable;
import ghidra.program.util.ProgramLocation;
+import ghidra.util.HelpLocation;
import ghidra.util.Msg;
public abstract class CreateStructureVariableAction extends DockingAction {
@@ -40,6 +42,7 @@ public abstract class CreateStructureVariableAction extends DockingAction {
super("Recover Structure Variable", owner);
this.tool = tool;
this.controller = controller;
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionAutoStructure"));
setPopupMenuData(new MenuData(new String[] { "Auto Create Structure" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_OPEN_BRACKET, InputEvent.SHIFT_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DebugDecompilerAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DebugDecompilerAction.java
index 8ff1404df6..32ebb46d7d 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DebugDecompilerAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DebugDecompilerAction.java
@@ -24,6 +24,8 @@ import docking.widgets.OptionDialog;
import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.app.decompiler.component.DecompilerController;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
+import ghidra.util.HelpLocation;
import ghidra.util.filechooser.ExtensionFileFilter;
public class DebugDecompilerAction extends AbstractDecompilerAction {
@@ -32,6 +34,7 @@ public class DebugDecompilerAction extends AbstractDecompilerAction {
public DebugDecompilerAction(DecompilerController controller) {
super("Debug Function Decompilation");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarDebug"));
this.controller = controller;
setMenuBarData(new MenuData(new String[] { "Debug Function Decompilation" }, "xDebug"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DeletePrototypeOverrideAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DeletePrototypeOverrideAction.java
index b9b71b052a..03ce6963a9 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DeletePrototypeOverrideAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/DeletePrototypeOverrideAction.java
@@ -18,19 +18,20 @@ package ghidra.app.plugin.core.decompile.actions;
import docking.action.MenuData;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.database.symbol.CodeSymbol;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.HighFunction;
import ghidra.program.model.symbol.*;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
public class DeletePrototypeOverrideAction extends AbstractDecompilerAction {
public DeletePrototypeOverrideAction() {
super("Remove Signature Override");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRemoveOverride"));
setPopupMenuData(new MenuData(new String[] { "Remove Signature Override" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditDataTypeAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditDataTypeAction.java
index d380bb749d..3fc4f2f5b7 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditDataTypeAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditDataTypeAction.java
@@ -21,16 +21,19 @@ import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.services.DataTypeManagerService;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.listing.Function;
+import ghidra.util.HelpLocation;
import ghidra.util.UndefinedFunction;
public class EditDataTypeAction extends AbstractDecompilerAction {
public EditDataTypeAction() {
super("Edit Data Type");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionEditDataType"));
setPopupMenuData(new MenuData(new String[] { "Edit Data Type" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditPropertiesAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditPropertiesAction.java
index 317715e61d..025785766d 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditPropertiesAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/EditPropertiesAction.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +15,13 @@
*/
package ghidra.app.plugin.core.decompile.actions;
-import docking.action.*;
+import docking.ActionContext;
+import docking.action.DockingAction;
+import docking.action.MenuData;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.OptionsService;
-import docking.*;
+import ghidra.util.HelpLocation;
public class EditPropertiesAction extends DockingAction {
private final static String OPTIONS_TITLE = "Decompiler";
@@ -29,6 +31,7 @@ public class EditPropertiesAction extends DockingAction {
public EditPropertiesAction(String owner, PluginTool tool) {
super("DecompilerProperties", owner);
this.tool = tool;
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "DisplayOptions"));
setPopupMenuData( new MenuData( new String[]{ "Properties"}, "ZED" ) );
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ExportToCAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ExportToCAction.java
index 6c947f3ee3..2a1461d8a6 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ExportToCAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ExportToCAction.java
@@ -25,7 +25,9 @@ import docking.widgets.filechooser.GhidraFileChooser;
import ghidra.app.decompiler.*;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.preferences.Preferences;
+import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.filechooser.ExtensionFileFilter;
import resources.ResourceManager;
@@ -36,6 +38,7 @@ public class ExportToCAction extends AbstractDecompilerAction {
public ExportToCAction() {
super("Export to C");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarExport"));
setToolBarData(new ToolBarData(EXPORT_ICON, "Local"));
setDescription("Export the current function to C");
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindAction.java
index df5503e470..f042cc7d62 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindAction.java
@@ -27,6 +27,7 @@ import docking.widgets.fieldpanel.support.FieldLocation;
import ghidra.app.decompiler.component.ClangTextField;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.util.HelpLocation;
public class FindAction extends AbstractDecompilerAction {
@@ -34,6 +35,7 @@ public class FindAction extends AbstractDecompilerAction {
public FindAction() {
super("Find");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionFind"));
setPopupMenuData(new MenuData(new String[] { "Find..." }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK));
setEnabled(true);
@@ -49,7 +51,8 @@ public class FindAction extends AbstractDecompilerAction {
decompilerPanel.setSearchResults(null);
}
};
- findDialog.setHelpLocation(new HelpLocation("DecompilePlugin", "Find"));
+ findDialog
+ .setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionFind"));
}
return findDialog;
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToAddressAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToAddressAction.java
index 33ee4284b4..d0d7517cdf 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToAddressAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToAddressAction.java
@@ -21,8 +21,10 @@ import ghidra.app.actions.AbstractFindReferencesToAddressAction;
import ghidra.app.context.NavigatableActionContext;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.plugin.core.navigation.locationreferences.LocationReferencesService;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.util.ProgramLocation;
+import ghidra.util.HelpLocation;
/**
* An action to show all references to the given address
@@ -32,6 +34,7 @@ public class FindReferencesToAddressAction extends AbstractFindReferencesToAddre
public FindReferencesToAddressAction(PluginTool tool, String owner) {
super(tool, owner);
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionShowReferences"));
setPopupMenuData(new MenuData(new String[] { LocationReferencesService.MENU_GROUP, NAME }));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToDataTypeAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToDataTypeAction.java
index 3591fbf78a..2803568a01 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToDataTypeAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToDataTypeAction.java
@@ -23,8 +23,10 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.plugin.core.navigation.locationreferences.LocationReferencesService;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
+import ghidra.util.HelpLocation;
public class FindReferencesToDataTypeAction extends AbstractFindReferencesDataTypeAction {
@@ -35,6 +37,7 @@ public class FindReferencesToDataTypeAction extends AbstractFindReferencesDataTy
super(tool, NAME, owner, DEFAULT_KEY_STROKE);
this.controller = controller;
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionFindUses"));
setPopupMenuData(
new MenuData(new String[] { LocationReferencesService.MENU_GROUP, "Find Uses of " }));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToSymbolAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToSymbolAction.java
index ffa99b2d85..59ecc9226a 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToSymbolAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/FindReferencesToSymbolAction.java
@@ -42,10 +42,9 @@ public class FindReferencesToSymbolAction extends AbstractDecompilerAction {
public FindReferencesToSymbolAction() {
super(NAME);
-
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionFindReferences"));
setPopupMenuData(
new MenuData(new String[] { LocationReferencesService.MENU_GROUP, MENU_ITEM_TEXT }));
- setHelpLocation(new HelpLocation(HelpTopics.FIND_REFERENCES, HelpTopics.FIND_REFERENCES));
}
private Symbol getSymbol(DecompilerActionContext context) {
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceAction.java
index b41d033c3e..211b5846d3 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceAction.java
@@ -22,13 +22,16 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
+import ghidra.util.HelpLocation;
public class ForwardSliceAction extends AbstractDecompilerAction {
public ForwardSliceAction() {
super("Highlight Forward Slice");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionHighlight"));
setPopupMenuData(new MenuData(new String[] { "Highlight", "Forward Slice" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceToPCodeOpsAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceToPCodeOpsAction.java
index 1203b345a6..5b013145d4 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceToPCodeOpsAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ForwardSliceToPCodeOpsAction.java
@@ -22,13 +22,16 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
+import ghidra.util.HelpLocation;
public class ForwardSliceToPCodeOpsAction extends AbstractDecompilerAction {
public ForwardSliceToPCodeOpsAction() {
super("Highlight Forward Inst Slice");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionHighlight"));
setPopupMenuData(
new MenuData(new String[] { "Highlight", "Forward Inst Slice" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/GraphASTControlFlowAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/GraphASTControlFlowAction.java
index a9a2e4ca56..67c647eaf8 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/GraphASTControlFlowAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/GraphASTControlFlowAction.java
@@ -20,16 +20,19 @@ import static ghidra.app.plugin.core.decompile.actions.ASTGraphTask.GraphType.*;
import docking.action.MenuData;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.services.GraphDisplayBroker;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.pcode.HighFunction;
+import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.task.TaskLauncher;
public class GraphASTControlFlowAction extends AbstractDecompilerAction {
public GraphASTControlFlowAction() {
super("Graph AST Control Flow");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarGraph"));
setMenuBarData(new MenuData(new String[] { "Graph AST Control Flow" }, "graph"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/HighlightDefinedUseAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/HighlightDefinedUseAction.java
index e8c2f7ac11..67ccef0598 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/HighlightDefinedUseAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/HighlightDefinedUseAction.java
@@ -22,13 +22,16 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerPanel;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.pcode.Varnode;
+import ghidra.util.HelpLocation;
public class HighlightDefinedUseAction extends AbstractDecompilerAction {
public HighlightDefinedUseAction() {
super("Highlight Defined Use");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionHighlight"));
setPopupMenuData(new MenuData(new String[] { "Highlight", "Def-use" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/IsolateVariableAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/IsolateVariableAction.java
index d3b79f4605..23ca493f0b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/IsolateVariableAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/IsolateVariableAction.java
@@ -18,15 +18,18 @@ package ghidra.app.plugin.core.decompile.actions;
import docking.action.MenuData;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.Function;
import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.SourceType;
+import ghidra.util.HelpLocation;
import ghidra.util.UndefinedFunction;
public class IsolateVariableAction extends AbstractDecompilerAction {
public IsolateVariableAction() {
super("Split Out As New Variable");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionIsolate"));
setPopupMenuData(new MenuData(new String[] { "Split Out As New Variable" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/OverridePrototypeAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/OverridePrototypeAction.java
index 2e0cd15444..d8f6bd5355 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/OverridePrototypeAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/OverridePrototypeAction.java
@@ -22,14 +22,14 @@ import docking.widgets.OptionDialog;
import ghidra.app.decompiler.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.plugin.core.function.EditFunctionSignatureDialog;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.Reference;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
import ghidra.util.exception.CancelledException;
public class OverridePrototypeAction extends AbstractDecompilerAction {
@@ -43,6 +43,7 @@ public class OverridePrototypeAction extends AbstractDecompilerAction {
public ProtoOverrideDialog(PluginTool tool, Function func, String signature, String conv) {
super(tool, "Override Signature", func);
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionOverrideSignature"));
setSignature(signature);
setCallingConvention(conv);
}
@@ -83,6 +84,7 @@ public class OverridePrototypeAction extends AbstractDecompilerAction {
public OverridePrototypeAction() {
super("Override Signature");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionOverrideSignature"));
setPopupMenuData(new MenuData(new String[] { "Override Signature" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveAllSecondaryHighlightsAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveAllSecondaryHighlightsAction.java
index cfc2194981..2e4d643834 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveAllSecondaryHighlightsAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveAllSecondaryHighlightsAction.java
@@ -18,6 +18,7 @@ package ghidra.app.plugin.core.decompile.actions;
import docking.action.MenuData;
import ghidra.app.decompiler.component.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.util.HelpLocation;
/**
@@ -34,7 +35,7 @@ public class RemoveAllSecondaryHighlightsAction extends AbstractDecompilerAction
setPopupMenuData(new MenuData(
new String[] { "Secondary Highlight", "Remove All Highlights" }, "Decompile"));
- setHelpLocation(new HelpLocation("DecompilePlugin", getName()));
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionSecondaryHighlight"));
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveSecondaryHighlightAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveSecondaryHighlightAction.java
index 565b2a58b1..b8d94eccd6 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveSecondaryHighlightAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RemoveSecondaryHighlightAction.java
@@ -19,6 +19,7 @@ import docking.action.MenuData;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.util.HelpLocation;
/**
@@ -35,7 +36,7 @@ public class RemoveSecondaryHighlightAction extends AbstractDecompilerAction {
setPopupMenuData(
new MenuData(new String[] { "Secondary Highlight", "Remove Highlight" }, "Decompile"));
- setHelpLocation(new HelpLocation("DecompilePlugin", getName()));
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionSecondaryHighlight"));
}
@Override
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFieldAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFieldAction.java
index 0011000a04..6f59db739b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFieldAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFieldAction.java
@@ -22,11 +22,11 @@ import docking.action.MenuData;
import ghidra.app.decompiler.ClangFieldToken;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.Structure;
import ghidra.program.model.listing.Function;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
/**
* Action triggered from a specific token in the decompiler window to rename a field within
@@ -39,6 +39,7 @@ public class RenameFieldAction extends AbstractDecompilerAction {
public RenameFieldAction() {
super("Rename Field");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRenameField"));
setPopupMenuData(new MenuData(new String[] { "Rename Field" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, 0));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFunctionAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFunctionAction.java
index b243876484..a978a5a314 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFunctionAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameFunctionAction.java
@@ -24,15 +24,17 @@ import ghidra.app.decompiler.ClangToken;
import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.util.AddEditDialog;
+import ghidra.app.util.HelpTopics;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
+import ghidra.util.HelpLocation;
import ghidra.util.UndefinedFunction;
public class RenameFunctionAction extends AbstractDecompilerAction {
public RenameFunctionAction() {
super("Rename Function");
-
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRenameFunction"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, 0));
setPopupMenuData(new MenuData(new String[] { "Rename Function" }, "Decompile"));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameGlobalAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameGlobalAction.java
index c8c384f994..48a8747a6b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameGlobalAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameGlobalAction.java
@@ -23,6 +23,7 @@ import ghidra.app.decompiler.ClangFieldToken;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.util.AddEditDialog;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function;
@@ -30,8 +31,7 @@ import ghidra.program.model.pcode.HighCodeSymbol;
import ghidra.program.model.pcode.HighSymbol;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.model.symbol.SymbolTable;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
/**
* Action triggered from a specific token in the decompiler window to rename a global variable.
@@ -42,6 +42,7 @@ public class RenameGlobalAction extends AbstractDecompilerAction {
public RenameGlobalAction() {
super("Rename Global");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRenameGlobal"));
setPopupMenuData(new MenuData(new String[] { "Rename Global" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, 0));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameLocalAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameLocalAction.java
index 70129ae064..3eb38c7650 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameLocalAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RenameLocalAction.java
@@ -22,10 +22,12 @@ import docking.action.MenuData;
import ghidra.app.decompiler.ClangFieldToken;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.listing.Function;
import ghidra.program.model.pcode.HighSymbol;
import ghidra.program.model.symbol.SourceType;
+import ghidra.util.HelpLocation;
import ghidra.util.UndefinedFunction;
/**
@@ -46,6 +48,7 @@ public class RenameLocalAction extends AbstractDecompilerAction {
public RenameLocalAction() {
super("Rename Variable");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRenameVariable"));
setPopupMenuData(new MenuData(new String[] { "Rename Variable" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, 0));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeFieldAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeFieldAction.java
index 7de3ab3a54..b22a11e7b9 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeFieldAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeFieldAction.java
@@ -23,12 +23,12 @@ import docking.action.MenuData;
import ghidra.app.decompiler.ClangFieldToken;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
/**
* Action triggered from a specific token in the decompiler window to change the data-type of
@@ -42,6 +42,7 @@ public class RetypeFieldAction extends AbstractDecompilerAction {
public RetypeFieldAction() {
super("Retype Field");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeField"));
setPopupMenuData(new MenuData(new String[] { "Retype Field" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeGlobalAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeGlobalAction.java
index 14cc4511cb..08b7e9ed78 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeGlobalAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeGlobalAction.java
@@ -22,6 +22,7 @@ import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.decompiler.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager;
@@ -30,8 +31,7 @@ import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.HighFunctionDBUtil;
import ghidra.program.model.pcode.HighSymbol;
import ghidra.program.model.symbol.SourceType;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
import ghidra.util.exception.*;
/**
@@ -46,6 +46,7 @@ public class RetypeGlobalAction extends AbstractDecompilerAction {
public RetypeGlobalAction() {
super("Retype Global");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeGlobal"));
setPopupMenuData(new MenuData(new String[] { "Retype Global" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeLocalAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeLocalAction.java
index 3d5681f353..03afbaec6f 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeLocalAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeLocalAction.java
@@ -22,6 +22,7 @@ import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.decompiler.*;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager;
@@ -29,8 +30,7 @@ import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.SourceType;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
import ghidra.util.exception.*;
/**
@@ -54,6 +54,7 @@ public class RetypeLocalAction extends AbstractDecompilerAction {
public RetypeLocalAction() {
super("Retype Variable");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeVariable"));
setPopupMenuData(new MenuData(new String[] { "Retype Variable" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeReturnAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeReturnAction.java
index 22a89a868c..37e29efbe1 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeReturnAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/RetypeReturnAction.java
@@ -24,6 +24,7 @@ import docking.widgets.OptionDialog;
import ghidra.app.decompiler.ClangReturnType;
import ghidra.app.decompiler.ClangToken;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager;
@@ -32,8 +33,7 @@ import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.HighFunction;
import ghidra.program.model.pcode.HighFunctionDBUtil;
import ghidra.program.model.symbol.SourceType;
-import ghidra.util.Msg;
-import ghidra.util.UndefinedFunction;
+import ghidra.util.*;
import ghidra.util.exception.*;
/**
@@ -48,6 +48,7 @@ public class RetypeReturnAction extends AbstractDecompilerAction {
public RetypeReturnAction() {
super("Retype Return");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeReturn"));
setPopupMenuData(new MenuData(new String[] { "Retype Return" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
}
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/SpecifyCPrototypeAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/SpecifyCPrototypeAction.java
index b1a46b5faa..b84b3cff2f 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/SpecifyCPrototypeAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/SpecifyCPrototypeAction.java
@@ -24,18 +24,21 @@ import ghidra.app.decompiler.component.DecompilerUtils;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
import ghidra.app.plugin.core.function.editor.*;
import ghidra.app.services.DataTypeManagerService;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.VariableStorage;
import ghidra.program.model.pcode.*;
import ghidra.program.model.symbol.SourceType;
+import ghidra.util.HelpLocation;
import ghidra.util.UndefinedFunction;
public class SpecifyCPrototypeAction extends AbstractDecompilerAction {
public SpecifyCPrototypeAction() {
super("Edit Function Signature");
+ setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionEditSignature"));
setPopupMenuData(new MenuData(new String[] { "Edit Function Signature" }, "Decompile"));
}