public class

AddressableInstruction

extends Object
implements ILocatedInstruction
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.AddressableInstruction<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>

Class Overview

Decorator that makes address-less instructions addressable.

Summary

Public Constructors
AddressableInstruction(long address, InsnType insn)
Wrap an instruction and attach an address to it.
Public Methods
boolean canThrow()
Determine if the instruction can throw an exception.
IFlowInformation collectIndirectCallReferences()
Collect the list of dereferenced addresses computed by a call-to-sub instruction.
IFlowInformation collectIndirectCallReferences(long instructionAddress)
Collect the list of dereferenced addresses computed by a call-to-sub instruction.
String format(Object context)
Format the instruction for printing
IFlowInformation getBreakingFlow(long instructionAddress)
Determine if an instruction breaks the flow of execution.
IFlowInformation getBreakingFlow()
Determine if an instruction breaks the flow of execution.
byte[] getCode()
Get the binary code that makes up this instruction.
void getDefUse(List<Integer> def, List<Integer> use, Object context)
Determine the variables defined and used by the instruction.
InsnType getInstruction()
Get the underlying instruction.
Collection<InstructionFlags> getInstructionFlags()
String getMnemonic()
The instruction mnemonic.
long getOffset()
Get the instruction offset or address.
IInstructionOperand[] getOperands()
Get the list of operands for this instruction.
String getPrefix()
Get the instruction's optional prefix(es).
long getPrimaryBranchAddress()
Convenience method used to retrieve the primary target of this branching instruction.
int getProcessorMode()
Get the mode the processor was in when it parsed and created this instruction.
IFlowInformation getRoutineCall(long instructionAddress)
Determine if an instruction branches to (or calls into) a sub-routine.
IFlowInformation getRoutineCall()
Determine if an instruction branches to (or calls into) a sub-routine.
int getSize()
Get the instruction size in bytes.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.IInstruction
From interface com.pnfsoftware.jeb.core.units.code.ILocatedInstruction

Public Constructors

public AddressableInstruction (long address, InsnType insn)

Wrap an instruction and attach an address to it.

Parameters
address the address
insn the instruction

Public Methods

public boolean canThrow ()

Determine if the instruction can throw an exception.

Returns
  • true if the exception can raise

public IFlowInformation collectIndirectCallReferences ()

Collect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused with getRoutineCall(long).

Returns
  • isBroken() is true if the instruction indirectly calls into a sub-routine, false otherwise (in particular for direct routine calls); if true, the getTargets() may be filled with the dereferenced addresses, else its contents is irrelevant

public IFlowInformation collectIndirectCallReferences (long instructionAddress)

Collect the list of dereferenced addresses computed by a call-to-sub instruction. This method should not be confused with getRoutineCall(long).

Parameters
instructionAddress the address of the current instruction
Returns
  • isBroken() is true if the instruction indirectly calls into a sub-routine, false otherwise (in particular for direct routine calls); if true, the getTargets() may be filled with the dereferenced addresses, else its contents is irrelevant

public String format (Object context)

Format the instruction for printing

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.

public IFlowInformation getBreakingFlow (long instructionAddress)

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.

Parameters
instructionAddress the address of the current instruction
Returns
  • isBroken() is true if the instruction breaks the current flow of execution (sub-routine call instructions are excluded) , false otherwise; if true, getTargets() may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any

public IFlowInformation getBreakingFlow ()

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.

Returns
  • isBroken() is true if the instruction breaks the current flow of execution (sub-routine call instructions are excluded) , false otherwise; if true, getTargets() may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any

public byte[] getCode ()

Get the binary code that makes up this instruction.

Returns
  • an array of bytes, or null if the instruction is abstract

public void getDefUse (List<Integer> def, List<Integer> use, Object context)

Determine the variables defined and used by the instruction.

Parameters
def output, the list of variables defined by the instruction.
use output, the list of variables used by the instruction
context optional context (implementation specific)

public InsnType getInstruction ()

Get the underlying instruction.

Returns
  • the instruction

public Collection<InstructionFlags> getInstructionFlags ()

public String getMnemonic ()

The instruction mnemonic.

public long getOffset ()

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.

Returns
  • the instruction offset/address

public IInstructionOperand[] getOperands ()

Get the list of operands for this instruction.

Returns
  • a list (possibly empty) of operands, or null if operands are not applicable to the instruction set

public String getPrefix ()

Get the instruction's optional prefix(es).

Returns
  • the prefix (or prefix string list), null if none

public long getPrimaryBranchAddress ()

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.

Returns
  • the target address, or -1 on error

public int getProcessorMode ()

Get the mode the processor was in when it parsed and created this instruction. Refer to IProcessor MODE_xxx.

Returns
  • the mode, 0 for none/default

public IFlowInformation getRoutineCall (long instructionAddress)

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 getTargets(). The list of targets should contain the branch address - or addresses, for example if the processor branching instruction allows branch selection.

Parameters
instructionAddress the address of the current instruction
Returns
  • isBroken() is true if the instruction calls into a sub-routine, false otherwise; if true, getTargets() may be filled, else its contents is irrelevant

public IFlowInformation getRoutineCall ()

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 getTargets(). The list of targets should contain the branch address - or addresses, for example if the processor branching instruction allows branch selection.

Returns
  • isBroken() is true if the instruction calls into a sub-routine, false otherwise; if true, getTargets() may be filled, else its contents is irrelevant

public int getSize ()

Get the instruction size in bytes.

Returns
  • the instruction size

public String toString ()