GP-3276 Put all C++ classes in ghidra namespace

This commit is contained in:
caheckman 2023-03-30 15:35:19 -04:00
parent ca9a56b5f4
commit fe137f20f3
217 changed files with 1635 additions and 554 deletions

View file

@ -18,6 +18,8 @@
#include "coreaction.hh"
namespace ghidra {
/// Specify the name, group, and properties of the Action
/// \param f is the collection of property flags
/// \param nm is the Action name
@ -1156,3 +1158,5 @@ Action *ActionDatabase::deriveAction(const string &baseaction, const string &grp
registerAction(grp,newact);
return newact;
}
} // End namespace ghidra

View file

@ -15,11 +15,13 @@
*/
/// \file action.hh
/// \brief Action, Rule, and other associates classes supporting transformations on function data-flow
#ifndef __CPUI_ACTION__
#define __CPUI_ACTION__
#ifndef __ACTION_HH__
#define __ACTION_HH__
#include "block.hh"
namespace ghidra {
/// \brief The list of groups defining a \e root Action
///
/// Any Rule or \e leaf Action belongs to a \b group. This class
@ -321,4 +323,5 @@ public:
void universalAction(Architecture *glb); ///< Build the universal action
};
} // End ghidra namespace
#endif

View file

@ -16,6 +16,8 @@
#include "address.hh"
#include "translate.hh"
namespace ghidra {
AttributeId ATTRIB_FIRST = AttributeId("first",27);
AttributeId ATTRIB_LAST = AttributeId("last",28);
AttributeId ATTRIB_UNIQ = AttributeId("uniq",29);
@ -991,3 +993,5 @@ int4 power2Divide(int4 n,uint8 divisor,uint8 &q,uint8 &r)
}
return 0;
}
} // End namespace ghidra

View file

@ -23,11 +23,13 @@
/// by placing them in their own space, separate from RAM. Indirection
/// (i.e. pointers) must be simulated through the LOAD and STORE ops.
#ifndef __CPUI_ADDR__
#define __CPUI_ADDR__
#ifndef __ADDRESS_HH__
#define __ADDRESS_HH__
#include "space.hh"
namespace ghidra {
class AddrSpaceManager;
extern AttributeId ATTRIB_FIRST; ///< Marshaling attribute "first"
@ -555,4 +557,5 @@ extern void unsignedSubtract128(uint8 *a,uint8 *b);
extern int4 unsignedCompare128(uint8 *a,uint8 *b);
extern int4 power2Divide(int4 n,uint8 divisor,uint8 &q,uint8 &r);
} // End namespace ghidra
#endif

View file

@ -22,6 +22,11 @@
#endif
#ifdef CPUI_STATISTICS
#include <cmath>
#endif
namespace ghidra {
#ifdef CPUI_STATISTICS
using std::sqrt;
#endif
@ -1532,3 +1537,5 @@ void Statistics::printResults(ostream &s)
}
#endif
} // End namespace ghidra

View file

@ -15,8 +15,8 @@
*/
/// \file architecture.hh
/// \brief Architecture and associated classes that help manage a single processor architecture and load image
#ifndef __CPUI_ARCHITECTURE__
#define __CPUI_ARCHITECTURE__
#ifndef __ARCHITECTURE_HH__
#define __ARCHITECTURE_HH__
#include "capability.hh"
#include "varmap.hh"
@ -34,6 +34,8 @@
#include "transform.hh"
#include "prefersplit.hh"
namespace ghidra {
#ifdef CPUI_STATISTICS
/// \brief Class for collecting statistics while processing over multiple functions
///
@ -397,4 +399,5 @@ inline bool Architecture::highPtrPossible(const Address &loc,int4 size) const {
return !nohighptr.inRange(loc,size);
}
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
*/
#include "bfd_arch.hh"
namespace ghidra {
// Constructing this object registers capability
BfdArchitectureCapability BfdArchitectureCapability::bfdArchitectureCapability;
@ -169,3 +171,5 @@ void BfdArchitecture::restoreXml(DocumentStorage &store)
SleighArchitecture::restoreXml(store);
}
}
} // End namespace ghidra

View file

@ -16,10 +16,14 @@
*/
/// \file bfd_arch.hh
/// \brief Specific implementation of Architecture using GNU BFD libraries
#ifndef __BFD_ARCH_HH__
#define __BFD_ARCH_HH__
#include "sleigh_arch.hh"
#include "loadimage_bfd.hh"
namespace ghidra {
extern ElementId ELEM_BFD_SAVEFILE; ///< Marshaling element \<bfd_savefile>
/// \brief Extension point for building a GNU BFD capable Architecture
@ -47,3 +51,6 @@ public:
BfdArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
virtual ~BfdArchitecture(void) {}
};
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
#include "block.hh"
#include "funcdata.hh"
namespace ghidra {
AttributeId ATTRIB_ALTINDEX = AttributeId("altindex",75);
AttributeId ATTRIB_DEPTH = AttributeId("depth",76);
AttributeId ATTRIB_END = AttributeId("end",77);
@ -3566,3 +3568,5 @@ FlowBlock *BlockMap::createBlock(const string &name)
sortlist.push_back(bl);
return bl;
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file block.hh
/// \brief Classes related to \e basic \e blocks and control-flow structuring
#ifndef __CPUI_BLOCK__
#define __CPUI_BLOCK__
#ifndef __BLOCK_HH__
#define __BLOCK_HH__
#include "jumptable.hh"
namespace ghidra {
class BlockBasic; // Forward declarations
class BlockList;
class BlockCopy;
@ -816,4 +818,5 @@ inline bool BlockSwitch::CaseOrder::compare(const CaseOrder &a,const CaseOrder &
return (a.depth < b.depth);
}
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "blockaction.hh"
#include "funcdata.hh"
namespace ghidra {
/// Retrieve the current edge (as a \e top FlowBlock and the index of the outgoing edge).
/// If the end-points have been collapsed together, this returns NULL.
/// The top and bottom nodes of the edge are updated to FlowBlocks in the current collapsed graph.
@ -2350,3 +2352,5 @@ int4 ActionNodeJoin::apply(Funcdata &data)
}
return 0;
}
} // End namespace ghidra

View file

