com.pnfsoftware.jeb.core.units.INativeCodeUnit<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction> |
Specialized code unit that manages a native code processor and uses a virtual memory.
Code units own and work closely with the following objects:
INativeCodeAnalyzer
- code analyzerIMemoryModel
- code model for INativeItem
and derived objectsITypeManager
- type and package managerNote: if a debugger is attached, a temporary physical image base can be set.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | externalSymbolsPrefix | EXTERN_FUNCTION routine prefix |
|||||||||
String | importPtrPrefix | PTRFUNCTION routine prefix |
|||||||||
String | targetPrefix | Target routine prefix with named trampoline: '*' | |||||||||
String | trampolinePrefix | Trampoline routines prefix: unicode RIGHTWARDS ARROW '→' |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.units.code.asm.items.IMethodManager
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract String | getAddressFromCodeCoordinates(ICodeCoordinates cc, AddressConversionPrecision precision) | ||||||||||
abstract INativeCodeAnalyzerExtension<InsnType> |
getAnalyzerExtension()
Get the principal code analyzer extension attached to this unit.
| ||||||||||
abstract long |
getCanonicalMemoryAddress(String address)
Convert a flexible native code unit address to a canonical memory address.
| ||||||||||
abstract long |
getCanonicalMemoryAddress(String address, AddressConversionPrecision precision)
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 INativeClassItem |
getClassByIndex(int index)
Get a class by its internal index.
| ||||||||||
abstract IClassManager | getClassManager() | ||||||||||
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 NativeCommentManager |
getCommentManager()
Get the comment manager.
| ||||||||||
abstract INativeType |
getDataTypeAt(long address)
Get the native type of the data item located at the provided address.
| ||||||||||
abstract INativeDecompilerUnit<InsnType> |
getDecompiler()
Retrieve or create a decompiler for this unit.
| ||||||||||
abstract INativeDisassemblyDocument |
getDisassemblyDocument()
Convenience method to retrieve the text document representing the disassembly of this code
unit.
| ||||||||||
abstract Endianness |
getEndianness()
Retrieve the endianness.
| ||||||||||
abstract long |
getEntryPointAddress()
Get the address of the entry-point of this unit, if any.
| ||||||||||
abstract INativeFieldItem |
getField(String fqname)
Convenience method used to retrieve a field by name.
| ||||||||||
abstract INativeFieldItem |
getFieldByIndex(int index)
Get a field by its internal index.
| ||||||||||
abstract IFieldManager | getFieldManager() | ||||||||||
abstract List<INativeFieldItem> |
getFields()
Get the list of fields.
| ||||||||||
abstract long |
getHighLevelEntryPointAddress()
Get the address of the high-level entry-point of this unit, if any.
| ||||||||||
abstract String |
getInlineComment(long address)
Convenience method used to retrieve the inline comment at the provided virtual address.
| ||||||||||
abstract INativeMethodItem |
getInternalMethod(long memoryAddress, boolean addressIsEntryPoint)
Retrieve an internal method by address (any address within the method).
| ||||||||||
abstract INativeMethodItem |
getInternalMethod(long memoryAddress)
Retrieve an internal method by its entry-point address.
| ||||||||||
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 List<? extends INativeMethodItem> |
getInternalMethodsLeafFirst()
Retrieve all internal methods, ordered from the leaves to the roots.
| ||||||||||
abstract List<? extends INativeMethodItem> |
getInternalMethodsSizeFirst()
Retrieve all internal methods, ordered from their ascending byte size.
| ||||||||||
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 INativeMethodItem |
getMethodByIndex(int index)
Get a method by its internal index.
| ||||||||||
abstract IMethodManager | getMethodManager() | ||||||||||
abstract List<? extends INativeMethodItem> |
getMethods()
Get the list of methods.
| ||||||||||
abstract INativeContinuousItem |
getNativeItemAt(long address)
Get the item located at the exact address.
| ||||||||||
abstract INativeContinuousItem |
getNativeItemOver(long address)
Get the item spanning over the provided address.
| ||||||||||
abstract SortedMap<Long, INativeContinuousItem> |
getNativeItemsOver(long address, int size)
Retrieve a read-only map of the native items located within the provided memory range.
| ||||||||||
abstract IPackageManager |
getPackageManager()
Get the package/namespace manager used by this unit.
| ||||||||||
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 String |
getProcessorName()
Convenience method used to retrieve the processor's name.
| ||||||||||
abstract NativeSignatureDBManager |
getSignatureManager()
Get the global signature manager used by this unit.
| ||||||||||
abstract INativeStringItem |
getStringByIndex(int index)
Retrieve a string by index.
| ||||||||||
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 boolean |
isAnalysisCompleted()
Determine whether a code analysis pass is ongoing.
| ||||||||||
abstract boolean |
isInitialAnalysisDone()
Determine whether or not an initial analysis pass has been done.
| ||||||||||
abstract boolean |
performAnalysis(boolean async, Boolean includeAdvancedAnalysis, Runnable onCompletion)
Start an analysis.
| ||||||||||
abstract boolean | performInitialAnalysis(Boolean blocking) | ||||||||||
abstract boolean |
performInitialAnalysis()
Perform the initial analysis pass.
| ||||||||||
abstract boolean |
process()
Quickly process the unit.
| ||||||||||
abstract void |
setAnalyzerExtension(INativeCodeAnalyzerExtension<InsnType> ext)
Set the principal code analyzer extension for this unit.
| ||||||||||
abstract void | setCallingConvention(ICallingConvention cc) | ||||||||||
abstract boolean |
setCodeAt(long address, int procmode, boolean undefineOverlappingItems)
Parse and create an instruction at the provided address.
| ||||||||||
abstract void | setCodeFormatter(GenericCodeFormatter<InsnType> codeFormatter) | ||||||||||
abstract void |
setCompilerType(CompilerType compilerType)
Set a hint.
| ||||||||||
abstract boolean |
setDataAt(long address, INativeType type, String name, boolean undefineOverlappingItems)
Create or update a data item at the provided address.
| ||||||||||
abstract boolean |
setDataAt(long address, INativeType type, String name)
Create or update a data item at the provided address.
| ||||||||||
abstract boolean |
setDataTypeAt(long address, INativeType type)
Convenience method to set the native type of a data item located at the provided address.
| ||||||||||
abstract boolean |
setInlineComment(long address, String comment)
Convenience method used to set the inline comment at the provided virtual address.
| ||||||||||
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)
Set a routine prototype.
| ||||||||||
abstract boolean |
setRoutineReferenceAt(long address, INativeMethodItem routine)
Create a special data item representing a reference to a method.
| ||||||||||
abstract boolean |
setRoutineSignature(INativeMethodItem routine, String signatureString, boolean prototypeOnly)
Set a routine signature or protytpe.
| ||||||||||
abstract boolean |
setStringAt(long address, long addressMax, StringEncoding stringType, int minChars, int maxChars)
Create a string data item.
| ||||||||||
abstract boolean |
setStringAt(long address, long addressMax, StringEncoding stringType, int minChars, int maxChars, boolean undefineOverlappingItems)
Create a string data item.
| ||||||||||
abstract void |
setSubsystemType(SubsystemType subsystemType)
Set a hint.
| ||||||||||
abstract void |
setVirtualImageBase(long virtualImageBase)
Set preferred image base
| ||||||||||
abstract boolean |
undefineItem(long address)
Undefine the memory item starting at the provided address.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.IUnitCreator
| |||||||||||
From interface
com.pnfsoftware.jeb.core.IUserDataSupport
| |||||||||||
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.core.units.code.asm.INativeContext
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.asm.items.IMethodManager
| |||||||||||
From interface
com.pnfsoftware.jeb.util.events.IEventSource
|
EXTERN_FUNCTION
routine prefix
Target routine prefix with named trampoline: '*'
Trampoline routines prefix: unicode RIGHTWARDS ARROW '→'
Get the principal code analyzer extension attached to this unit.
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.
address | an 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.
address | an address |
---|---|
precision | use COARSE to bypass early name resolution, and attempt a simple number conversion first (e.g., with coarse address "aabb" will be resolved to 0xAABB before looking if an item is named "aabb"); with FINE (or DEFAULT), item name resolution is attempted first; therefore, for quick and unreliable conversions, use COARSE; else, use the DEFAULT setting |
Convenience method used to retrieve a class by name.
Get a class by its internal index. Class indices are monotonously increasing, and gaps may
exist as classes get destroyed and created. The caller should not assume that
getClassByIndex(i)==getClasses().get(i)
.
index | an opaque class index, eg one present in ICodeCoordinates |
---|
Get the code analyzer.
Life-cycle information: this method will return null until the unit is processed
.
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.
Get the helper object used to format instructions into a sink.
Do not confuse the code formatter with the unit's formatter
.
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.
Get the comment manager. This method is optional. When the unit is disposed, this method must return null. The default implementation returns null.
Get the native type of the data item located at the provided address.
Retrieve or create a decompiler for this unit. If a corresponding gendec
plugin is
not available with your JEB license, null is returned.
Convenience method to retrieve the text document representing the disassembly of this code unit.
The caller is responsible for disposing the returned document after usage.
Retrieve the endianness. This method is for convenience only; byte ordering can always be
retrieved through the IProcessor
.
Get the address of the entry-point of this unit, if any.
Convenience method used to retrieve a field by name.
Get a field by its internal index. Field indices are monotonously increasing, and gaps may
exist as fields get destroyed and created. The caller should not assume that
getFieldByIndex(i)==getFields().get(i)
.
index | an opaque field index, eg one present in ICodeCoordinates |
---|
Get the address of the high-level entry-point of this unit, if any.
The high-level entry-point corresponds to a main()
(or similar) routine. It is
the routine executed after the compiler-generated initialization code is executed. Note that
it might be set as a result of the initial analysis.
Convenience method used to retrieve the inline comment at the provided virtual address.
address | VA |
---|
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.
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 |
---|
Retrieve an internal method by its entry-point address. An internal method has an associated
data
item associated to it. If multiple methods share the
provided entry-point address, the first one is returned.
Retrieve all internal methods. An internal method has an associated
data
item associated to it.
Retrieve the internal methods spanning over the provided address
Retrieve all internal methods, ordered from the leaves to the roots. An internal method has
an associated data
item associated to it.
Retrieve all internal methods, ordered from their ascending byte size. An internal method has
an associated data
item associated to it.
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.
id | the item id |
---|
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.
Convenience method used to retrieve a method by name.
Get a method by its internal index. Method indices are monotonously increasing, and gaps may
exist as methods get destroyed and created. The caller should not assume that
getMethodByIndex(i)==getMethods().get(i)
.
index | an opaque method index, eg one present in ICodeCoordinates |
---|
Get the item located at the exact address.
address | item start address |
---|
Get the item spanning over the provided address.
address | an address |
---|
Retrieve a read-only map of the native items located within the provided memory range.
Get the package/namespace manager used by this unit.
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.
Retrieve the machine code parser (pseudo-processor) managed by this unit.
Convenience method used to retrieve the processor's name. The processor value specifies, among other things, the underlying instruction set used by the instructions of this code unit.
Get the global signature manager used by this unit.
Retrieve a string by index. Careful, this is not the same as getStrings().get(index)
.
Retrieve the simplest symbol address that corresponds to the given physical address. Same as
getSymbolicStringAddress(address, 0)
.
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".
address | a memory address |
---|---|
sspref | resolution type: (in the examples a below, a routine exists at address
0x401000) 0= will resolve to a standard hex-formatted address, e.g. 0x402000 to
402000h 1= will first resolve to any existing label, routine address, e.g. 0x401000 to sub_401000 etc.2= will first resolve to a routine-based address, e.g. sub_401010 to
sub_401000+10h |
Determine whether a code analysis pass is ongoing.
Determine whether or not an initial analysis pass has been done.
Start an analysis.
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) |
Perform the initial analysis pass. This method should be called once, after
successful unit processing
. The initial analysis pass parameters, such
as synchronicity, the inclusion of global or advanced analysis, etc. are determined
automatically.
Quickly process the unit. Be careful that the IUnit
is not analyzed while
performInitialAnalysis()
was not called.
IUnit
was processed (may then check isInitialAnalysisDone()
to check that unit is fully usable)
Set the principal code analyzer extension for this unit.
Parse and create an instruction at the provided address.
address | instruction address |
---|---|
procmode | processor mode (refer to MODE_xxx constants in
IProcessor ) |
undefineOverlappingItems | if false, the method will fail if existing items overlap with the memory range needed to accommodate a newly-created item |
Set a hint. This method may be called optionally, before process(). The hint may be disregarded.
Create or update a data item at the provided address.
Note: to create String items, see setStringAt(long, long, StringEncoding, int, int)
.
address | item address |
---|---|
type | item type |
name | optional name |
undefineOverlappingItems | if false, the method will fail if existing items overlap with the memory range needed to accommodate a newly-created item |
Create or update a data item at the provided address. Overlapping items may be deleted.
Note: to create String items, see setStringAt(long, long, StringEncoding, int, int)
.
address | item address |
---|---|
type | item type |
name | optional name |
Convenience method to set the native type of a data item located at the provided address. If no item exists at the provided address, one will be created. Overlapping items may be deleted.
Note: to create String items, see setStringAt(long, long, StringEncoding, int, int)
.
Convenience method used to set the inline comment at the provided virtual address.
address | VA |
---|---|
comment | a comment |
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()
.
mem | optional VM |
---|
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.
physicalImageBase | the physical image base of this code unit; the value 0 means that the physical address is unknown |
---|
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.
proc | mandatory processor |
---|
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.
address | routine start address |
---|
Parse and attempt to create a routine at the provided address.
address | routine start address |
---|---|
procmode | processor mode |
permission | one of the PERMISSION_xxx constants of
INativeCodeAnalyzer (refer to
enqueuePointerForAnalysis for details) |
Parse and attempt to create a routine at the provided address. The analysis is done forcefully.
address | routine start address |
---|---|
procmode | processor mode |
Set a routine prototype. This method uses non-standard prototype declarations and should be
avoided. Use setRoutineSignature(INativeMethodItem, String, boolean)
instead.
routine | target routine |
---|---|
prototypeString | a prototype string having the following style:
<calling-convention> returnType(paramType1 _) <calling-convention> returnType(paramType1, paramType2) <calling-convention> returnType(paramType1, paramType2, ...) |
Create a special data item representing a reference to a method. Those items are similar to function pointer items (pointer to prototypes), except that they refer specifically to routine objects managed by this unit.
Set a routine signature or protytpe.
routine | target routine |
---|---|
signatureString | a C-like signature; some C++ features such as namespaces (::) or templates (<...>) are allowed but disregarded |
prototypeOnly | if true, only the prototype will be applied; method and parameter names, if provided, will not be applied |
Create a string data item. Overlapping items may be deleted.
address | mandatory start address |
---|---|
addressMax | optional maximum (final) address for the string; use -1 for no limit |
stringType | the string type hint; null to let this method determine the best string type heuristically |
minChars | minimum number of characters to be found in the string for it to be considered valid; set to -1 for default (currently: 3) |
maxChars | maximum number of characters (not bytes) to be parsed; set to -1 for default (currently: 100_000) |
Create a string data item.
address | mandatory start address |
---|---|
addressMax | optional maximum (final) address for the string; use -1 for no limit |
stringType | the string type hint; null to let this method determine the best string type heuristically |
minChars | minimum number of characters to be found in the string for it to be considered valid; set to -1 for default (currently: 3) |
maxChars | maximum number of characters (not bytes) to be parsed; set to -1 for default (currently: 100_000) |
undefineOverlappingItems | if false, the method will fail if existing items overlap with the memory range needed to accommodate a newly-created item |
Set a hint. This method may be called optionally, before process(). The hint may be disregarded.
Set preferred image base
Undefine the memory item starting at the provided address. Careful, this method may have unintended side effects. Example: deleting an instruction item that's part of a routine body will also discard that routine, which in turn may discard other items or references, within this unit or other units.
address | item address |
---|