decompiler  1.0.0
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
ActionConstantPtr Class Reference

Check for constants, with pointer type, that correspond to global symbols. More...

#include <coreaction.hh>

Inheritance diagram for ActionConstantPtr:
Action

Public Member Functions

 ActionConstantPtr (const string &g)
 Constructor.
 
virtual void reset (Funcdata &data)
 Reset the Action for a new function. More...
 
virtual Actionclone (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 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 void saveXml (ostream &s) const
 Save specifics of this action to stream.
 
virtual void restoreXml (const Element *el, Funcdata *fd)
 Load specifics of action from XML.
 
virtual ActiongetSubAction (const string &specify)
 Retrieve a specific sub-action by name. More...
 
virtual RulegetSubRule (const string &specify)
 Retrieve a specific sub-rule by name. More...
 

Static Private Member Functions

static AddrSpacesearchForLoadStore (Varnode *vn, PcodeOp *op)
 Make a limited search from a constant for a LOAD or STORE so we can see the AddrSpace being accessed. More...
 
static AddrSpaceselectInferSpace (Varnode *vn, PcodeOp *op, const vector< AddrSpace * > &spaceList)
 Select the AddrSpace in which we infer with the given constant is a pointer. More...
 
static SymbolEntryisPointer (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 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 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 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.
 

Detailed Description

Check for constants, with pointer type, that correspond to global symbols.

Member Function Documentation

int4 ActionConstantPtr::apply ( Funcdata data)
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.

Parameters
datais the function to inspect/modify
Returns
0 for a complete application, -1 for a partial completion (due to breakpoint)

Implements Action.

References Funcdata::beginLoc(), PcodeOp::code(), CPUI_INT_ADD, CPUI_PTRADD, CPUI_PTRSUB, Funcdata::endLoc(), Funcdata::getArch(), AddrSpaceManager::getConstantSpace(), PcodeOp::getIn(), Varnode::getOffset(), Varnode::getSize(), PcodeOp::getSlot(), Varnode::hasNoDescend(), Architecture::inferPtrSpaces, Varnode::isConstant(), Varnode::isPtrCheck(), Varnode::isSpacebase(), Funcdata::isTypeRecoveryOn(), Varnode::loneDescend(), Funcdata::opSwapInput(), Varnode::setPtrCheck(), and Funcdata::spacebaseConstant().

virtual Action* ActionConstantPtr::clone ( const ActionGroupList grouplist) const
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.

Parameters
grouplistis the list of groups being cloned
Returns
the cloned Action or NULL

Implements Action.

References ActionStart::apply(), ActionGroupList::contains(), and Action::getGroup().

SymbolEntry * ActionConstantPtr::isPointer ( AddrSpace spc,
Varnode vn,
PcodeOp op,
int4  slot,
Address rampoint,
uintb &  fullEncoding,
Funcdata data 
)
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.

Parameters
spcis the address space being pointed to
vnis the given Varnode
opis the lone descendant of the Varnode
slotis the slot index of the Varnode
rampointwill hold the Address of the resolved symbol
fullEncodingwill hold the full pointer encoding being passed back
datais the function being analyzed
Returns
the recovered symbol or NULL

References bit_transitions(), PcodeOp::code(), CPUI_CALL, CPUI_CALLIND, CPUI_COPY, CPUI_INT_ADD, CPUI_INT_EQUAL, CPUI_INT_LESS, CPUI_INT_LESSEQUAL, CPUI_INT_NOTEQUAL, CPUI_RETURN, CPUI_STORE, SymbolEntry::getAddr(), PcodeOp::getAddr(), Funcdata::getArch(), PcodeOp::getIn(), Datatype::getMetatype(), Varnode::getOffset(), PcodeOp::getOut(), Scope::getParent(), AddrSpace::getPointerLowerBound(), AddrSpace::getPointerUpperBound(), Funcdata::getScopeLocal(), Varnode::getSize(), SymbolEntry::getSymbol(), Varnode::getType(), Symbol::getType(), Architecture::infer_pointers, Datatype::isCharPrint(), Address::isInvalid(), Varnode::isTypeLock(), Scope::queryContainer(), AddrSpaceManager::resolveConstant(), TYPE_ARRAY, and TYPE_PTR.

virtual void ActionConstantPtr::reset ( Funcdata data)
inlinevirtual

Reset the Action for a new function.

Parameters
datais the new function this Action may affect

Reimplemented from Action.

AddrSpace * ActionConstantPtr::searchForLoadStore ( Varnode vn,
PcodeOp op 
)
staticprivate

Make a limited search from a constant for a LOAD or STORE so we can see the AddrSpace being accessed.

We traverse forward through the op reading the constant, through INT_ADD, INDIRECT, COPY, and MULTIEQUAL until we hit a LOAD or STORE.

Parameters
vnis the constant we are searching from
opis the PcodeOp reading the constant
Returns
the discovered AddrSpace or null

References Varnode::beginDescend(), PcodeOp::code(), CPUI_COPY, CPUI_INDIRECT, CPUI_INT_ADD, CPUI_LOAD, CPUI_MULTIEQUAL, CPUI_STORE, Varnode::endDescend(), Varnode::getAddr(), PcodeOp::getIn(), PcodeOp::getOut(), Address::getSpaceFromConst(), and Varnode::loneDescend().

AddrSpace * ActionConstantPtr::selectInferSpace ( Varnode vn,
PcodeOp op,
const vector< AddrSpace * > &  spaceList 
)
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.

Parameters
vnis the given constant Varnode
opis the PcodeOp which uses the constant
spaceListis the list of address spaces to select from
Returns
the selected address space or null

References AddrSpace::getAddrSize(), AddrSpace::getMinimumPtrSize(), and Varnode::getSize().


The documentation for this class was generated from the following files: