My Project
inject_ghidra.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 __INJECT_GHIDRA__
20 #define __INJECT_GHIDRA__
21 
22 #include "pcodeinject.hh"
23 #include "ghidra_arch.hh"
24 
30 public:
31  virtual void saveXml(ostream &s) const;
32 };
33 
40  string source;
41 public:
42  InjectPayloadGhidra(const string &src,const string &nm,int4 tp) : InjectPayload(nm,tp) { source = src; }
43  virtual void inject(InjectContext &context,PcodeEmit &emit) const;
44  virtual void restoreXml(const Element *el) {}
45  virtual void printTemplate(ostream &s) const;
46  virtual string getSource(void) const { return source; }
47 };
48 
51 public:
52  InjectCallfixupGhidra(const string &src,const string &nm);
53  virtual void restoreXml(const Element *el);
54 };
55 
58 public:
59  InjectCallotherGhidra(const string &src,const string &nm);
60  virtual void restoreXml(const Element *el);
61 };
62 
69 public:
70  ExecutablePcodeGhidra(Architecture *g,const string &src,const string &nm);
71  virtual void inject(InjectContext &context,PcodeEmit &emit) const;
72  virtual void restoreXml(const Element *el);
73  virtual void printTemplate(ostream &s) const;
74 };
75 
81  InjectContextGhidra contextCache;
82  vector<OpBehavior *> inst;
83  virtual int4 allocateInject(const string &sourceName,const string &name,int4 type);
84  virtual void registerInject(int4 injectid);
85 public:
87  virtual int4 manualCallFixup(const string &name,const string &snippet);
88  virtual int4 manualCallOtherFixup(const string &name,const string &outname,const vector<string> &inname,
89  const string &snippet);
90  virtual InjectContext &getCachedContext(void) { return contextCache; }
91  virtual const vector<OpBehavior *> &getBehaviors(void);
92 };
93 
94 #endif
virtual void saveXml(ostream &s) const
Save this context to an XML stream as a <context> tag.
Definition: inject_ghidra.cc:18
Classes for managing p-code injection.
Context needed to emit a p-code injection as a full set of p-code operations.
Definition: pcodeinject.hh:56
A callother-fixup injection that uses a Ghidra client to generate the p-code ops. ...
Definition: inject_ghidra.hh:57
A collection of p-code injection payloads.
Definition: pcodeinject.hh:162
Abstract class for emitting pcode to an application.
Definition: translate.hh:76
A snippet of p-code that can be executed outside of normal analysis.
Definition: pcodeinject.hh:134
virtual InjectContext & getCachedContext(void)
Retrieve a reusable context object for this library.
Definition: inject_ghidra.hh:90
virtual string getSource(void) const
Return a string describing the source of the injection (.cspec, prototype model, etc.)
Definition: inject_ghidra.hh:46
An active container for a set of p-code operations that can be injected into data-flow.
Definition: pcodeinject.hh:78
A call-fixup injection that uses a Ghidra client to generate the p-code ops.
Definition: inject_ghidra.hh:50
An injection context that can be serialized and sent to the Ghidra client.
Definition: inject_ghidra.hh:29
An injection payload that uses a Ghidra client to generate the p-code ops.
Definition: inject_ghidra.hh:39
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
A p-code script that uses a Ghidra client to generate the p-code ops.
Definition: inject_ghidra.hh:68
An XML element. A node in the DOM tree.
Definition: xml.hh:150
InjectPayloadGhidra(const string &src, const string &nm, int4 tp)
Constructor.
Definition: inject_ghidra.hh:42
A p-code injection library that uses a Ghidra client to generate/compile the injection p-code...
Definition: inject_ghidra.hh:80
virtual void restoreXml(const Element *el)
Restore this payload from an XML stream.
Definition: inject_ghidra.hh:44
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