public interface

IInstruction

com.pnfsoftware.jeb.core.units.code.IInstruction
Known Indirect Subclasses

Class Overview

A generic interface to represent machine-code or bytecode instructions. Note that this interface does not specify an address or offset for the instruction.

Summary

Public Methods
abstract boolean canThrow()
Determine if the instruction can throw an exception.
abstract String format(Object context)
Format the instruction for printing
abstract IFlowInformation getBreakingFlow(long instructionAddress)
Determine if an instruction breaks the flow of execution.
abstract byte[] getCode()
Get the binary code that makes up this instruction.
abstract void getDefUse(List<Integer> def, List<Integer> use, Object context)
Determine the registers defined and used by the instruction.
abstract IFlowInformation getIndirectRoutineCall(long instructionAddress)
Determine if an instruction indirectly branches to (or calls into) a sub-routine.
abstract String getMnemonic()
The instruction mnemonic.
abstract IInstructionOperand[] getOperands()
Get the list of operands for this instruction.
abstract String getPrefix()
Get the instruction's optional prefix(es).
abstract int getProcessorMode()
Get the mode the processor was in when it parsed and created this instruction.
abstract IFlowInformation getRoutineCall(long instructionAddress)
Determine if an instruction branches to (or calls into) a sub-routine.
abstract int getSize()
Get the instruction size in bytes.
abstract boolean isConditional()
Determine if the instruction executes conditionally.

Public Methods

public abstract boolean canThrow ()

Determine if the instruction can throw an exception.

Returns
  • true if the exception can raise

public abstract 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 abstract IFlowInformation getBreakingFlow (long instructionAddress)

Determine if an instruction breaks the flow of execution. 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, the getTargets() may be filled with potential addresses, and the first entry should be the fall-through instruction, if there is any

public abstract byte[] getCode ()

Get the binary code that makes up this instruction.

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

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

Determine the registers defined and used by the instruction.

Parameters
def Output, the list of registers defined by the instruction.
use Output, the list of registers used by the instruction.
context Optional context, implementation specific.

public abstract IFlowInformation getIndirectRoutineCall (long instructionAddress)

Determine if an instruction indirectly branches to (or calls into) a sub-routine. Such routine calls first dereference an address to find the actual called address.

Warning: the addresses returned are the dereferenced addresses, not the final address executed.

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 abstract String getMnemonic ()

The instruction mnemonic.

public abstract 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 abstract String getPrefix ()

Get the instruction's optional prefix(es).

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

public abstract 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 abstract IFlowInformation getRoutineCall (long instructionAddress)

Determine if an instruction branches to (or calls into) a sub-routine.

Under normal circumstances, those instructions save the return value (eg, on a stack or in a register). Therefore, the fall-through address is implied and should not be returned by the caller in the getTargets(). That array 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, the getTargets() may be filled, else its contents is irrelevant

public abstract int getSize ()

Get the instruction size in bytes.

Returns
  • the instruction size

public abstract boolean isConditional ()

Determine if the instruction executes conditionally. Note that this method only checks the instruction itself, and not the surrounding code.

Returns
  • true if the instruction executes only under certain condition, false if it always executes