Interface IDGlobalContext


public interface IDGlobalContext
dexdec IR global context. This object also provides factory methods to create non-instruction elements. (IR instructions can be created using a method context).
  • Method Details

    • getDex

      IDexUnit getDex()
      Retrieve the underlying dex unit object.
      Returns:
    • getDecompiler

      IDexDecompilerUnit getDecompiler()
      Retrieve the managing dex decompiler object.
      Returns:
    • getOperatorFactory

      IJavaOperatorFactory getOperatorFactory()
      Retrieve the global high-level operator factory. The type factory can be used to create all operators, including conditionals, string concatenation, and create cast operators.
      Returns:
    • getTypeFactory

      IJavaTypeFactory getTypeFactory()
      Retrieve the global high-level type factory.
      Returns:
    • getTypeInfoProvider

      IDTypeInfoProvider getTypeInfoProvider()
      Retrieve the type information provider. This provider can access additional, user-provided libraries (jar, dex) to retrieve information on types referenced but not defined in the underlying dex unit.
      Returns:
    • createMasterOptimizer

      IDMasterOptimizer createMasterOptimizer(IDMethodContext methodContext, boolean registerBuiltinOptimizers, boolean initializeWithDexdecSettings, boolean registerExternalOptimizers)
      Create a master optimizer targeting the provided method.
      Parameters:
      methodContext -
      registerBuiltinOptimizers -
      initializeWithDexdecSettings -
      registerExternalOptimizers -
      Returns:
    • createMasterOptimizer

      default IDMasterOptimizer createMasterOptimizer(IDMethodContext methodContext)
      Create a pre-initialized master optimizer targeting the provided method. This convenience method is equivalent to createMasterOptimizer(ctx, true, true, true).
      Parameters:
      methodContext -
      Returns:
    • getThreadSharedState

      IDState getThreadSharedState()
      Retrieve the current IR state associated with the current thread. Each thread has its own associated State: the first time this method is called by thread T, a new state object will be created; the subsequent times this method is called by thread T, the previously created state is returned.
      Returns:
      the IR state associated with the running thread
    • getEmulator

      IDState getEmulator()
      Retrieve the current IR state associated with the current thread. Each thread has its own associated State: the first time this method is called by thread T, a new state object will be created; the subsequent times this method is called by thread T, the previously created state is returned.

      This method also performs two important tasks:
      - the first time it is called, the State is initialized with settings to allow for practical emulation (large emulation count and timeout, emulation and sandboxing enabled, etc.)
      - each time this method is called, settings from the global dexdec emulator configuration file (dexdec-emu.cfg in your plugins folder) is pulled and applied to the State if they have changed

      Returns:
      the IR state associated with the running thread
    • createState

      IDState createState()
      Create a fresh, uninitialized IR state. The IR state is context-less (no context is created). Settings are left on default values, in particular, the maximum iteration count and duration are set to the default values (see IDState.DEFAULT_MAX_ITERCOUNT, IDState.DEFAULT_MAX_DURATION). The emulator and sandbox are disabled. The client should use the State's setters before proceeding with emulation.
      Returns:
      a new IR state
    • createState

      IDState createState(boolean initForEmulation, boolean loadDexdecEmuSettings)
      Create a fresh IR state. The IR state is context-less (no context is created).
      Parameters:
      initForEmulation - if true, the state settings are changed to allow for IR emulation
      loadDexdecEmuSettings - if true, the global dexdec emulator configuration file (dexdec-emu.cfg in your plugins folder) is used to further configure the State
      Returns:
      a new IR state
    • setData

      Object setData(String key, Object value)
      Store an arbitrary object in this global context.
      Parameters:
      key - non-null key
      value - null means remove the entry
      Returns:
      the previous value associated with the key
    • getData

      Object getData(String key)
      Retrieve an arbitrary object in this global context.
      Parameters:
      key -
      Returns:
      the value or null if none isassociated with the key
    • getData

      Object getData(String key, Function<String,Object> creator)
      Retrieve or create (and register) an arbitrary object in this global context.
      Parameters:
      key -
      creator - the creator function is called if no value is mapped to the provided key
      Returns:
      the value (existing or newly created)
    • getDataKeys

      Set<String> getDataKeys()
      Retrieve the set of objects keys for data elements stored using setData.
      Returns:
      a read-only collection
    • resetDeobfuscatorCounters

      void resetDeobfuscatorCounters()
      Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation. Counters are used to track emulation successes and failures for methods. Some optimizers may check the counters to avoid attempting to emulate methods for which too many failures were reported. Calling this method resets such counters, allowing emulation to be re-attempted.

      This method resets all counters.

    • resetDeobfuscatorCounters

      void resetDeobfuscatorCounters(String entryName)
      Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation. Counters are used to track emulation successes and failures for methods. Some optimizers may check the counters to avoid attempting to emulate methods for which too many failures were reported. Calling this method resets such counters, allowing emulation to be re-attempted.

      This method resets a specific counter.

      Parameters:
      entryName - counter name; generally, a method fully-qualified name, e.g. Lcom/abc/Foo->bar(I)V
    • createConstant

      default IDImm createConstant(long rawvalue, IJavaType type)
      Create immediate constants. The same as createImm(long, IJavaType).
      Parameters:
      rawvalue -
      type -
      Returns:
    • createImm

      IDImm createImm(long rawvalue, IJavaType type)
      Create immediate constants.
      Parameters:
      rawvalue -
      type -
      Returns:
    • createRef

      IDImm createRef(int refid, IJavaType reftype)
      Create an object reference.
      Parameters:
      refid - object reference id
      reftype - optional object type; if null is provided, the generic wildcard object type is used
      Returns:
      an imm representing an object reference
    • createRef

      IDImm createRef(int refid)
      Create an object reference. The type of the reference will be the generic wildcard object type
      Parameters:
      refid - object reference id
      Returns:
      an imm representing an object reference
    • createBoolean

      IDImm createBoolean(boolean value)
      Wrapper used to create boolean constants.
      Parameters:
      value -
      Returns:
    • createByte

      IDImm createByte(byte value)
      Wrapper used to create byte constants.
      Parameters:
      value -
      Returns:
    • createChar

      IDImm createChar(char value)
      Wrapper used to create char constants.
      Parameters:
      value -
      Returns:
    • createShort

      IDImm createShort(short value)
      Wrapper used to create short constants.
      Parameters:
      value -
      Returns:
    • createInt

      IDImm createInt(int value)
      Wrapper used to create int constants.
      Parameters:
      value -
      Returns:
    • createLong

      IDImm createLong(long value)
      Wrapper used to create long constants.
      Parameters:
      value -
      Returns:
    • createFloat

      IDImm createFloat(float value)
      Wrapper used to create float constants.
      Parameters:
      value -
      Returns:
    • createDouble

      IDImm createDouble(double value)
      Wrapper used to create double constants.
      Parameters:
      value -
      Returns:
    • createNull

      IDImm createNull()
      Wrapper used to create the null constant.
      Returns:
    • createString

      IDImm createString(String value)
      Wrapper used to create string constants.
      Parameters:
      value -
      Returns:
    • createString

      IDImm createString(IDIndex stringIndex)
      Wrapper used to create string constants.
      Parameters:
      stringIndex -
      Returns:
    • createArrayElt

      IDArrayElt createArrayElt(IDExpression array, IDExpression index, IJavaType type)
      Create an array element.
      Parameters:
      array -
      index -
      type -
      Returns:
    • createOperation

      IDOperation createOperation(IJavaType type, JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)
      Create an operation element with at most two operands, such an an arithmetic or bitwise expression, string concatenation, or cast operation.
      Parameters:
      type - may be left null to let a basic type for the expression be auto-determined
      optype -
      opnd1 -
      opnd2 -
      Returns:
    • createOperation

      IDOperation createOperation(IJavaType type, IDExpression left, IJavaOperator operator, IDExpression right)
      Create an operation element, such an an arithmetic or bitwise expression, conditional, string concatenation, or cast operation.
      Parameters:
      type -
      left -
      operator -
      right -
      Returns:
    • createCastOperation

      IDOperation createCastOperation(IJavaType castType, IDExpression exp)
      Create a cast operation.
      Parameters:
      castType -
      exp -
      Returns:
    • createCastOperation

      IDOperation createCastOperation(String castTypeSignature, IDExpression exp)
      Create a cast operation.
      Parameters:
      castTypeSignature -
      exp -
      Returns:
    • createConditional

      IDOperation createConditional(IJavaType type, IDExpression pred, IDExpression expTrue, IDExpression expFalse)
      Convenience operation.
      Parameters:
      type -
      pred -
      expTrue -
      expFalse -
      Returns:
    • createPredicate

      IDOperation createPredicate(JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)
      Create a predicate operation (typed boolean).
      Parameters:
      optype - a logical operator
      opnd1 -
      opnd2 -
      Returns:
    • createPredicate

      IDOperation createPredicate(IDExpression left, IJavaOperator operator, IDExpression right)
      Create a predicate operation (typed boolean).
      Parameters:
      left -
      operator - a logical operator
      right -
      Returns:
    • createReferenceType

      IDReferenceType createReferenceType(IDIndex cindex, IJavaType ctype)
      Create a reference type expression.
      Parameters:
      cindex -
      ctype -
      Returns:
    • createReferenceType

      IDReferenceType createReferenceType(String csig)
      Create a reference type expression.
      Parameters:
      csig -
      Returns:
    • createIndex

      IDIndex createIndex(int value)
      Create an immutable pool index value.
      Parameters:
      value - index value
      Returns:
      the index object
    • createStaticField

      IDStaticField createStaticField(String fsig)
    • createStaticField

      IDStaticField createStaticField(String fsig, boolean createRefIfDoesNotExist)
    • createStaticField

      IDStaticField createStaticField(IDexField f)
    • createStaticField

      IDStaticField createStaticField(IDIndex index, IJavaType fieldtype, String csig, String fieldname)
      Parameters:
      index -
      fieldtype -
      csig -
      fieldname -
      Returns:
    • createInstanceField

      IDInstanceField createInstanceField(IDExpression instance, String fsig)
    • createInstanceField

      IDInstanceField createInstanceField(IDExpression instance, String fsig, boolean createRefIfDoesNotExist)
    • createInstanceField

      IDInstanceField createInstanceField(IDExpression instance, IDexField f)
    • createInstanceField

      IDInstanceField createInstanceField(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname)
      Parameters:
      instance -
      index -
      fieldtype -
      fieldname -
      Returns:
    • createClassObject

      IDStaticField createClassObject(String csig)
    • createArrayLength

      IDInstanceField createArrayLength(IDExpression instance)
    • createCallInfo

      IDCallInfo createCallInfo(IDIndex methodindex, IDExpression[] arguments, IJavaType returntype, String methodsig, DInvokeType invoketype)
    • createCallInfo

      IDCallInfo createCallInfo(IDIndex methodindex, List<IDExpression> arguments, IJavaType returntype, String methodsig, DInvokeType invoketype)
    • createCallInfo

      IDCallInfo createCallInfo(DInvokeType invoketype, int methodindex, List<IDExpression> arguments)
    • createCallInfo

      IDCallInfo createCallInfo(DInvokeType invoketype, String msig, List<IDExpression> arguments)
    • createAllocObjectInfo

      IDAllocObjectInfo createAllocObjectInfo(IJavaType objectType)
    • createAllocObjectInfo

      IDAllocObjectInfo createAllocObjectInfo(String objectType)
    • createNewInfo

      IDNewInfo createNewInfo(String constructorSig, IDExpression... arguments)
      Convenience method to create a new SomeObject(..) operand.
    • createNewInfo

      IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, IDExpression[] arguments, String methodsig)
    • createNewInfo

      IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, List<IDExpression> arguments, String methodsig)
    • createNewArrayInfo

      IDNewArrayInfo createNewArrayInfo(IJavaType type, IDExpression size, List<IDExpression> initvals)
    • createBooleanArray

      IDNewArrayInfo createBooleanArray(boolean[] values)
    • createByteArray

      IDNewArrayInfo createByteArray(byte[] values)
    • createCharArray

      IDNewArrayInfo createCharArray(char[] values)
    • createShortArray

      IDNewArrayInfo createShortArray(short[] values)
    • createIntArray

      IDNewArrayInfo createIntArray(int[] values)
    • createLongArray

      IDNewArrayInfo createLongArray(long[] values)
    • createFloatArray

      IDNewArrayInfo createFloatArray(float[] values)
    • createDoubleArray

      IDNewArrayInfo createDoubleArray(double[] values)
    • createStringArray

      IDNewArrayInfo createStringArray(String[] values)
    • createTarget

      IDTarget createTarget(int offset)
    • createSwitchData

      IDSwitchData createSwitchData()
      Create a switch data element used in Switch instructions.
      Returns: