My Project
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 OPACTION_DEBUG
234 extern void turn_on_debugging(Funcdata *fd);
235 extern void turn_off_debugging(Funcdata *fd);
236 #endif
237 
238 #endif
GhidraCommand(void)
Construct given i/o streams.
Definition: ghidra_process.hh:80
const string & getName(void) const
Get the capability name.
Definition: ghidra_process.hh:43
Base class for a command to the decompiler as issued by a Ghidra client.
Definition: ghidra_process.hh:71
static map< string, GhidraCommand * > commandmap
The central map from name to Ghidra command.
Definition: ghidra_process.hh:40
string name
Identifier for capability and associated commands.
Definition: ghidra_process.hh:41
Container for data structures associated with a single function.
Definition: funcdata.hh:45
Command to toggle options within the decompiler.
Definition: ghidra_process.hh:222
int4 archid
Resulting id of the program to send back.
Definition: ghidra_process.hh:110
Infrastructure for discovering code extensions to the decompiler.
int4 res
The meta-command being issued to send back.
Definition: ghidra_process.hh:124
The core decompiler commands capability.
Definition: ghidra_process.hh:52
bool res
Set to true if the option change succeeded.
Definition: ghidra_process.hh:229
bool res
Set to true if the configuration action was successful.
Definition: ghidra_process.hh:209
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Command to decompile a specific function.
Definition: ghidra_process.hh:152
ostream & sout
The output stream to the Ghidra client.
Definition: ghidra_process.hh:74
A control-flow block built out of sub-components.
Definition: block.hh:270
Registration point and dispatcher for commands sent to the decompiler.
Definition: ghidra_process.hh:38
istream & sin
The input stream from the Ghidra client.
Definition: ghidra_process.hh:73
virtual void initialize(void)=0
Complete initialization of an extension point.
A complete in-memory XML document.
Definition: xml.hh:206
Command to flush all symbols associated with a Program (executable)
Definition: ghidra_process.hh:135
virtual ~GhidraCommand(void)
Destructor.
Definition: ghidra_process.hh:83
Class for automatically registering extension points to the decompiler.
Definition: capability.hh:36
Ghidra specific architecture information and connection to a Ghidra client.
An implementation of the Architecture interface and connection to a Ghidra client.
Definition: ghidra_arch.hh:60
Command to register a new Program (executable) with the decompiler.
Definition: ghidra_process.hh:102
static int4 readCommand(istream &sin, ostream &out)
Dispatch a Ghidra command.
Definition: ghidra_process.cc:459
ArchitectureGhidra * ghidra
The Architecture on which to perform the command.
Definition: ghidra_process.hh:75
Interface for requesting data-type information from a Ghidra client.
Command to set the root Action used by the decompiler or toggle output components.
Definition: ghidra_process.hh:203
Command to release all resources associated with a Program (executable) in the decompiler.
Definition: ghidra_process.hh:119
int4 status
Meta-command to system (0=wait for next command, 1=terminate process)
Definition: ghidra_process.hh:76
static void shutDown(void)
Release all GhidraCommand resources.
Definition: ghidra_process.cc:483
Command to structure a control-flow graph.
Definition: ghidra_process.hh:170
int4 res
Success status returned to the client (0=success)
Definition: ghidra_process.hh:138