decompiler
1.0.0
|
Concatenating structure pieces gets printed as explicit write statements. More...
Public Member Functions | |
RulePieceStructure (const string &g) | |
Constructor. | |
virtual Rule * | clone (const ActionGroupList &grouplist) const |
Clone the Rule. More... | |
virtual void | getOpList (vector< uint4 > &oplist) const |
List of op codes this rule operates on. More... | |
virtual int4 | applyOp (PcodeOp *op, Funcdata &data) |
Attempt to apply this Rule. More... | |
Public Member Functions inherited from ghidra::Rule | |
Rule (const string &g, uint4 fl, const string &nm) | |
Construct given group, properties name. More... | |
virtual | ~Rule (void) |
Destructor. | |
const string & | getName (void) const |
Return the name of this Rule. | |
const string & | getGroup (void) const |
Return the group this Rule belongs to. | |
uint4 | getNumTests (void) |
Get number of attempted applications. | |
uint4 | getNumApply (void) |
Get number of successful applications. | |
void | setBreak (uint4 tp) |
Set a breakpoint on this Rule. | |
void | clearBreak (uint4 tp) |
Clear a breakpoint on this Rule. | |
void | clearBreakPoints (void) |
Clear all breakpoints on this Rule. | |
void | turnOnWarnings (void) |
Enable warnings for this Rule. | |
void | turnOffWarnings (void) |
Disable warnings for this Rule. | |
bool | isDisabled (void) const |
Return true if this Rule is disabled. | |
void | setDisable (void) |
Disable this Rule (within its pool) | |
void | clearDisable (void) |
Enable this Rule (within its pool) | |
bool | checkActionBreak (void) |
Check if an action breakpoint is turned on. More... | |
uint4 | getBreakPoint (void) const |
Return breakpoint toggles. | |
virtual void | reset (Funcdata &data) |
Reset this Rule. More... | |
virtual void | resetStats (void) |
Reset Rule statistics. More... | |
virtual void | printStatistics (ostream &s) const |
Print statistics for this Rule. More... | |
Static Private Member Functions | |
static Datatype * | determineDatatype (Varnode *vn, int4 &baseOffset) |
Markup for Varnodes pieced together into structure/array. More... | |
static bool | spanningRange (Datatype *ct, int4 off, int4 size) |
For a structured data-type, determine if the given range spans multiple elements. More... | |
static bool | convertZextToPiece (PcodeOp *zext, Datatype *structuredType, int4 offset, Funcdata &data) |
Convert an INT_ZEXT operation to a PIECE with a zero constant as the first parameter. More... | |
static bool | findReplaceZext (vector< PieceNode > &stack, Datatype *structuredType, Funcdata &data) |
Search for leaves in the CONCAT tree defined by an INT_ZEXT operation and convert them to PIECE. More... | |
static bool | separateSymbol (Varnode *root, Varnode *leaf) |
Return true if the two given root and leaf should be part of different symbols. More... | |
Additional Inherited Members | |
Public Types inherited from ghidra::Rule | |
enum | typeflags { type_disable = 1, rule_debug = 2, warnings_on = 4, warnings_given = 8 } |
Properties associated with a Rule. More... | |
Concatenating structure pieces gets printed as explicit write statements.
Set properties so that a CONCAT expression like v = CONCAT(CONCAT(v1,v2),CONCAT(v3,v4))
gets rendered as a sequence of separate write statements. v.field1 = v1; v.field2 = v2; v.field3 = v3; v.field4 = v4;
Attempt to apply this Rule.
This method contains the main logic for applying the Rule. It must use a given PcodeOp as the point at which the Rule applies. If it does apply, changes are made directly to the function and 1 (non-zero) is returned, otherwise 0 is returned.
Reimplemented from ghidra::Rule.
References ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INT_ZEXT, ghidra::CPUI_PIECE, ghidra::AddTreeState::ct, ghidra::AddTreeState::data, ghidra::Funcdata::deleteVarnode(), ghidra::PieceNode::gatherPieces(), ghidra::PcodeOp::getAddr(), ghidra::Varnode::getAddr(), ghidra::Funcdata::getArch(), ghidra::Varnode::getDef(), ghidra::TypeFactory::getExactPiece(), ghidra::Funcdata::getMerge(), ghidra::PieceNode::getOp(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::PieceNode::getSlot(), ghidra::Varnode::getType(), ghidra::PieceNode::getTypeOffset(), ghidra::PieceNode::getVarnode(), ghidra::Funcdata::inheritResolution(), ghidra::Varnode::isAddrTied(), ghidra::PieceNode::isLeaf(), ghidra::PcodeOp::isPartialRoot(), ghidra::Varnode::isProtoPartial(), ghidra::Varnode::loneDescend(), ghidra::Datatype::needsResolution(), ghidra::Funcdata::newOp(), ghidra::Funcdata::newVarnode(), ghidra::Funcdata::newVarnodeOut(), ghidra::Funcdata::opInsertBefore(), ghidra::Funcdata::opSetInput(), ghidra::Funcdata::opSetOpcode(), ghidra::Funcdata::opSetOutput(), ghidra::Merge::registerProtoPartialRoot(), ghidra::Address::renormalize(), ghidra::Datatype::resolveInFlow(), ghidra::PcodeOp::setPartialRoot(), ghidra::Varnode::setProtoPartial(), ghidra::Architecture::types, and ghidra::Varnode::updateType().
|
inlinevirtual |
Clone the Rule.
If this Rule is a member of one of the groups in the grouplist, this returns a clone of the Rule, otherwise NULL is returned.
grouplist | is the list of groups being cloned |
Implements ghidra::Rule.
References ghidra::ActionGroupList::contains().
|
staticprivate |
Convert an INT_ZEXT operation to a PIECE with a zero constant as the first parameter.
The caller provides a parent data-type and an offset into it corresponding to the output of the INT_ZEXT. The op is converted to a PIECE with a 0 Varnode, which will be assigned a data-type based on the parent data-type and a computed offset.
zext | is the INT_ZEXT operation |
ct | is the parent data-type |
offset | is the byte offset of the output within the parent data-type |
data | is the function containing the operation |
References ghidra::CPUI_PIECE, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Datatype::getSize(), ghidra::Varnode::getSpace(), ghidra::Datatype::getSubType(), ghidra::Varnode::getType(), ghidra::Funcdata::inheritResolution(), ghidra::AddrSpace::isBigEndian(), ghidra::Varnode::isConstant(), ghidra::Datatype::needsResolution(), ghidra::Funcdata::newConstant(), ghidra::AddTreeState::offset, ghidra::Funcdata::opInsertInput(), ghidra::Funcdata::opSetOpcode(), and ghidra::Varnode::updateType().
|
staticprivate |
Markup for Varnodes pieced together into structure/array.
Find the base structure or array data-type that the given Varnode is part of.
If the Varnode's data-type is already a structure or array, return that data-type. If the Varnode is part of a known symbol, use that data-type. The starting byte offset of the given Varnode within the structure or array is passed back.
vn | is the given Varnode |
baseOffset | is used to pass back the starting offset |
References ghidra::AddTreeState::ct, ghidra::SymbolEntry::getAddr(), ghidra::Varnode::getAddr(), ghidra::SymbolEntry::getOffset(), ghidra::Varnode::getSize(), ghidra::Datatype::getSize(), ghidra::Varnode::getStructuredType(), ghidra::Datatype::getSubType(), ghidra::Varnode::getSymbolEntry(), ghidra::Datatype::isPieceStructured(), and ghidra::Address::overlap().
|
staticprivate |
Search for leaves in the CONCAT tree defined by an INT_ZEXT operation and convert them to PIECE.
The CONCAT tree can be extended through an INT_ZEXT, if the extensions output crosses multiple fields of the parent data-type. We check this and replace the INT_ZEXT with PIECE if appropriate.
stack | is the node container for the CONCAT tree |
structuredType | is the parent data-type for the tree |
data | is the function containing the tree |
References ghidra::PcodeOp::code(), ghidra::CPUI_INT_ZEXT, ghidra::AddTreeState::data, ghidra::Varnode::getDef(), ghidra::Varnode::getSize(), ghidra::PieceNode::getTypeOffset(), ghidra::PieceNode::getVarnode(), ghidra::PieceNode::isLeaf(), and ghidra::Varnode::isWritten().
|
virtual |
List of op codes this rule operates on.
Populate the given array with all possible OpCodes this Rule might apply to. By default, this method returns all possible OpCodes
oplist | is the array to populate |
Reimplemented from ghidra::Rule.
References ghidra::CPUI_INT_ZEXT, and ghidra::CPUI_PIECE.
Return true if the two given root and leaf should be part of different symbols.
A leaf in a CONCAT tree can be in a separate from the root if it is a parameter or a separate root.
root | is the root of the CONCAT tree |
leaf | is the given leaf Varnode |
References ghidra::PcodeOp::code(), ghidra::CPUI_PIECE, ghidra::Varnode::getDef(), ghidra::Varnode::getSymbolEntry(), ghidra::Varnode::getType(), ghidra::Varnode::isAddrTied(), ghidra::PcodeOp::isMarker(), ghidra::Datatype::isPieceStructured(), ghidra::Varnode::isProtoPartial(), and ghidra::Varnode::isWritten().
|
staticprivate |
For a structured data-type, determine if the given range spans multiple elements.
Return true unless the range falls within a single non-structured element.
ct | is the structured data-type |
offset | is the start of the given range |
size | is the number of bytes in the range |
References ghidra::Datatype::getSize(), ghidra::Datatype::getSubType(), ghidra::Datatype::isPieceStructured(), and ghidra::AddTreeState::offset.