public interface

IEGlobalContext

com.pnfsoftware.jeb.core.units.code.asm.decompiler.IEGlobalContext

Class Overview

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.

Summary

Public Methods
abstract void addRoutineContext(IERoutineContext ctx)
Register a routine context with this global context.
abstract EState buildEmptyState()
Create a machine state for IR emulation.
abstract EState buildState(boolean initRegisters, boolean initSymbols, boolean initGlobals)
Create a machine state for IR emulation.
abstract EState buildState()
Create a machine state for IR emulation with all defined registers, symbols, and globals reset to 0.
abstract boolean canCreateVariable(int id, int bitsize)
abstract IEBranchDetails createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta, IPrototypeItem nativePrototypeHint, List<IBranchTarget> dynamicTargetCandidates)
Create basic branch details information.
abstract IEBranchDetails createBranchDetails(List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta)
Create basic branch details information.
abstract IECompose createCompose(Collection<IEGeneric> elts)
abstract IECompose createCompose(IEGeneric... elts)
Create a composition of IR elements.
abstract IECond createCond(IEGeneric p, IEGeneric a, IEGeneric b)
abstract IEOperation 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.
abstract FunctionOptype createFunctionType(String name, int flags, int minOpndCount, int maxOpndCount, int resultBitsize)
Create a new function operation type.
abstract IEVar createGlobalReference(String name, Long address)
Create or retrieve a variable referencing a global element.
abstract IEVar createGlobalVariable(long address, int bitsize)
Create a global, memory-mapped variable.
abstract IEGroupElt createGroupElt(IEGroup collection, IEGeneric index)
abstract IEImm createImm(double v)
abstract IEImm createImm(BigInteger v, int bitsize)
abstract IEImm createImm(float v)
abstract IEImm createImm(long v, int bitsize)
abstract IEImm createImm(byte[] v, int bitsize)
abstract IEImm createImm(String v, int bitsize)
abstract IEMem createMem(IEGeneric segment, IEGeneric opaddr, int bitsize)
abstract IEMem createMem(IEGeneric opaddr, int bitsize)
abstract IEOperation createOperation(OperationType optype, IEGeneric op1)
abstract IEOperation createOperation(FunctionOptype functionOptype, IEGeneric... opnds)
abstract IEOperation createOperation(OperationType optype, IEGeneric op1, IEGeneric op2)
abstract IERange createRange(int begin, int end)
abstract IEVar createRegister(int id, String name, int bitsize)
Create a physical register with a manually assigned id (use with care).
abstract IEVar createRegister(String name, int bitsize)
Create a physical register.
abstract IEOperation createResizeOperation(IEGeneric opnd, int bitsize, boolean signed)
Create a resize operation operation: truncation, zero-extension, or sign-extension.
abstract IERoutineContext createRoutineContext(INativeMethodItem routine)
Create a new routine context.
abstract IERoutineContext createRoutineContext()
Create a new routine-less routine context.
abstract IESlice createSlice(IEGeneric e, IERange range)
abstract IESlice createSlice(IEGeneric e, int bitstart, int bitend)
abstract IEVar createSymbolForData(INativeDataItem data, IERoutineContext userctx)
abstract IEVar createSymbolForRoutine(INativeMethodItem routine, IERoutineContext userctx)
abstract IEVar createVirtualRegister(int id, String name, int bitsize)
Create a virtual register with a manually assigned id (use with care).
abstract IEVar createVirtualRegister(String name, int bitsize)
Create a virtual register.
abstract int getAddressBitsize()
abstract Collection<IEVar> getAllRegisters()
abstract Collection<IEVar> getAllRegisters(Set<Integer> exclusions)
abstract Collection<IEVar> getAllVariables()
abstract IWildcardPrototype getCandidatePrototype(INativeMethodItem routine)
abstract AbstractConverter<?> getConverter()
abstract Object getData(Object key)
Retrieve a piece of transient data.
abstract FunctionOptype getFunctionType(String name)
Retrieve a function operation type by name.
abstract IEVar getGlobalVariable(long address)
abstract Collection<IEVar> getGlobalVariables()
Retrieve the list of globals (memory) variables defined in this context.
abstract INativeContext getNativeContext()
abstract IVirtualMemory getNativeMemory()
Convenience method.
abstract INativeObjectTracker getObjectTracker()
abstract int getRegisterBitsize()
abstract IERoutineContext getRoutineContext(int index)
abstract List<IERoutineContext> getRoutineContexts()
Retrieve a list of all converted routines.
abstract IEVar getVar(int id)
Retrieve a global context IEVar by id.
abstract IEVar getVarSafe(int id)
abstract IEVar getVariableByName(String name)
Retrieve a global-scope variable by name.
abstract Collection<IEVar> getVariables(int idStart, int idEnd)
abstract IWildcardTypeManager getWildcardTypeManager()
abstract boolean isBigEndian()
abstract boolean removeRoutineContext(IERoutineContext ctx, boolean stopTrackingNativeDeps)
Delete a converted routine.
abstract INativeDataItem retrieveDataFromSymbol(IEVar var)
abstract INativeMethodItem retrieveRoutineFromSymbol(IEVar var)
abstract boolean setCandidatePrototype(INativeMethodItem routine, IWildcardPrototype proto, int guarantee)
abstract void setData(Object key, Object value)
Store a piece of transient data.

