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 Summary
Modifier and TypeMethodDescriptioncreateAllocObjectInfo(IJavaType objectType) Create object allocation information.createAllocObjectInfo(String objectType) Create object allocation information.createArrayElt(IDExpression array, IDExpression index, IJavaType type) Create an array element.createArrayLength(IDExpression instance) Create an array-length expression.createBoolean(boolean value) Wrapperused to create boolean constants.createBooleanArray(boolean[] values) Create boolean-array information from concrete values.createByte(byte value) Wrapperused to create byte constants.createByteArray(byte[] values) Create byte-array information from concrete values.createCallInfo(DInvokeType invoketype, int methodindex, List<IDExpression> arguments) Create call information for an invocation.createCallInfo(DInvokeType invoketype, String msig, List<IDExpression> arguments) Create call information for an invocation.createCallInfo(IDIndex methodindex, IDExpression[] arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) Create call information for an invocation.createCallInfo(IDIndex methodindex, List<IDExpression> arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) Create call information for an invocation.createCastOperation(IJavaType castType, IDExpression exp) Create a cast operation.createCastOperation(String castTypeSignature, IDExpression exp) Create a cast operation.createChar(char value) Wrapperused to create char constants.createCharArray(char[] values) Create char-array information from concrete values.createClassObject(String csig) Create a class object pseudo-field expression.createConditional(IJavaType type, IDExpression pred, IDExpression expTrue, IDExpression expFalse) Convenience operation.default IDImmcreateConstant(long rawvalue, IJavaType type) Create immediate constants.createDouble(double value) Wrapperused to create double constants.createDoubleArray(double[] values) Create double-array information from concrete values.createFloat(float value) Wrapperused to create float constants.createFloatArray(float[] values) Create float-array information from concrete values.Create immediate constants.createIndex(int value) Create an immutable pool index value.createInstanceField(IDExpression instance, IDexField f) Create an instance field expression from a dex field.createInstanceField(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname) Create an instance field expression.createInstanceField(IDExpression instance, String fsig) Create an instance field expression from a field signature.createInstanceField(IDExpression instance, String fsig, boolean createRefIfDoesNotExist) Create an instance field expression from a field signature.createInt(int value) Wrapperused to create int constants.createIntArray(int[] values) Create int-array information from concrete values.createLong(long value) Wrapperused to create long constants.createLongArray(long[] values) Create long-array information from concrete values.default IDMasterOptimizercreateMasterOptimizer(IDMethodContext methodContext) Create a pre-initialized master optimizer targeting the provided method.createMasterOptimizer(IDMethodContext methodContext, boolean registerBuiltinOptimizers, boolean initializeWithDexdecSettings, boolean registerExternalOptimizers) Create a master optimizer targeting the provided method.createNewArrayInfo(IJavaType type, IDExpression size, List<IDExpression> initvals) Create new-array information.createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, IDExpression[] arguments, String methodsig) Create new-instance information.createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, List<IDExpression> arguments, String methodsig) Create new-instance information.createNewInfo(String constructorSig, IDExpression... arguments) Convenience method to create anew SomeObject(..)operand.Wrapperused to create the null constant.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.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.createPredicate(IDExpression left, IJavaOperator operator, IDExpression right) Create a predicate operation (typed boolean).createPredicate(JavaOperatorType optype, IDExpression opnd1, IDExpression opnd2) Create a predicate operation (typed boolean).createRef(int refid) Create an object reference.Create an object reference.createReferenceType(IDIndex cindex, IJavaType ctype) Create a reference type expression.createReferenceType(String csig) Create a reference type expression.createShort(short value) Wrapperused to create short constants.createShortArray(short[] values) Create short-array information from concrete values.Create a fresh, uninitialized IR state.createState(boolean initForEmulation, boolean loadDexdecEmuSettings) Create a fresh IR state.Create a static field expression from a dex field.createStaticField(IDIndex index, IJavaType fieldtype, String csig, String fieldname) Create a static field expression.createStaticField(String fsig) Create a static field expression from a field signature.createStaticField(String fsig, boolean createRefIfDoesNotExist) Create a static field expression from a field signature.createString(IDIndex stringIndex) Wrapperused to create string constants.createString(String value) Wrapperused to create string constants.createStringArray(String[] values) Create string-array information from concrete values.Create a switch data element used in Switch instructions.createTarget(int offset) Create a branch target.Retrieve an arbitrary object in this global context.Retrieve or create (and register) an arbitrary object in this global context.Retrieve the set of objects keys for persisted data elements.Retrieve the managing dex decompiler object.getDex()Retrieve the underlying dex unit object.Retrieve the current IR state associated with the current thread.Retrieve the global high-level operator factory.Retrieve the current IR state associated with the current thread.getTransientData(String key) Retrieve a non-persisted object in this global context.getTransientData(String key, Function<String, Object> creator) Retrieve or create a non-persisted object in this global context.Retrieve the set of objects keys for non-persisted objects stored in this global context.Retrieve the global high-level type factory.Retrieve the type information provider.voidReset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.voidresetDeobfuscatorCounters(String entryName) Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.Store an arbitrary object in this global context.setTransientData(String key, Object value) Store a non-persisted object in this global context.
-
Method Details
-
getDex
IDexUnit getDex()Retrieve the underlying dex unit object.- Returns:
- underlying Dex unit
-
getDecompiler
IDexDecompilerUnit getDecompiler()Retrieve the managing dex decompiler object.- Returns:
- managing Dex decompiler unit
-
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:
- high-level operator factory
-
getTypeFactory
IJavaTypeFactory getTypeFactory()Retrieve the global high-level type factory.- Returns:
- high-level type factory
-
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:
- type information provider
-
createMasterOptimizer
IDMasterOptimizer createMasterOptimizer(IDMethodContext methodContext, boolean registerBuiltinOptimizers, boolean initializeWithDexdecSettings, boolean registerExternalOptimizers) Create a master optimizer targeting the provided method.- Parameters:
methodContext- target method contextregisterBuiltinOptimizers- true to register built-in optimizersinitializeWithDexdecSettings- true to initialize the optimizer with Dex decompiler settingsregisterExternalOptimizers- true to register external optimizers- Returns:
- master optimizer
-
createMasterOptimizer
Create a pre-initialized master optimizer targeting the provided method. This convenience method is equivalent tocreateMasterOptimizer(ctx, true, true, true).- Parameters:
methodContext- target method context- Returns:
- master optimizer
-
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.cfgin 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 (nocontextis created). Settings are left on default values, in particular, the maximum iteration count and duration are set to the default values (seeIDState.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
Create a fresh IR state. The IR state is context-less (nocontextis created).- Parameters:
initForEmulation- if true, the state settings are changed to allow for IR emulationloadDexdecEmuSettings- if true, the global dexdec emulator configuration file (dexdec-emu.cfgin your plugins folder) is used to further configure the State- Returns:
- a new IR state
-
setData
Store an arbitrary object in this global context.Note: As of JEB 5.39, these objects are persisted in a JDB2 database.
- Parameters:
key- non-null keyvalue- a serializable object; null means remove the entry- Returns:
- the previous value associated with the key
-
getData
Retrieve an arbitrary object in this global context.Note: As of JEB 5.39, these objects are persisted in a JDB2 database.
- Parameters:
key- non-null key- Returns:
- the value or null if none is associated with the key
-
getData
Retrieve or create (and register) an arbitrary object in this global context.Note: As of JEB 5.39, these objects are persisted in a JDB2 database.
- Parameters:
key- non-null keycreator- the optional creator function is called if no value is mapped to the provided key- Returns:
- the value (existing or newly created)
-
getDataKeys
Retrieve the set of objects keys for persisted data elements.Note: As of JEB 5.39, these objects are persisted in a JDB2 database.
- Returns:
- a read-only collection
-
setTransientData
Store a non-persisted object in this global context.- Parameters:
key- non-null keyvalue- null means remove the entry- Returns:
- the previous value associated with the key
-
getTransientData
Retrieve a non-persisted object in this global context.- Parameters:
key- non-null key- Returns:
- the value (existing or newly created)
-
getTransientData
Retrieve or create a non-persisted object in this global context.- Parameters:
key- non-null keycreator- the optional creator function is called if no value is mapped to the provided key- Returns:
- the value (existing or newly created)
-
getTransientDataKeys
Retrieve the set of objects keys for non-persisted objects stored in this global context.- 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
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
Create immediate constants. The same ascreateImm(long, IJavaType).- Parameters:
rawvalue- raw constant valuetype- constant type- Returns:
- immediate constant
-
createImm
Create immediate constants.- Parameters:
rawvalue- raw constant valuetype- constant type- Returns:
- immediate constant
-
createRef
Create an object reference.- Parameters:
refid- object reference idreftype- optional object type; if null is provided, thegeneric wildcard objecttype is used- Returns:
- an imm representing an object reference
-
createRef
Create an object reference. The type of the reference will be thegeneric wildcard objecttype- Parameters:
refid- object reference id- Returns:
- an imm representing an object reference
-
createBoolean
Wrapperused to create boolean constants.- Parameters:
value- boolean value- Returns:
- immediate constant
-
createByte
Wrapperused to create byte constants.- Parameters:
value- byte value- Returns:
- immediate constant
-
createChar
Wrapperused to create char constants.- Parameters:
value- char value- Returns:
- immediate constant
-
createShort
Wrapperused to create short constants.- Parameters:
value- short value- Returns:
- immediate constant
-
createInt
Wrapperused to create int constants.- Parameters:
value- int value- Returns:
- immediate constant
-
createLong
Wrapperused to create long constants.- Parameters:
value- long value- Returns:
- immediate constant
-
createFloat
Wrapperused to create float constants.- Parameters:
value- float value- Returns:
- immediate constant
-
createDouble
Wrapperused to create double constants.- Parameters:
value- double value- Returns:
- immediate constant
-
createNull
IDImm createNull()Wrapperused to create the null constant.- Returns:
- null immediate constant
-
createString
Wrapperused to create string constants.- Parameters:
value- string value- Returns:
- immediate constant
-
createString
Wrapperused to create string constants.- Parameters:
stringIndex- Dex string pool index- Returns:
- immediate constant
-
createArrayElt
Create an array element.- Parameters:
array- array expressionindex- element index expressiontype- element type- Returns:
- array element expression
-
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-determinedoptype- operator typeopnd1- first operandopnd2- optional second operand- Returns:
- operation expression
-
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- operation typeleft- left operandoperator- operatorright- right operand- Returns:
- operation expression
-
createCastOperation
Create a cast operation.- Parameters:
castType- target cast typeexp- expression to cast- Returns:
- cast operation expression
-
createCastOperation
Create a cast operation.- Parameters:
castTypeSignature- target cast type signatureexp- expression to cast- Returns:
- cast operation expression
-
createConditional
IDOperation createConditional(IJavaType type, IDExpression pred, IDExpression expTrue, IDExpression expFalse) Convenience operation.- Parameters:
type- result typepred- predicate expressionexpTrue- expression evaluated when the predicate is trueexpFalse- expression evaluated when the predicate is false- Returns:
- conditional operation expression
-
createPredicate
Create a predicate operation (typed boolean).- Parameters:
optype- a logical operatoropnd1- first operandopnd2- optional second operand- Returns:
- predicate operation expression
-
createPredicate
Create a predicate operation (typed boolean).- Parameters:
left- left operandoperator- a logical operatorright- right operand- Returns:
- predicate operation expression
-
createReferenceType
Create a reference type expression.- Parameters:
cindex- class type indexctype- class type- Returns:
- reference type expression
-
createReferenceType
Create a reference type expression.- Parameters:
csig- class signature- Returns:
- reference type expression
-
createIndex
Create an immutable pool index value.- Parameters:
value- index value- Returns:
- the index object
-
createStaticField
Create a static field expression from a field signature.- Parameters:
fsig- field signature- Returns:
- static field expression
-
createStaticField
Create a static field expression from a field signature.- Parameters:
fsig- field signaturecreateRefIfDoesNotExist- true to create a reference if the field is not found- Returns:
- static field expression
-
createStaticField
Create a static field expression from a dex field.- Parameters:
f- dex field- Returns:
- static field expression
-
createStaticField
Create a static field expression.- Parameters:
index- field indexfieldtype- field typecsig- owner class signaturefieldname- field name- Returns:
- static field expression
-
createInstanceField
Create an instance field expression from a field signature.- Parameters:
instance- object instance expressionfsig- field signature- Returns:
- instance field expression
-
createInstanceField
IDInstanceField createInstanceField(IDExpression instance, String fsig, boolean createRefIfDoesNotExist) Create an instance field expression from a field signature.- Parameters:
instance- object instance expressionfsig- field signaturecreateRefIfDoesNotExist- true to create a reference if the field is not found- Returns:
- instance field expression
-
createInstanceField
Create an instance field expression from a dex field.- Parameters:
instance- object instance expressionf- dex field- Returns:
- instance field expression
-
createInstanceField
IDInstanceField createInstanceField(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname) Create an instance field expression.- Parameters:
instance- object instance expressionindex- field indexfieldtype- field typefieldname- field name- Returns:
- instance field expression
-
createClassObject
Create a class object pseudo-field expression.- Parameters:
csig- class signature- Returns:
- class object expression
-
createArrayLength
Create an array-length expression.- Parameters:
instance- array instance expression- Returns:
- array-length expression
-
createCallInfo
IDCallInfo createCallInfo(IDIndex methodindex, IDExpression[] arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) Create call information for an invocation.- Parameters:
methodindex- method pool indexarguments- invocation argumentsreturntype- return typemethodsig- method signatureinvoketype- invocation type- Returns:
- call information
-
createCallInfo
IDCallInfo createCallInfo(IDIndex methodindex, List<IDExpression> arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) Create call information for an invocation.- Parameters:
methodindex- method pool indexarguments- invocation argumentsreturntype- return typemethodsig- method signatureinvoketype- invocation type- Returns:
- call information
-
createCallInfo
Create call information for an invocation.- Parameters:
invoketype- invocation typemethodindex- method pool indexarguments- invocation arguments- Returns:
- call information
-
createCallInfo
Create call information for an invocation.- Parameters:
invoketype- invocation typemsig- method signaturearguments- invocation arguments- Returns:
- call information
-
createAllocObjectInfo
Create object allocation information.- Parameters:
objectType- allocated object type- Returns:
- allocation information
-
createAllocObjectInfo
Create object allocation information.- Parameters:
objectType- allocated object type signature- Returns:
- allocation information
-
createNewInfo
Convenience method to create anew SomeObject(..)operand.- Parameters:
constructorSig- constructor signaturearguments- constructor arguments- Returns:
- new-instance information
-
createNewInfo
IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, IDExpression[] arguments, String methodsig) Create new-instance information.- Parameters:
objecttype- allocated object typeconstclasstype- constant class typeconstructorindex- constructor method indexarguments- constructor argumentsmethodsig- constructor signature- Returns:
- new-instance information
-
createNewInfo
IDNewInfo createNewInfo(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, List<IDExpression> arguments, String methodsig) Create new-instance information.- Parameters:
objecttype- allocated object typeconstclasstype- constant class typeconstructorindex- constructor method indexarguments- constructor argumentsmethodsig- constructor signature- Returns:
- new-instance information
-
createNewArrayInfo
Create new-array information.- Parameters:
type- array typesize- size expressioninitvals- optional initial values- Returns:
- new-array information
-
createBooleanArray
Create boolean-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createByteArray
Create byte-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createCharArray
Create char-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createShortArray
Create short-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createIntArray
Create int-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createLongArray
Create long-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createFloatArray
Create float-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createDoubleArray
Create double-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createStringArray
Create string-array information from concrete values.- Parameters:
values- initial values- Returns:
- new-array information
-
createTarget
Create a branch target.- Parameters:
offset- target offset- Returns:
- branch target
-
createSwitchData
IDSwitchData createSwitchData()Create a switch data element used in Switch instructions.- Returns:
- empty switch data element
-