Interface IEGlobalContext
Global IR context. A native decompiler instance holds a single global IR context. The global
context is also a factory for non-local IR objects, such as IR constants or IR operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRegister a routine context with this global context.default EStateCreate a machine state for IR emulation.default EStateCreate a machine state for IR emulation with all defined registers, symbols, and globals reset to 0.buildState(boolean initRegisters, boolean initSymbols, boolean initGlobals) Create a machine state for IR emulation.booleancanCreateVariable(int id, int bitsize) Determine whether a variable id can be created.createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta) Create basic branch details information.createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta, IPrototypeItem nativePrototypeHint, List<IBranchTarget> dynamicTargetCandidates) Create basic branch details information.createCompose(IEGeneric... elts) Create a composition of IR elements.createCompose(Collection<IEGeneric> elts) Create a composition of IR elements.createCond(IEGeneric p, IEGeneric a, IEGeneric b) Create a conditional expression.createConversionOperation(OperationType convOperator, IEGeneric src, int dstSize) Create a conversion operation: an integer truncation, integer extension (zero or signed), float truncation or extension, float-to-int and int-to-float conversion.createFunctionType(String name, int flags, int opndCount, int resultBitsize) Create a new function operation type.createGlobalReference(String name, Long address) Create or retrieve a variable referencing a global element.createGlobalVariable(long address, int bitsize) Create a global, memory-mapped variable.createGroupElt(IEGroup collection, IEGeneric index) Create an expression selecting an element from a group.createImm(byte[] v, int bitsize) Create an immediate from bytes.createImm(double v) Create a double-precision floating-point immediate.createImm(float v) Create a single-precision floating-point immediate.createImm(long v, int bitsize) Create an integer immediate.Create an immediate from a string representation.createImm(BigInteger v, int bitsize) Create an integer immediate.Create a memory expression.Create a segmented memory expression.createOperation(FunctionOptype functionOptype, IEGeneric... opnds) Create a function operation expression.createOperation(OperationType optype, IEGeneric op1) Create a unary operation expression.createOperation(OperationType optype, IEGeneric op1, IEGeneric op2) Create a binary operation expression.createRange(int begin, int end) Create a bit range.createRegister(int id, String name, int bitsize) Create a physical register with a manually assigned id (use with care).createRegister(String name, int bitsize) Create a physical register.createResizeOperation(IEGeneric opnd, int bitsize, boolean signed) Create a resize operation operation: truncation, zero-extension, or sign-extension.Create a new routine-less routine context.createRoutineContext(INativeMethodItem routine) Create a new routine context.createSlice(IEGeneric e, int bitstart, int bitend) Create a slice expression.createSlice(IEGeneric e, IERange range) Create a slice expression.createSymbolForData(INativeDataItem data, IERoutineContext userctx) Create or retrieve a symbol for native data.createSymbolForRoutine(INativeMethodItem routine, IERoutineContext userctx) Create or retrieve a symbol for a native routine.createVirtualRegister(int id, String name, int bitsize) Create a virtual register with a manually assigned id (use with care).createVirtualRegister(String name, int bitsize) Create a virtual register.intRetrieve the native address size.Retrieve all register variables.getAllRegisters(Set<Integer> exclusions) Retrieve all register variables except selected ids.Retrieve all variables defined in this global context.getCandidatePrototype(INativeMethodItem routine) Retrieve the candidate prototype for a native routine.Retrieve the converter associated with this global context.Retrieve a piece of transient data.getFunctionType(String name) Retrieve a function operation type by name.getGlobalVariable(long address) Retrieve a global memory variable by address.Retrieve the list of globals (memory) variables defined in this context.Retrieve the native code context.Convenience method.Retrieve the native object tracker.intRetrieve the default register size.getRoutineContext(int index) Retrieve a routine context by index.Retrieve a list of all converted routines.getVar(int id) Retrieve a global contextIEVarby id.getVariableByName(String name) Retrieve a global-scope variable by name.getVariables(int idStart, int idEnd) Retrieve variables whose ids are in the provided range.getVarSafe(int id) Retrieve a global context variable by id.Retrieve the wildcard type manager.booleanDetermine the native byte order.booleanremoveRoutineContext(IERoutineContext ctx, boolean stopTrackingNativeDeps) Delete a converted routine.Retrieve native data from its symbol variable.Retrieve a native routine from its symbol variable.booleansetCandidatePrototype(INativeMethodItem routine, IWildcardPrototype proto, int guarantee) Set a candidate prototype for a native routine.voidStore a piece of transient data.
-
Method Details
-
getNativeMemory
IVirtualMemory getNativeMemory()Convenience method.- Returns:
- the native virtual memory associated with this context
-
getWildcardTypeManager
IWildcardTypeManager getWildcardTypeManager()Retrieve the wildcard type manager.- Returns:
- the wildcard type manager
-
getCandidatePrototype
Retrieve the candidate prototype for a native routine.- Parameters:
routine- native routine- Returns:
- the candidate prototype, or null if none was recorded
-
setCandidatePrototype
Set a candidate prototype for a native routine.- Parameters:
routine- native routineproto- candidate prototypeguarantee- use 0 for an unknown guarantee- Returns:
- true if the candidate prototype was accepted
-
createRoutineContext
IERoutineContext createRoutineContext()Create a new routine-less routine context. The newly created routine context is not attached to this global context. UseaddRoutineContext(IERoutineContext)to add it to the global context.- Returns:
- a new routine context
-
createRoutineContext
Create a new routine context. The newly created routine context is not attached to this global context. UseaddRoutineContext(IERoutineContext)to add it to the global context.- Parameters:
routine- native routine associated with the context- Returns:
- a new routine context
-
getRoutineContexts
List<IERoutineContext> getRoutineContexts()Retrieve a list of all converted routines.- Returns:
- all routine contexts registered with this global context
-
getRoutineContext
Retrieve a routine context by index.- Parameters:
index- routine context index- Returns:
- the routine context
-
addRoutineContext
Register a routine context with this global context.- Parameters:
ctx- routine context to register
-
removeRoutineContext
Delete a converted routine.- Parameters:
ctx- routine context to removestopTrackingNativeDeps- true to stop tracking native dependencies for the routine- Returns:
- true if the routine context was removed
-
getRegisterBitsize
int getRegisterBitsize()Retrieve the default register size.- Returns:
- register size, in bits
-
getAddressBitsize
int getAddressBitsize()Retrieve the native address size.- Returns:
- address size, in bits
-
isBigEndian
boolean isBigEndian()Determine the native byte order.- Returns:
- true if the native context is big-endian
-
getConverter
AbstractConverter<?> getConverter()Retrieve the converter associated with this global context.- Returns:
- the converter
-
getNativeContext
INativeContext getNativeContext()Retrieve the native code context.- Returns:
- the native context
-
getObjectTracker
INativeObjectTracker getObjectTracker()Retrieve the native object tracker.- Returns:
- the native object tracker
-
createBranchDetails
IEBranchDetails createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta) Create basic branch details information.- Parameters:
def- defined variablesuse- used variablesspoiled- spoiled variablesfallbackStackPointerDelta- the provided SP delta will have unknown guarantee and unknown origin- Returns:
- branch details information
-
createBranchDetails
IEBranchDetails createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta, IPrototypeItem nativePrototypeHint, List<IBranchTarget> dynamicTargetCandidates) Create basic branch details information.- Parameters:
def- defined variablesuse- used variablesspoiled- spoiled variablesfallbackStackPointerDelta- fallback stack pointer deltanativePrototypeHint- optional native prototype hintdynamicTargetCandidates- optional dynamic target candidates- Returns:
- branch details information
-
createCompose
Create a composition of IR elements.- Parameters:
elts- at least two elements, from lowest-significant to highest-significant- Returns:
- a composition expression
-
createCompose
Create a composition of IR elements.- Parameters:
elts- elements ordered from lowest-significant to highest-significant- Returns:
- a composition expression
-
createCond
Create a conditional expression.- Parameters:
p- predicate expressiona- expression selected when the predicate is trueb- expression selected when the predicate is false- Returns:
- a conditional expression
-
createGroupElt
Create an expression selecting an element from a group.- Parameters:
collection- group expressionindex- index expression- Returns:
- a group element expression
-
createImm
Create an integer immediate.- Parameters:
v- immediate valuebitsize- value size, in bits- Returns:
- an immediate expression
-
createImm
Create an immediate from bytes.- Parameters:
v- immediate bytesbitsize- value size, in bits- Returns:
- an immediate expression
-
createImm
Create an integer immediate.- Parameters:
v- immediate valuebitsize- value size, in bits- Returns:
- an immediate expression
-
createImm
Create an immediate from a string representation.- Parameters:
v- immediate valuebitsize- value size, in bits- Returns:
- an immediate expression
-
createImm
Create a single-precision floating-point immediate.- Parameters:
v- immediate value- Returns:
- an immediate expression
-
createImm
Create a double-precision floating-point immediate.- Parameters:
v- immediate value- Returns:
- an immediate expression
-
createMem
Create a memory expression.- Parameters:
opaddr- memory address expressionbitsize- memory access size, in bits- Returns:
- a memory expression
-
createMem
Create a segmented memory expression.- Parameters:
segment- segment expressionopaddr- memory address expressionbitsize- memory access size, in bits- Returns:
- a memory expression
-
createOperation
Create a unary operation expression.- Parameters:
optype- operation typeop1- operand- Returns:
- an operation expression
-
createOperation
Create a binary operation expression.- Parameters:
optype- operation typeop1- first operandop2- second operand- Returns:
- an operation expression
-
createOperation
Create a function operation expression.- Parameters:
functionOptype- function operation typeopnds- operands- Returns:
- an operation expression
-
createFunctionType
Create a new function operation type.- Parameters:
name- function name (cannot be blank)flags- function flags, seeFLAG_xxxinFunctionOptypefor a list of legal flagsopndCount- 0+resultBitsize- leave to 0 to signify that the resulting bitsize must be the same as the first operand's (in which case minOpndCount must be at least 1), else a valid positive bitsize must be specified- Returns:
- the function (never null; this method throws on error)
-
getFunctionType
Retrieve a function operation type by name.- Parameters:
name- function name- Returns:
- the function, null if it does not exist (was not previously created)
-
createResizeOperation
Create a resize operation operation: truncation, zero-extension, or sign-extension.- Parameters:
opnd- the source to be extended (dstSize > srcSize) or truncated (dstSize < srcSize)bitsize- the destination size; should be different than the source'ssigned- for extensions, else N/A- Returns:
- the operation IRE
-
createConversionOperation
Create a conversion operation: an integer truncation, integer extension (zero or signed), float truncation or extension, float-to-int and int-to-float conversion.- Parameters:
convOperator- one of for whichOperationType.isConversion()returns true (eg,OperationType.CAST,OperationType.CAST_S,OperationType.FP2FP,OperationType.FP2INT,OperationType.INT2FP)src- operand to be extended, truncated, or converteddstSize- resulting bitsize- Returns:
- the operation IRE
-
createRange
Create a bit range.- Parameters:
begin- start bitend- end bit- Returns:
- a range expression
-
createSlice
Create a slice expression.- Parameters:
e- sliced expressionbitstart- start bitbitend- end bit- Returns:
- a slice expression
-
createSlice
Create a slice expression.- Parameters:
e- sliced expressionrange- bit range- Returns:
- a slice expression
-
createRegister
Create a physical register with a manually assigned id (use with care). Shared across routines boundaries. No address, no type.- Parameters:
id- register idname- register namebitsize- register size, in bits- Returns:
- a register variable
-
createRegister
Create a physical register. Shared across routines boundaries. No address, no type.- Parameters:
name- register namebitsize- register size, in bits- Returns:
- a register variable
-
createVirtualRegister
Create a virtual register with a manually assigned id (use with care). Preserved/not shared across routines boundaries. No address, no type.- Parameters:
id- register idname- register namebitsize- register size, in bits- Returns:
- a virtual register variable
-
createVirtualRegister
Create a virtual register. Preserved/not shared across routines boundaries. No address, no type.- Parameters:
name- register namebitsize- register size, in bits- Returns:
- a virtual register variable
-
createGlobalReference
Create or retrieve a variable referencing a global element. Reference variables cannot be assigned to. The reference is not tracked.- Parameters:
name- optional nameaddress- optional address referenced (e.g. if the reference is a concrete data element); if the name is null, an address must be specified- Returns:
- a reference variable
-
getGlobalVariable
Retrieve a global memory variable by address.- Parameters:
address- global address- Returns:
- the global variable, or null if none exists
-
createGlobalVariable
Create a global, memory-mapped variable.- Parameters:
address- global addressbitsize- variable size, in bits- Returns:
- a global variable
-
getGlobalVariables
Collection<IEVar> getGlobalVariables()Retrieve the list of globals (memory) variables defined in this context.- Returns:
- all global variables
-
createSymbolForRoutine
Create or retrieve a symbol for a native routine.- Parameters:
routine- native routineuserctx- routine context using the symbol- Returns:
- a routine symbol variable
-
retrieveRoutineFromSymbol
Retrieve a native routine from its symbol variable.- Parameters:
var- symbol variable- Returns:
- the native routine, or null if the variable is not a routine symbol
-
createSymbolForData
Create or retrieve a symbol for native data.- Parameters:
data- native data itemuserctx- routine context using the symbol- Returns:
- a data symbol variable
-
retrieveDataFromSymbol
Retrieve native data from its symbol variable.- Parameters:
var- symbol variable- Returns:
- the native data item, or null if the variable is not a data symbol
-
getVariableByName
Retrieve a global-scope variable by name.- Parameters:
name- variable name- Returns:
- the variable or null
-
getVarSafe
Retrieve a global context variable by id.- Parameters:
id- variable id- Returns:
- the variable, or null if it does not exist
-
getVar
Retrieve a global contextIEVarby id. Throws if does not exist.- Parameters:
id- variable id- Returns:
- the variable
-
canCreateVariable
boolean canCreateVariable(int id, int bitsize) Determine whether a variable id can be created.- Parameters:
id- variable idbitsize- variable size, in bits- Returns:
- true if the variable can be created
-
getVariables
Retrieve variables whose ids are in the provided range.- Parameters:
idStart- first variable ididEnd- last variable id- Returns:
- matching variables
-
getAllVariables
Collection<IEVar> getAllVariables()Retrieve all variables defined in this global context.- Returns:
- all variables
-
getAllRegisters
Collection<IEVar> getAllRegisters()Retrieve all register variables.- Returns:
- all registers
-
getAllRegisters
Retrieve all register variables except selected ids.- Parameters:
exclusions- excluded register ids- Returns:
- matching registers
-
buildState
Create a machine state for IR emulation.- Parameters:
initRegisters- initialize all global IEVar-registers to 0initSymbols- initialize all global symbols IEVars to 0initGlobals- initialize all global memory IEVars to 0- Returns:
- a fresh state
-
buildState
Create a machine state for IR emulation with all defined registers, symbols, and globals reset to 0.Same as
buildState(true, true, true)- Returns:
- a fresh state
-
buildEmptyState
Create a machine state for IR emulation.Same as
buildState(false, false, false)- Returns:
- a fresh state
-
setData
Store a piece of transient data.- Parameters:
key- data keyvalue- data value
-
getData
Retrieve a piece of transient data.- Parameters:
key- data key- Returns:
- the stored value, or null if none exists
-