public interface

INativeCodeUnit

implements ICodeUnit IMethodManager
com.pnfsoftware.jeb.core.units.INativeCodeUnit<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>

Class Overview

Specialized code unit that manages a native code processor and uses a virtual memory.

Note: if a debugger is attached, a temporary physical image base can be set.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.corei.parsers.asm.analyzer.IMethodManager
Public Methods
abstract long getCanonicalMemoryAddress(String address)
Convert a flexible native code unit address to a canonical memory address.
abstract INativeClassItem getClass(String fqname)
Convenience method used to retrieve a class by name.
abstract List<? extends INativeClassItem> getClasses()
Get the list of classes.
abstract INativeCodeAnalyzer<InsnType> getCodeAnalyzer()
Get the code analyzer.
abstract INativeCodeAnalyzerExtensionsManager<InsnType> getCodeAnalyzerExtensionsManager()
Retrieve the currently-set analyzer extensions manager.
abstract GenericCodeFormatter<InsnType> getCodeFormatter()
Get the helper object used to format instructions into a sink.
abstract INativeCodeModel<InsnType> getCodeModel()
Get the code model.
abstract ICodeObjectUnit getCodeObjectContainer()
Provide the parent code object container, if there is one.
abstract INativeType getDataTypeAt(long address)
abstract INativeDisassemblyDocument getDisassemblyDocument()
Provide the disassembly document.
abstract Endianness getEndianness()
Retrieve the endianness.
abstract INativeFieldItem getField(String fqname)
Convenience method used to retrieve a field by name.
abstract List<? extends INativeFieldItem> getFields()
Get the list of fields.
abstract long getImageSize()
Retrieve the size of the image
abstract INativeMethodItem getInternalMethod(long memoryAddress, boolean addressIsEntryPoint)
Retrieve an internal method by address (any address within the method).
abstract List<? extends INativeMethodItem> getInternalMethods()
Retrieve all internal methods.
abstract List<? extends INativeMethodItem> getInternalMethods(long memoryAddress)
Retrieve the internal methods spanning over the provided address
abstract INativeItem getItemObject(long id)
Optionally provide an object associated with the given item.
abstract IUnitLock getLock()
Retrieve the model lock, used to request a full-access model lock or a partial, read-only, transactional lock.
abstract IVirtualMemory getMemory()
Retrieve the virtual memory managed used by this unit.
abstract INativeMethodItem getMethod(String fqname)
Convenience method used to retrieve a method by name.
abstract List<? extends INativeMethodItem> getMethods()
Get the list of methods.
abstract INativeContinuousItem getNativeItemAt(long address)
abstract INativeContinuousItem getNativeItemOver(long address)
abstract SortedMap<Long, INativeContinuousItem> getNativeItemsOver(long address, int size)
abstract List<? extends IPackage> getPackages()
Get the list of code packages.
abstract long getPhysicalImageDelta()
Retrieve the difference between Physical Image base as set by #setPhysicalImageBase(Long) and Virtual Image Base as retrieved by getVirtualImageBase().
abstract IProcessor<InsnType> getProcessor()
Retrieve the machine code parser (pseudo-processor) managed by this unit.
abstract List<? extends INativeStringItem> getStrings()
Get the list of code strings.
abstract String getSymbolicStringAddress(long address)
Retrieve the simplest symbol address that corresponds to the given physical address.
abstract String getSymbolicStringAddress(long address, int sspref)
Retrieve a symbol address that corresponds to the given physical address.
abstract TypeLibraryService getTypeLibraryService()
Get the global type library service.
abstract ITypeManager getTypeManager()
Get the global type manager used by this unit.
abstract List<? extends INativeType> getTypes()
Get the list of types.
abstract long getVirtualImageBase()
Retrieve the virtual image base, indicated in the code container (most of the time a PE, ELF, or MachO container).
abstract boolean isAnalysisCompleted()
abstract boolean performAnalysis(boolean async, Boolean includeAdvancedAnalysis, Runnable onCompletion)
Start an analysis.
abstract boolean setCodeAt(long address, int procmode, boolean undefineOverlappingItems)
abstract void setCodeFormatter(GenericCodeFormatter<InsnType> codeFormatter)
abstract boolean setDataAt(long address, INativeType type, String name)
abstract boolean setDataTypeAt(long address, INativeType type)
abstract void setMemory(IVirtualMemory mem)
Optionally set the current optional virtual memory (VM) used by this unit.
abstract void setPhysicalImageBase(long physicalImageBase)
Set the real (physical) image base for this piece of code.
abstract void setProcessor(IProcessor<InsnType> proc)
Set the code parser (processor) used by this unit.
abstract boolean setRoutineAt(long address)
Parse and attempt to create a routine at the provided address.
abstract boolean setRoutineAt(long address, int procmode, int permission)
Parse and attempt to create a routine at the provided address.
abstract boolean setRoutineAt(long address, int procmode)
Parse and attempt to create a routine at the provided address.
abstract boolean setRoutinePrototype(INativeMethodItem routine, String prototypeString)
abstract boolean setRoutineReferenceAt(long address, INativeMethodItem routine)
abstract boolean setStringAt(long address, long addressMax, StringType st, int minChars, int maxChars)
abstract void setVirtualImageBase(long virtualImageBase)
Preferred image base for raw binary files.
abstract boolean undefineItem(long address)
[Expand]
Inherited Methods
From interface com.pnfsoftware.jeb.core.IUnitCreator
From interface com.pnfsoftware.jeb.core.units.IAddressableUnit
From interface com.pnfsoftware.jeb.core.units.IInteractiveUnit
From interface com.pnfsoftware.jeb.core.units.IUnit
From interface com.pnfsoftware.jeb.core.units.code.ICodeUnit
From interface com.pnfsoftware.jeb.corei.parsers.asm.analyzer.IMethodManager
From interface com.pnfsoftware.jeb.util.events.IEventSource

