public abstract class

AbstractProcessor

extends Object
implements IProcessor<InsnType extends IInstruction>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.processor.AbstractProcessor<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>

Class Overview

An abstract implementation of a processor. It is recommended to inherit from this class. The implementor simply needs to implement a parseAt() method. Instruction alignment is enforced.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor
Fields
protected int defaultMode
protected int mode
Public Constructors
AbstractProcessor(int parseCacheLength)
Create a processor with default options: MODE_DEFAULT, little-endian, 1-byte instruction alignment.
AbstractProcessor(int parseCacheLength, int defaultMode, boolean bigEndian, int instructionAlign)
Create a processor.
AbstractProcessor(int parseCacheLength, int defaultMode, IUnitCreator parent, int instructionAlign)
Create a processor, retrieving Endianness from parent IUnitCreator.
Protected Constructors
AbstractProcessor()
Public Methods
int getDefaultMode()
Get the default processor mode.
int getInstructionAlignment()
Retrieve the instruction alignment, in bytes.
int getMode()
Get the processor mode.
ICodeResolver<InsnType> getResolver()
Retrieve a code resolver.
boolean isBigEndian()
Indicates if IProcessor uses BigEndians
InsnType parseAt(IVirtualMemory vm, long address)
Parse a single instruction at the specified address in memory.
InsnType parseWithContext(IMachineContext context)
Parse a single instruction given a machine context.
void setBigEndian(boolean endianness)
Set endianness
void setInstructionAlignment(int align)
Set the instruction alignment, in bytes.
void setMode(int mode)
Set the processor mode.
Protected Methods
void setDefaultMode(int defaultMode)
Set the default mode.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor

Fields

protected int defaultMode

protected int mode

Public Constructors

public AbstractProcessor (int parseCacheLength)

Create a processor with default options: MODE_DEFAULT, little-endian, 1-byte instruction alignment.

public AbstractProcessor (int parseCacheLength, int defaultMode, boolean bigEndian, int instructionAlign)

Create a processor.

public AbstractProcessor (int parseCacheLength, int defaultMode, IUnitCreator parent, int instructionAlign)

Create a processor, retrieving Endianness from parent IUnitCreator.

Protected Constructors

protected AbstractProcessor ()

Public Methods

public int getDefaultMode ()

Get the default processor mode.

Returns

public int getInstructionAlignment ()

Retrieve the instruction alignment, in bytes.

Returns
  • the instruction alignment, eg, 1, 2, 4, 8, etc.

public int getMode ()

Get the processor mode. Typically, the processor mode is a size in bits that indicates how instructions are parsed and/or how addresses are calculated and addressed. Typical processor modes are 16, 32, or 64 (bits). Note: A 'processor mode' could have a different semantic, but anything non-standard is unlikely to be understood by client code. This function will never return 0 See MODE_Xxx for common constants.

Returns

public ICodeResolver<InsnType> getResolver ()

Retrieve a code resolver. A resolver is optional; implementors may decide to not provide one, and return null.

Returns
  • a resolver

public boolean isBigEndian ()

Indicates if IProcessor uses BigEndians

public InsnType parseAt (IVirtualMemory vm, long address)

Parse a single instruction at the specified address in memory.

Parameters
vm the input virtual memory
address the address to read at, with permission of read+write
Returns
  • the instruction, never null. On parsing error, an exception is raised

public InsnType parseWithContext (IMachineContext context)

Parse a single instruction given a machine context. The context provides access to at least:

  • memory data
  • a register bank, including the program counter
When using this method, other settings determined by this interface, such as the processor mode or endianness, can be disregarded: the context has higher priority. However, an implementor is allowed to raise a processor exception if mismatches are detected (typically, the endianness).@return

public void setBigEndian (boolean endianness)

Set endianness

Parameters
endianness true if Big Endian, false if Little Endian (default)

public void setInstructionAlignment (int align)

Set the instruction alignment, in bytes. The implementation may decide to enforce alignment, or ignore it. If alignment is enforced, attempting to parse an unaligned instruction should raise a ProcessorException.

Parameters
align the alignment, must be a strictly positive power of 2

public void setMode (int mode)

Set the processor mode. Implementors may override this class, if they have other/better/proper ways to determine the processor operating mode. In that case, the mode provided by thi method may be regarded as a hint - or disregarded entirely.

Parameters
mode the mode, the value MODE_DEFAULT (0) can be provided to revert to the default processor mode

Protected Methods

protected void setDefaultMode (int defaultMode)

Set the default mode. Only for implementors. This method is and should be called just once (at construction time).

Parameters
defaultMode the default processor mode, cannot be 0