@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BLOCK_ACTION__
#define __BLOCK_ACTION__
#ifndef __BLOCKACTION_HH__
#define __BLOCKACTION_HH__
/// \file blockaction.hh
/// \brief Actions and classes associated with transforming and structuring the control-flow graph
#include "action.hh"
namespace ghidra {
/// \brief Class for holding an edge while the underlying graph is being manipulated
///
/// The original FlowBlock nodes that define the end-points of the edge may get
@ -355,4 +357,5 @@ public:
virtual int4 apply(Funcdata &data);
};
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "callgraph.hh"
#include "funcdata.hh"
namespace ghidra {
ElementId ELEM_CALLGRAPH = ElementId("callgraph",226);
ElementId ELEM_NODE = ElementId("node",227);
@ -463,3 +465,4 @@ void CallGraph::decoder(Decoder &decoder)
decoder.closeElement(elemId);
}
} // End namespace ghidra

View file

@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_CALLGRAPH__
#define __CPUI_CALLGRAPH__
#ifndef __CALLGRAPH_HH__
#define __CALLGRAPH_HH__
#include "address.hh"
namespace ghidra {
// Forward declarations
class Architecture;
class Funcdata;
@ -122,4 +124,5 @@ public:
void decoder(Decoder &decoder);
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "capability.hh"
namespace ghidra {
/// Access static vector of CapabilityPoint objects that are registered during static initialization
/// The list itself is created once on the first call to this method
/// \e after all the static initializers have run
@ -46,3 +48,4 @@ void CapabilityPoint::initializeAll(void)
list.clear();
}
} // End namespace ghidra

View file

