My Project
ghidra_arch.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_ARCH__
20 #define __GHIDRA_ARCH__
21 
22 #include "architecture.hh"
23 
33 struct JavaError : public LowlevelError {
34  string type;
35  JavaError(const string &tp,const string &message) : LowlevelError(message) {
36  type = tp; }
37 };
38 
61  istream &sin;
62  ostream &sout;
63  mutable string warnings;
64  string pspecxml;
65  string cspecxml;
66  string tspecxml;
67  string corespecxml;
68  bool sendsyntaxtree;
69  bool sendCcode;
70  bool sendParamMeasures;
71  virtual Scope *buildGlobalScope(void);
72  virtual Translate *buildTranslator(DocumentStorage &store);
73  virtual void buildLoader(DocumentStorage &store);
74  virtual PcodeInjectLibrary *buildPcodeInjectLibrary(void);
75  virtual void buildTypegrp(DocumentStorage &store);
76  virtual void buildCommentDB(DocumentStorage &store);
77  virtual void buildConstantPool(DocumentStorage &store);
78  virtual void buildContext(DocumentStorage &store);
79  virtual void buildSpecFile(DocumentStorage &store);
80  virtual void modifySpaces(Translate *trans) {} // This is handled directly by GhidraTranslate::initialize
81  virtual void postSpecFile(void);
82  virtual void resolveArchitecture(void);
83 public:
84  ArchitectureGhidra(const string &pspec,const string &cspec,const string &tspec,const string &corespec,istream &i,ostream &o);
85  const string &getWarnings(void) const { return warnings; }
86  void clearWarnings(void) { warnings.clear(); }
87  Document *getRegister(const string &regname);
88  string getRegisterName(const VarnodeData &vndata);
89  Document *getTrackedRegisters(const Address &addr);
90  string getUserOpName(int4 index);
91  uint1 *getPcodePacked(const Address &addr);
92  Document *getMappedSymbolsXML(const Address &addr);
93  Document *getExternalRefXML(const Address &addr);
94  string getCodeLabel(const Address &addr);
95  Document *getType(const string &name,uint8 id);
96  Document *getComments(const Address &fad,uint4 flags);
97  void getBytes(uint1 *buf,int4 size,const Address &inaddr);
98  Document *getPcodeInject(const string &name,int4 type,const InjectContext &con);
99  Document *getCPoolRef(const vector<uintb> &refs);
100  // Document *getScopeProperties(Scope *newscope);
101 
106  void setSendSyntaxTree(bool val) { sendsyntaxtree = val; }
107 
108  bool getSendSyntaxTree(void) const { return sendsyntaxtree; }
109 
114  void setSendCCode(bool val) { sendCcode = val; }
115 
116  bool getSendCCode(void) const { return sendCcode; }
117 
123  void setSendParamMeasures(bool val) { sendParamMeasures = val; }
124 
125  bool getSendParamMeasures(void) const { return sendParamMeasures; }
126 
127  virtual void printMessage(const string &message) const;
128 
129  static void segvHandler(int4 sig);
130  static int4 readToAnyBurst(istream &s);
131  static void readStringStream(istream &s,string &res);
132  static void writeStringStream(ostream &s,const string &msg);
133  static void readToResponse(istream &s);
134  static void readResponseEnd(istream &s);
135  static Document *readXMLAll(istream &s);
136  static Document *readXMLStream(istream &s);
137  static uint1 *readPackedStream(istream &s);
138  static uint1 *readPackedAll(istream &s);
139  static void passJavaException(ostream &s,const string &tp,const string &msg);
140 };
141 
142 #endif
A container for parsed XML documents.
Definition: xml.hh:249
void setSendCCode(bool val)
Toggle whether the recovered source code is emitted as part of the main decompile action...
Definition: ghidra_arch.hh:114
Context needed to emit a p-code injection as a full set of p-code operations.
Definition: pcodeinject.hh:56
bool getSendSyntaxTree(void) const
Get the current setting for emitting data/control-flow.
Definition: ghidra_arch.hh:108
Architecture and associated classes that help manage a single processor architecture and load image...
A collection of p-code injection payloads.
Definition: pcodeinject.hh:162
bool getSendCCode(void) const
Get the current setting for emitting source code.
Definition: ghidra_arch.hh:116
JavaError(const string &tp, const string &message)
Construct given a class and message.
Definition: ghidra_arch.hh:35
bool getSendParamMeasures(void) const
Get the current setting for emitting parameter info.
Definition: ghidra_arch.hh:125
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
Exception that mirrors exceptions thrown by the Ghidra client.
Definition: ghidra_arch.hh:33
The interface to a translation engine for a processor.
Definition: translate.hh:293
void setSendSyntaxTree(bool val)
Toggle whether the data-flow and control-flow is emitted as part of the main decompile action...
Definition: ghidra_arch.hh:106
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
The lowest level error generated by the decompiler.
Definition: error.hh:44
const string & getWarnings(void) const
Get warnings produced by the last decompilation.
Definition: ghidra_arch.hh:85
void setSendParamMeasures(bool val)
Toggle whether recovered parameter information is emitted as part of the main decompile action...
Definition: ghidra_arch.hh:123
A complete in-memory XML document.
Definition: xml.hh:206
string type
The name of the Java exception class.
Definition: ghidra_arch.hh:34
An implementation of the Architecture interface and connection to a Ghidra client.
Definition: ghidra_arch.hh:60
void clearWarnings(void)
Clear warnings.
Definition: ghidra_arch.hh:86
Data defining a specific memory location.
Definition: pcoderaw.hh:33
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:413