# Interface: com.pnfsoftware.jeb.core.units.code.asm.decompiler.INativeDecompilerExtension

Decompiler extension plugins. Refer to [AbstractNativeDecompilerExtension](AbstractNativeDecompilerExtension) for additional details concerning the lifecycle of those objects. 

 Important notes:
 \- Be careful with state data stored in decompiler extensions; those plugins are shared among all decompilers \(except for a decompiler primary extension\)
 \- Methods must not return null

## Method: applyAdditionalTypes
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IDecompiledMethod`
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEStatement>`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called by the decompiler just before type propagation on the IR\-CFG takes place. Extensions can use it to set additional types on IR expressions.
parameter: target: method being decompiled
parameter: cfg: routine CFG
return: success indicator

## Method: augmentSimulationContext
- parameter: `decompiler`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.INativeDecompilerContext`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IERoutineContext`
- parameter: `simulationContext`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IESimulationResults`
- parameter: `offset`, type: `long`
- parameter: `insn`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEStatement`
- parameter: `state`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.EState`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called during the early simulation phase \(unoptimized IR emulation\) in the decompilation pipeline. Extensions can provide additional details to enhance further decompilation stages. 

 For an example of this method, refer to the MIPS decompiler primary extension code.
parameter: decompiler: native decompiler context
parameter: ctx: routine context
parameter: simulationContext: simulation context, the extension may record information in this            context
parameter: offset: IR offset
parameter: insn: IR instruction
parameter: state: input pre\-execution state at the provided instruction
return: success indicator

## Method: collectCandidateMemoryDerefs
- parameter: `exp`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEGeneric`
- parameter: `defuse`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.EDefUseInfo`
- parameter: `isDef`, type: `boolean`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called potentially\-used/defined variables \(candidates\) are being collected for [IEMem](IEMem) IR expressions. It may be used to replace EMem's built\-in implementation, which uses gendec internal heuristics, or add to the results generated by the built\-in implementation.
parameter: exp: an IR expression \(in its current form, always an EMem\)
parameter: defuse: sink for collection; also provides the current [IR            context](IERoutineContext)
parameter: isDef: true if potentially\-defined variables are to be collected, false if            potentially\-used variables are to be collected
return: success indicator

## Method: convertInstruction
- parameter: `converter`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IEConverter<?>`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IERoutineContext`
- parameter: `e`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ConverterInstructionEntry<?>`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: Convert a native instruction to IR code. It is the responsibility of [native code converters](IEConverter) to decide whether they want to call this method, before attempting to convert the instruction themselves. Extensions implementing this method have a chance to provide alternate conversion of low\-level instructions or even provide conversion support for instructions not supported by a converter.
parameter: converter: converter requesting the extension
parameter: ctx: routine context
parameter: e: the entry to be converted, holding references to the [IInstruction](IInstruction) and            current state of the IR basic block
return: success indicator \- upon success, an extension must return TRUE/STOP, else another         conversion will be attempted, leading to undefined behavior

## Method: convertToInlinedCall
- parameter: `converter`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IEConverter<?>`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IERoutineContext`
- parameter: `e`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ConverterInstructionEntry<?>`
- parameter: `target`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: Convert a native instruction into an inlined call.
parameter: converter: converter requesting the extension
parameter: ctx: routine context
parameter: e: instruction entry being converted
parameter: target: target native address
return: success indicator

## Method: customizeIntermediateOptimizer
- parameter: `decompiler`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.INativeDecompilerContext`
- parameter: `mo`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.opt.IEMasterOptimizer`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called by a decompiler unit to customize a master IR optimizer. Extensions may use it to change settings of the master optimizer, provide additional IR optimizers, etc.
parameter: decompiler: native decompiler context
parameter: mo: IR master optimizer
return: success indicator

## Method: executePostPipelineStage
- parameter: `stage`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.NativeDecompilationStage`
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IDecompiledMethod`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<com.pnfsoftware.jeb.core.units.code.asm.decompiler.DecompilationStatus>`

Description: Extensions may customize the decompilation pipeline by implementing this method. It is called by the pipeline at the end of each stage of method decompilation.
parameter: stage: stage that just executed
parameter: target: the method being decompiled
return: decompilation status override

## Method: executePrePipelineStage
- parameter: `stage`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.NativeDecompilationStage`
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IDecompiledMethod`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<com.pnfsoftware.jeb.core.units.code.asm.decompiler.DecompilationStatus>`

Description: Extensions may customize the decompilation pipeline by implementing this method. It is called by the pipeline at the beginning of each stage of method decompilation.
parameter: stage: the stage about to be executed
parameter: target: the method being decompiled
return: [DecompilationStatus#IN_PROCESS](DecompilationStatus#IN_PROCESS) to continue; for this method, returning         [DecompilationStatus#COMPLETED](DecompilationStatus#COMPLETED) means to skip the stage execution \(it does not         mean the decompilation is complete\)

## Method: isMemoryResolutionAllowed
- parameter: `decompiler`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.INativeDecompilerContext`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IERoutineContext`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEMem`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called when the decompiler is attempting to dereference memory in order to replace a memory access by an actual immediate value. Extension can prevent a resolution that could normally take place.
parameter: decompiler: native decompiler context
parameter: ctx: routine context
parameter: mem: memory expression considered for resolution
return: resolution policy override

## Method: isOpaquePointerType
- parameter: `t`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IWildcardType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<java.lang.Boolean>`

Description: This method is called during [IECall](IECall)'s def\-use determination on parameters that are unresolved pointer types. If a type is deemed as "opaque" by this method, the pointer is not considered to access any global or local data. I.e., its effect on def\-use calculation is none.
parameter: t: a type
return: true if the type is "opaque"

## Method: resolveVariableArgumentInformation
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.IERoutineContext`
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEStatement>`
- parameter: `iblk`, type: `int`
- parameter: `proto`, type: `com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IWildcardPrototype`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.ChainedOperationResult<com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.VariableArgumentInformation>`

Description: Resolve variable argument information for a routine call.
parameter: ctx: routine context
parameter: cfg: routine CFG
parameter: iblk: block index
parameter: proto: call prototype
return: variable argument information, if resolved

