public interface

IDGlobalContext

com.pnfsoftware.jeb.core.units.code.android.ir.IDGlobalContext

Class Overview

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

Summary

Public Methods
abstract IDArrayElt createArrayElt(IDExpression array, IDExpression index, IJavaType type)
Create an array element.
abstract IDInstanceField createArrayLength(IDExpression instance)
abstract IDImm createBoolean(boolean value)
Wrapper used to create boolean constants.
abstract IDImm createByte(byte value)
Wrapper used to create byte constants.
abstract IDNewArrayInfo createByteArray(byte[] bytes)
abstract IDCallInfo createCallInfo(DInvokeType invoketype, int methodindex, List<IDExpression> arguments)
abstract IDCallInfo createCallInfo(IDIndex methodindex, IDExpression[] arguments, IJavaType returntype, String methodsig, DInvokeType invoketype)
abstract IDCallInfo createCallInfo(IDIndex methodindex, List<IDExpression> arguments, IJavaType returntype, String methodsig, DInvokeType invoketype)
abstract IDOperation createCast(IJavaType casttype, IDExpression e)
Convenience operation.
abstract IDImm createChar(char value)
Wrapper used to create char constants.
abstract IDStaticField createClassObject(String csig)
abstract IDOperation createConditional(IDPredicate pred, IDExpression expTrue, IDExpression expFalse)
Convenience operation.
abstract IDImm createConstant(long rawvalue, IJavaType type)
Create immediate constants.
abstract IDImm createDouble(double value)
Wrapper used to create double constants.
abstract IDImm createFloat(float value)
Wrapper used to create float constants.
abstract IDImm createImm(long rawvalue, IJavaType type)
Create immediate constants.
abstract IDIndex createIndex(int value)
Create an immutable pool index value.
abstract IDInstanceField createInstanceField(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname)
abstract IDImm createInt(int value)
Wrapper used to create int constants.
abstract IDImm createLong(long value)
Wrapper used to create long constants.
abstract IDMasterOptimizer createMasterOptimizer(IDMethodContext methodContext)
Create a pre-initialized master optimized targeting the provided method.
abstract IDMasterOptimizer createMasterOptimizer(IDMethodContext methodContext, boolean registerBuiltinOptimizers, boolean initializeWithDexdecSettings, boolean registerExternalOptimizers)
Create a master optimizer targeting the provided method.
abstract IDNewArrayInfo createNewArrayInfo(IJavaType type, IDExpression size, List<IDExpression> initvals)
abstract IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, List<IDExpression> arguments, String methodsig)
abstract IDNewInfo createNewInfo(String constructorSig, IDExpression... arguments)
Convenience method to create a new SomeObject(..) operand.
abstract IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, IDExpression[] arguments, String methodsig)
abstract IDImm createNull()
Wrapper used to create the null constant.
abstract IDOperation createOperation(IDExpression left, IJavaOperator operator, IDExpression right)
Create an operation element, such an an arithmetic or bitwise expression, conditional, string concatenation, or cast operation.
abstract IDOperation createOperation(JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)
Create an operation element, such an an arithmetic or bitwise expression, conditional, string concatenation, or cast operation.
abstract IDPredicate createPredicate(JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)
Create a predicate expression.
abstract IDPredicate createPredicate(IDExpression left, IJavaOperator operator, IDExpression right)
Create a predicate expression.
abstract IDPredicate createPredicate(IDExpression e)
Create a predicate expression.
abstract IDReferenceType createReferenceType(String csig)
Create a reference type expression.
abstract IDReferenceType createReferenceType(IDIndex cindex, IJavaType ctype)
Create a reference type expression.
abstract IDImm createShort(short value)
Wrapper used to create short constants.
abstract IDState createState(boolean initForEmulation, boolean loadDexdecEmuSettings)
Create a fresh IR state (~ IR emulator).
abstract IDState createState()
Create a fresh, uninitialized IR state (~ IR emulator).
abstract IDStaticField createStaticField(IDIndex index, IJavaType fieldtype, String csig, String fieldname)
abstract IDImm createString(IDIndex stringIndex)
Wrapper used to create string constants.
abstract IDImm createString(String value)
Wrapper used to create string constants.
abstract IDSwitchData createSwitchData()
Create a switch data element used in Switch instructions.
abstract IDTarget createTarget(int offset)
abstract IDVar createVar(int reg, IJavaType type)
Create a single-slot variable.
abstract IDVar createVar(int regLo, int regHi, IJavaType type)
Create a double-slot variable.
abstract Object getData(String key)
Retrieve an arbitrary object in this global context.
abstract Set<String> getDataKeys()
Retrieve the set of objects keys for data elements stored using setData.
abstract IDexDecompilerUnit getDecompiler()
Retrieve the managing dex decompiler object.
abstract IDexUnit getDex()
Retrieve the underlying dex unit object.
abstract IDState getEmulator()
Retrieve the current IR state (~ IR emulator) associated with the current thread.
abstract IJavaOperatorFactory getOperatorFactory()
Retrieve the global high-level operator factory.
abstract IDState getThreadSharedState()
Retrieve the current IR state (~ IR emulator) associated with the current thread.
abstract IJavaTypeFactory getTypeFactory()
Retrieve the global high-level type factory.
abstract IDTypeInfoProvider getTypeInfoProvider()
Retrieve the type information provider.
abstract void resetDeobfuscatorCounters(String entryName)
Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.
abstract void resetDeobfuscatorCounters()
Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.
abstract Object setData(String key, Object value)
Store an arbitrary object in this global context.

