Ghidra Decompiler Analysis Engine
ghidra_process.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 
19 #ifndef __GHIDRA_PROCESS__
20 #define __GHIDRA_PROCESS__
21 
22 #include "capability.hh"
23 #include "ghidra_arch.hh"
24 #include "typegrp_ghidra.hh"
25 #include "grammar.hh"
26 #include "paramid.hh"
27 #include <iostream>
28 #include <csignal>
29 
30 class GhidraCommand;
31 
39 protected:
40  static map<string,GhidraCommand *> commandmap;
41  string name;
42 public:
43  const string &getName(void) const { return name; }
44  static int4 readCommand(istream &sin,ostream &out);
45  static void shutDown(void);
46 };
47 
53  static GhidraDecompCapability ghidraDecompCapability;
54  GhidraDecompCapability(void) { name = "decomp"; }
56  GhidraDecompCapability &operator=(const GhidraDecompCapability &op2);
57 public:
58  virtual void initialize(void);
59 };
60 
72 protected:
73  istream &sin;
74  ostream &sout;
76  int4 status;
77  virtual void loadParameters(void);
78  virtual void sendResult(void);
79 public:
80  GhidraCommand(void) : sin(cin),sout(cout) {
81  ghidra = (ArchitectureGhidra *)0;
82  }
83  virtual ~GhidraCommand(void) {}
84 
89  virtual void rawAction(void)=0;
90  int4 doit(void);
91 };
92 
103  string pspec;
104  string cspec;
105  string tspec;
106  string corespec;
107  virtual void loadParameters(void);
108  virtual void sendResult(void);
109 public:
110  int4 archid;
111  virtual void rawAction(void);
112 };
113 
120  int4 inid;
121  virtual void loadParameters(void);
122  virtual void sendResult(void);
123 public:
124  int4 res;
125  virtual void rawAction(void);
126 };
127 
135 class FlushNative : public GhidraCommand {
136  virtual void sendResult(void);
137 public:
138  int4 res;
139  virtual void rawAction(void);
140 };
141 
152 class DecompileAt : public GhidraCommand {
153  Address addr;
154  virtual void loadParameters(void);
155 public:
156  virtual void rawAction(void);
157 };
158 
171  BlockGraph ingraph;
172  virtual void loadParameters(void);
173 public:
174  virtual void rawAction(void);
175 };
176 
203 class SetAction : public GhidraCommand {
204  string actionstring;
205  string printstring;
206  virtual void loadParameters(void);
207  virtual void sendResult(void);
208 public:
209  bool res;
210  virtual void rawAction(void);
211 };
212 
222 class SetOptions : public GhidraCommand {
223  Document *doc;
224  virtual void loadParameters(void);
225  virtual void sendResult(void);
226 public:
227  SetOptions(void);
228  virtual ~SetOptions(void);
229  bool res;
230  virtual void rawAction(void);
231 };
232 
233 #ifdef __REMOTE_SOCKET__
234 extern void connect_to_console(Funcdata *fd);
235 #endif
236 
237 #endif
GhidraCommand::sout
ostream & sout
The output stream to the Ghidra client.
Definition: ghidra_process.hh:74
FlushNative
Command to flush all symbols associated with a Program (executable)
Definition: ghidra_process.hh:135
SetAction
Command to set the root Action used by the decompiler or toggle output components.
Definition: ghidra_process.hh:203
BlockGraph
A control-flow block built out of sub-components.
Definition: block.hh:271
ghidra_arch.hh
Ghidra specific architecture information and connection to a Ghidra client.
GhidraCommand
Base class for a command to the decompiler as issued by a Ghidra client.
Definition: ghidra_process.hh:71
GhidraDecompCapability::initialize
virtual void initialize(void)
Complete initialization of an extension point.
Definition: ghidra_process.cc:497
SetAction::res
bool res
Set to true if the configuration action was successful.
Definition: ghidra_process.hh:209
Document
A complete in-memory XML document.
Definition: xml.hh:206
SetOptions
Command to toggle options within the decompiler.
Definition: ghidra_process.hh:222
SetAction::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:372
DeregisterProgram::res
int4 res
The meta-command being issued to send back.
Definition: ghidra_process.hh:124
StructureGraph::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:342
GhidraCapability
Registration point and dispatcher for commands sent to the decompiler.
Definition: ghidra_process.hh:38
GhidraCommand::sin
istream & sin
The input stream from the Ghidra client.
Definition: ghidra_process.hh:73
SetOptions::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:436
GhidraCapability::shutDown
static void shutDown(void)
Release all GhidraCommand resources.
Definition: ghidra_process.cc:489
GhidraCapability::commandmap
static map< string, GhidraCommand * > commandmap
The central map from name to Ghidra command.
Definition: ghidra_process.hh:40
GhidraCommand::ghidra
ArchitectureGhidra * ghidra
The Architecture on which to perform the command.
Definition: ghidra_process.hh:75
GhidraCommand::status
int4 status
Meta-command to system (0=wait for next command, 1=terminate process)
Definition: ghidra_process.hh:76
GhidraCapability::name
string name
Identifier for capability and associated commands.
Definition: ghidra_process.hh:41
GhidraCapability::readCommand
static int4 readCommand(istream &sin, ostream &out)
Dispatch a Ghidra command.
Definition: ghidra_process.cc:465
capability.hh
Infrastructure for discovering code extensions to the decompiler.
GhidraCommand::loadParameters
virtual void loadParameters(void)
Read parameters directing command execution.
Definition: ghidra_process.cc:75
RegisterProgram::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:165
StructureGraph
Command to structure a control-flow graph.
Definition: ghidra_process.hh:170
Address
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Funcdata
Container for data structures associated with a single function.
Definition: funcdata.hh:45
GhidraCommand::rawAction
virtual void rawAction(void)=0
Perform the action of the command.
CapabilityPoint
Class for automatically registering extension points to the decompiler.
Definition: capability.hh:36
typegrp_ghidra.hh
Interface for requesting data-type information from a Ghidra client.
RegisterProgram
Command to register a new Program (executable) with the decompiler.
Definition: ghidra_process.hh:102
GhidraCommand::sendResult
virtual void sendResult(void)
Send results of the command (if any) back to the Ghidra client.
Definition: ghidra_process.cc:97
DeregisterProgram::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:216
GhidraCommand::doit
int4 doit(void)
Configure and execute the command, then send back results.
Definition: ghidra_process.cc:114
RegisterProgram::archid
int4 archid
Resulting id of the program to send back.
Definition: ghidra_process.hh:110
ArchitectureGhidra
An implementation of the Architecture interface and connection to a Ghidra client.
Definition: ghidra_arch.hh:60
DecompileAt
Command to decompile a specific function.
Definition: ghidra_process.hh:152
FlushNative::res
int4 res
Success status returned to the client (0=success)
Definition: ghidra_process.hh:138
GhidraDecompCapability
The core decompiler commands capability.
Definition: ghidra_process.hh:52
DecompileAt::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:281
DeregisterProgram
Command to release all resources associated with a Program (executable) in the decompiler.
Definition: ghidra_process.hh:119
FlushNative::rawAction
virtual void rawAction(void)
Perform the action of the command.
Definition: ghidra_process.cc:247
SetOptions::res
bool res
Set to true if the option change succeeded.
Definition: ghidra_process.hh:229