Class AbstractConverter<InsnType extends IInstruction>
- Type Parameters:
InsnType
-
- All Implemented Interfaces:
IEConverter<InsnType>
gendec
intermediate
representation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IERoutineContext
Per-routine data - works because convert() is not re-entrant (same found in X86ConvXxx helper classes).
Should be set before converting a routine, and reset to null after it's done.protected boolean
protected IEGlobalContext
protected int
protected int
protected INativeContext
protected IProcessor<InsnType>
protected int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractConverter
(IProcessor<InsnType> proc) protected
AbstractConverter
(IProcessor<InsnType> proc, int registerBitsize) protected
AbstractConverter
(IProcessor<InsnType> proc, int registerBitsize, int addressBitsize) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
attemptCallInliningByExtension
(ConverterInstructionEntry<InsnType> e, long target) protected boolean
final boolean
autoConvert
(ConverterInstructionEntry<InsnType> e, ACS acs) The default implementation provides a no-arg/no-return prototype: "void __defaultCC ()".boolean
The default implementation returns true.convert
(INativeMethodItem routine) Convert the blocks of the native routine's CFG after the other.protected void
convertBlock
(BasicBlock<InsnType> b, List<IEStatement> interlist) Convert a basic block.final List<IEStatement>
Reserved for testing.void
This method is called byconvertBlock(BasicBlock, List)
.protected boolean
convertInstructionFirstChance
(ConverterInstructionEntry<InsnType> e, String mn, boolean allowRecurse) protected boolean
protected IEGeneric
convertOperand
(long insnAddress, InsnType insn, int opndIndex) This method is called by theAbstractConverter<InsnType extends IInstruction>.com.pnfsoftware.jeb.core.units.code.asm.decompiler.AbstractConverter.AutoConverter
.convertParameterExpressions
(IERoutineContext ctx, IWildcardPrototype prototype, INativeMethodItem targetRoutine, List<IWildcardType> varArgTypes) Given a prototype, determine the list of IR expressions representing the input expressions (would also contain implicitly read registers).convertReturnExpressions
(IERoutineContext ctx, IWildcardPrototype prototype, INativeMethodItem targetRoutine, List<IWildcardType> varArgTypes, List<IEGeneric> outSpoiled) Given a prototype, determine the list of IR expressions representing the output expressions.convertReturnLocation
(IERoutineContext ctx, IWildcardPrototype prototype) Given a prototype, determine the IR expression representing the return address location of a call to a method of said prototype.createStackMemoryAccess
(IEGeneric address, int bitsize) The default implementation assumes a segment-less memory model.void
customInitStateRegisters
(EState state, Long optionalNativeProgramCounter) The default implementation does nothing.int
Convert PC-assignment toIEJumpFar
statements.determineStackBytesUsedByCall
(IWildcardPrototype prototype, List<IWildcardType> varArgTypes) Determine the amount of bytes that were pushed on the stack before calling the routine with the provided prototype and optional additional slots.determineStackPointerDeltaAfterIRCall
(IWildcardPrototype prototype, List<IWildcardType> varArgTypes) Determine the stack pointer delta (in bytes) after theIECall
executed and returned.
Careful: "IR-Call" and the "native-call" may not have the same structure; it depends on how the conversion of "native-call" is implemented, and therefore is converter-dependent.The default implementation returns null.evaluateUntranslatedIR
(IEUntranslatedInstruction insn, IERoutineContext ectx, EState state) The default implementation returns null.The default implementation formats basic details about the number of converted methods.generateASTForUntranslatedIR
(IEUntranslatedInstruction insn, IERoutineContext ectx, ICMethod cctx) The default implementation returns null.int
The default implementation returns the size of the program counter.Retrieve a reference to the decompiler managing this converter.getDefaultBranchToRoutineSideEffects
(INativeMethodItem optionalRoutine) The default implementation returns a basic branch detail object specifying nothing (no def, no use, no spoils, etc.).getFPRegister
(int index) Retrieve the IR variable object that represents the Floating-point register.Retrieve the global program context.getGPRegister
(int index) Retrieve the IR variable object that represents the General Purpose register.getInputVariableByIndex
(IERoutineContext ctx, int i) The default implementation returns null.Retrieve the native code context that this converter should use.final long
long
getNativeRegisterIdFromRegisterVariable
(IEVar regVar, boolean shortForm) The default implementation attempts to resolve the register variable by querying the associated processor's register bank layout.getOutputVariableByIndex
(IERoutineContext ctx, int i) The default implementation returns null.Create an instance of a prototype handler.final IEGeneric
getRegister
(String name) getRegister
(String name, ELocation loc) The default implementation forwards toIEGlobalContext.getVariableByName(String)
.int
The default implementation returns the address bitsize.final IEGeneric
getRegisterVariableFromNativeRegisterId
(long nativeRegId) getRegisterVariableFromNativeRegisterId
(long nativeRegId, ELocation loc) The default implementation attempts to resolve the native register id or number by querying the associated processor's register bank layout.The default implementation considers that there is no specific Return Address Register.getSlicedRegisterName
(String registerName, int bitstart, int bitend) Get the name of the slice of a physical register.int
Get the size of standard slot on the stack, in bytes.int
getStateProcessorMode
(EState state) Retrieve the current processor mode relative to the providedEState
.getTempRegister
(int index) The default implementation returnsIWildcardType.Group.INTEGER
.void
This method is called by the owner decompiler after the principal components of the lower-level code unit have been initialized.final void
initializeStateRegisters
(EState state, Long optionalNativeProgramCounter) This method initializes and sets all physical registers declared by this converter to 0, except for the ones possibly used as arguments that are kept undefined (seeisPossibleParameterRegisterForProcessorCallingConventions(long)
).protected final boolean
insertOptionalEntryPointTrampoline
(IERoutineContext ctx, List<IEStatement> irlist) For native routines that have their entry point in-the-middle (i.e., not at their lowest address), insert a syntheticIEJump
as the first instruction of the converted method.int
This method introducesIEReturn
statements into the IR.boolean
protected final boolean
isPCRightValueCompatibleReturnValue
(IDFA<IEStatement> dfa, BasicBlock<IEStatement> b, IEGeneric PCRightVal, IEGeneric expectedReturnAddress) Can be overridden by implementors when complex return expression matching is needed.boolean
isPossibleParameterRegisterForProcessorCallingConventions
(long nativeRegId) Check if a native register id corresponds to a register that can possibly be used as a routine parameter on this processor.boolean
isPossibleSpoiledRegistersForProcessorCallingConventions
(long nativeRegId) Check if a native register id corresponds to a physical register that can possibly be spoiled by a routine call on this processor.The default implementation returns true: by default, all EMem are assumed to reference bytes in the primary VM.normalizeBranchingExpression
(IDFA<IEStatement> dfa, BasicBlock<IEStatement> b, IEGeneric target, IEGeneric expectedTarget) Normalize a branching expression.protected void
postBlockConversion
(CFG<InsnType> cfg, BasicBlock<InsnType> b, List<IEStatement> interlist, int cnt) This method is called afterconvertBlock(BasicBlock, List)
is called.protected void
postRoutineConversion
(INativeMethodItem routine, IERoutineContext ctx) Executed byconvert
after converting the blocks.protected BasicBlock<InsnType>
preBlockConversion
(CFG<InsnType> cfg, BasicBlock<InsnType> b, List<IEStatement> interlist) This method is called beforeconvertBlock(BasicBlock, List)
is called.protected void
preRoutineConversion
(INativeMethodItem routine, IERoutineContext ctx, List<IEStatement> irlist) Executed byconvert
before converting the blocks.boolean
Implementations should be aggressive and fast: calls to this method should always be enclosed in a try-catch.long
sanitizeNativeAddress
(long address) The default implementation truncates the provided value to accomodategetAddressBitsize()
.void
setup the helper converter classesvoid
setDecompiler
(INativeDecompilerContext decompiler) Reserved.void
setDoNotGenerateNops
(boolean doNotGenerateNops) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.decompiler.IEConverter
getProgramCounter, getStackPointer
-
Field Details
-
gCtx
-
nctx
-
proc
-
regNormalBitsize
protected int regNormalBitsize -
doNotGenerateNops
protected boolean doNotGenerateNops -
methodConversionCountFailure
protected int methodConversionCountFailure -
methodConversionCountSuccess
protected int methodConversionCountSuccess -
ctx
Per-routine data - works because convert() is not re-entrant (same found in X86ConvXxx helper classes).
Should be set before converting a routine, and reset to null after it's done. -
parameterRegistersForAllCC
-
spoiledRegistersForAllCC
-
-
Constructor Details
-
AbstractConverter
-
AbstractConverter
-
AbstractConverter
-
AbstractConverter
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:IEConverter
This method is called by the owner decompiler after the principal components of the lower-level code unit have been initialized. Initialization requiring, e.g. access to the type manager, should be performed here instead of within the constructor.- Specified by:
initialize
in interfaceIEConverter<InsnType extends IInstruction>
-
setNativeContext
-
getNativeContext
Description copied from interface:IEConverter
Retrieve the native code context that this converter should use.- Specified by:
getNativeContext
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- never null
-
getGlobalContext
Description copied from interface:IEConverter
Retrieve the global program context. There is a single global context per decompiler, common to allroutine contexts
.- Specified by:
getGlobalContext
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- the global context
-
setDoNotGenerateNops
public void setDoNotGenerateNops(boolean doNotGenerateNops) -
isDoNotGenerateNops
public boolean isDoNotGenerateNops() -
setDecompiler
Reserved.- Parameters:
decompiler
-
-
getDecompiler
Description copied from interface:IEConverter
Retrieve a reference to the decompiler managing this converter.- Specified by:
getDecompiler
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- a reference to a decompiler (likely, a
INativeDecompilerUnit
), or null
-
insertOptionalEntryPointTrampoline
protected final boolean insertOptionalEntryPointTrampoline(IERoutineContext ctx, List<IEStatement> irlist) For native routines that have their entry point in-the-middle (i.e., not at their lowest address), insert a syntheticIEJump
as the first instruction of the converted method.That ensures that native routines that have their entry-point in the middle of their code can be converted to IR routines with an entry-point always set to offset 0 (the beginning of the IR code). The reason is that this helps with graph manipulation passes that come later on, in the AST phases.
- Parameters:
ctx
- translation contextirlist
- the current list of converted IR statements, which should be empty when this method is called- Returns:
- true if a trampoline was inserted, false if it was not needed (and therefore, not inserted)
-
getAddressBitsize
public int getAddressBitsize()The default implementation returns the size of the program counter.- Specified by:
getAddressBitsize
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getRegisterBitsize
public int getRegisterBitsize()The default implementation returns the address bitsize.- Specified by:
getRegisterBitsize
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getStackSlotSize
public int getStackSlotSize()Description copied from interface:IEConverter
Get the size of standard slot on the stack, in bytes.- Specified by:
getStackSlotSize
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getWildcardTypeManagerDefaultResolutionGroup
The default implementation returnsIWildcardType.Group.INTEGER
.- Specified by:
getWildcardTypeManagerDefaultResolutionGroup
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getRegister
- Specified by:
getRegister
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getRegister
The default implementation forwards toIEGlobalContext.getVariableByName(String)
.- Specified by:
getRegister
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
name
- register nameloc
- optional IR statement location at which the conversion is taking place- Returns:
-
getRegisterVariableFromNativeRegisterId
Description copied from interface:IEConverter
SeeIEConverter.getRegisterVariableFromNativeRegisterId(long, ELocation)
. No location provided- Specified by:
getRegisterVariableFromNativeRegisterId
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- a global
IEVar
-register
-
getRegisterVariableFromNativeRegisterId
The default implementation attempts to resolve the native register id or number by querying the associated processor's register bank layout. It throws if the resolution fails.- Specified by:
getRegisterVariableFromNativeRegisterId
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
nativeRegId
- a native register id, used by theIProcessor
that this converter is relying on; the id may be a full id, that is, one supported byIInstructionOperandRegisterBased.getRegisterName(long)
, or a short-form of it (eg, the default X86 Processor module uses short-form 0 for the eAX register, that is the first GP register whose size matches the current processor mode).loc
- optional IR statement location at which the conversion is taking place- Returns:
- a global
IEVar
-register
-
getNativeRegisterIdFromRegisterVariable
The default implementation attempts to resolve the register variable by querying the associated processor's register bank layout. It throws if the resolution fails.- Specified by:
getNativeRegisterIdFromRegisterVariable
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
regVar
- a globalIEVar
-registershortForm
- if true the value provided does not contain the converter-specific information present in the long form (used in particular byIInstructionOperandRegisterBased.getRegisterName(long)
), otherwise it is the long form- Returns:
- a native register id
-
getNativeRegisterIdFromRegisterVariable
Description copied from interface:IEConverter
- Specified by:
getNativeRegisterIdFromRegisterVariable
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getSlicedRegisterName
Description copied from interface:IEConverter
Get the name of the slice of a physical register. The slice name may be an official name or a convenience name decided by the converter.- Specified by:
getSlicedRegisterName
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
registerName
- full name of a physical register- Returns:
- null if the slice does not have a particular name
-
setCurrentContext
setup the helper converter classes -
preRoutineConversion
protected void preRoutineConversion(INativeMethodItem routine, IERoutineContext ctx, List<IEStatement> irlist) Executed byconvert
before converting the blocks. The default implementation simply callsinsertOptionalEntryPointTrampoline(IERoutineContext, List)
.- Parameters:
routine
-ctx
-
-
postRoutineConversion
Executed byconvert
after converting the blocks. The default implementation does nothing.- Parameters:
routine
-ctx
-
-
convert
Convert the blocks of the native routine's CFG after the other. The blocks' edges are not considered.The default implementation works as follows:
- call
preRoutineConversion
- for each block:
- call
preBlockConversion
- call
convertBlock
- call
postBlockConversion
- call
- call
postRoutineConversion
once
- Specified by:
convert
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
routine
- the routine to be converted; must have adata
definition- Returns:
- the converted IR routine context
- call
-
preBlockConversion
protected BasicBlock<InsnType> preBlockConversion(CFG<InsnType> cfg, BasicBlock<InsnType> b, List<IEStatement> interlist) This method is called beforeconvertBlock(BasicBlock, List)
is called. It can be overridden. Sub-classes do not need to call the default implementation. The default implementation returns the provided input block.- Parameters:
cfg
- the CFGb
- block about to be convertedinterlist
-- Returns:
- the provided input block or a new block
-
convertBlock
Convert a basic block. This method may be overridden. The lower-level addresses are set onIEStatement
if they are not present.- Parameters:
b
- block to be convertedinterlist
- output list of converted IR statements
-
convertInstruction
This method is called byconvertBlock(BasicBlock, List)
. If this method is not overridden, the methodsconvertInstructionFirstChance(ConverterInstructionEntry, String, boolean)
andconvertInstructionLastChance(ConverterInstructionEntry)
must be implemented. If this method is overridden, the two aforementioned methods can be ignored.- Parameters:
e
-
-
convertInstructionFirstChance
protected boolean convertInstructionFirstChance(ConverterInstructionEntry<InsnType> e, String mn, boolean allowRecurse) -
convertInstructionLastChance
-
convertOperand
This method is called by theAbstractConverter<InsnType extends IInstruction>.com.pnfsoftware.jeb.core.units.code.asm.decompiler.AbstractConverter.AutoConverter
. If the auto-converter is used, it must be implemented.- Parameters:
insnAddress
-insn
-opndIndex
-- Returns:
-
attemptConversionByExtension
-
attemptCallInliningByExtension
protected boolean attemptCallInliningByExtension(ConverterInstructionEntry<InsnType> e, long target) -
postBlockConversion
protected void postBlockConversion(CFG<InsnType> cfg, BasicBlock<InsnType> b, List<IEStatement> interlist, int cnt) This method is called afterconvertBlock(BasicBlock, List)
is called. The default implementation sanitizes fake calls, i.e. it switches call-to-sub-PC-assigns to regular PC-assigns if the underlying analyzer detected that what looked like a call-to-sub is not.- Parameters:
cfg
- the native CFG of the method being convertedb
- the native basic block that was just convertedinterlist
- the current list of IR statements for the routine (not only for the provided block!); the last IR statements in that list are those of the routine that was just convertedcnt
- the number of IR statements that correspond to the conversion of the provided native block
-
convertBlockForTest
Reserved for testing.- Parameters:
b
-- Returns:
-
createStackMemoryAccess
The default implementation assumes a segment-less memory model. (The EMem segment component is set to null.)- Specified by:
createStackMemoryAccess
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
sanitizeNativeAddress
public long sanitizeNativeAddress(long address) The default implementation truncates the provided value to accomodategetAddressBitsize()
.- Specified by:
sanitizeNativeAddress
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
isSegmentEMemReferencingPrimaryMemory
The default implementation returns true: by default, all EMem are assumed to reference bytes in the primary VM.- Specified by:
isSegmentEMemReferencingPrimaryMemory
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- 3-state result: true/false, null= cannot determine
-
getPrototypeHandler
Description copied from interface:IEConverter
Create an instance of a prototype handler.- Specified by:
getPrototypeHandler
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
canCreateCalls
public boolean canCreateCalls()The default implementation returns true.- Specified by:
canCreateCalls
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
convertReturnLocation
Description copied from interface:IEConverter
Given a prototype, determine the IR expression representing the return address location of a call to a method of said prototype.Used by
IECall
.- Specified by:
convertReturnLocation
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
convertReturnExpressions
public List<IEGeneric> convertReturnExpressions(IERoutineContext ctx, IWildcardPrototype prototype, INativeMethodItem targetRoutine, List<IWildcardType> varArgTypes, List<IEGeneric> outSpoiled) Description copied from interface:IEConverter
Given a prototype, determine the list of IR expressions representing the output expressions. Spoiled register expressions can also be returned.Used by
IECall
.- Specified by:
convertReturnExpressions
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- a list of non-copy IEVars holding storage of output expressions
-
convertParameterExpressions
public List<IEGeneric> convertParameterExpressions(IERoutineContext ctx, IWildcardPrototype prototype, INativeMethodItem targetRoutine, List<IWildcardType> varArgTypes) Description copied from interface:IEConverter
Given a prototype, determine the list of IR expressions representing the input expressions (would also contain implicitly read registers).Used by
IECall
.- Specified by:
convertParameterExpressions
in interfaceIEConverter<InsnType extends IInstruction>
prototype
- mandatory prototypetargetRoutine
- optionalvarArgTypes
- optional- Returns:
- a list of non-copy IEVars holding storage of input expressions
-
getInputVariableByIndex
The default implementation returns null.- Specified by:
getInputVariableByIndex
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
getOutputVariableByIndex
The default implementation returns null.- Specified by:
getOutputVariableByIndex
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
determineStackPointerDeltaAfterIRCall
public Integer determineStackPointerDeltaAfterIRCall(IWildcardPrototype prototype, List<IWildcardType> varArgTypes) Description copied from interface:IEConverter
Determine the stack pointer delta (in bytes) after theIECall
executed and returned.
Careful: "IR-Call" and the "native-call" may not have the same structure; it depends on how the conversion of "native-call" is implemented, and therefore is converter-dependent. The SP delta returned by this method is the one after an execution overIECall
.Used by
IECall
.- Specified by:
determineStackPointerDeltaAfterIRCall
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- null on error
-
determineStackBytesUsedByCall
public Integer determineStackBytesUsedByCall(IWildcardPrototype prototype, List<IWildcardType> varArgTypes) Description copied from interface:IEConverter
Determine the amount of bytes that were pushed on the stack before calling the routine with the provided prototype and optional additional slots. That should include all routine parameters pushed on the stack as well as the return address bytes as well, if it is located on the stack (per the provided calling convention).Used by
IECall
.- Specified by:
determineStackBytesUsedByCall
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
determineStackPointerDeltaFromSimulation
The default implementation returns null.- Specified by:
determineStackPointerDeltaFromSimulation
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
simuinfo
- state of IR execution; PC is assumed to be on the target routine entry-point- Returns:
- null on error, otherwise, the SP delta after the routine has executed and returned to the caller
-
getDefaultBranchToRoutineSideEffects
The default implementation returns a basic branch detail object specifying nothing (no def, no use, no spoils, etc.).Converters should override this method.
- Specified by:
getDefaultBranchToRoutineSideEffects
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
optionalRoutine
- the optional target routine; if provided, the implementation may use that information to provide more accurate results- Returns:
- a branch details object (never null)
-
buildFailsafePrototype
The default implementation provides a no-arg/no-return prototype: "void __defaultCC ()".Custom implementations may return something more suitable to a given architecture
- Specified by:
buildFailsafePrototype
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
ctx
- routine for which a failsafe prototype is to be generatedstm
- optional statement calling into the routine- Returns:
- a prototype object, should never be null
-
insertReturns
Description copied from interface:IEConverter
This method introducesIEReturn
statements into the IR. Must be performed only after prototype discovery is completed.Data chains: not used, may be invalidated; in the latter case, this method is responsible for recalculating them.
- Specified by:
insertReturns
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
ctx
- the routine context- Returns:
- the number of insertions performed
-
normalizeBranchingExpression
public IEGeneric normalizeBranchingExpression(IDFA<IEStatement> dfa, BasicBlock<IEStatement> b, IEGeneric target, IEGeneric expectedTarget) Description copied from interface:IEConverter
Normalize a branching expression.- Specified by:
normalizeBranchingExpression
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
dfa
- a DFA objectb
- basic block whose last instruction is a branching statement (e.g. EAssign to PC, ECall, EJumpFar, etc.)target
- the callsite of the branching statement targeted by the basic block `b`expectedTarget
- optional- Returns:
-
isPCRightValueCompatibleReturnValue
protected final boolean isPCRightValueCompatibleReturnValue(IDFA<IEStatement> dfa, BasicBlock<IEStatement> b, IEGeneric PCRightVal, IEGeneric expectedReturnAddress) Can be overridden by implementors when complex return expression matching is needed.- Parameters:
dfa
- current DFAb
-BasicBlock
containing the PC assign instruction (last one of the block)PCRightVal
- right Value of the PC assign instructionexpectedReturnAddress
- ExpectedIEVar
as per current Calling Convention- Returns:
- true if right value is equivalent to a return instruction
-
defaultPCConversion
Description copied from interface:IEConverter
Convert PC-assignment toIEJumpFar
statements. This method is a fail-safe converter for PC-assignments, and should be called as late as possible in the IR conversion phases. After executing this method, the CFG should no longer contain PC-assignments.- Specified by:
defaultPCConversion
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- the number of PC-conversions performed
-
resolveCustomCalls
Description copied from interface:IEConverter
Implementations should be aggressive and fast: calls to this method should always be enclosed in a try-catch.TODO: MOVE to the CBDU
- Specified by:
resolveCustomCalls
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
initializeStateRegisters
This method initializes and sets all physical registers declared by this converter to 0, except for the ones possibly used as arguments that are kept undefined (seeisPossibleParameterRegisterForProcessorCallingConventions(long)
). After this is done,customInitStateRegisters(EState, Long)
is invoked.- Specified by:
initializeStateRegisters
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
state
- input state to be initializedoptionalNativeProgramCounter
- optional current native PC
-
customInitStateRegisters
The default implementation does nothing.- Specified by:
customInitStateRegisters
in interfaceIEConverter<InsnType extends IInstruction>
-
isPossibleParameterRegisterForProcessorCallingConventions
public boolean isPossibleParameterRegisterForProcessorCallingConventions(long nativeRegId) Check if a native register id corresponds to a register that can possibly be used as a routine parameter on this processor.To do so, the given id is compared against all input registers for all known calling conventions for the current processor. In particular, this method does not rely on the routine prototype and calling convention being defined, and can therefore be used early on during decompilation.
- Parameters:
nativeRegId
- native register id- Returns:
- true if the provided register id corresponds to a register that can be used as a parameter, false otherwise
-
isPossibleSpoiledRegistersForProcessorCallingConventions
public boolean isPossibleSpoiledRegistersForProcessorCallingConventions(long nativeRegId) Check if a native register id corresponds to a physical register that can possibly be spoiled by a routine call on this processor.To do so, the given id is compared against all spoiled registers for all known calling conventions for the current processor. In particular, this method does not rely on the routine prototype and calling convention being defined, and can therefore be used early on during decompilation.
- Parameters:
nativeRegId
- native register id- Returns:
- true if the provided a native register id is a register that can be spoiled by a routine call, false otherwise
-
getStateProcessorMode
Description copied from interface:IEConverter
Retrieve the current processor mode relative to the providedEState
. Refer toIProcessor.getMode()
for the semantics of mode.- Specified by:
getStateProcessorMode
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
state
- optional IR state- Returns:
- the processor mode (most often 8, 16, 32 or 64)
-
getReturnAddressRegister
The default implementation considers that there is no specific Return Address Register. Override if one exists.- Specified by:
getReturnAddressRegister
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
- can return null value if Processor does not use Return Address Register
-
getGPRegister
Description copied from interface:IEConverter
Retrieve the IR variable object that represents the General Purpose register.- Specified by:
getGPRegister
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
index
- register index (eg 0 for x86 eax, ARM R0, Arm64 X0...)- Returns:
-
getFPRegister
Description copied from interface:IEConverter
Retrieve the IR variable object that represents the Floating-point register.- Specified by:
getFPRegister
in interfaceIEConverter<InsnType extends IInstruction>
- Parameters:
index
- register index- Returns:
-
getTempRegister
- Specified by:
getTempRegister
in interfaceIEConverter<InsnType extends IInstruction>
-
formatStatistics
The default implementation formats basic details about the number of converted methods.- Specified by:
formatStatistics
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
generateASTForUntranslatedIR
public ICStatement generateASTForUntranslatedIR(IEUntranslatedInstruction insn, IERoutineContext ectx, ICMethod cctx) The default implementation returns null.- Specified by:
generateASTForUntranslatedIR
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
evaluateUntranslatedIR
public IEImm evaluateUntranslatedIR(IEUntranslatedInstruction insn, IERoutineContext ectx, EState state) The default implementation returns null.- Specified by:
evaluateUntranslatedIR
in interfaceIEConverter<InsnType extends IInstruction>
- Returns:
-
autoConvert
-