Public Methods

public abstract void addRoutineContext (IERoutineContext ctx)

Register a routine context with this global context.

public abstract EState buildEmptyState ()

Create a machine state for IR emulation.

Same as buildState(false, false, false)

Returns
  • a fresh state

public abstract EState buildState (boolean initRegisters, boolean initSymbols, boolean initGlobals)

Create a machine state for IR emulation.

Parameters
initRegisters initialize all global IEVar-registers to 0
initSymbols initialize all global symbols IEVars to 0
initGlobals initialize all global memory IEVars to 0
Returns
  • a fresh state

public abstract EState 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

public abstract boolean canCreateVariable (int id, int bitsize)

public abstract IEBranchDetails createBranchDetails (List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta, IPrototypeItem nativePrototypeHint, List<IBranchTarget> dynamicTargetCandidates)

Create basic branch details information.

public abstract IEBranchDetails createBranchDetails (List<IEVar> def, List<IEVar> use, List<IEVar> spoiled, int fallbackStackPointerDelta)

Create basic branch details information.

Parameters
fallbackStackPointerDelta the provided SP delta will have unknown guarantee and unknown origin

public abstract IECompose createCompose (Collection<IEGeneric> elts)

public abstract IECompose createCompose (IEGeneric... elts)

Create a composition of IR elements.

Parameters
elts at least two elements, from lowest-significant to highest-significant

public abstract IECond createCond (IEGeneric p, IEGeneric a, IEGeneric b)

public abstract IEOperation 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.

Parameters
convOperator one of for which isConversion() returns true (eg, CAST, CAST_S, FP2FP, FP2INT, INT2FP)
src operand to be extended, truncated, or converted
dstSize resulting bitsize
Returns
  • the operation IRE

public abstract FunctionOptype createFunctionType (String name, int flags, int minOpndCount, int maxOpndCount, int resultBitsize)

Create a new function operation type.

Parameters
name function name (cannot be blank)
flags function flags, see FLAG_xxx in FunctionOptype for a list of legal flags
minOpndCount 0+
maxOpndCount 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)

public abstract IEVar createGlobalReference (String name, Long address)

Create or retrieve a variable referencing a global element. Reference variables cannot be assigned to. The reference is not tracked.

Parameters
name optional name
address 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

public abstract IEVar createGlobalVariable (long address, int bitsize)

Create a global, memory-mapped variable.

public abstract IEGroupElt createGroupElt (IEGroup collection, IEGeneric index)

public abstract IEImm createImm (double v)

public abstract IEImm createImm (BigInteger v, int bitsize)

public abstract IEImm createImm (float v)

public abstract IEImm createImm (long v, int bitsize)

public abstract IEImm createImm (byte[] v, int bitsize)

public abstract IEImm createImm (String v, int bitsize)

public abstract IEMem createMem (IEGeneric segment, IEGeneric opaddr, int bitsize)

