Package ghidra.util.state.analysis
Class MySwitchAnalyzer
- java.lang.Object
-
- ghidra.util.state.analysis.MySwitchAnalyzer
-
- All Implemented Interfaces:
FunctionAnalyzer
public class MySwitchAnalyzer extends java.lang.Object implements FunctionAnalyzer
-
-
Constructor Summary
Constructors Constructor Description MySwitchAnalyzer(Program program)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ResultsState
analyze(Program program, Address functionEntry, TaskMonitor monitor)
void
dataReference(PcodeOp op, int instrOpIndex, Varnode storageVarnode, RefType refType, TaskMonitor monitor)
Callback indicating that an absolute memory reference was encounteredvoid
indirectDataReference(PcodeOp op, int instrOpIndex, Varnode offsetVarnode, int size, int storageSpaceID, RefType refType, TaskMonitor monitor)
Callback indicating that an indirect/computed memory reference was encountered using an indirect/computed offsetboolean
resolvedFlow(PcodeOp op, int instrOpIndex, Address destAddr, ContextState currentState, ResultsState results, TaskMonitor monitor)
Callback indicating that a call/branch destination was identified.boolean
resolvedFlow(PcodeOp op, java.lang.Object opIndex, Address destAddr, ContextState currentState, ResultsState results, TaskMonitor monitor)
void
stackReference(PcodeOp op, int instrOpIndex, int stackOffset, int size, int storageSpaceID, RefType refType, TaskMonitor monitor)
Callback indicating that an absolute stack reference was encountered.void
stackReference(PcodeOp op, int instrOpIndex, VarnodeOperation computedStackOffset, int size, int storageSpaceID, RefType refType, TaskMonitor monitor)
Callback indicating that a computed stack reference was encountered.java.util.List<Address>
unresolvedIndirectFlow(PcodeOp op, int instrOpIndex, Varnode destination, ContextState currentState, ResultsState results, TaskMonitor monitor)
Callback indicating that a computed call/branch destination was not resolved.java.util.List<Address>
unresolvedIndirectFlow(PcodeOp op, java.lang.Object opIndex, Varnode destination, ContextState currentState, ResultsState results, TaskMonitor monitor)
-
-
-
Constructor Detail
-
MySwitchAnalyzer
public MySwitchAnalyzer(Program program)
-
-
Method Detail
-
analyze
public static ResultsState analyze(Program program, Address functionEntry, TaskMonitor monitor) throws CancelledException
- Throws:
CancelledException
-
resolvedFlow
public boolean resolvedFlow(PcodeOp op, java.lang.Object opIndex, Address destAddr, ContextState currentState, ResultsState results, TaskMonitor monitor)
-
unresolvedIndirectFlow
public java.util.List<Address> unresolvedIndirectFlow(PcodeOp op, java.lang.Object opIndex, Varnode destination, ContextState currentState, ResultsState results, TaskMonitor monitor)
-
dataReference
public void dataReference(PcodeOp op, int instrOpIndex, Varnode storageVarnode, RefType refType, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that an absolute memory reference was encountered- Specified by:
dataReference
in interfaceFunctionAnalyzer
- Parameters:
op
- pcode operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determinedstorageVarnode
- absolute storage VarnoderefType
- read/write/data reference typemonitor
- task monitor- Throws:
CancelledException
- if callback canceled by monitor
-
indirectDataReference
public void indirectDataReference(PcodeOp op, int instrOpIndex, Varnode offsetVarnode, int size, int storageSpaceID, RefType refType, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that an indirect/computed memory reference was encountered using an indirect/computed offset- Specified by:
indirectDataReference
in interfaceFunctionAnalyzer
- Parameters:
op
- pcode operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determinedoffsetVarnode
- indirect/computed offsetsize
- access size or -1 if not applicablestorageSpaceID
- storage space IDrefType
- read/write/data reference typemonitor
- task monitor- Throws:
CancelledException
- if callback canceled by monitor
-
resolvedFlow
public boolean resolvedFlow(PcodeOp op, int instrOpIndex, Address destAddr, ContextState currentState, ResultsState results, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that a call/branch destination was identified. Analyzer should create reference if appropriate Keep in mind that there could be other unidentified destinations.- Specified by:
resolvedFlow
in interfaceFunctionAnalyzer
- Parameters:
op
- branch or call flow operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determineddestAddr
- destination addresscurrentState
- current state at the branch/callresults
- contains previous states leading upto the currentStatemonitor
- task monitor- Returns:
- true if destination should be disassembled if not already
- Throws:
CancelledException
- if callback canceled by monitor
-
stackReference
public void stackReference(PcodeOp op, int instrOpIndex, int stackOffset, int size, int storageSpaceID, RefType refType, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that an absolute stack reference was encountered. A non-load/store operation will have a -1 for both storageSpaceId and size.- Specified by:
stackReference
in interfaceFunctionAnalyzer
- Parameters:
op
- pcode operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determinedstackOffset
- stack offsetsize
- access size or -1 if not applicablestorageSpaceID
- storage space ID or -1 if not applicablerefType
- read/write/data reference typemonitor
- task monitor- Throws:
CancelledException
- if callback canceled by monitor
-
stackReference
public void stackReference(PcodeOp op, int instrOpIndex, VarnodeOperation computedStackOffset, int size, int storageSpaceID, RefType refType, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that a computed stack reference was encountered. A non-load/store operation will have a -1 for both storageSpaceId and size.- Specified by:
stackReference
in interfaceFunctionAnalyzer
- Parameters:
op
- pcode operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determinedcomputedStackOffset
- stack offset computation (i.e., VarnodeOperation w/ stack pointer)size
- access size or -1 if not applicablestorageSpaceID
- storage space ID or -1 if not applicablerefType
- read/write/data reference typemonitor
- task monitor- Throws:
CancelledException
- if callback canceled by monitor
-
unresolvedIndirectFlow
public java.util.List<Address> unresolvedIndirectFlow(PcodeOp op, int instrOpIndex, Varnode destination, ContextState currentState, ResultsState results, TaskMonitor monitor) throws CancelledException
Description copied from interface:FunctionAnalyzer
Callback indicating that a computed call/branch destination was not resolved.- Specified by:
unresolvedIndirectFlow
in interfaceFunctionAnalyzer
- Parameters:
op
- indirect branch or call flow operationinstrOpIndex
- opIndex associated with reference or -1 if it could not be determineddestination
- destination identified as a Varnode (may be an expression represented by aVarnodeOperation
currentState
- current state at the branch/callresults
- contains previous states leading upto the currentStatemonitor
- task monitor- Returns:
- list of resolved destinations which should be used or null. List of destination addresses will trigger disassembly where necessary.
- Throws:
CancelledException
- if callback cancelled by monitor
-
-