decompiler
1.0.0
|
Check for constants, with pointer type, that correspond to global symbols. More...
#include <coreaction.hh>
Public Member Functions | |
ActionConstantPtr (const string &g) | |
Constructor. | |
virtual void | reset (Funcdata &data) |
Reset the Action for a new function. More... | |
virtual Action * | clone (const ActionGroupList &grouplist) const |
Clone the Action. More... | |
virtual int4 | apply (Funcdata &data) |
Make a single attempt to apply this Action. More... | |
Public Member Functions inherited from ghidra::Action | |
Action (uint4 f, const string &nm, const string &g) | |
Base constructor for an Action. More... | |
virtual | ~Action (void) |
Destructor. | |
virtual void | printStatistics (ostream &s) const |
Dump statistics to stream. More... | |
int4 | perform (Funcdata &data) |
Perform this action (if necessary) More... | |
bool | setBreakPoint (uint4 tp, const string &specify) |
Set a breakpoint on this action. More... | |
virtual void | clearBreakPoints (void) |
Clear all breakpoints set on this Action. | |
bool | setWarning (bool val, const string &specify) |
Set a warning on this action. More... | |
bool | disableRule (const string &specify) |
Disable a specific Rule within this. More... | |
bool | enableRule (const string &specify) |
Enable a specific Rule within this. More... | |
const string & | getName (void) const |
Get the Action's name. | |
const string & | getGroup (void) const |
Get the Action's group. | |
uint4 | getStatus (void) const |
Get the current status of this Action. | |
uint4 | getNumTests (void) |
Get the number of times apply() was invoked. | |
uint4 | getNumApply (void) |
virtual void | resetStats (void) |
Reset all the counts to zero. More... | |
virtual int4 | print (ostream &s, int4 num, int4 depth) const |
Print a description of this Action to stream. More... | |
virtual void | printState (ostream &s) const |
Print status to stream. More... | |
virtual Action * | getSubAction (const string &specify) |
Retrieve a specific sub-action by name. More... | |
virtual Rule * | getSubRule (const string &specify) |
Retrieve a specific sub-rule by name. More... | |
Static Private Member Functions | |
static AddrSpace * | searchForSpaceAttribute (Varnode *vn, PcodeOp *op) |
Search for address space annotations in the path of a pointer constant. More... | |
static AddrSpace * | selectInferSpace (Varnode *vn, PcodeOp *op, const vector< AddrSpace *> &spaceList) |
Select the AddrSpace in which we infer with the given constant is a pointer. More... | |
static SymbolEntry * | isPointer (AddrSpace *spc, Varnode *vn, PcodeOp *op, int4 slot, Address &rampoint, uintb &fullEncoding, Funcdata &data) |
Determine if given Varnode might be a pointer constant. More... | |
Private Attributes | |
int4 | localcount |
Number of passes made for this function. | |
Additional Inherited Members | |
Public Types inherited from ghidra::Action | |
enum | ruleflags { rule_repeatapply = 4, rule_onceperfunc = 8, rule_oneactperfunc = 16, rule_debug = 32, rule_warnings_on = 64, rule_warnings_given = 128 } |
Boolean behavior properties governing this particular Action. More... | |
enum | statusflags { status_start =1, status_breakstarthit =2, status_repeat =4, status_mid =8, status_end =16, status_actionbreak =32 } |
Boolean properties describing the status of an action. More... | |
enum | breakflags { break_start = 1, tmpbreak_start = 2, break_action = 4, tmpbreak_action = 8 } |
Break points associated with an Action. More... | |
Protected Member Functions inherited from ghidra::Action | |
void | issueWarning (Architecture *glb) |
Warn that this Action has applied. More... | |
bool | checkStartBreak (void) |
Check start breakpoint. More... | |
bool | checkActionBreak (void) |
Check action breakpoint. More... | |
void | turnOnWarnings (void) |
Enable warnings for this Action. | |
void | turnOffWarnings (void) |
Disable warnings for this Action. | |
Protected Attributes inherited from ghidra::Action | |
int4 | lcount |
Changes not including last call to apply() | |
int4 | count |
Number of changes made by this action so far. | |
uint4 | status |
Current status. | |
uint4 | breakpoint |
Breakpoint properties. | |
uint4 | flags |
Behavior properties. | |
uint4 | count_tests |
Number of times apply() has been called. | |
uint4 | count_apply |
Number of times apply() made changes. | |
string | name |
Name of the action. | |
string | basegroup |
Base group this action belongs to. | |
Check for constants, with pointer type, that correspond to global symbols.
|
virtual |
Make a single attempt to apply this Action.
This is the main entry point for applying changes to a function that are specific to this Action. The method can inspect whatever it wants to decide if the Action does or does not apply. Changes are indicated by incrementing the count field.
data | is the function to inspect/modify |
Implements ghidra::Action.
References ghidra::Funcdata::beginLoc(), ghidra::PcodeOp::code(), ghidra::CPUI_INT_ADD, ghidra::CPUI_PTRADD, ghidra::CPUI_PTRSUB, ghidra::Funcdata::endLoc(), ghidra::Funcdata::getArch(), ghidra::AddrSpaceManager::getConstantSpace(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::Varnode::hasNoDescend(), ghidra::Funcdata::hasTypeRecoveryStarted(), ghidra::Architecture::inferPtrSpaces, ghidra::Varnode::isConstant(), ghidra::Varnode::isPtrCheck(), ghidra::Varnode::isSpacebase(), ghidra::Varnode::loneDescend(), ghidra::Funcdata::opSwapInput(), ghidra::Varnode::setPtrCheck(), and ghidra::Funcdata::spacebaseConstant().
|
inlinevirtual |
Clone the Action.
If this Action is a member of one of the groups in the grouplist, this returns a clone of the Action, otherwise NULL is returned.
grouplist | is the list of groups being cloned |
Implements ghidra::Action.
References ghidra::ActionStart::apply(), ghidra::ActionGroupList::contains(), and ghidra::Action::getGroup().
|
staticprivate |
Determine if given Varnode might be a pointer constant.
If it is a pointer, return the symbol it points to, or NULL otherwise. If it is determined that the Varnode is a pointer to a specific symbol, the encoding of the full pointer is passed back. Usually this is just the constant value of the Varnode, but in this case of partial pointers (like near pointers) the full pointer may contain additional information.
spc | is the address space being pointed to |
vn | is the given Varnode |
op | is the lone descendant of the Varnode |
slot | is the slot index of the Varnode |
rampoint | will hold the Address of the resolved symbol |
fullEncoding | will hold the full pointer encoding being passed back |
data | is the function being analyzed |
References ghidra::PcodeOp::code(), ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_COPY, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_EQUAL, ghidra::CPUI_INT_LESS, ghidra::CPUI_INT_LESSEQUAL, ghidra::CPUI_INT_NOTEQUAL, ghidra::CPUI_PIECE, ghidra::CPUI_RETURN, ghidra::CPUI_STORE, ghidra::SymbolEntry::getAddr(), ghidra::PcodeOp::getAddr(), ghidra::Funcdata::getArch(), ghidra::PcodeOp::getIn(), ghidra::Datatype::getMetatype(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::Scope::getParent(), ghidra::AddrSpace::getPointerLowerBound(), ghidra::AddrSpace::getPointerUpperBound(), ghidra::Funcdata::getScopeLocal(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::Symbol::getType(), ghidra::Varnode::getTypeDefFacing(), ghidra::Varnode::getTypeReadFacing(), ghidra::Architecture::infer_pointers, ghidra::Datatype::isCharPrint(), ghidra::Address::isInvalid(), ghidra::Varnode::isTypeLock(), ghidra::Scope::queryContainer(), ghidra::AddrSpaceManager::resolveConstant(), ghidra::TYPE_ARRAY, and ghidra::TYPE_PTR.
|
inlinevirtual |
Reset the Action for a new function.
data | is the new function this Action may affect |
Reimplemented from ghidra::Action.
|
staticprivate |
Search for address space annotations in the path of a pointer constant.
From a constant, search forward in its data-flow either for a LOAD or STORE operation where we can see the address space being accessed, or search for a pointer data-type with an address space attribute. We make a limited traversal through the op reading the constant, through INT_ADD, INDIRECT, COPY, and MULTIEQUAL until we hit a LOAD or STORE.
vn | is the constant we are searching from |
op | is the PcodeOp reading the constant |
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_ADD, ghidra::CPUI_LOAD, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_STORE, ghidra::Varnode::endDescend(), ghidra::AddrSpace::getAddrSize(), ghidra::PcodeOp::getIn(), ghidra::Datatype::getMetatype(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::getSpaceFromConst(), ghidra::Varnode::getType(), ghidra::Varnode::loneDescend(), and ghidra::TYPE_PTR.
|
staticprivate |
Select the AddrSpace in which we infer with the given constant is a pointer.
The constant must match the AddrSpace address size. If there is more than one possible match, search for more information in the syntax tree.
vn | is the given constant Varnode |
op | is the PcodeOp which uses the constant |
spaceList | is the list of address spaces to select from |
References ghidra::AddrSpace::getAddrSize(), ghidra::Datatype::getMetatype(), ghidra::AddrSpace::getMinimumPtrSize(), ghidra::Varnode::getSize(), ghidra::Varnode::getType(), and ghidra::TYPE_PTR.