Interface IEGlobalContext


@Ser public 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 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

      IWildcardPrototype getCandidatePrototype(INativeMethodItem routine)
      Retrieve the candidate prototype for a native routine.
      Parameters:
      routine - native routine
      Returns:
      the candidate prototype, or null if none was recorded
    • setCandidatePrototype

      boolean setCandidatePrototype(INativeMethodItem routine, IWildcardPrototype proto, int guarantee)
      Set a candidate prototype for a native routine.
      Parameters:
      routine - native routine
      proto - candidate prototype
      guarantee - 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. Use addRoutineContext(IERoutineContext) to add it to the global context.
      Returns:
      a new routine context
    • createRoutineContext

      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.
      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

      IERoutineContext getRoutineContext(int index)
      Retrieve a routine context by index.
      Parameters:
      index - routine context index
      Returns:
      the routine context
    • addRoutineContext

      void addRoutineContext(IERoutineContext ctx)
      Register a routine context with this global context.
      Parameters:
      ctx - routine context to register
    • removeRoutineContext

      boolean removeRoutineContext(IERoutineContext ctx, boolean stopTrackingNativeDeps)
      Delete a converted routine.
      Parameters:
      ctx - routine context to remove
      stopTrackingNativeDeps - 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 variables
      use - used variables
      spoiled - spoiled variables
      fallbackStackPointerDelta - 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 variables
      use - used variables
      spoiled - spoiled variables
      fallbackStackPointerDelta - fallback stack pointer delta
      nativePrototypeHint - optional native prototype hint
      dynamicTargetCandidates - optional dynamic target candidates
      Returns:
      branch details information
    • createCompose

      IECompose createCompose(IEGeneric... elts)
      Create a composition of IR elements.
      Parameters:
      elts - at least two elements, from lowest-significant to highest-significant
      Returns:
      a composition expression
    • createCompose

      IECompose createCompose(Collection<IEGeneric> elts)
      Create a composition of IR elements.
      Parameters:
      elts - elements ordered from lowest-significant to highest-significant
      Returns:
      a composition expression
    • createCond

      IECond createCond(IEGeneric p, IEGeneric a, IEGeneric b)
      Create a conditional expression.
      Parameters:
      p - predicate expression
      a - expression selected when the predicate is true
      b - expression selected when the predicate is false
      Returns:
      a conditional expression
    • createGroupElt

      IEGroupElt createGroupElt(IEGroup collection, IEGeneric index)
      Create an expression selecting an element from a group.
      Parameters:
      collection - group expression
      index - index expression
      Returns:
      a group element expression
    • createImm

      IEImm createImm(long v, int bitsize)
      Create an integer immediate.
      Parameters:
      v - immediate value
      bitsize - value size, in bits
      Returns:
      an immediate expression
    • createImm

      IEImm createImm(byte[] v, int bitsize)
      Create an immediate from bytes.
      Parameters:
      v - immediate bytes
      bitsize - value size, in bits
      Returns:
      an immediate expression
    • createImm

      IEImm createImm(BigInteger v, int bitsize)
      Create an integer immediate.
      Parameters:
      v - immediate value
      bitsize - value size, in bits
      Returns:
      an immediate expression
    • createImm

      IEImm createImm(String v, int bitsize)
      Create an immediate from a string representation.
      Parameters:
      v - immediate value
      bitsize - value size, in bits
      Returns:
      an immediate expression
    • createImm

      IEImm createImm(float v)
      Create a single-precision floating-point immediate.
      Parameters:
      v - immediate value
      Returns:
      an immediate expression
    • createImm

      IEImm createImm(double v)
      Create a double-precision floating-point immediate.
      Parameters:
      v - immediate value
      Returns:
      an immediate expression
    • createMem

      IEMem createMem(IEGeneric opaddr, int bitsize)
      Create a memory expression.
      Parameters:
      opaddr - memory address expression
      bitsize - memory access size, in bits
      Returns:
      a memory expression
    • createMem

      IEMem createMem(IEGeneric segment, IEGeneric opaddr, int bitsize)
      Create a segmented memory expression.
      Parameters:
      segment - segment expression
      opaddr - memory address expression
      bitsize - memory access size, in bits
      Returns:
      a memory expression
    • createOperation

      IEOperation createOperation(OperationType optype, IEGeneric op1)
      Create a unary operation expression.
      Parameters:
      optype - operation type
      op1 - operand
      Returns:
      an operation expression
    • createOperation

      IEOperation createOperation(OperationType optype, IEGeneric op1, IEGeneric op2)
      Create a binary operation expression.
      Parameters:
      optype - operation type
      op1 - first operand
      op2 - second operand
      Returns:
      an operation expression
    • createOperation

      IEOperation createOperation(FunctionOptype functionOptype, IEGeneric... opnds)
      Create a function operation expression.
      Parameters:
      functionOptype - function operation type
      opnds - operands
      Returns:
      an operation expression
    • createFunctionType

      FunctionOptype createFunctionType(String name, int flags, int opndCount, 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
      opndCount - 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

      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)
    • createResizeOperation

      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
    • createConversionOperation

      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 OperationType.isConversion() returns true (eg, OperationType.CAST, OperationType.CAST_S, OperationType.FP2FP, OperationType.FP2INT, OperationType.INT2FP)
      src - operand to be extended, truncated, or converted
      dstSize - resulting bitsize
      Returns:
      the operation IRE
    • createRange

      IERange createRange(int begin, int end)
      Create a bit range.
      Parameters:
      begin - start bit
      end - end bit
      Returns:
      a range expression
    • createSlice

      IESlice createSlice(IEGeneric e, int bitstart, int bitend)
      Create a slice expression.
      Parameters:
      e - sliced expression
      bitstart - start bit
      bitend - end bit
      Returns:
      a slice expression
    • createSlice

      IESlice createSlice(IEGeneric e, IERange range)
      Create a slice expression.
      Parameters:
      e - sliced expression
      range - bit range
      Returns:
      a slice expression
    • createRegister

      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.
      Parameters:
      id - register id
      name - register name
      bitsize - register size, in bits
      Returns:
      a register variable
    • createRegister

      IEVar createRegister(String name, int bitsize)
      Create a physical register. Shared across routines boundaries. No address, no type.
      Parameters:
      name - register name
      bitsize - register size, in bits
      Returns:
      a register variable
    • createVirtualRegister

      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.
      Parameters:
      id - register id
      name - register name
      bitsize - register size, in bits
      Returns:
      a virtual register variable
    • createVirtualRegister

      IEVar createVirtualRegister(String name, int bitsize)
      Create a virtual register. Preserved/not shared across routines boundaries. No address, no type.
      Parameters:
      name - register name
      bitsize - register size, in bits
      Returns:
      a virtual register variable
    • createGlobalReference

      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
    • getGlobalVariable

      IEVar getGlobalVariable(long address)
      Retrieve a global memory variable by address.
      Parameters:
      address - global address
      Returns:
      the global variable, or null if none exists
    • createGlobalVariable

      IEVar createGlobalVariable(long address, int bitsize)
      Create a global, memory-mapped variable.
      Parameters:
      address - global address
      bitsize - 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

      IEVar createSymbolForRoutine(INativeMethodItem routine, IERoutineContext userctx)
      Create or retrieve a symbol for a native routine.
      Parameters:
      routine - native routine
      userctx - routine context using the symbol
      Returns:
      a routine symbol variable
    • retrieveRoutineFromSymbol

      INativeMethodItem retrieveRoutineFromSymbol(IEVar var)
      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

      IEVar createSymbolForData(INativeDataItem data, IERoutineContext userctx)
      Create or retrieve a symbol for native data.
      Parameters:
      data - native data item
      userctx - routine context using the symbol
      Returns:
      a data symbol variable
    • retrieveDataFromSymbol

      INativeDataItem retrieveDataFromSymbol(IEVar var)
      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

      IEVar getVariableByName(String name)
      Retrieve a global-scope variable by name.
      Parameters:
      name - variable name
      Returns:
      the variable or null
    • getVarSafe

      IEVar getVarSafe(int id)
      Retrieve a global context variable by id.
      Parameters:
      id - variable id
      Returns:
      the variable, or null if it does not exist
    • getVar

      IEVar getVar(int id)
      Retrieve a global context IEVar by 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 id
      bitsize - variable size, in bits
      Returns:
      true if the variable can be created
    • getVariables

      Collection<IEVar> getVariables(int idStart, int idEnd)
      Retrieve variables whose ids are in the provided range.
      Parameters:
      idStart - first variable id
      idEnd - 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

      Collection<IEVar> getAllRegisters(Set<Integer> exclusions)
      Retrieve all register variables except selected ids.
      Parameters:
      exclusions - excluded register ids
      Returns:
      matching registers
    • buildState

      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
    • buildState

      default 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
    • buildEmptyState

      default EState buildEmptyState()
      Create a machine state for IR emulation.

      Same as buildState(false, false, false)

      Returns:
      a fresh state
    • setData

      void setData(Object key, Object value)
      Store a piece of transient data.
      Parameters:
      key - data key
      value - data value
    • getData

      Object getData(Object key)
      Retrieve a piece of transient data.
      Parameters:
      key - data key
      Returns:
      the stored value, or null if none exists