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 Summary
Modifier and TypeMethodDescriptioncreateAllocObjectInfo
(IJavaType objectType) createAllocObjectInfo
(String objectType) createArrayElt
(IDExpression array, IDExpression index, IJavaType type) Create an array element.createArrayLength
(IDExpression instance) createBoolean
(boolean value) Wrapper
used to create boolean constants.createBooleanArray
(boolean[] values) createByte
(byte value) Wrapper
used to create byte constants.createByteArray
(byte[] values) createCallInfo
(DInvokeType invoketype, int methodindex, List<IDExpression> arguments) createCallInfo
(DInvokeType invoketype, String msig, List<IDExpression> arguments) createCallInfo
(IDIndex methodindex, IDExpression[] arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) createCallInfo
(IDIndex methodindex, List<IDExpression> arguments, IJavaType returntype, String methodsig, DInvokeType invoketype) createCastOperation
(IJavaType castType, IDExpression exp) Create a cast operation.createCastOperation
(String castTypeSignature, IDExpression exp) Create a cast operation.createChar
(char value) Wrapper
used to create char constants.createCharArray
(char[] values) createClassObject
(String csig) createConditional
(IJavaType type, IDExpression pred, IDExpression expTrue, IDExpression expFalse) Convenience operation.default IDImm
createConstant
(long rawvalue, IJavaType type) Create immediate constants.createDouble
(double value) Wrapper
used to create double constants.createDoubleArray
(double[] values) createFloat
(float value) Wrapper
used to create float constants.createFloatArray
(float[] values) Create immediate constants.createIndex
(int value) Create an immutable pool index value.createInstanceField
(IDExpression instance, IDexField f) createInstanceField
(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname) createInstanceField
(IDExpression instance, String fsig) createInstanceField
(IDExpression instance, String fsig, boolean createRefIfDoesNotExist) createInt
(int value) Wrapper
used to create int constants.createIntArray
(int[] values) createLong
(long value) Wrapper
used to create long constants.createLongArray
(long[] values) default IDMasterOptimizer
createMasterOptimizer
(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) createNewInfo
(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, IDExpression[] arguments, String methodsig) createNewInfo
(IJavaType objecttype, IJavaType constclasstype, IDIndex constructorindex, List<IDExpression> arguments, String methodsig) createNewInfo
(String constructorSig, IDExpression... arguments) Convenience method to create anew SomeObject(..)
operand.Wrapper
used 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) Wrapper
used to create short constants.createShortArray
(short[] values) Create a fresh, uninitialized IR state.createState
(boolean initForEmulation, boolean loadDexdecEmuSettings) Create a fresh IR state.createStaticField
(IDIndex index, IJavaType fieldtype, String csig, String fieldname) createStaticField
(String fsig) createStaticField
(String fsig, boolean createRefIfDoesNotExist) createString
(IDIndex stringIndex) Wrapper
used to create string constants.createString
(String value) Wrapper
used to create string constants.createStringArray
(String[] values) Create a switch data element used in Switch instructions.createTarget
(int offset) 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 data elements stored usingsetData
.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.Retrieve the global high-level type factory.Retrieve the type information provider.void
Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.void
resetDeobfuscatorCounters
(String entryName) Reset deobfuscators counters, generally updated by IR optimizers that rely on IR emulation.Store an arbitrary object in this global 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
Create a pre-initialized master optimizer targeting the provided method. This convenience method is equivalent tocreateMasterOptimizer(ctx, true, true, true)
.- Parameters:
methodContext
-- Returns:
-
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 (nocontext
is 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 (nocontext
is 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.cfg
in your plugins folder) is used to further configure the State- Returns:
- a new IR state
-
setData
Store an arbitrary object in this global context.- Parameters:
key
- non-null keyvalue
- null means remove the entry- Returns:
- the previous value associated with the key
-
getData
Retrieve an arbitrary object in this global context.- Parameters:
key
-- Returns:
- the value or null if none isassociated with the key
-
getData
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
Retrieve the set of objects keys for data elements stored usingsetData
.- 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
-type
-- Returns:
-
createImm
Create immediate constants.- Parameters:
rawvalue
-type
-- Returns:
-
createRef
Create an object reference.- Parameters:
refid
- object reference idreftype
- optional object type; if null is provided, thegeneric wildcard object
type is used- Returns:
- an imm representing an object reference
-
createRef
Create an object reference. The type of the reference will be thegeneric wildcard object
type- Parameters:
refid
- object reference id- Returns:
- an imm representing an object reference
-
createBoolean
Wrapper
used to create boolean constants.- Parameters:
value
-- Returns:
-
createByte
Wrapper
used to create byte constants.- Parameters:
value
-- Returns:
-
createChar
Wrapper
used to create char constants.- Parameters:
value
-- Returns:
-
createShort
Wrapper
used to create short constants.- Parameters:
value
-- Returns:
-
createInt
Wrapper
used to create int constants.- Parameters:
value
-- Returns:
-
createLong
Wrapper
used to create long constants.- Parameters:
value
-- Returns:
-
createFloat
Wrapper
used to create float constants.- Parameters:
value
-- Returns:
-
createDouble
Wrapper
used to create double constants.- Parameters:
value
-- Returns:
-
createNull
IDImm createNull()Wrapper
used to create the null constant.- Returns:
-
createString
Wrapper
used to create string constants.- Parameters:
value
-- Returns:
-
createString
Wrapper
used to create string constants.- Parameters:
stringIndex
-- Returns:
-
createArrayElt
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-determinedoptype
-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
Create a cast operation.- Parameters:
castType
-exp
-- Returns:
-
createCastOperation
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
Create a predicate operation (typed boolean).- Parameters:
optype
- a logical operatoropnd1
-opnd2
-- Returns:
-
createPredicate
Create a predicate operation (typed boolean).- Parameters:
left
-operator
- a logical operatorright
-- Returns:
-
createReferenceType
Create a reference type expression.- Parameters:
cindex
-ctype
-- Returns:
-
createReferenceType
Create a reference type expression.- Parameters:
csig
-- Returns:
-
createIndex
Create an immutable pool index value.- Parameters:
value
- index value- Returns:
- the index object
-
createStaticField
-
createStaticField
-
createStaticField
-
createStaticField
- Parameters:
index
-fieldtype
-csig
-fieldname
-- Returns:
-
createInstanceField
-
createInstanceField
IDInstanceField createInstanceField(IDExpression instance, String fsig, boolean createRefIfDoesNotExist) -
createInstanceField
-
createInstanceField
IDInstanceField createInstanceField(IDExpression instance, IDIndex index, IJavaType fieldtype, String fieldname) - Parameters:
instance
-index
-fieldtype
-fieldname
-- Returns:
-
createClassObject
-
createArrayLength
-
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
-
createCallInfo
-
createAllocObjectInfo
-
createAllocObjectInfo
-
createNewInfo
Convenience method to create anew SomeObject(..)
operand. -
createNewInfo
-
createNewInfo
-
createNewArrayInfo
-
createBooleanArray
-
createByteArray
-
createCharArray
-
createShortArray
-
createIntArray
-
createLongArray
-
createFloatArray
-
createDoubleArray
-
createStringArray
-
createTarget
-
createSwitchData
IDSwitchData createSwitchData()Create a switch data element used in Switch instructions.- Returns:
-