| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.core.units.code.android.DexUtil |
Dex utility routines.
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static String |
bytearrayMUTF8ToString(byte[] data, int pos, int[] readsize)
Decode a MUTF-8 encoded string whose length is unknown.
| ||||||||||
| static String |
bytearrayMUTF8ToStringFast(byte[] data, int pos, int[] readsize, int expectedLength)
Decode a MUTF-8 encoded string whose length is known.
| ||||||||||
| static int |
bytearraySLEB128ToInt(byte[] data, int pos, int[] readsize)
Read a signed LEB128-encoded int.
| ||||||||||
| static int |
bytearrayULEB128P1ToInt(byte[] data, int pos, int[] readsize)
Read an unsigned LEB128-encoded int shifted by 1.
| ||||||||||
| static int |
bytearrayULEB128ToInt(byte[] data, int pos, int[] readsize)
Read an unsigned LEB128-encoded int.
| ||||||||||
| static int |
bytearrayULEInt16ToInt(byte[] data, int pos)
Read a little-endian uint16 short.
| ||||||||||
| static int |
bytearrayULEInt32ToInt(byte[] data, int pos)
Read a little-endian uint32 int.
| ||||||||||
| static int |
convertDexFlagsToCodeFlags(int nativeFlags)
Convert native Dalvik flags to generic
ICodeItem flags. | ||||||||||
| static int | determineBestBase(long value) | ||||||||||
| static IDexAnnotation |
findAnnotation(IDexUnit dex, Collection<IDexAnnotationItem> aicoll, String requestedType, Integer requestedVisibility)
Find an annotation by type and optional visibility.
| ||||||||||
| static IDexValue |
findAnnotationElement(IDexUnit dex, IDexAnnotation annotation, String name)
Find an annotation element by name.
| ||||||||||
| static IDexMethod |
findInternalVirtualMethodTarget(IDexUnit dex, IDexClass cl, String mname, String... parameterTypes)
Check if a dex method is present in the provided class or if a super method is present in one
of its super classes.
| ||||||||||
| static String |
findPackageName(IDexUnit dex)
Attempt to retrieve the package name of a Dex.
| ||||||||||
| static IApkUnit |
findParentApk(IDexUnit dex)
Attempt to retrieve the container APK unit of a Dex.
| ||||||||||
| static String |
formatAccessFlags(int f, int add_final_space)
Format Java access flags to an appropriate string.
| ||||||||||
| final static String |
formatFieldsigs(IDexUnit dex, Collection<Integer> indices)
Format a list of DEX fields.
| ||||||||||
| final static String |
formatMethodsigs(IDexUnit dex, Collection<Integer> indices)
Format a list of DEX methods.
| ||||||||||
| final static String |
formatTypenames(IDexUnit dex, Collection<Integer> indices)
Format a list of DEX types.
| ||||||||||
| static String[] |
generateDefaultJniNames(String msig)
Generate default JNI method names used for auto-binding.
| ||||||||||
| static List<String> |
getAnnotatedParameterNames(IDexUnit dex, IDexMethodData md)
Retrieve the list of parameters names provided by a
MethodParameters annotation. | ||||||||||
| static List<String> |
getDebugParameterNames(IDexUnit dex, IDexMethodData md)
Retrieve the list of parameters names provided by the debug metadata of a dex method.
| ||||||||||
| static List<IDexClass> | getMemberClasses(IDexUnit dex, IDexMethod m) | ||||||||||
| static List<IDexClass> | getMemberClasses(IDexUnit dex, IDexClass c) | ||||||||||
| static int[] |
getMethodParameterIndices(IDexMethod m)
Retrieve an array of register indices holding the method parameters.
| ||||||||||
| static ParametersInfo |
getMethodParametersInfo(IDexUnit dex, IDexMethodData md)
Generate method parameters' registers information.
| ||||||||||
| static ParametersInfo |
getMethodParametersInfo(String shorty, boolean isStaticMethod)
Generate method parameters' registers information.
| ||||||||||
| static int |
getMethodSlotCount(String shorty, boolean isStaticMethod)
Determine the number of slots required by a method to hold all of its parameters (including
`this` if the method is not static).
| ||||||||||
| static IDexClass | getParentClass(IDexUnit dex, IDexClass c) | ||||||||||
| static IDexValue |
getStaticFieldInitializer(IDexClass c, IDexFieldData fd)
Retrieve the initial value of a static final class field.
| ||||||||||
| static String | getStringSafe(IDexUnit dex, int index, String defval) | ||||||||||
| static IDexClass | getSuperClass(IDexUnit dex, IDexClass c) | ||||||||||
| final static int |
getVersion(IBinaryUnit unit)
Extract the version number from an Android binary unit.
| ||||||||||
| static boolean |
isClassname(String s, boolean validate, List<String> elements, int dexVersion)
Determine whether a string looks like a valid binary-form (dot-separated) class name.
| ||||||||||
| static boolean |
isInternalClassname(String s, boolean validate, List<String> elements, int dexVersion)
Determine whether a string looks like a valid internal-form (jvm) class name.
| ||||||||||
| static boolean |
isSimpleName(String s, int dexVersion)
Verify if the provided string is a valid dex
SimpleName. | ||||||||||
| static boolean | isSubtypeOf(IDexUnit dex, int typeIndex, int candidateParentTypeIndex) | ||||||||||
| static int |
parseSimpleName(String s, int start, int dexVersion)
Determine if the token at the provided index is the start of a
SimpleName. | ||||||||||
| static String |
stringFromMUTF8(byte[] data)
Decode a String encoded as MUTF-8.
| ||||||||||
| static byte[] |
stringToMUTF8(String str, boolean appendZero)
Encode a String to MUTF-8.
| ||||||||||
| static byte[] |
stringToMUTF8(String str)
Encode a String to MUTF-8.
| ||||||||||
| static void |
validateClassFlags(int f)
Validate Dalvik class item flags: this method throws if some flags are undefined or illegal
for class items.
| ||||||||||
| static void |
validateFieldFlags(int f)
Validate Dalvik field item flags: this method throws if some flags are undefined or illegal
for field items.
| ||||||||||
| static void |
validateFlags(int f)
Validate Dalvik flags: this method throws if some flags are undefined Dalvik flags.
| ||||||||||
| static void |
validateMethodFlags(int f)
Validate Dalvik method item flags: this method throws if some flags are undefined or illegal
for method items.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Decode a MUTF-8 encoded string whose length is unknown. The encoded string must be terminated by a null (0) byte, per the JVM MUTF-8 specifications.
If the length of the constructed string is known, it is recommended to use
bytearrayMUTF8ToStringFast
instead.
| data | bytes of the encoded string |
|---|---|
| pos | start position in the bytes buffer |
| readsize | optional one-element output array |
Decode a MUTF-8 encoded string whose length is known. The encoded string must be terminated by a null (0) byte, per the JVM MUTF-8 specifications.
| data | bytes of the encoded string |
|---|---|
| pos | start position in the bytes buffer |
| readsize | optional one-element output array |
| expectedLength | expected length of the constructed string (in chars); the method will throw if the constructed string's length exceeds the expected length |
Read a signed LEB128-encoded int.
Read an unsigned LEB128-encoded int shifted by 1.
Read an unsigned LEB128-encoded int.
Read a little-endian uint16 short.
Read a little-endian uint32 int.
Convert native Dalvik flags to generic ICodeItem flags.
Find an annotation by type and optional visibility.
| dex | owner dex unit |
|---|---|
| aicoll | collection of annotation items |
| requestedType | mandatory annotation type (internal signature) |
| requestedVisibility | optional visibility (see IDexAnnotationItem) |
Find an annotation element by name.
| dex | owner dex unit |
|---|---|
| annotation | an annotation |
| name | the element name |
Check if a dex method is present in the provided class or if a super method is present in one of its super classes. For internal methods only.
| dex | dex unit |
|---|---|
| cl | a class |
| mname | method name |
| parameterTypes | list of parameter signatures |
Attempt to retrieve the package name of a Dex. The parent unit will be examined. If it is an
APK unit, the package name will be returned.
| dex | dex unit |
|---|
Attempt to retrieve the container APK unit of a Dex. The parent unit will be examined.
| dex | dex unit |
|---|
Format Java access flags to an appropriate string.
| f | Flags, as defined by the Dalvik specs |
|---|---|
| add_final_space | if 1, append a trailing space; if -1, append a trailing space only if the access flags string is not empty |
Format a list of DEX fields.
| dex | unit |
|---|---|
| indices | DEX method indices |
Format a list of DEX methods.
| dex | unit |
|---|---|
| indices | DEX method indices |
Format a list of DEX types.
| dex | unit |
|---|---|
| indices | DEX type indices |
Generate default JNI method names used for auto-binding.
| msig | java method signature (e.g. La/b/C;->foo(I)Ljava/lang/String;) |
|---|
Retrieve the list of parameters names provided by a MethodParameters annotation.
| md | method body |
|---|
Retrieve the list of parameters names provided by the debug metadata of a dex method.
| md | non-abstract method body |
|---|
Retrieve an array of register indices holding the method parameters. Unlike
getMethodParametersInfo, the list returned by this method includes `this` (for
non-static methods). Double-slot variables are represented by their first register in the
pair.
| m | an internal, non-abstract dex method |
|---|
Generate method parameters' registers information.
Generate method parameters' registers information.
Determine the number of slots required by a method to hold all of its parameters (including `this` if the method is not static).
| shorty | method's shorty prototype, e.g. BILJ for
byte foo(int, String, long), V for void bar() |
|---|
Retrieve the initial value of a static final class field.
| c | a dex class object |
|---|---|
| fd | field definition of an internal field |
Extract the version number from an Android binary unit.
| unit | an Android binary unit respecting the standard header (xxxxNNN0), such as dex, vdex, cdex, art, etc. |
|---|
| ParseException | on parsing error |
|---|
Determine whether a string looks like a valid binary-form (dot-separated) class name. Arrays are not accepted.
| s | the input string, e.g. com.abc.Foo |
|---|---|
| validate | if true, verify the legality of the simple names of the class name |
| elements | if non-null, an output sink used to collect the simple names of the input class name |
| dexVersion | optional dex version (0 means latest) |
Determine whether a string looks like a valid internal-form (jvm) class name. Arrays are not accepted.
| s | the input string, e.g. Lcom/abc/Foo; |
|---|---|
| validate | if true, verify the legality of the simple names of the class name |
| elements | if non-null, an output sink used to collect the simple names of the input class name |
| dexVersion | optional dex version (0 means latest) |
Verify if the provided string is a valid dex SimpleName.
Ref: https://source.android.com/docs/core/runtime/dex-format#simplename
| s | a Dalvik simple name, such as a non-qualified class/method/field name |
|---|---|
| dexVersion | optional dex version; 0 means latest |
Determine if the token at the provided index is the start of a SimpleName. The end
offset is provided.
Ref: https://source.android.com/docs/core/runtime/dex-format#simplename
| s | a string |
|---|---|
| start | simple name start offset |
| dexVersion | optional dex version; 0 means latest |
Decode a String encoded as MUTF-8.
| data | MUTF-8 buffer (always zero-terminated) |
|---|
Encode a String to MUTF-8.
| str | a string |
|---|---|
| appendZero | if true, a zero-byte is appended to the resulting buffer |
Encode a String to MUTF-8.
| str | a string |
|---|
Validate Dalvik class item flags: this method throws if some flags are undefined or illegal for class items.
Validate Dalvik field item flags: this method throws if some flags are undefined or illegal for field items.
Validate Dalvik flags: this method throws if some flags are undefined Dalvik flags.
Validate Dalvik method item flags: this method throws if some flags are undefined or illegal for method items.