Public Methods

public abstract long getCanonicalMemoryAddress (String address)

Convert a flexible native code unit address to a canonical memory address.

Unit addresses can be code labels, pseudo labels, string representations of physical addresses, etc.

Parameters
address an address
Returns
  • the memory address, or -1 (0xFFFFFFFF_FFFFFFFFL) on failure

public abstract INativeClassItem getClass (String fqname)

Convenience method used to retrieve a class by name.

public abstract List<? extends INativeClassItem> getClasses ()

Get the list of classes.

public abstract INativeCodeAnalyzer<InsnType> getCodeAnalyzer ()

Get the code analyzer. Life-cycle information: this method will return null until the unit is processed.

public abstract INativeCodeAnalyzerExtensionsManager<InsnType> getCodeAnalyzerExtensionsManager ()

Retrieve the currently-set analyzer extensions manager. Life-cycle information: this method will return null until the unit is processed.

Note: third-party code should not use this for now.

public abstract GenericCodeFormatter<InsnType> getCodeFormatter ()

Get the helper object used to format instructions into a sink.

Do not confuse the code formatter with the unit's formatter.

public abstract INativeCodeModel<InsnType> getCodeModel ()

Get the code model.

public abstract ICodeObjectUnit getCodeObjectContainer ()

Provide the parent code object container, if there is one. Typically, that would be an ELF, PE-COFF, or Mach-O unit accessible through the generic interface ICodeObjectUnit or any of the derived specialized interfaces.

Returns
  • a unit or null

public abstract INativeType getDataTypeAt (long address)

public abstract INativeDisassemblyDocument getDisassemblyDocument ()

Provide the disassembly document. This is a convenience method that returns an INativeDisassemblyDocument instead of a generic ITextDocument (provided by getFormatter()).

public abstract Endianness getEndianness ()

Retrieve the endianness. This method is for convenience only; byte ordering can always be retrieved through the IProcessor.

Returns
  • byte ordering for the target

public abstract INativeFieldItem getField (String fqname)

Convenience method used to retrieve a field by name.

public abstract List<? extends INativeFieldItem> getFields ()

Get the list of fields.

public abstract long getImageSize ()

Retrieve the size of the image

public abstract INativeMethodItem getInternalMethod (long memoryAddress, boolean addressIsEntryPoint)

Retrieve an internal method by address (any address within the method). An internal method has an associated data item associated to it. If multiple methods share the provided address, the one with the lowest entry-point address is returned.

Parameters
addressIsEntryPoint true if the provided address is the method entry-point; false if the address is just part of the routine. In the latter case, if the address belongs to several routines, any one is returned
Returns
  • a routine item or null

public abstract List<? extends INativeMethodItem> getInternalMethods ()

Retrieve all internal methods. An internal method has an associated data item associated to it.

Returns
  • a list of internal methods

public abstract List<? extends INativeMethodItem> getInternalMethods (long memoryAddress)

Retrieve the internal methods spanning over the provided address

public abstract INativeItem getItemObject (long id)

Optionally provide an object associated with the given item. This method may return null, an opaque object, or an object defined by the contract of the implementing object or sub-interface. The SPI of sub-interfaces should specify the item id formats, if any, as well as types and semantics associated with the objects returned by this method.

Parameters
id the item id
Returns
  • an object, whose type is defined by contract, potentially null

public abstract IUnitLock getLock ()

Retrieve the model lock, used to request a full-access model lock or a partial, read-only, transactional lock. All plugin code accessing the native units and units relying on native units should use those locks to perform operations safely in a concurrent environment.

public abstract IVirtualMemory getMemory ()

Retrieve the virtual memory managed used by this unit.

public abstract INativeMethodItem getMethod (String fqname)

Convenience method used to retrieve a method by name.

public abstract List<? extends INativeMethodItem> getMethods ()

Get the list of methods.

public abstract INativeContinuousItem getNativeItemAt (long address)

