Class AddressableInstruction<InsnType extends IInstruction>
- All Implemented Interfaces:
IInstruction
,ILocatedInstruction
address-less
instructions addressable
.-
Constructor Summary
ConstructorsConstructorDescriptionAddressableInstruction
(long address, InsnType insn) Wrap an instruction and attach an address to it. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canThrow()
Determine if the instruction can throw an exception.Collect the list of dereferenced addresses computed by a call-to-sub instruction.collectIndirectCallReferences
(long instructionAddress) Collect the list of dereferenced addresses computed by a call-to-sub instruction.Format the instruction for printingDetermine if an instruction breaks the flow of execution.getBreakingFlow
(long instructionAddress) Determine if an instruction breaks the flow of execution.byte[]
getCode()
Get the binary code that makes up this instruction.void
Determine the variables defined and used by the instruction.Get the underlying instruction.The instruction mnemonic.long
Get the instruction offset or address.Get the list of operands for this instruction.Get the instruction's optional prefix(es).long
Convenience method used to retrieve the primary target of this branching instruction.int
Get the mode the processor was in when it parsed and created this instruction.Determine if an instruction branches to (or calls into) a sub-routine.getRoutineCall
(long instructionAddress) Determine if an instruction branches to (or calls into) a sub-routine.int
getSize()
Get the instruction size in bytes.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstruction
getACS, getCountOfOperands, getDefUse, getDefUseInfo, getOperand, getPrimaryBranchAddress
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.ILocatedInstruction
getOffsetEnd
-
Constructor Details
-
AddressableInstruction
Wrap an instruction and attach an address to it.- Parameters:
address
- the addressinsn
- the instruction
-
-
Method Details
-
getInstruction
Get the underlying instruction.- Returns:
- the instruction
-
getOffset
public long getOffset()Description copied from interface:ILocatedInstruction
Get the instruction offset or address. The offset may be relative to a base, or absolute in the case of a memory address. The choice is up to the implementor.- Specified by:
getOffset
in interfaceILocatedInstruction
- Returns:
- the instruction offset/address
-
getProcessorMode
public int getProcessorMode()Description copied from interface:IInstruction
Get the mode the processor was in when it parsed and created this instruction. Refer toIProcessor
MODE_xxx
.- Specified by:
getProcessorMode
in interfaceIInstruction
- Returns:
- the mode, 0 for none/default
-
getSize
public int getSize()Description copied from interface:IInstruction
Get the instruction size in bytes.- Specified by:
getSize
in interfaceIInstruction
- Returns:
- the instruction size
-
getCode
public byte[] getCode()Description copied from interface:IInstruction
Get the binary code that makes up this instruction.- Specified by:
getCode
in interfaceIInstruction
- Returns:
- an array of bytes, or null if the instruction is abstract
-
getPrefix
Description copied from interface:IInstruction
Get the instruction's optional prefix(es).- Specified by:
getPrefix
in interfaceIInstruction
- Returns:
- the prefix (or prefix string list), null if none
-
getMnemonic
Description copied from interface:IInstruction
The instruction mnemonic.- Specified by:
getMnemonic
in interfaceIInstruction
- Returns:
-
getOperands
Description copied from interface:IInstruction
Get the list of operands for this instruction.- Specified by:
getOperands
in interfaceIInstruction
- Returns:
- a list (possibly empty) of operands, or null if operands are not applicable to the instruction set
-
getBreakingFlow
Description copied from interface:IInstruction
Determine if an instruction breaks the flow of execution.Examples: jump instructions, conditional jumps, return-to-caller instructions, etc. Sub-routine calls should not be regarded as flow-breakers by this method. Refer to
getRoutineCall
.- Specified by:
getBreakingFlow
in interfaceIInstruction
- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction breaks the current flow of execution (sub-routine call instructions are excluded) , false otherwise; if true,IFlowInformation.getTargets()
may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any
-
getBreakingFlow
Description copied from interface:ILocatedInstruction
Determine if an instruction breaks the flow of execution. Examples: jump instructions, conditional jumps, return-to-caller instructions, etc. Sub-routine calls should not be regarded as flow-breakers by this method. Refer togetRoutineCall
.- Specified by:
getBreakingFlow
in interfaceILocatedInstruction
- Returns:
IFlowInformation.isBroken()
is true if the instruction breaks the current flow of execution (sub-routine call instructions are excluded) , false otherwise; if true,IFlowInformation.getTargets()
may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any- See Also:
-
getRoutineCall
Description copied from interface:IInstruction
Determine if an instruction branches to (or calls into) a sub-routine.Under normal circumstances, those instructions save the return address (e.g., on a stack or in a register). Therefore, the fall-through address is implied and should not be returned by
IFlowInformation.getTargets()
. The list of targets should contain the branch address - or addresses, for example if the processor branching instruction allows branch selection.- Specified by:
getRoutineCall
in interfaceIInstruction
- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction calls into a sub-routine, false otherwise; if true,IFlowInformation.getTargets()
may be filled, else its contents is irrelevant
-
getRoutineCall
Description copied from interface:ILocatedInstruction
Determine if an instruction branches to (or calls into) a sub-routine.Under normal circumstances, those instructions save the return address (e.g., on a stack or in a register). Therefore, the fall-through address is implied and should not be returned by
IFlowInformation.getTargets()
. The list of targets should contain the branch address - or addresses, for example if the processor branching instruction allows branch selection.- Specified by:
getRoutineCall
in interfaceILocatedInstruction
- Returns:
IFlowInformation.isBroken()
is true if the instruction calls into a sub-routine, false otherwise; if true,IFlowInformation.getTargets()
may be filled, else its contents is irrelevant- See Also:
-
collectIndirectCallReferences
Description copied from interface:IInstruction
Collect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused withIInstruction.getRoutineCall(long)
.- Specified by:
collectIndirectCallReferences
in interfaceIInstruction
- Parameters:
instructionAddress
- the address of the current instruction- Returns:
IFlowInformation.isBroken()
is true if the instruction indirectly calls into a sub-routine, false otherwise (in particular for direct routine calls); if true, theIFlowInformation.getTargets()
may be filled with the dereferenced addresses, else its contents is irrelevant
-
collectIndirectCallReferences
Description copied from interface:ILocatedInstruction
Collect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused withIInstruction.getRoutineCall(long)
.- Specified by:
collectIndirectCallReferences
in interfaceILocatedInstruction
- Returns:
IFlowInformation.isBroken()
is true if the instruction indirectly calls into a sub-routine, false otherwise (in particular for direct routine calls); if true, theIFlowInformation.getTargets()
may be filled with the dereferenced addresses, else its contents is irrelevant- See Also:
-
getPrimaryBranchAddress
public long getPrimaryBranchAddress()Description copied from interface:ILocatedInstruction
Convenience method used to retrieve the primary target of this branching instruction. If the instruction is not branching, or if the target cannot be determined, -1 is returned. If the instruction has multiple branches, only one is returned.- Specified by:
getPrimaryBranchAddress
in interfaceILocatedInstruction
- Returns:
- the target address, or -1 on error
-
getDefUse
Description copied from interface:IInstruction
Determine the variables defined and used by the instruction.- Specified by:
getDefUse
in interfaceIInstruction
- Parameters:
def
- output, the list of variables defined by the instruction.use
- output, the list of variables used by the instructioncontext
- optional context (implementation specific)
-
getInstructionFlags
- Specified by:
getInstructionFlags
in interfaceIInstruction
- Returns:
- instruction flags, never null
-
canThrow
public boolean canThrow()Description copied from interface:IInstruction
Determine if the instruction can throw an exception.- Specified by:
canThrow
in interfaceIInstruction
- Returns:
- true if the exception can raise
-
format
Description copied from interface:IInstruction
Format the instruction for printing- Specified by:
format
in interfaceIInstruction
- Parameters:
context
- optional context, used to provide a better representation of the instruction (for instance, resolving strings or method names.) The implementor should do its best to return a decent result even if context is null.- Returns:
-
toString
-