Public Methods

public abstract IDArrayElt createArrayElt (IDExpression array, IDExpression index, IJavaType type)

Create an array element.

public abstract IDInstanceField createArrayLength (IDExpression instance)

public abstract IDImm createBoolean (boolean value)

Wrapper used to create boolean constants.

public abstract IDImm createByte (byte value)

Wrapper used to create byte constants.

public abstract IDNewArrayInfo createByteArray (byte[] bytes)

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

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

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

public abstract IDOperation createCast (IJavaType casttype, IDExpression e)

Convenience operation.

public abstract IDImm createChar (char value)

Wrapper used to create char constants.

public abstract IDStaticField createClassObject (String csig)

public abstract IDOperation createConditional (IDPredicate pred, IDExpression expTrue, IDExpression expFalse)

Convenience operation.

public abstract IDImm createConstant (long rawvalue, IJavaType type)

Create immediate constants. The same as createImm(long, IJavaType).

public abstract IDImm createDouble (double value)

Wrapper used to create double constants.

public abstract IDImm createFloat (float value)

Wrapper used to create float constants.

public abstract IDImm createImm (long rawvalue, IJavaType type)

Create immediate constants.

public abstract IDIndex createIndex (int value)

Create an immutable pool index value.

Parameters
value index value
Returns
  • the index object

public abstract IDInstanceField createInstanceField (IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname)

public abstract IDImm createInt (int value)

Wrapper used to create int constants.

public abstract IDImm createLong (long value)

Wrapper used to create long constants.

public abstract IDMasterOptimizer createMasterOptimizer (IDMethodContext methodContext)

Create a pre-initialized master optimized targeting the provided method. This convenience method is equivalent to createMasterOptimizer(ctx, true, true, true).

public abstract IDMasterOptimizer createMasterOptimizer (IDMethodContext methodContext, boolean registerBuiltinOptimizers, boolean initializeWithDexdecSettings, boolean registerExternalOptimizers)

Create a master optimizer targeting the provided method.

public abstract IDNewArrayInfo createNewArrayInfo (IJavaType type, IDExpression size, List<IDExpression> initvals)

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

public abstract IDNewInfo createNewInfo (String constructorSig, IDExpression... arguments)

Convenience method to create a new SomeObject(..) operand.

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

public abstract IDImm createNull ()

Wrapper used to create the null constant.

public abstract IDOperation createOperation (IDExpression left, IJavaOperator operator, IDExpression right)

Create an operation element, such an an arithmetic or bitwise expression, conditional, string concatenation, or cast operation.

public abstract IDOperation createOperation (JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)

Create an operation element, such an an arithmetic or bitwise expression, conditional, string concatenation, or cast operation.

public abstract IDPredicate createPredicate (JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2)

Create a predicate expression.

public abstract IDPredicate createPredicate (IDExpression left, IJavaOperator operator, IDExpression right)

Create a predicate expression.

public abstract IDPredicate createPredicate (IDExpression e)

Create a predicate expression.

public abstract IDReferenceType createReferenceType (String csig)

Create a reference type expression.

public abstract IDReferenceType createReferenceType (IDIndex cindex, IJavaType ctype)

Create a reference type expression.

public abstract IDImm createShort (short value)

Wrapper used to create short constants.

public abstract IDState createState (boolean initForEmulation, boolean loadDexdecEmuSettings)

Create a fresh IR state (~ IR emulator). 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

public abstract IDState createState ()

Create a fresh, uninitialized IR state (~ IR emulator). 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 DEFAULT_MAX_ITERCOUNT, DEFAULT_MAX_DURATION). The emulator may is disabled, sandbox is disabled, etc. The client should use the State's setters before proceeding with emulation.

Returns
  • a new IR state

public abstract IDStaticField createStaticField (IDIndex index, IJavaType fieldtype, String csig, String fieldname)

public abstract IDImm createString (IDIndex stringIndex)

Wrapper used to create string constants.

public abstract IDImm createString (String value)

Wrapper used to create string constants.

public abstract IDSwitchData createSwitchData ()

Create a switch data element used in Switch instructions.

public abstract IDTarget createTarget (int offset)

public abstract IDVar createVar (int reg, IJavaType type)

Create a single-slot variable.

Parameters
reg positive number, the underlying register number; physical registers have an id less than LIM; virtual registers have an id greater or equal then LIM
type mandatory type
Returns
  • a variable

public abstract IDVar createVar (int regLo, int regHi, IJavaType type)

Create a double-slot variable.

Parameters
regLo positive number, the underlying register number; physical registers have an id less than LIM; virtual registers have an id greater or equal then LIM
regHi the second-register value; for a variable rooted in physical registers, this id should be equals to regLow+1; for virtual identifiers, it may be any number, although regLow+1 is strongly recommended
type mandatory type
Returns
  • a variable

public abstract Object getData (String key)

Retrieve an arbitrary object in this global context.

public abstract Set<String> getDataKeys ()

Retrieve the set of objects keys for data elements stored using setData.

Returns
  • a read-only collection

public abstract IDexDecompilerUnit getDecompiler ()

Retrieve the managing dex decompiler object.

public abstract IDexUnit getDex ()

Retrieve the underlying dex unit object.

public abstract IDState getEmulator ()

Retrieve the current IR state (~ IR emulator) 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

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

public abstract IDState getThreadSharedState ()

Retrieve the current IR state (~ IR emulator) 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

public abstract IJavaTypeFactory getTypeFactory ()

Retrieve the global high-level type factory.

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

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

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

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