public abstract INativeContinuousItem getNativeItemOver (long address)

public abstract SortedMap<Long, INativeContinuousItem> getNativeItemsOver (long address, int size)

public abstract List<? extends IPackage> getPackages ()

Get the list of code packages.

public abstract long getPhysicalImageDelta ()

Retrieve the difference between Physical Image base as set by #setPhysicalImageBase(Long) and Virtual Image Base as retrieved by getVirtualImageBase(). This value should only be used for rendering.

public abstract IProcessor<InsnType> getProcessor ()

Retrieve the machine code parser (pseudo-processor) managed by this unit.

public abstract List<? extends INativeStringItem> getStrings ()

Get the list of code strings.

public abstract String getSymbolicStringAddress (long address)

Retrieve the simplest symbol address that corresponds to the given physical address. Same as getSymbolicStringAddress(address, 0).

public abstract String getSymbolicStringAddress (long address, int sspref)

Retrieve a symbol address that corresponds to the given physical address.

Example: if address if at offset 10h inside method foo() (at address 401000h), querying this method with sspref=2 will return a label "foo+10h"; however, querying with sspref=0 would simply return "401010h".

Parameters
sspref 0=simplest, 1=existing_label, 2=routine-based (TODO: enum for API pub.)

public abstract TypeLibraryService getTypeLibraryService ()

Get the global type library service.

public abstract ITypeManager getTypeManager ()

Get the global type manager used by this unit.

public abstract List<? extends INativeType> getTypes ()

Get the list of types.

public abstract long getVirtualImageBase ()

Retrieve the virtual image base, indicated in the code container (most of the time a PE, ELF, or MachO container). This virtual address is the reference for every memory access.

Returns
  • the virtual image base

public abstract boolean isAnalysisCompleted ()

public abstract boolean performAnalysis (boolean async, Boolean includeAdvancedAnalysis, Runnable onCompletion)

Start an analysis.

Parameters
async if true, this method is executed asynchronously and returns immediately; use isAnalyzing() to determine whether the analysis has completed.
includeAdvancedAnalysis if null, use the unit's settings; if non-null, bypass the unit's configuration and force-enable or force-disable the advanced analysis
onCompletion optional runnable to be executed on completion (always)

public abstract boolean setCodeAt (long address, int procmode, boolean undefineOverlappingItems)

public abstract void setCodeFormatter (GenericCodeFormatter<InsnType> codeFormatter)

public abstract boolean setDataAt (long address, INativeType type, String name)

Parameters
name optional

public abstract boolean setDataTypeAt (long address, INativeType type)

public abstract void setMemory (IVirtualMemory mem)

Optionally set the current optional virtual memory (VM) used by this unit. This method should be called at most once (typically done in the unit's identifier), before processing the unit. It is optional; the VM object set may be overridden during unit processing if it is deemed inappropriate to handle the code object. Therefore, after processing, client code should always retrieve the actual VM object via getMemory().

Parameters
mem optional VM

public abstract void setPhysicalImageBase (long physicalImageBase)

Set the real (physical) image base for this piece of code. That address is the real address of the first loaded byte on a target device. The existence of this method implies that at most one physical address can be used at any time. (Typically, debuggers use this method to let code units know of where they are currently mapped, which in turn is used to better render assembly output.) Generally, the physical image address changes across different launches.

Parameters
physicalImageBase the physical image base of this code unit; the value 0 means that the physical address is unknown

public abstract void setProcessor (IProcessor<InsnType> proc)

Set the code parser (processor) used by this unit. This method should be called at most once (typically done in the unit's identifier), before processing the unit.

Parameters
proc mandatory processor

public abstract boolean setRoutineAt (long address)

Parse and attempt to create a routine at the provided address. The processor mode used will be the default one, and the analysis will be done forcefully.

Parameters
address address
Returns
  • success indicator: if true, a routine was created (or existed) at the provided address

public abstract boolean setRoutineAt (long address, int procmode, int permission)

Parse and attempt to create a routine at the provided address.

Parameters
address address
procmode processor mode
permission one of the PERMISSION_xxx constants of INativeCodeAnalyzer (refer to enqueuePointerForAnalysis for details)
Returns
  • success indicator: if true, a routine was created (or existed) at the provided address

public abstract boolean setRoutineAt (long address, int procmode)

Parse and attempt to create a routine at the provided address. The analysis is done forcefully.

Parameters
address address
procmode processor mode
Returns
  • success indicator: if true, a routine was created (or existed) at the provided address

public abstract boolean setRoutinePrototype (INativeMethodItem routine, String prototypeString)

public abstract boolean setRoutineReferenceAt (long address, INativeMethodItem routine)

public abstract boolean setStringAt (long address, long addressMax, StringType st, int minChars, int maxChars)

public abstract void setVirtualImageBase (long virtualImageBase)

Preferred image base for raw binary files. Will be disregarded and set to a proper value for managed binaries.

public abstract boolean undefineItem (long address)