public abstract IEMem createMem (IEGeneric opaddr, int bitsize)

public abstract IEOperation createOperation (OperationType optype, IEGeneric op1)

public abstract IEOperation createOperation (FunctionOptype functionOptype, IEGeneric... opnds)

public abstract IEOperation createOperation (OperationType optype, IEGeneric op1, IEGeneric op2)

public abstract IERange createRange (int begin, int end)

public abstract IEVar createRegister (int id, String name, int bitsize)

Create a physical register with a manually assigned id (use with care). Shared across routines boundaries. No address, no type.

public abstract IEVar createRegister (String name, int bitsize)

Create a physical register. Shared across routines boundaries. No address, no type.

public abstract IEOperation createResizeOperation (IEGeneric opnd, int bitsize, boolean signed)

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's
signed for extensions, else N/A
Returns
  • the operation IRE

public abstract IERoutineContext createRoutineContext (INativeMethodItem routine)

Create a new routine context. The newly created routine context is not attached to this global context. Use addRoutineContext(IERoutineContext) to add it to the global context.

public abstract IERoutineContext createRoutineContext ()

Create a new routine-less routine context. The newly created routine context is not attached to this global context. Use addRoutineContext(IERoutineContext) to add it to the global context.

public abstract IESlice createSlice (IEGeneric e, IERange range)

public abstract IESlice createSlice (IEGeneric e, int bitstart, int bitend)

public abstract IEVar createSymbolForData (INativeDataItem data, IERoutineContext userctx)

public abstract IEVar createSymbolForRoutine (INativeMethodItem routine, IERoutineContext userctx)

public abstract IEVar createVirtualRegister (int id, String name, int bitsize)

Create a virtual register with a manually assigned id (use with care). Preserved/not shared across routines boundaries. No address, no type.

public abstract IEVar createVirtualRegister (String name, int bitsize)

Create a virtual register. Preserved/not shared across routines boundaries. No address, no type.

public abstract int getAddressBitsize ()

public abstract Collection<IEVar> getAllRegisters ()

public abstract Collection<IEVar> getAllRegisters (Set<Integer> exclusions)

public abstract Collection<IEVar> getAllVariables ()

public abstract IWildcardPrototype getCandidatePrototype (INativeMethodItem routine)

public abstract AbstractConverter<?> getConverter ()

public abstract Object getData (Object key)

Retrieve a piece of transient data.

public abstract FunctionOptype getFunctionType (String name)

Retrieve a function operation type by name.

Parameters
name function name
Returns
  • the function, null if it does not exist (was not previously created)

public abstract IEVar getGlobalVariable (long address)

public abstract Collection<IEVar> getGlobalVariables ()

Retrieve the list of globals (memory) variables defined in this context.

public abstract INativeContext getNativeContext ()

public abstract IVirtualMemory getNativeMemory ()

Convenience method.

public abstract INativeObjectTracker getObjectTracker ()

public abstract int getRegisterBitsize ()

public abstract IERoutineContext getRoutineContext (int index)

public abstract List<IERoutineContext> getRoutineContexts ()

Retrieve a list of all converted routines.

public abstract IEVar getVar (int id)

Retrieve a global context IEVar by id. Throws if does not exist.

public abstract IEVar getVarSafe (int id)

public abstract IEVar getVariableByName (String name)

Retrieve a global-scope variable by name.

Returns
  • the variable or null

public abstract Collection<IEVar> getVariables (int idStart, int idEnd)

public abstract IWildcardTypeManager getWildcardTypeManager ()

public abstract boolean isBigEndian ()

public abstract boolean removeRoutineContext (IERoutineContext ctx, boolean stopTrackingNativeDeps)

Delete a converted routine.

public abstract INativeDataItem retrieveDataFromSymbol (IEVar var)

public abstract INativeMethodItem retrieveRoutineFromSymbol (IEVar var)

public abstract boolean setCandidatePrototype (INativeMethodItem routine, IWildcardPrototype proto, int guarantee)

Parameters
guarantee use 0 for an unknown guarantee

public abstract void setData (Object key, Object value)

Store a piece of transient data.