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 TypeMethodDescriptionbooleancanThrow()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.voidDetermine the variables defined and used by the instruction.Get the underlying instruction.The instruction mnemonic.longGet the instruction offset or address.Get the list of operands for this instruction.Get the instruction's optional prefix(es).longConvenience method used to retrieve the primary target of this branching instruction.intGet 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.intgetSize()Get the instruction size in bytes.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstruction
getACS, getCountOfOperands, getDefUse, getDefUseInfo, getOperand, getPrimaryBranchAddressMethods 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:ILocatedInstructionGet 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:
getOffsetin interfaceILocatedInstruction- Returns:
- the instruction offset/address
-
getProcessorMode
public int getProcessorMode()Description copied from interface:IInstructionGet the mode the processor was in when it parsed and created this instruction. Refer toIProcessorMODE_xxx.- Specified by:
getProcessorModein interfaceIInstruction- Returns:
- the mode, 0 for none/default
-
getSize
public int getSize()Description copied from interface:IInstructionGet the instruction size in bytes.- Specified by:
getSizein interfaceIInstruction- Returns:
- the instruction size
-
getCode
public byte[] getCode()Description copied from interface:IInstructionGet the binary code that makes up this instruction.- Specified by:
getCodein interfaceIInstruction- Returns:
- an array of bytes, or null if the instruction is abstract
-
getPrefix
Description copied from interface:IInstructionGet the instruction's optional prefix(es).- Specified by:
getPrefixin interfaceIInstruction- Returns:
- the prefix (or prefix string list), null if none
-
getMnemonic
Description copied from interface:IInstructionThe instruction mnemonic.- Specified by:
getMnemonicin interfaceIInstruction- Returns:
-
getOperands
Description copied from interface:IInstructionGet the list of operands for this instruction.- Specified by:
getOperandsin interfaceIInstruction- Returns:
- a list (possibly empty) of operands, or null if operands are not applicable to the instruction set
-
getBreakingFlow
Description copied from interface:IInstructionDetermine 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:
getBreakingFlowin 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:ILocatedInstructionDetermine 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:
getBreakingFlowin 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:IInstructionDetermine 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:
getRoutineCallin 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:ILocatedInstructionDetermine 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:
getRoutineCallin 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:IInstructionCollect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused withIInstruction.getRoutineCall(long).- Specified by:
collectIndirectCallReferencesin 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:ILocatedInstructionCollect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused withIInstruction.getRoutineCall(long).- Specified by:
collectIndirectCallReferencesin 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:ILocatedInstructionConvenience 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:
getPrimaryBranchAddressin interfaceILocatedInstruction- Returns:
- the target address, or -1 on error
-
getDefUse
Description copied from interface:IInstructionDetermine the variables defined and used by the instruction.- Specified by:
getDefUsein 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:
getInstructionFlagsin interfaceIInstruction- Returns:
- instruction flags, never null
-
canThrow
public boolean canThrow()Description copied from interface:IInstructionDetermine if the instruction can throw an exception.- Specified by:
canThrowin interfaceIInstruction- Returns:
- true if the exception can raise
-
format
Description copied from interface:IInstructionFormat the instruction for printing- Specified by:
formatin 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
-