@ -15,13 +15,15 @@
*/
/// \file capability.hh
/// \brief Infrastructure for discovering code extensions to the decompiler
#ifndef __CAPABILITY__
#define __CAPABILITY__
#ifndef __CAPABILITY_HH__
#define __CAPABILITY_HH__
#include "types.h"
#include <vector>
#include <string>
namespace ghidra {
using std::vector;
using std::string;
@ -49,5 +51,5 @@ public:
static void initializeAll(void); ///< Finish initialization for all extension points
};
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "cast.hh"
#include "op.hh"
namespace ghidra {
/// Sets the TypeFactory used to produce data-types for the arithmeticOutputStandard() method
/// \param t is the TypeFactory
void CastStrategy::setTypeFactory(TypeFactory *t)
@ -530,3 +532,5 @@ bool CastStrategyJava::isZextCast(Datatype *outtype,Datatype *intype) const
if (intype->getSize()>=4) return false; // cast is not zext for int and long
return true;
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file cast.hh
/// \brief API and specific strategies for applying type casts
#ifndef __CPUI_CAST__
#define __CPUI_CAST__
#ifndef __CAST_HH__
#define __CAST_HH__
#include "type.hh"
namespace ghidra {
class Varnode;
class PcodeOp;
@ -199,4 +201,5 @@ public:
virtual bool isZextCast(Datatype *outtype,Datatype *intype) const;
};
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
#include "codedata.hh"
#include "loadimage_bfd.hh"
namespace ghidra {
// Constructing this registers the capability
IfaceCodeDataCapability IfaceCodeDataCapability::ifaceCodeDataCapability;
@ -786,3 +788,5 @@ void IfcCodeDataDumpTargetHits::execute(istream &s)
{
codedata->dumpTargetHits(*status->fileoptr);
}
} // End namespace ghidra

View file

@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_CODEDATA__
#define __CPUI_CODEDATA__
#ifndef __CODEDATA_HH__
#define __CODEDATA_HH__
#include "ifacedecomp.hh"
namespace ghidra {
class IfaceCodeDataCapability : public IfaceCapability {
static IfaceCodeDataCapability ifaceCodeDataCapability; // Singleton instance
IfaceCodeDataCapability(void); // Singleton
@ -194,4 +196,5 @@ public:
virtual void execute(istream &s);
};
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "comment.hh"
#include "funcdata.hh"
namespace ghidra {
ElementId ELEM_COMMENT = ElementId("comment",86);
ElementId ELEM_COMMENTDB = ElementId("commentdb",87);
ElementId ELEM_TEXT = ElementId("text",88);
@ -400,3 +402,5 @@ void CommentSorter::setupHeader(uint4 headerType)
subsort.pos = 0xffffffff;
opstop = commmap.upper_bound(subsort);
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file comment.hh
/// \brief A database interface for high-level language comments
#ifndef __CPUI_COMMENT__
#define __CPUI_COMMENT__
#ifndef __COMMENT_HH__
#define __COMMENT_HH__
#include "address.hh"
namespace ghidra {
class FlowBlock;
class PcodeOp;
class Funcdata;
@ -249,4 +251,5 @@ public:
Comment *getNext(void) const { Comment *res=(*start).second; ++start; return res; } ///< Advance to the next comment
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "comment_ghidra.hh"
namespace ghidra {
CommentDatabaseGhidra::CommentDatabaseGhidra(ArchitectureGhidra *g)
: CommentDatabase()
{
@ -78,3 +80,4 @@ CommentSet::const_iterator CommentDatabaseGhidra::endComment(const Address &fad)
return cache.endComment(fad);
}
} // End namespace ghidra

View file

@ -15,12 +15,14 @@
*/
/// \file comment_ghidra.hh
/// \brief Obtain comments by talking to a Ghidra client
#ifndef __COMMENT_GHIDRA__
#define __COMMENT_GHIDRA__
#ifndef __COMMENT_GHIDRA_HH__
#define __COMMENT_GHIDRA_HH__
#include "comment.hh"
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An implementation of CommentDatabase backed by a Ghidra client
///
/// Comment information about particular functions is obtained by querying
@ -51,4 +53,5 @@ public:
throw LowlevelError("CommentDatabaseGhidra::decode unimplemented"); }
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "condexe.hh"
namespace ghidra {
ConditionMarker::ConditionMarker(void)
{
@ -1094,3 +1096,5 @@ int4 RuleOrPredicate::applyOp(PcodeOp *op,Funcdata &data)
data.opSetOpcode(op,CPUI_COPY);
return 1;
}
} // End namespace ghidra

View file

@ -15,11 +15,13 @@
*/
/// \file condexe.hh
/// \brief Classes for simplifying control-flow with shared conditional expressions
#ifndef __CONDEXE__
#define __CONDEXE__
#ifndef __CONDEXE_HH__
#define __CONDEXE_HH__
#include "funcdata.hh"
namespace ghidra {
/// \brief A helper class for describing the similarity of the boolean condition between 2 CBRANCH operations
///
/// This class determines if two CBRANCHs share the same condition. It also determines if the conditions
@ -234,4 +236,5 @@ public:
virtual int4 applyOp(PcodeOp *op,Funcdata &data);
};
} // End namespace ghidra
#endif

View file

@ -15,13 +15,14 @@
*/
#include <iostream>
#include <cstdlib>
#include "libdecomp.hh"
namespace ghidra {
using std::cin;
using std::cout;
using std::cerr;
#include "libdecomp.hh"
class IfcLoadFile : public IfaceDecompCommand {
public:
virtual void execute(istream &s);
@ -170,9 +171,13 @@ void IfcRestore::execute(istream &s)
*status->optr << savefile << " successfully loaded: " << dcp->conf->getDescription() << endl;
}
} // End namespace ghidra
int main(int argc,char **argv)
{
using namespace ghidra;
const char *initscript = (const char *)0;
{
@ -244,4 +249,3 @@ int main(int argc,char **argv)
exit(retval);
}

View file

@ -17,6 +17,8 @@
#include "slghsymbol.hh"
#include "translate.hh"
namespace ghidra {
ParserContext::ParserContext(ContextCache *ccache,Translate *trans)
{
@ -234,3 +236,4 @@ void ParserWalkerChange::calcCurrentLength(int4 length,int4 numopers)
point->length = length - point->offset; // Convert back to relative length
}
} // End namespace ghidra

View file

@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CONTEXT__
#define __CONTEXT__
#ifndef __CONTEXT_HH__
#define __CONTEXT_HH__
#include "globalcontext.hh"
#include "opcodes.hh"
namespace ghidra {
class Token { // A multiple-byte sized chunk of pattern in a bitstream
string name;
int4 size; // Number of bytes in token;
@ -198,4 +200,5 @@ inline void ParserContext::allocateOperand(int4 i,ParserWalkerChange &walker) {
walker.breadcrumb[walker.depth] = 0;
}
} // End namespace ghidra
#endif

View file

@ -18,6 +18,8 @@
#include "double.hh"
#include "subflow.hh"
namespace ghidra {
/// \brief A stack equation
struct StackEqn {
int4 var1; ///< Variable with 1 coefficient
@ -5500,3 +5502,5 @@ void ActionDatabase::universalAction(Architecture *conf)
act->addAction( new ActionPrototypeWarnings("protorecovery") );
act->addAction( new ActionStop("base") );
}
} // End namespace ghidra

View file

@ -21,13 +21,15 @@
/// (if they do they must check the covers themselves)
#ifndef __CORE_ACTION__
#define __CORE_ACTION__
#ifndef __COREACTION_HH__
#define __COREACTION_HH__
#include "ruleaction.hh"
#include "blockaction.hh"
#include "funcdata.hh"
namespace ghidra {
/// \brief Gather raw p-code for a function.
class ActionStart : public Action {
public:
@ -1088,4 +1090,5 @@ public:
inline bool TermOrder::additiveCompare(const AdditiveEdge *op1,const AdditiveEdge *op2) {
return (-1 == op1->getVarnode()->termOrder(op2->getVarnode())); }
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "cover.hh"
#include "block.hh"
namespace ghidra {
const CoverBlock Cover::emptyBlock;
/// PcodeOp objects and a CoverBlock start/stop boundaries have
@ -562,3 +564,5 @@ void Cover::print(ostream &s) const
s << endl;
}
}
} // End namespace ghidra

View file

@ -15,11 +15,13 @@
*/
/// \file cover.hh
/// \brief Classes describing the topological scope of variables within a function
#ifndef __CPUI_COVER__
#define __CPUI_COVER__
#ifndef __COVER_HH__
#define __COVER_HH__
#include "type.hh"
namespace ghidra {
class PcodeOp;
class FlowBlock;
class Varnode;
@ -89,4 +91,5 @@ public:
map<int4,CoverBlock>::const_iterator end(void) const { return cover.end(); } ///< Get end of CoverBlocks
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "cpool.hh"
namespace ghidra {
AttributeId ATTRIB_A = AttributeId("a",80);
AttributeId ATTRIB_B = AttributeId("b",81);
AttributeId ATTRIB_LENGTH = AttributeId("length",82);
@ -239,3 +241,5 @@ void ConstantPoolInternal::decode(Decoder &decoder,TypeFactory &typegrp)
}
decoder.closeElement(elemId);
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file cpool.hh
/// \brief Definitions to support a constant pool for \e deferred compilation languages (i.e. java byte-code)
#ifndef __CPOOL__
#define __CPOOL__
#ifndef __CPOOL_HH__
#define __CPOOL_HH__
#include "type.hh"
namespace ghidra {
extern AttributeId ATTRIB_A; ///< Marshaling attribute "a"
extern AttributeId ATTRIB_B; ///< Marshaling attribute "b"
extern AttributeId ATTRIB_LENGTH; ///< Marshaling attribute "length"
@ -205,4 +207,5 @@ public:
virtual void decode(Decoder &decoder,TypeFactory &typegrp);
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "cpool_ghidra.hh"
namespace ghidra {
ConstantPoolGhidra::ConstantPoolGhidra(ArchitectureGhidra *g)
{
@ -64,3 +66,5 @@ void ConstantPoolGhidra::decode(Decoder &decoder,TypeFactory &typegrp)
{
throw LowlevelError("Cannot access constant pool with this method");
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file cpool_ghidra.hh
/// \brief Utility for implementing a \e constant \e pool backed by a Ghidra client
#ifndef __CPOOL_GHIDRA__
#define __CPOOL_GHIDRA__
#ifndef __CPOOL_GHIDRA_HH__
#define __CPOOL_GHIDRA_HH__
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An implementation of ConstantPool using a Ghidra client as the backing storage
///
/// The actual CPoolRecord objects are cached locally, but new queries are placed
@ -41,4 +43,5 @@ public:
virtual void decode(Decoder &decoder,TypeFactory &typegrp);
};
} // End namespace ghidra
#endif

View file

@ -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,6 +15,8 @@
*/
#include "crc32.hh"
namespace ghidra {
// Table for bytewise calculation of a 32-bit Cyclic Redundancy Check
uint4 crc32tab[] = {
0x0,0x77073096,0xee0e612c,0x990951ba,0x76dc419,0x706af48f,
@ -70,3 +71,4 @@ uint4 crc32tab[] = {
0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8,0x5d681b02,
0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b,0x2d02ef8d };
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file crc32.hh
/// \brief Table and function for computing a CRC32
#ifndef __CRC32__
#define __CRC32__
#ifndef __CRC32_HH__
#define __CRC32_HH__
#include "types.h"
namespace ghidra {
extern uint4 crc32tab[]; ///< Table for quickly computing a 32-bit Cyclic Redundacy Check (CRC)
/// \brief Feed 8 bits into a CRC register
@ -31,4 +33,5 @@ extern uint4 crc32tab[]; ///< Table for quickly computing a 32-bit Cyclic Redund
inline uint4 crc_update(uint4 reg,uint4 val) {
return crc32tab[(reg ^ val)&0xff] ^ (reg>>8); }
} // End namespace ghidra
#endif

View file

@ -18,6 +18,8 @@
#include "crc32.hh"
#include <ctype.h>
namespace ghidra {
AttributeId ATTRIB_CAT = AttributeId("cat",61);
AttributeId ATTRIB_FIELD = AttributeId("field",62);
AttributeId ATTRIB_MERGE = AttributeId("merge",63);
@ -3364,3 +3366,5 @@ void Database::decodeScope(Decoder &decoder,Scope *newScope)
}
decoder.closeElement(elemId);
}
} // End namespace ghidra

View file

@ -20,13 +20,15 @@
/// scopes, namespaces etc. Search can be by name or the address of the Symbol storage
/// location.
#ifndef __CPUI_DATABASE__
#define __CPUI_DATABASE__
#ifndef __DATABASE_HH__
#define __DATABASE_HH__
#include "variable.hh"
#include "partmap.hh"
#include "rangemap.hh"
namespace ghidra {
class Architecture;
class Funcdata;
class Scope;
@ -976,4 +978,5 @@ inline Symbol::Symbol(Scope *sc)
depthResolution = 0;
}
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "database_ghidra.hh"
#include "funcdata.hh"
namespace ghidra {
Scope *ScopeGhidra::buildSubScope(uint8 id,const string &nm)
{
@ -389,3 +391,5 @@ bool ScopeGhidraNamespace::isNameUsed(const string &nm,const Scope *op2) const
uint8 otherId = (otherScope != (const ScopeGhidraNamespace *)0) ? otherScope->getId() : 0;
return ghidra->isNameUsed(nm, uniqueId, otherId);
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file database_ghidra.hh
/// \brief Facilities for retrieving symbol information from a Ghidra client
#ifndef __DATABASE_GHIDRA__
#define __DATABASE_GHIDRA__
#ifndef __DATABASE_GHIDRA_HH__
#define __DATABASE_GHIDRA_HH__
#include "database.hh"
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An implementation of the Scope interface by querying a Ghidra client for Symbol information
///
/// This object is generally instantiated once for an executable and
@ -137,4 +139,5 @@ public:
virtual bool isNameUsed(const string &nm,const Scope *op2) const;
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "double.hh"
namespace ghidra {
/// Internally, the \b lo and \b hi Varnodes are set to null, and the \b val field
/// holds the constant value.
/// \param sz is the size in bytes of the constant
@ -3484,3 +3486,5 @@ void RuleDoubleStore::reassignIndirects(Funcdata &data,PcodeOp *newStore,const v
data.opSetInput(op,data.newVarnodeIop(newStore),1); // Assign the INDIRECT to the new STORE
}
}
} // End namespace ghidra

View file

@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_DOUBLE__
#define __CPUI_DOUBLE__
#ifndef __DOUBLE_HH__
#define __DOUBLE_HH__
#include "ruleaction.hh"
#include "funcdata.hh"
namespace ghidra {
/// \brief A logical value whose storage is split between two Varnodes
///
/// This is usually a pair of Varnodes \b lo and \b hi holding the least and
@ -339,4 +341,6 @@ public:
static bool testIndirectUse(PcodeOp *op1,PcodeOp *op2,const vector<PcodeOp *> &indirects);
static void reassignIndirects(Funcdata &data,PcodeOp *newStore,const vector<PcodeOp *> &indirects);
};
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
#include "funcdata.hh"
#include "crc32.hh"
namespace ghidra {
// Table for how to hash opcodes, lumps certain operators (i.e. ADD SUB PTRADD PTRSUB) into one hash
// zero indicates the operator should be skipped
const uint4 DynamicHash::transtable[] = {
@ -763,3 +765,5 @@ void DynamicHash::clearTotalPosition(uint8 &h)
val = ~val;
h &= val;
}
} // End namespace ghidra

View file

@ -17,11 +17,13 @@
/// \brief Utilities for making references to \b dynamic variables: defined as
/// locations and constants that can only be identified by their context within the data-flow graph.
#ifndef __CPUI_DYNAMIC__
#define __CPUI_DYNAMIC__
#ifndef __DYNAMIC_HH__
#define __DYNAMIC_HH__
#include "varnode.hh"
namespace ghidra {
/// \brief An edge between a Varnode and a PcodeOp
///
/// A DynamicHash is defined on a sub-graph of the data-flow, and this defines an edge
@ -102,4 +104,5 @@ public:
static const uint4 transtable[]; ///< Translation of op-codes to hash values
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "emulate.hh"
namespace ghidra {
/// Any time the emulator is about to execute a user-defined pcode op with the given name,
/// the indicated breakpoint is invoked first. The break table does \e not assume responsibility
/// for freeing the breakpoint object.
@ -454,3 +456,5 @@ void EmulatePcodeCache::executeInstruction(void)
executeCurrentOp();
} while(!instruction_start);
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file emulate.hh
/// \brief Classes for emulating p-code
#ifndef __CPUI_EMULATE__
#define __CPUI_EMULATE__
#ifndef __EMULATE_HH__
#define __EMULATE_HH__
#include "memstate.hh"
#include "translate.hh"
namespace ghidra {
class Emulate; // Forward declaration
/// \brief A collection of breakpoints for the emulator
@ -545,4 +547,5 @@ inline Address EmulatePcodeCache::getExecuteAddress(void) const
- VarnodeData
*/
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "architecture.hh"
#include "emulateutil.hh"
namespace ghidra {
/// \param g is the Architecture providing the LoadImage
EmulatePcodeOp::EmulatePcodeOp(Architecture *g)
@ -391,3 +393,5 @@ uintb EmulateSnippet::getTempValue(uintb offset) const
return 0;
return (*iter).second;
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file emulateutil.hh
/// \brief (Lightweight) emulation interface for executing PcodeOp objects within a syntax tree
/// or for executing snippets defined with PcodeOpRaw objects
#ifndef __CPUI_EMUTREE__
#define __CPUI_EMUTREE__
#ifndef __EMULATEUTIL_HH__
#define __EMULATEUTIL_HH__
#include "emulate.hh"
#include "op.hh"
namespace ghidra {
/// \brief Emulation based on (existing) PcodeOps and Varnodes.
///
/// This is still an abstract class. It does most of the work of emulating
@ -172,4 +174,5 @@ public:
uintb getTempValue(uintb offset) const;
};
} // End namespace ghidra
#endif

View file

@ -18,8 +18,8 @@
///
/// This is also doubles as a place to list the common include files
#ifndef __CPUI_ERROR__
#define __CPUI_ERROR__
#ifndef __ERROR_HH__
#define __ERROR_HH__
#include "types.h"
#include <sstream>
@ -33,6 +33,8 @@
#include <cstring>
#include <cctype>
namespace ghidra {
using std::string;
using std::map;
using std::set;
@ -95,4 +97,5 @@ struct ParseError : public LowlevelError { // Parsing error
ParseError(const string &s) : LowlevelError(s) {}
};
} // End namespace ghidra
#endif

View file

@ -29,6 +29,8 @@ extern "C" {
}
#endif
namespace ghidra {
// Path name separator
#ifdef _WINDOWS
char FileManage::separator = '\\';
@ -381,3 +383,5 @@ string FileManage::discoverGhidraRoot(const char *argv0)
}
return "";
}
} // End namespace ghidra

View file

@ -15,8 +15,8 @@
*/
// Generic (POSIX) class for searching files and managing paths
#ifndef __FILEMANAGE__
#define __FILEMANAGE__
#ifndef __FILEMANAGE_HH__
#define __FILEMANAGE_HH__
#include <vector>
#include <string>
@ -24,6 +24,8 @@
#include <sstream>
#include <fstream>
namespace ghidra {
using std::vector;
using std::string;
using std::ifstream;
@ -49,4 +51,5 @@ public:
static string discoverGhidraRoot(const char *argv0);
};
} // End namespace ghidra
#endif

View file

@ -19,6 +19,9 @@
#include <cmath>
#include <limits>
namespace ghidra {
using std::ldexp;
using std::frexp;
using std::signbit;
@ -687,3 +690,5 @@ void FloatFormat::restoreXml(const Element *el)
maxexponent = (1<<exp_size)-1;
calcPrecision();
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file float.hh
/// \brief Support for decoding different floating-point formats
#ifndef __CPUI_FLOATFORMAT__
#define __CPUI_FLOATFORMAT__
#ifndef __FLOAT_HH__
#define __FLOAT_HH__
#include "xml.hh"
namespace ghidra {
/// \brief Encoding information for a single floating-point format
///
/// This class supports manipulation of a single floating-point encoding.
@ -96,4 +98,5 @@ public:
void restoreXml(const Element *el); ///< Restore the format from XML
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "flow.hh"
namespace ghidra {
/// Prepare for tracing flow for a new function.
/// The Funcdata object and references to its internal containers must be explicitly given.
/// \param d is the new function to trace
@ -1416,3 +1418,4 @@ void FlowInfo::recoverJumpTables(vector<JumpTable *> &newTables,vector<PcodeOp *
}
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file flow.hh
/// \brief Utilities for following control-flow in p-code generated from machine instructions
#ifndef __CPUI_FLOW__
#define __CPUI_FLOW__
#ifndef __FLOW_HH__
#define __FLOW_HH__
#include "funcdata.hh"
namespace ghidra {
/// \brief A class for generating the control-flow structure for a single function
///
/// Control-flow for the function is generated in two phases: the method generateOps() produces
@ -165,4 +167,5 @@ public:
bool doesJumpRecord(void) const { return ((flags & record_jumploads)!=0); } ///< Should jump table structure be recorded
};
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "fspec.hh"
#include "funcdata.hh"
namespace ghidra {
AttributeId ATTRIB_CUSTOM = AttributeId("custom",114);
AttributeId ATTRIB_DOTDOTDOT = AttributeId("dotdotdot",115);
AttributeId ATTRIB_EXTENSION = AttributeId("extension",116);
@ -5623,3 +5625,5 @@ void FuncCallSpecs::countMatchingCalls(const vector<FuncCallSpecs *> &qlst)
for(;lastChange<i;++lastChange)
copyList[lastChange]->matchCallCount = num;
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file fspec.hh
/// \brief Definitions for specifying functions prototypes
#ifndef __CPUI_FSPEC__
#define __CPUI_FSPEC__
#ifndef __FSPEC_HH__
#define __FSPEC_HH__
#include "op.hh"
#include "rangemap.hh"
namespace ghidra {
class JoinRecord;
extern AttributeId ATTRIB_CUSTOM; ///< Marshaling attribute "custom"
@ -1717,4 +1719,5 @@ inline bool EffectRecord::operator!=(const EffectRecord &op2) const
return (type != op2.type);
}
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "funcdata.hh"
namespace ghidra {
AttributeId ATTRIB_NOCODE = AttributeId("nocode",84);
ElementId ELEM_AST = ElementId("ast",115);
@ -1044,3 +1046,4 @@ void Funcdata::debugPrintRange(int4 i) const
#endif
} // End namespace ghidra

View file

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_FUNCDATA__
#define __CPUI_FUNCDATA__
#ifndef __FUNCDATA_HH__
#define __FUNCDATA_HH__
/// \file funcdata.hh
/// \brief Utilities for processing data structures associated with a single function
@ -26,6 +26,8 @@
#include "dynamic.hh"
#include "unionresolve.hh"
namespace ghidra {
class FlowInfo;
extern AttributeId ATTRIB_NOCODE; ///< Marshaling attribute "nocode"
@ -682,4 +684,5 @@ extern PcodeOp *cseElimination(Funcdata &data,PcodeOp *op1,PcodeOp *op2);
extern void cseEliminateList(Funcdata &data,vector< pair<uintm,PcodeOp *> > &list,
vector<Varnode *> &outlist);
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "funcdata.hh"
#include "flow.hh"
namespace ghidra {
// Funcdata members pertaining directly to blocks
/// A description of each block in the current structure hierarchy is
@ -1085,3 +1087,5 @@ void Funcdata::spliceBlockBasic(BlockBasic *bl)
bblocks.spliceBlock(bl);
structureReset();
}
} // End namespace ghidra

View file

@ -16,6 +16,8 @@
#include "funcdata.hh"
#include "flow.hh"
namespace ghidra {
// Funcdata members pertaining directly to ops
/// \param op is the given PcodeOp
@ -1412,3 +1414,5 @@ bool Funcdata::moveRespectingCover(PcodeOp *op,PcodeOp *lastOp)
}
return false;
}
} // End namespace ghidra

View file

@ -15,6 +15,8 @@
*/
#include "funcdata.hh"
namespace ghidra {
// Funcdata members pertaining directly to varnodes
/// Properties of a given storage location are gathered from symbol information and
@ -2044,3 +2046,5 @@ bool AncestorRealistic::execute(PcodeOp *op,int4 slot,ParamTrial *t,bool allowFa
}
return false;
}
} // End namespace ghidra

View file

@ -23,6 +23,8 @@
#include "cpool_ghidra.hh"
#include "inject_ghidra.hh"
namespace ghidra {
//AttributeId ATTRIB_BADDATA = AttributeId("baddata",145);
ElementId ELEM_COMMAND_ISNAMEUSED = ElementId("command_isnameused",239);
@ -935,3 +937,4 @@ bool ArchitectureGhidra::isDynamicSymbolName(const string &nm)
return true;
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file ghidra_arch.hh
/// \brief Ghidra specific architecture information and connection to a Ghidra client
#ifndef __GHIDRA_ARCH__
#define __GHIDRA_ARCH__
#ifndef __GHIDRA_ARCH_HH__
#define __GHIDRA_ARCH_HH__
#include "architecture.hh"
namespace ghidra {
extern ElementId ELEM_COMMAND_ISNAMEUSED; ///< Marshaling element \<command_isnameused>
extern ElementId ELEM_COMMAND_GETBYTES; ///< Marshaling element \<command_getbytes>
extern ElementId ELEM_COMMAND_GETCALLFIXUP; ///< Marshaling element \<command_getcallfixup>
@ -166,4 +168,5 @@ public:
static bool isDynamicSymbolName(const string &nm); ///< Check if name is of form FUN_.. or DAT_..
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "ghidra_context.hh"
namespace ghidra {
const TrackedSet &ContextGhidra::getTrackedSet(const Address &addr) const
{
@ -40,3 +42,4 @@ void ContextGhidra::decodeFromSpec(Decoder &decoder)
decoder.skipElement(); // Ignore details handled by ghidra
}
} // End namespace ghidra

View file

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CONTEXT_GHIDRA__
#define __CONTEXT_GHIDRA__
#ifndef __GHIDRA_CONTEXT_HH__
#define __GHIDRA_CONTEXT_HH__
/// \file ghidra_context.hh
/// \brief Obtaining context information from a Ghidra client
@ -22,6 +22,8 @@
#include "globalcontext.hh"
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An implementation of a ContextDatabase obtaining context information via a Ghidra client
///
/// This only implements the tracked register parts of the interface. In fact, this only implements
@ -72,4 +74,5 @@ public:
throw LowlevelError("getTrackedDefault should not be called for GHIDRA"); }
};
} // End namespace ghidra
#endif

View file

@ -23,9 +23,12 @@
#endif
#ifdef __REMOTE_SOCKET__
#include "ifacedecomp.hh"
#endif
namespace ghidra {
#ifdef __REMOTE_SOCKET__
static IfaceStatus *ghidra_dcp = (IfaceStatus *)0;
static RemoteSocket *remote = (RemoteSocket *)0;
@ -502,9 +505,13 @@ void GhidraDecompCapability::initialize(void)
commandmap["setOptions"] = new SetOptions();
}
} // End namespace ghidra
int main(int argc,char **argv)
{
using namespace ghidra;
signal(SIGSEGV, &ArchitectureGhidra::segvHandler); // Exit on SEGV errors
#ifdef _WINDOWS
// Force i/o streams to be in binary mode
@ -520,4 +527,3 @@ int main(int argc,char **argv)
}
GhidraCapability::shutDown();
}

View file

@ -16,8 +16,8 @@
/// \file ghidra_process.hh
/// \brief The formal commands that can be issued to the decompiler by the Ghidra client
#ifndef __GHIDRA_PROCESS__
#define __GHIDRA_PROCESS__
#ifndef __GHIDRA_PROCESS_HH__
#define __GHIDRA_PROCESS_HH__
#include "capability.hh"
#include "ghidra_arch.hh"
@ -27,6 +27,8 @@
#include <iostream>
#include <csignal>
namespace ghidra {
using std::cin;
using std::cout;
@ -239,4 +241,5 @@ public:
extern void connect_to_console(Funcdata *fd);
#endif
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
#include "ghidra_translate.hh"
#include "funcdata.hh"
namespace ghidra {
/// \brief Associate a Varnode with a register name
///
/// \param nm is the register name
@ -154,3 +156,4 @@ void GhidraTranslate::decode(Decoder &decoder)
decoder.closeElement(elemId);
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file ghidra_translate.hh
/// \brief Class for fetching p-code from a Ghidra client
#ifndef __TRANSLATE_GHIDRA__
#define __TRANSLATE_GHIDRA__
#ifndef __GHIDRA_TRANSLATE_HH__
#define __GHIDRA_TRANSLATE_HH__
#include "translate.hh"
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An implementation of Translate that queries a Ghidra client for p-code information
///
/// This class provides:
@ -53,4 +55,5 @@ public:
throw LowlevelError("Cannot dump assembly through this interface"); }
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "globalcontext.hh"
namespace ghidra {
ElementId ELEM_CONTEXT_DATA = ElementId("context_data",120);
ElementId ELEM_CONTEXT_POINTS = ElementId("context_points",121);
ElementId ELEM_CONTEXT_POINTSET = ElementId("context_pointset",122);
@ -613,3 +615,4 @@ void ContextCache::setContext(const Address &addr1,const Address &addr2,int4 num
curspace = (AddrSpace *)0; // Invalidate cache
}
} // End namespace ghidra

View file

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __GLOBALCONTEXT__
#define __GLOBALCONTEXT__
#ifndef __GLOBALCONTEXT_HH__
#define __GLOBALCONTEXT_HH__
/// \file globalcontext.hh
/// \brief Utilities for getting address-based context to the disassembler and decompiler
@ -22,6 +22,8 @@
#include "pcoderaw.hh"
#include "partmap.hh"
namespace ghidra {
extern ElementId ELEM_CONTEXT_DATA; ///< Marshaling element \<context_data>
extern ElementId ELEM_CONTEXT_POINTS; ///< Marshaling element \<context_points>
extern ElementId ELEM_CONTEXT_POINTSET; ///< Marshaling element \<context_pointset>
@ -328,4 +330,5 @@ public:
void setContext(const Address &addr1,const Address &addr2,int4 num,uintm mask,uintm value);
};
} // End namespace ghidra
#endif

View file

@ -90,6 +90,8 @@
#include "grammar.hh"
namespace ghidra {
extern int grammarlex(void);
extern int grammarerror(const char *str);
static CParse *parse;
@ -484,14 +486,14 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 60, 60, 61, 65, 66, 70, 71, 72, 73,
74, 75, 76, 77, 81, 82, 86, 91, 92, 93,
97, 98, 99, 100, 101, 102, 106, 107, 111, 115,
116, 117, 118, 122, 123, 127, 132, 133, 134, 135,
136, 140, 141, 145, 146, 150, 151, 155, 156, 157,
158, 160, 165, 166, 167, 168, 172, 173, 177, 178,
182, 183, 187, 188, 189, 193, 194, 195, 199, 201,
203, 207
0, 62, 62, 63, 67, 68, 72, 73, 74, 75,
76, 77, 78, 79, 83, 84, 88, 93, 94, 95,
99, 100, 101, 102, 103, 104, 108, 109, 113, 117,
118, 119, 120, 124, 125, 129, 134, 135, 136, 137,
138, 142, 143, 147, 148, 152, 153, 157, 158, 159,
160, 162, 167, 168, 169, 170, 174, 175, 179, 180,
184, 185, 189, 190, 191, 195, 196, 197, 201, 203,
205, 209
};
#endif
@ -3360,3 +3362,4 @@ Address parse_machaddr(istream &s,int4 &defaultsize,const TypeFactory &typegrp,b
return res;
}
} // End namespace ghidra

View file

@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CPUI_GRAMMAR__
#define __CPUI_GRAMMAR__
#ifndef __GRAMMAR_HH__
#define __GRAMMAR_HH__
#include "funcdata.hh"
namespace ghidra {
class GrammarToken {
friend class GrammarLexer;
public:
@ -288,4 +290,5 @@ extern Address parse_machaddr(istream &s,int4 &defaultsize,const TypeFactory &ty
extern Address parse_varnode(istream &s,int4 &size,Address &pc,uintm &uq,const TypeFactory &typegrp);
extern Address parse_op(istream &s,uintm &uq,const TypeFactory &typegrp);
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
%{
#include "grammar.hh"
namespace ghidra {
extern int grammarlex(void);
extern int grammarerror(const char *str);
static CParse *parse;
@ -1567,3 +1569,4 @@ Address parse_machaddr(istream &s,int4 &defaultsize,const TypeFactory &typegrp,b
return res;
}
} // End namespace ghidra

View file

@ -16,6 +16,8 @@
*/
#include "graph.hh"
namespace ghidra {
static void print_varnode_vertex(Varnode *vn,ostream &s)
{
@ -496,3 +498,5 @@ void dump_dom_graph(const string &name,const BlockGraph &graph,ostream &s)
dump_block_vertex(graph,s,falsenode);
dump_dom_edges(graph,s,falsenode);
}
} // End namespace ghidra

View file

@ -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.
@ -14,8 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __GRAPH_HH__
#define __GRAPH_HH__
#include "funcdata.hh"
namespace ghidra {
extern void dump_dataflow_graph(Funcdata &data,ostream &s);
extern void dump_controlflow_graph(const string &name,const BlockGraph &graph,ostream &s);
extern void dump_dom_graph(const string &name,const BlockGraph &graph,ostream &s);
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
#include "funcdata.hh"
#include "prefersplit.hh"
namespace ghidra {
/// Update disjoint cover making sure (addr,size) is contained in a single element and return
/// an iterator to this element. The element's \b pass number is set to be the smallest value
/// of any previous intersecting element. Additionally an \b intersect code is passed back:
@ -2670,3 +2672,5 @@ void Heritage::clear(void)
maxdepth = -1;
pass = 0;
}
} // End namespace ghidra

View file

@ -17,11 +17,13 @@
/// \file heritage.hh
/// \brief Utilities for building Static Single Assignment (SSA) form
#ifndef __CPUI_HERITAGE__
#define __CPUI_HERITAGE__
#ifndef __HERITAGE_HH__
#define __HERITAGE_HH__
#include "block.hh"
namespace ghidra {
/// Container holding the stack system for the renaming algorithm. Every disjoint address
/// range (indexed by its initial address) maps to its own Varnode stack.
typedef map<Address,vector<Varnode *> > VariableStack;
@ -294,4 +296,5 @@ public:
const LoadGuard *getStoreGuard(PcodeOp *op) const; ///< Get LoadGuard record associated with given PcodeOp
};
} // End namespace ghidra
#endif

View file

@ -20,6 +20,8 @@ extern "C" {
#include "pcodeparse.hh"
#include "blockaction.hh"
namespace ghidra {
// Constructing this registers the capability
IfaceDecompCapability IfaceDecompCapability::ifaceDecompCapability;
@ -3612,3 +3614,5 @@ void IfcSource::execute(istream &s)
s >> filename;
status->pushScript(filename,filename+"> ");
}
} // End namespace ghidra

View file

@ -16,8 +16,8 @@
/// \file ifacedecomp.hh
/// \brief Console interface commands for the decompiler engine
#ifndef __IFACE_DECOMP__
#define __IFACE_DECOMP__
#ifndef __IFACEDECOMP_HH__
#define __IFACEDECOMP_HH__
#include "graph.hh"
#include "grammar.hh"
@ -28,6 +28,8 @@
#include "rulecompile.hh"
#endif
namespace ghidra {
/// \brief Interface capability point for all decompiler commands
class IfaceDecompCapability : public IfaceCapability {
static IfaceDecompCapability ifaceDecompCapability; ///< Singleton instance
@ -656,4 +658,5 @@ public:
#endif
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "ifaceterm.hh"
namespace ghidra {
IfaceTerm::IfaceTerm(const string &prmpt,istream &is,ostream &os)
: IfaceStatus(prmpt,os)
{
@ -265,3 +267,5 @@ bool IfaceTerm::isStreamFinished(void) const
if (done||inerror) return true;
return sptr->eof();
}
} // End namespace ghidra

View file

@ -16,6 +16,9 @@
/// \file ifaceterm.hh
/// \brief Add some terminal capabilities to the command-line interface (IfaceStatus)
#ifndef __IFACETERM_HH__
#define __IFACETERM_HH__
#include "interface.hh"
#ifdef __TERMINAL__
@ -25,6 +28,8 @@ extern "C" {
}
#endif
namespace ghidra {
/// \brief Implement the command-line interface on top of a specific input stream
///
/// An initial input stream is provided as the base stream to parse for commands.
@ -48,3 +53,6 @@ public:
virtual void popScript(void);
virtual bool isStreamFinished(void) const;
};
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "inject_ghidra.hh"
namespace ghidra {
void InjectContextGhidra::encode(Encoder &encoder) const
{
@ -230,3 +232,5 @@ int4 PcodeInjectLibraryGhidra::manualCallOtherFixup(const string &name,const str
{
return 0; // We don't have to do anything
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file inject_ghidra.hh
/// \brief P-code injection classes using a Ghidra client as the back-end for generating p-code
#ifndef __INJECT_GHIDRA__
#define __INJECT_GHIDRA__
#ifndef __INJECT_GHIDRA_HH__
#define __INJECT_GHIDRA_HH__
#include "pcodeinject.hh"
#include "ghidra_arch.hh"
namespace ghidra {
/// \brief An injection context that can be serialized and sent to the Ghidra client
///
/// This adds the capability to wrap up the context data in \<context> XML tag
@ -91,4 +93,5 @@ public:
virtual const vector<OpBehavior *> &getBehaviors(void);
};
} // End namespace ghidra
#endif

View file

@ -17,6 +17,8 @@
#include "pcodeparse.hh"
#include "architecture.hh"
namespace ghidra {
InjectContextSleigh::~InjectContextSleigh(void)
{
@ -468,3 +470,5 @@ int4 PcodeInjectLibrarySleigh::manualCallOtherFixup(const string &name,const str
registerInject(injectid);
return injectid;
}
} // End namespace ghidra

View file

@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __INJECT_SLEIGH__
#define __INJECT_SLEIGH__
#ifndef __INJECT_SLEIGH_HH__
#define __INJECT_SLEIGH_HH__
#include "pcodeinject.hh"
#include "sleigh.hh"
namespace ghidra {
class InjectContextSleigh : public InjectContext {
public:
PcodeCacher cacher;
@ -109,4 +111,5 @@ public:
virtual const vector<OpBehavior *> &getBehaviors(void);
};
} // End namespace ghidra
#endif

View file

@ -21,6 +21,8 @@
#include "ext/stdio_filebuf.h"
#endif
namespace ghidra {
vector<IfaceCapability *> IfaceCapability::thelist;
void IfaceCapability::initialize(void)
@ -612,3 +614,5 @@ void IfcEcho::execute(istream &s)
status->fileoptr->put(c);
*status->fileoptr << endl;
}
} // End namespace ghidra

View file

@ -16,8 +16,8 @@
/// \file interface.hh
/// \brief Classes and utilities for a \e generic command-line interface
#ifndef __INTERFACE__
#define __INTERFACE__
#ifndef __INTERFACE_HH__
#define __INTERFACE_HH__
#include "capability.hh"
#include <map>
@ -26,6 +26,8 @@
#include <sstream>
#include <cstdio>
namespace ghidra {
using std::map;
using std::istream;
using std::ostream;
@ -295,4 +297,5 @@ public:
virtual void execute(istream &s);
};
} // End namespace ghidra
#endif

View file

@ -17,6 +17,9 @@
#include "emulate.hh"
#include "flow.hh"
namespace ghidra {
AttributeId ATTRIB_LABEL = AttributeId("label",131);
AttributeId ATTRIB_NUM = AttributeId("num",132);
@ -2811,3 +2814,5 @@ bool JumpTable::checkForMultistage(Funcdata *fd)
}
return false;
}
} // End namespace ghidra

View file

@ -16,12 +16,14 @@
/// \file jumptable.hh
/// \brief Classes to support jump-tables and their recovery
#ifndef __CPUI_JUMPTABLE__
#define __CPUI_JUMPTABLE__
#ifndef __JUMPTABLE_HH__
#define __JUMPTABLE_HH__
#include "emulateutil.hh"
#include "rangeutil.hh"
namespace ghidra {
class EmulateFunction;
extern AttributeId ATTRIB_LABEL; ///< Marshaling attribute "label"
@ -601,4 +603,5 @@ inline bool JumpTable::IndexPair::compareByPosition(const IndexPair &op1,const I
return (op1.blockPosition < op2.blockPosition);
}
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "libdecomp.hh"
namespace ghidra {
void startDecompilerLibrary(const char *sleighhome)
{
@ -59,3 +61,4 @@ void shutdownDecompilerLibrary(void)
{
}
} // End namespace ghidra

View file

@ -17,13 +17,15 @@
// You should be able to include this header to get all functionality
// and we put a startup and shutdown routine here
#ifndef __LIBDECOMP__
#define __LIBDECOMP__
#ifndef __LIBDECOMP_HH__
#define __LIBDECOMP_HH__
#include "architecture.hh"
#include "sleigh_arch.hh"
#include "ifacedecomp.hh"
namespace ghidra {
// Initialize all decompiler capabilities and register any sleigh specifications
// If you have an entire ghidra distribution, you can specify its root with the -sleighhome- input,
// otherwise you can provide a list of directories that contain '.lspec' files.
@ -33,4 +35,5 @@ extern void startDecompilerLibrary(const char *sleighhome,const vector<string> &
extern void shutdownDecompilerLibrary(void);
} // End namespace ghidra
#endif

View file

@ -15,6 +15,8 @@
*/
#include "loadimage.hh"
namespace ghidra {
/// This is a convenience method wrapped around the core
/// loadFill() routine. It automatically allocates an array
/// of the desired size, and then fills it with load image data.
@ -110,3 +112,5 @@ void RawLoadImage::loadFill(uint1 *ptr,int4 size,const Address &addr)
throw DataUnavailError(errmsg.str());
}
}
} // End namespace ghidra

View file

@ -16,11 +16,13 @@
/// \file loadimage.hh
/// \brief Classes and API for accessing a binary load image
#ifndef __CPUI_LOADIMAGE__
#define __CPUI_LOADIMAGE__
#ifndef __LOADIMAGE_HH__
#define __LOADIMAGE_HH__
#include "address.hh"
namespace ghidra {
/// \brief Exception indicating data was not available
///
/// This exception is thrown when a request for load image
@ -224,4 +226,5 @@ inline void LoadImage::getReadonly(RangeList &list) const {
/// \param size is the number of bytes to retrieve from the image
/// \param addr is the starting address of the bytes to retrieve
} // End namespace ghidra
#endif

View file

@ -16,6 +16,8 @@
*/
#include "loadimage_bfd.hh"
namespace ghidra {
int4 LoadImageBfd::bfdinit = 0; // Global initialization variable
LoadImageBfd::LoadImageBfd(const string &f,const string &t) : LoadImage(f)
@ -297,3 +299,5 @@ void LoadImageBfd::getReadonly(RangeList &list) const
}
}
}
} // End namespace ghidra

View file

@ -16,8 +16,8 @@
*/
// Use the GNU bfd library to manipulate a load image
#ifndef __LOADIMAGE_BFD__
#define __LOADIMAGE_BFD__
#ifndef __LOADIMAGE_BFD_HH__
#define __LOADIMAGE_BFD_HH__
#include "loadimage.hh"
@ -46,6 +46,8 @@
#undef __LOADIMAGE_BFD__DEFINED_PACKAGE_VERSION
#endif
namespace ghidra {
struct ImportRecord {
string dllname;
string funcname;
@ -88,4 +90,5 @@ public:
virtual void adjustVma(long adjust);
};
} // End namespace ghidra
#endif

Some files were not shown because too many files have changed in this diff Show more