|
dex++ 0.3.1
C++ and C API reference
|
C API for code analysis and APK metadata. More...
#include <stddef.h>#include <stdint.h>Classes | |
| struct | DexppText |
| A string constant of the analysed program. More... | |
| struct | DexppMethodId |
| The identity of a method: its class, name and prototype. More... | |
| struct | DexppFieldId |
| The identity of a field: its class, name and type. More... | |
| struct | DexppValue |
| An annotation element value, or the initial value of a static field. More... | |
| struct | DexppAnnotationElement |
One name = value pair of an annotation. More... | |
| struct | DexppAnnotation |
| One annotation on a class, a method or a field. More... | |
| struct | DexppParameterRegister |
| An incoming argument and the register it arrives in. More... | |
| struct | DexppMethodCall |
| One call in a method's code. More... | |
| struct | DexppFieldAccess |
| One field read or write in a method's code. More... | |
| struct | DexppStringLoad |
| One const-string instruction in a method's code. More... | |
| struct | DexppTypeUse |
| One instruction in a method's code that names a type. More... | |
| struct | DexppCatchHandler |
| One typed catch clause of a try block. More... | |
| struct | DexppTryBlock |
| A range of code covered by exception handlers. More... | |
| struct | DexppSwitchCase |
| One case of a switch instruction. More... | |
| struct | DexppInstruction |
| One decoded instruction. More... | |
| struct | DexppCfgEdge |
| An edge from one basic block to another. More... | |
| struct | DexppBasicBlock |
| A run of instructions entered at its first and left at its last one. More... | |
| struct | DexppCallNode |
| A node of the call graph: a method, or an invoke-custom call site. More... | |
| struct | DexppCallEdge |
| One call-site edge. More... | |
| struct | DexppMethodXref |
| One invoke instruction that calls a method. More... | |
| struct | DexppFieldXref |
| One instruction that reads or writes a field. More... | |
| struct | DexppStringXref |
| One const-string instruction. More... | |
| struct | DexppTypeXref |
| One instruction that names a type. More... | |
| struct | DexppMethodRefGroup |
| The call sites of one method, as found by name. More... | |
| struct | DexppIntentFilter |
An <intent-filter> of a component. More... | |
| struct | DexppComponent |
| An activity, service, receiver or provider declared in the manifest. More... | |
| struct | DexppDeclaredPermission |
| A permission the app declares. More... | |
| struct | DexppManifest |
| The decoded AndroidManifest.xml. More... | |
| struct | DexppResourceName |
| The full name of a resource: package:type/entry. More... | |
| struct | DexppCertificate |
| An X.509 certificate that signed the APK. More... | |
| struct | DexppSigningInfo |
| Which signature schemes the APK carries, and their certificates. More... | |
Typedefs | |
Handles | |
| typedef struct DexppContext | DexppContext |
| The code of a program: one or more DEX files loaded together. | |
| typedef struct DexppApk | DexppApk |
| An APK: archive, manifest, resources and signatures. | |
| typedef struct DexppClass | DexppClass |
| A class defined in a loaded DEX file. | |
| typedef struct DexppClassRef | DexppClassRef |
| A reference to a class by descriptor; the class may not be loaded. | |
| typedef struct DexppMethod | DexppMethod |
| A method defined by a loaded class. | |
| typedef struct DexppField | DexppField |
| A field declared by a loaded class. | |
| typedef struct DexppCallGraph | DexppCallGraph |
| The whole-program call graph. | |
| typedef struct DexppClassHierarchy | DexppClassHierarchy |
| The whole-program class hierarchy. | |
| typedef struct DexppXrefs | DexppXrefs |
| The whole-program cross-reference index. | |
Functions | |
Loading and the analysis context | |
| DexppContext * | dexpp_context_from_dex (const char *path, DexppError **err) |
| Load one DEX file. | |
| DexppContext * | dexpp_context_from_dex_files (const char *const *paths, size_t count, DexppError **err) |
| Load several DEX files into one context, for example the unpacked files of a multidex app. | |
| DexppContext * | dexpp_context_from_apk (const char *path, uint32_t threads, DexppError **err) |
| Load every top-level classes*.dex of an APK, in multidex order. | |
| void | dexpp_context_free (DexppContext *ctx) |
| Free a context. | |
| DexppClass ** | dexpp_context_classes (const DexppContext *ctx, size_t *count) |
| Every class of every loaded DEX file, in file order. | |
| DexppClass * | dexpp_context_find_class (const DexppContext *ctx, const char *descriptor) |
| The class with this descriptor (e.g. "Lcom/example/Foo;"), or NULL when no loaded file defines it. | |
| DexppText * | dexpp_context_strings (const DexppContext *ctx, size_t *count) |
| Every string of every loaded DEX file's string table, including names of classes and members. | |
| DexppCallGraph * | dexpp_context_call_graph (const DexppContext *ctx, DexppError **err) |
| The call graph of the whole program, built on the first call and kept. | |
| DexppClassHierarchy * | dexpp_context_class_hierarchy (const DexppContext *ctx, DexppError **err) |
| The class hierarchy of the whole program, built on the first call and kept. | |
| DexppXrefs * | dexpp_context_xrefs (const DexppContext *ctx, DexppError **err) |
| The cross-reference index of the whole program, built on the first call and kept. | |
Classes and class references | |
| char * | dexpp_class_descriptor (const DexppClass *cls) |
| The class descriptor, e.g. "Lcom/example/Foo;". | |
| char * | dexpp_class_package (const DexppClass *cls) |
| The package in Java source form, with dots between its parts, e.g. | |
| DexppClassRef * | dexpp_class_superclass (const DexppClass *cls) |
| The direct superclass, or NULL for java.lang.Object itself. | |
| DexppClassRef ** | dexpp_class_interfaces (const DexppClass *cls, size_t *count) |
| The interfaces the class implements directly, in declaration order. | |
| uint32_t | dexpp_class_access_flags (const DexppClass *cls) |
| The access flags (see DexppAccessFlag). | |
| int | dexpp_class_is_interface (const DexppClass *cls) |
| 1 when the class is an interface, otherwise 0. | |
| int | dexpp_class_is_abstract (const DexppClass *cls) |
| 1 when the class is abstract, otherwise 0. | |
| char * | dexpp_class_source_file (const DexppClass *cls) |
| The source file name recorded for the class, or NULL. | |
| DexppMethod ** | dexpp_class_methods (const DexppClass *cls, size_t *count) |
| The methods the class defines: direct methods first, then virtual ones. | |
| DexppField ** | dexpp_class_fields (const DexppClass *cls, size_t *count) |
| The fields the class declares: static fields first, then instance fields. | |
| DexppAnnotation * | dexpp_class_annotations (const DexppClass *cls, size_t *count) |
| The annotations on the class. | |
| void | dexpp_class_free (DexppClass *cls) |
| Free a class handle. | |
| void | dexpp_class_array_free (DexppClass **classes, size_t count) |
| Free an array of class handles and every handle in it. | |
| char * | dexpp_class_ref_descriptor (const DexppClassRef *ref) |
| The descriptor the reference names. | |
| int | dexpp_class_ref_is_resolved (const DexppClassRef *ref) |
| 1 when the class is defined in a loaded DEX file, otherwise 0. | |
| DexppClass * | dexpp_class_ref_resolve (const DexppClassRef *ref) |
| The referenced class, or NULL when no loaded file defines it. | |
| void | dexpp_class_ref_free (DexppClassRef *ref) |
| Free a class reference. | |
| void | dexpp_class_ref_array_free (DexppClassRef **refs, size_t count) |
| Free an array of class references and every reference in it. | |
Fields | |
| char * | dexpp_field_name (const DexppField *f) |
| The field name. | |
| DexppClassRef * | dexpp_field_declaring_class (const DexppField *f) |
| The class that declares the field. | |
| char * | dexpp_field_type (const DexppField *f) |
| The field's type descriptor. | |
| void | dexpp_field_id (const DexppField *f, DexppFieldId *out) |
Fill out with the field's identity: its class, name and type (release with dexpp_field_id_clear()). | |
| uint32_t | dexpp_field_access_flags (const DexppField *f) |
| The access flags (see DexppAccessFlag). | |
| DexppAnnotation * | dexpp_field_annotations (const DexppField *f, size_t *count) |
| The annotations on the field. | |
| int | dexpp_field_initial_value (const DexppField *f, DexppValue *out) |
| The constant a static field starts with. | |
| void | dexpp_field_free (DexppField *f) |
| Free a field handle. | |
| void | dexpp_field_array_free (DexppField **fields, size_t count) |
| Free an array of field handles and every handle in it. | |
Class hierarchy | |
| char ** | dexpp_class_hierarchy_supertypes (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| The direct superclass, then the directly implemented interfaces. | |
| char * | dexpp_class_hierarchy_superclass_of (const DexppClassHierarchy *h, const char *descriptor) |
| The direct superclass, or NULL when none is recorded (java.lang.Object, a class outside the loaded files, or a descriptor the hierarchy does not know). | |
| char ** | dexpp_class_hierarchy_direct_interfaces (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| The interfaces implemented (or, for an interface, extended) directly. | |
| char ** | dexpp_class_hierarchy_subclasses (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| The classes that directly extend the class. | |
| char ** | dexpp_class_hierarchy_implementers (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| The classes that directly implement the interface. | |
| char ** | dexpp_class_hierarchy_all_supertypes (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| Every ancestor class and interface; the class itself is not included. | |
| char ** | dexpp_class_hierarchy_all_descendants (const DexppClassHierarchy *h, const char *descriptor, size_t *count) |
| Everything below the class, through extends and implements; the class itself is not included. | |
| int | dexpp_class_hierarchy_is_subtype_of (const DexppClassHierarchy *h, const char *sub, const char *super) |
1 when sub is super or has it among its ancestors. | |
| int | dexpp_class_hierarchy_is_loaded (const DexppClassHierarchy *h, const char *descriptor) |
| 1 when the class is defined in a loaded file. | |
| int | dexpp_class_hierarchy_is_interface (const DexppClassHierarchy *h, const char *descriptor) |
| 1 when the class is loaded and is an interface. | |
| int | dexpp_class_hierarchy_empty (const DexppClassHierarchy *h) |
| 1 when the hierarchy has no classes. | |
| void | dexpp_class_hierarchy_free (DexppClassHierarchy *h) |
| Free a class-hierarchy handle. | |
Errors | |
| enum | DexppErrorCode { DEXPP_ERROR_FILE_NOT_FOUND = 1 , DEXPP_ERROR_CANNOT_READ = 2 , DEXPP_ERROR_CANNOT_WRITE = 3 , DEXPP_ERROR_INVALID_APK = 4 , DEXPP_ERROR_INVALID_DEX = 5 , DEXPP_ERROR_UNSUPPORTED_DEX = 6 , DEXPP_ERROR_INVALID_MODEL = 7 , DEXPP_ERROR_POOL_OVERFLOW = 8 , DEXPP_ERROR_VERSION_TOO_LOW = 9 , DEXPP_ERROR_MODEL = 10 , DEXPP_ERROR_INTERNAL = 11 } |
| What went wrong in a failed call. More... | |
| typedef enum DexppErrorCode | DexppErrorCode |
| What went wrong in a failed call. | |
| typedef struct DexppError | DexppError |
| An error reported by a failed call. | |
| DexppErrorCode | dexpp_error_code (const DexppError *error) |
| The kind of the error. | |
| const char * | dexpp_error_message (const DexppError *error) |
| The error message. | |
| size_t | dexpp_error_problem_count (const DexppError *error) |
| How many problems an error with code DEXPP_ERROR_INVALID_MODEL lists (0 for every other code). | |
| const char * | dexpp_error_problem_where (const DexppError *error, size_t index) |
Where problem index is, e.g. "Lcom/a/B;->run()V, item 12"; empty for a problem with the whole file. | |
| const char * | dexpp_error_problem_message (const DexppError *error, size_t index) |
What is wrong in problem index. | |
| void | dexpp_error_free (DexppError *error) |
| Free an error. | |
Annotations and values | |
| enum | DexppValueKind { DEXPP_VALUE_NULL = 0 , DEXPP_VALUE_BOOL = 1 , DEXPP_VALUE_INT = 2 , DEXPP_VALUE_FLOAT = 3 , DEXPP_VALUE_STRING = 4 , DEXPP_VALUE_TYPE = 5 , DEXPP_VALUE_ENUM = 6 , DEXPP_VALUE_FIELD = 7 , DEXPP_VALUE_METHOD = 8 , DEXPP_VALUE_METHOD_TYPE = 9 , DEXPP_VALUE_METHOD_HANDLE = 10 , DEXPP_VALUE_ARRAY = 11 , DEXPP_VALUE_ANNOTATION = 12 } |
| The kind of a DexppValue. More... | |
| typedef enum DexppValueKind | DexppValueKind |
| The kind of a DexppValue. | |
| typedef struct DexppValue | DexppValue |
| An annotation element value, or the initial value of a static field. | |
| typedef struct DexppAnnotationElement | DexppAnnotationElement |
One name = value pair of an annotation. | |
| typedef struct DexppAnnotation | DexppAnnotation |
| One annotation on a class, a method or a field. | |
| void | dexpp_value_clear (DexppValue *value) |
| Free everything a DexppValue owns and reset it to a NULL value. | |
| void | dexpp_annotation_array_free (DexppAnnotation *annotations, size_t count) |
| Free an array of annotations and everything they own. | |
Instructions | |
| enum | DexppInstructionKind { DEXPP_INSN_NOP = 0 , DEXPP_INSN_GOTO = 1 , DEXPP_INSN_IF = 2 , DEXPP_INSN_IF_ZERO = 3 , DEXPP_INSN_SWITCH = 4 , DEXPP_INSN_RETURN = 5 , DEXPP_INSN_THROW = 6 , DEXPP_INSN_MOVE = 7 , DEXPP_INSN_CONST = 8 , DEXPP_INSN_CONST_STRING = 9 , DEXPP_INSN_CONST_CLASS = 10 , DEXPP_INSN_CONST_METHOD_HANDLE = 11 , DEXPP_INSN_TYPE = 12 , DEXPP_INSN_FILLED_NEW_ARRAY = 13 , DEXPP_INSN_MONITOR = 14 , DEXPP_INSN_FILL_ARRAY = 15 , DEXPP_INSN_COMPARE = 16 , DEXPP_INSN_ARRAY_OP = 17 , DEXPP_INSN_FIELD = 18 , DEXPP_INSN_INVOKE = 19 , DEXPP_INSN_INVOKE_CUSTOM = 20 , DEXPP_INSN_UNARY_OP = 21 , DEXPP_INSN_BINARY_OP = 22 , DEXPP_INSN_BINARY_LIT = 23 , DEXPP_INSN_CONST_METHOD_TYPE = 24 , DEXPP_INSN_INVOKE_POLYMORPHIC = 25 , DEXPP_INSN_ARRAY_LENGTH = 26 , DEXPP_INSN_INVALID = 27 } |
| The kind of a decoded instruction: one per instruction family, the same families as the C++ and Python APIs. More... | |
| typedef enum DexppInstructionKind | DexppInstructionKind |
| The kind of a decoded instruction: one per instruction family, the same families as the C++ and Python APIs. | |
| typedef struct DexppSwitchCase | DexppSwitchCase |
| One case of a switch instruction. | |
| typedef struct DexppInstruction | DexppInstruction |
| One decoded instruction. | |
| DexppInstruction * | dexpp_method_instructions (const DexppMethod *m, size_t *count) |
| The decoded bytecode of a method, in order. | |
| void | dexpp_instruction_array_free (DexppInstruction *insns, size_t count) |
| Free an array of instructions. | |
| const char * | dexpp_opcode_name (uint8_t opcode) |
| The name of a Dalvik opcode byte, such as "invoke-virtual". | |
| char * | dexpp_instruction_to_string (const DexppInstruction *insn) |
One instruction as text: the opcode name, then its operands, with pool operands as raw indices (string@12). | |
Memory | |
| typedef struct DexppText | DexppText |
| A string constant of the analysed program. | |
| void | dexpp_string_free (char *s) |
| Free a string returned by any dexpp function. | |
| void | dexpp_string_array_free (char **strings, size_t count) |
| Free an array of strings and every string in it. | |
| void | dexpp_text_clear (DexppText *text) |
| Free the bytes of one DexppText and set its members to NULL and 0. | |
| void | dexpp_text_array_free (DexppText *texts, size_t count) |
| Free an array of DexppText and every text in it. | |
| void | dexpp_buffer_free (uint8_t *buffer) |
| Free a byte buffer returned by dexpp_apk_read() or dexpp_model_write(). | |
| void | dexpp_index_array_free (uint32_t *indices, size_t count) |
| Free an array of indices (node, edge or block numbers). | |
Identities | |
| typedef struct DexppMethodId | DexppMethodId |
| The identity of a method: its class, name and prototype. | |
| typedef struct DexppFieldId | DexppFieldId |
| The identity of a field: its class, name and type. | |
| void | dexpp_method_id_clear (DexppMethodId *id) |
| Free the strings of one DexppMethodId and set them to NULL. | |
| void | dexpp_field_id_clear (DexppFieldId *id) |
| Free the strings of one DexppFieldId and set them to NULL. | |
| void | dexpp_method_id_array_free (DexppMethodId *ids, size_t count) |
| Free an array of DexppMethodId. | |
Methods | |
| typedef struct DexppParameterRegister | DexppParameterRegister |
| An incoming argument and the register it arrives in. | |
| typedef struct DexppMethodCall | DexppMethodCall |
| One call in a method's code. | |
| typedef struct DexppFieldAccess | DexppFieldAccess |
| One field read or write in a method's code. | |
| typedef struct DexppStringLoad | DexppStringLoad |
| One const-string instruction in a method's code. | |
| typedef struct DexppTypeUse | DexppTypeUse |
| One instruction in a method's code that names a type. | |
| typedef struct DexppCatchHandler | DexppCatchHandler |
| One typed catch clause of a try block. | |
| typedef struct DexppTryBlock | DexppTryBlock |
| A range of code covered by exception handlers. | |
| char * | dexpp_method_name (const DexppMethod *m) |
| The method name. | |
| char * | dexpp_method_proto (const DexppMethod *m) |
| The prototype: the parameter types inside parentheses, then the return type, e.g. "(Ljava/lang/String;I)V". | |
| DexppClassRef * | dexpp_method_declaring_class (const DexppMethod *m) |
| The class that defines the method. | |
| void | dexpp_method_id (const DexppMethod *m, DexppMethodId *out) |
Fill out with the method's identity: its class, name and prototype (release with dexpp_method_id_clear()). | |
| char * | dexpp_method_return_type (const DexppMethod *m) |
| The return type descriptor; "V" for void. | |
| char ** | dexpp_method_parameters (const DexppMethod *m, size_t *count) |
The declared parameter types, in order (this is not included). | |
| uint32_t | dexpp_method_access_flags (const DexppMethod *m) |
| The access flags (see DexppAccessFlag). | |
| int | dexpp_method_has_code (const DexppMethod *m) |
| 1 when the method has bytecode (it is neither abstract nor native). | |
| int | dexpp_method_is_static (const DexppMethod *m) |
| 1 when the method is static. | |
| int | dexpp_method_is_constructor (const DexppMethod *m) |
1 for <init> and <clinit>. | |
| uint16_t | dexpp_method_register_count (const DexppMethod *m) |
| The number of registers in the method's frame; 0 without code. | |
| DexppParameterRegister * | dexpp_method_parameter_registers (const DexppMethod *m, size_t *count) |
The incoming arguments and their registers, this first for an instance method. | |
| DexppMethodCall * | dexpp_method_calls (const DexppMethod *m, size_t *count) |
| Every call in the method's code, in order. | |
| DexppFieldAccess * | dexpp_method_field_accesses (const DexppMethod *m, size_t *count) |
| Every field read and write in the method's code, in order. | |
| DexppStringLoad * | dexpp_method_string_loads (const DexppMethod *m, size_t *count) |
| Every const-string in the method's code, in order. | |
| DexppTypeUse * | dexpp_method_type_uses (const DexppMethod *m, size_t *count) |
| Every instruction that names a type, in order. | |
| DexppTryBlock * | dexpp_method_try_blocks (const DexppMethod *m, size_t *count) |
| The try blocks and their handlers. | |
| DexppAnnotation * | dexpp_method_annotations (const DexppMethod *m, size_t *count) |
| The annotations on the method. | |
| void | dexpp_method_free (DexppMethod *m) |
| Free a method handle. | |
| void | dexpp_method_array_free (DexppMethod **methods, size_t count) |
| Free an array of method handles and every handle in it. | |
| void | dexpp_parameter_register_array_free (DexppParameterRegister *regs, size_t count) |
| Free an array of DexppParameterRegister. | |
| void | dexpp_method_call_array_free (DexppMethodCall *calls, size_t count) |
| Free an array of DexppMethodCall. | |
| void | dexpp_field_access_array_free (DexppFieldAccess *accesses, size_t count) |
| Free an array of DexppFieldAccess. | |
| void | dexpp_string_load_array_free (DexppStringLoad *loads, size_t count) |
| Free an array of DexppStringLoad. | |
| void | dexpp_type_use_array_free (DexppTypeUse *uses, size_t count) |
| Free an array of DexppTypeUse. | |
| void | dexpp_try_block_array_free (DexppTryBlock *blocks, size_t count) |
| Free an array of DexppTryBlock and their handlers. | |
Control-flow graph | |
| typedef struct DexppCfgEdge | DexppCfgEdge |
| An edge from one basic block to another. | |
| typedef struct DexppBasicBlock | DexppBasicBlock |
| A run of instructions entered at its first and left at its last one. | |
| DexppBasicBlock * | dexpp_method_cfg (const DexppMethod *m, size_t *count) |
| The method's control-flow graph: blocks ordered by offset, block 0 is the entry. | |
| void | dexpp_basic_block_array_free (DexppBasicBlock *blocks, size_t count) |
| Free an array of basic blocks and the edges they own. | |
Call graph | |
| typedef struct DexppCallNode | DexppCallNode |
| A node of the call graph: a method, or an invoke-custom call site. | |
| typedef struct DexppCallEdge | DexppCallEdge |
| One call-site edge. | |
| size_t | dexpp_call_graph_node_count (const DexppCallGraph *g) |
| Number of nodes. | |
| size_t | dexpp_call_graph_edge_count (const DexppCallGraph *g) |
| Number of edges. | |
| DexppCallNode * | dexpp_call_graph_nodes (const DexppCallGraph *g, size_t *count) |
| Every node, in index order. | |
| int | dexpp_call_graph_node (const DexppCallGraph *g, uint32_t node, DexppCallNode *out) |
Fill out with node node (release with dexpp_call_node_clear()). | |
| DexppCallEdge * | dexpp_call_graph_edges (const DexppCallGraph *g, size_t *count) |
| Every edge, in index order. | |
| int | dexpp_call_graph_edge (const DexppCallGraph *g, uint32_t edge, DexppCallEdge *out) |
Fill out with edge edge. | |
| int64_t | dexpp_call_graph_find (const DexppCallGraph *g, const char *class_descriptor, const char *name, const char *proto) |
| The index of the node with this identity, or -1 when the graph has none. | |
| uint32_t * | dexpp_call_graph_out_edges (const DexppCallGraph *g, uint32_t node, size_t *count) |
Indices of the edges that leave node node (its call sites). | |
| uint32_t * | dexpp_call_graph_in_edges (const DexppCallGraph *g, uint32_t node, size_t *count) |
Indices of the edges that enter node node (the calls into it). | |
| uint32_t * | dexpp_call_graph_dispatch_targets (const DexppCallGraph *g, uint32_t node, size_t *count) |
Nodes a virtual or interface call declared against node may dispatch to, besides itself and its own resolution. | |
| uint32_t * | dexpp_call_graph_dispatch_sources (const DexppCallGraph *g, uint32_t node, size_t *count) |
| The reverse of dexpp_call_graph_dispatch_targets(). | |
| uint32_t * | dexpp_call_graph_callees (const DexppCallGraph *g, uint32_t node, size_t *count) |
Every node node may call, dispatch targets included; no duplicates. | |
| uint32_t * | dexpp_call_graph_callers (const DexppCallGraph *g, uint32_t node, size_t *count) |
Every node that may call node, through dispatch included. | |
| uint32_t * | dexpp_call_graph_edge_dispatch_targets (const DexppCallGraph *g, uint32_t edge, size_t *count) |
The dispatch targets that apply at edge edge: those of its callee for a DECLARED virtual or interface edge, none for every other edge. | |
| uint32_t * | dexpp_call_graph_edges_where (const DexppCallGraph *g, int origin, int kind, size_t *count) |
| Indices of the edges that match both filters. | |
| DexppMethod * | dexpp_call_graph_method_for (const DexppCallGraph *g, uint32_t node) |
| The method behind a DEFINED node, or NULL for an EXTERNAL or CALL_SITE node or an index out of range. | |
| void | dexpp_call_graph_free (DexppCallGraph *g) |
| Free a call-graph handle. | |
| void | dexpp_call_node_clear (DexppCallNode *node) |
| Free the strings of one DexppCallNode. | |
| void | dexpp_call_node_array_free (DexppCallNode *nodes, size_t count) |
| Free an array of DexppCallNode. | |
| void | dexpp_call_edge_array_free (DexppCallEdge *edges, size_t count) |
| Free an array of DexppCallEdge. | |
Cross-references | |
| typedef struct DexppMethodXref | DexppMethodXref |
| One invoke instruction that calls a method. | |
| typedef struct DexppFieldXref | DexppFieldXref |
| One instruction that reads or writes a field. | |
| typedef struct DexppStringXref | DexppStringXref |
| One const-string instruction. | |
| typedef struct DexppTypeXref | DexppTypeXref |
| One instruction that names a type. | |
| typedef struct DexppMethodRefGroup | DexppMethodRefGroup |
| The call sites of one method, as found by name. | |
| size_t | dexpp_xrefs_referrer_count (const DexppXrefs *x) |
| Number of referrers: methods that contain an indexed instruction. | |
| DexppMethodId * | dexpp_xrefs_referrers (const DexppXrefs *x, size_t *count) |
| The identity of every referrer, in index order. | |
| int | dexpp_xrefs_referrer_id (const DexppXrefs *x, uint32_t referrer, DexppMethodId *out) |
Fill out with the identity of one referrer (release with dexpp_method_id_clear()). | |
| DexppMethod * | dexpp_xrefs_referrer_method (const DexppXrefs *x, uint32_t referrer) |
The method of one referrer, or NULL when referrer is out of range. | |
| DexppMethodXref * | dexpp_xrefs_method_refs (const DexppXrefs *x, const char *class_descriptor, const char *name, const char *proto, size_t *count) |
| The call sites whose target, as the bytecode names it, is exactly this method. | |
| DexppMethodRefGroup * | dexpp_xrefs_method_refs_by_name (const DexppXrefs *x, const char *name, size_t *count) |
| The call sites of every method with this name, in any class and with any prototype, grouped by called method. | |
| DexppFieldXref * | dexpp_xrefs_field_refs (const DexppXrefs *x, const char *class_descriptor, const char *name, const char *type, size_t *count) |
| Every read and write of this field. | |
| DexppFieldXref * | dexpp_xrefs_field_reads (const DexppXrefs *x, const char *class_descriptor, const char *name, const char *type, size_t *count) |
| Only the reads of this field. | |
| DexppFieldXref * | dexpp_xrefs_field_writes (const DexppXrefs *x, const char *class_descriptor, const char *name, const char *type, size_t *count) |
| Only the writes of this field. | |
| DexppStringXref * | dexpp_xrefs_string_refs (const DexppXrefs *x, const char *value, size_t length, size_t *count) |
The const-string instructions that load exactly this string, given as length bytes (it may contain NUL bytes). | |
| DexppText * | dexpp_xrefs_referenced_strings (const DexppXrefs *x, size_t *count) |
| Every distinct string that some const-string instruction loads. | |
| DexppTypeXref * | dexpp_xrefs_type_refs (const DexppXrefs *x, const char *descriptor, size_t *count) |
| The instructions that name this type. | |
| int | dexpp_xrefs_empty (const DexppXrefs *x) |
| 1 when nothing is indexed. | |
| void | dexpp_xrefs_free (DexppXrefs *x) |
| Free a cross-reference handle. | |
| void | dexpp_method_xref_array_free (DexppMethodXref *xrefs, size_t count) |
| Free an array of DexppMethodXref. | |
| void | dexpp_method_ref_group_array_free (DexppMethodRefGroup *groups, size_t count) |
| Free an array of DexppMethodRefGroup and their sites. | |
| void | dexpp_field_xref_array_free (DexppFieldXref *xrefs, size_t count) |
| Free an array of DexppFieldXref. | |
| void | dexpp_string_xref_array_free (DexppStringXref *xrefs, size_t count) |
| Free an array of DexppStringXref. | |
| void | dexpp_type_xref_array_free (DexppTypeXref *xrefs, size_t count) |
| Free an array of DexppTypeXref. | |
APK, manifest, resources and signing | |
| typedef struct DexppIntentFilter | DexppIntentFilter |
An <intent-filter> of a component. | |
| typedef struct DexppComponent | DexppComponent |
| An activity, service, receiver or provider declared in the manifest. | |
| typedef struct DexppDeclaredPermission | DexppDeclaredPermission |
| A permission the app declares. | |
| typedef struct DexppManifest | DexppManifest |
| The decoded AndroidManifest.xml. | |
| typedef struct DexppResourceName | DexppResourceName |
| The full name of a resource: package:type/entry. | |
| typedef struct DexppCertificate | DexppCertificate |
| An X.509 certificate that signed the APK. | |
| typedef struct DexppSigningInfo | DexppSigningInfo |
| Which signature schemes the APK carries, and their certificates. | |
| DexppApk * | dexpp_apk_open (const char *path, DexppError **err) |
| Open an APK file. | |
| DexppApk * | dexpp_apk_open_buffer (const uint8_t *bytes, size_t len, const char *label, DexppError **err) |
| Open an APK from its bytes in memory, for example bytes received over the network. | |
| void | dexpp_apk_free (DexppApk *apk) |
| Free an APK handle. | |
| char ** | dexpp_apk_entries (const DexppApk *apk, size_t *count) |
| The name of every archive entry. | |
| int | dexpp_apk_read (const DexppApk *apk, const char *name, uint8_t **out, size_t *length) |
The uncompressed bytes of the entry name. | |
| char * | dexpp_apk_package (const DexppApk *apk) |
| The manifest's package name, or NULL when there is no decodable manifest. | |
| int | dexpp_apk_manifest (const DexppApk *apk, DexppManifest *out) |
Fill out with the decoded manifest. | |
| void | dexpp_manifest_clear (DexppManifest *manifest) |
| Free everything a DexppManifest owns. | |
| int | dexpp_apk_has_resources (const DexppApk *apk) |
| 1 when the APK has a decodable resources.arsc table. | |
| int | dexpp_apk_resources_empty (const DexppApk *apk) |
| 1 when the APK has no resource table, or the table has no entries. | |
| int | dexpp_apk_resource_name (const DexppApk *apk, uint32_t id, DexppResourceName *out) |
Fill out with the name of resource id (release with dexpp_resource_name_clear()). | |
| void | dexpp_resource_name_clear (DexppResourceName *name) |
| Free the strings of a DexppResourceName. | |
| int | dexpp_apk_resolve_string (const DexppApk *apk, uint32_t id, DexppText *out) |
The value of string resource id: returns 1 and fills out (release with dexpp_text_clear()); returns 0 when the id is missing or its value is not a string. | |
| int | dexpp_apk_resolve_bool (const DexppApk *apk, uint32_t id, int *out) |
The value of resource id as a boolean: a bool resource, or any integer-typed value (nonzero is true), as Android reads it. | |
| int | dexpp_apk_resolve_int (const DexppApk *apk, uint32_t id, int64_t *out) |
The value of resource id as an integer: an integer resource, or any other integer-typed value, read as its signed 32-bit data. | |
| int | dexpp_apk_resource_id (const DexppApk *apk, const char *type, const char *entry, uint32_t *out) |
| The id of the resource with this type and entry name. | |
| void | dexpp_apk_signing (const DexppApk *apk, DexppSigningInfo *out) |
Fill out with the signature schemes and certificates (release with dexpp_signing_info_clear()). | |
| void | dexpp_signing_info_clear (DexppSigningInfo *info) |
| Free everything a DexppSigningInfo owns. | |
| DexppContext * | dexpp_apk_analysis (const DexppApk *apk, uint32_t threads, DexppError **err) |
| A code-analysis context over every classes*.dex of the APK, in multidex order, loaded from the bytes the APK handle already holds. | |
C API for code analysis and APK metadata.
This is the interop boundary for programs that cannot call C++ directly (Go through cgo, and other languages with a C foreign-function interface). It covers what the Python binding covers: loading, classes, methods and fields, decoded bytecode, control-flow graphs, try blocks, annotations, the call graph, the class hierarchy, cross-references, the manifest, resources, archive entries and signing. The editable model is in dexpp_model.h.
Conventions, the same for every function:
DexppError **err as its last argument. On failure it returns NULL (or 0) and, when err is not NULL, sets *err to a new error object. On success it sets *err to NULL. So the caller can always pass the result to dexpp_error_free(), which accepts NULL. err may be NULL when the caller does not want the details._free function. Every handle keeps the analysis it came from alive, so it stays valid after the context or APK handle it came from is freed. A handle must not be NULL when it is passed to a function, unless the function says so.*count. An empty array is returned as NULL with *count set to 0. Free an array with the _array_free function named for its type; it frees everything the elements own, and accepts NULL. An array of handles is one block from malloc(): a caller that keeps the handles, to free each one later with its _free function, frees the block alone with the array's _array_free function and a count of 0. free() also works when the library is linked statically, but not across the boundary of a Windows DLL, where the library and the caller can use different C runtimes._clear function, which frees the members (not the struct) and sets them to NULL.| typedef enum DexppErrorCode DexppErrorCode |
What went wrong in a failed call.
The names match the Python exceptions.
| typedef struct DexppError DexppError |
An error reported by a failed call.
Free it with dexpp_error_free().
A string constant of the analysed program.
data is malloc'd and also NUL-terminated, but the string itself may contain NUL bytes: length is the number of bytes.
| typedef enum DexppAccessFlag DexppAccessFlag |
Access flags of a class, a method or a field, as the DEX format stores them.
Two pairs share a bit: VOLATILE/BRIDGE and TRANSIENT/VARARGS.
| typedef enum DexppInvokeKind DexppInvokeKind |
The kind of invoke instruction at a call site.
| typedef enum DexppEdgeOrigin DexppEdgeOrigin |
How a call-graph edge came to point at its callee.
| typedef enum DexppCallNodeKind DexppCallNodeKind |
What a call-graph node stands for.
| typedef enum DexppCfgEdgeKind DexppCfgEdgeKind |
The kind of an edge between two basic blocks.
| typedef enum DexppTypeUseKind DexppTypeUseKind |
What an instruction does with the type it names.
| typedef enum DexppOperandWidth DexppOperandWidth |
How many registers a value takes.
| typedef enum DexppAnnotationVisibility DexppAnnotationVisibility |
Who can see an annotation.
| typedef enum DexppMethodHandleKind DexppMethodHandleKind |
What a method handle does: the method_handle_type codes of the DEX format.
The four field kinds read or write a field; the five invoke kinds call a method.
| typedef enum DexppComponentKind DexppComponentKind |
The kind of a manifest component.
| typedef struct DexppMethodId DexppMethodId |
The identity of a method: its class, name and prototype.
The members are malloc'd strings owned by the struct or array that holds it.
| typedef struct DexppFieldId DexppFieldId |
The identity of a field: its class, name and type.
| typedef struct DexppContext DexppContext |
The code of a program: one or more DEX files loaded together.
| typedef struct DexppClass DexppClass |
A class defined in a loaded DEX file.
| typedef struct DexppClassRef DexppClassRef |
A reference to a class by descriptor; the class may not be loaded.
| typedef struct DexppMethod DexppMethod |
A method defined by a loaded class.
| typedef struct DexppField DexppField |
A field declared by a loaded class.
| typedef struct DexppCallGraph DexppCallGraph |
The whole-program call graph.
| typedef struct DexppClassHierarchy DexppClassHierarchy |
The whole-program class hierarchy.
| typedef struct DexppXrefs DexppXrefs |
The whole-program cross-reference index.
| typedef enum DexppValueKind DexppValueKind |
The kind of a DexppValue.
| typedef struct DexppValue DexppValue |
An annotation element value, or the initial value of a static field.
Only the members named by kind are set; the others are 0 or NULL.
| typedef struct DexppAnnotationElement DexppAnnotationElement |
One name = value pair of an annotation.
| typedef struct DexppAnnotation DexppAnnotation |
One annotation on a class, a method or a field.
Elements left at their default value are not listed.
| typedef struct DexppParameterRegister DexppParameterRegister |
An incoming argument and the register it arrives in.
| typedef struct DexppMethodCall DexppMethodCall |
One call in a method's code.
| typedef struct DexppFieldAccess DexppFieldAccess |
One field read or write in a method's code.
| typedef struct DexppStringLoad DexppStringLoad |
One const-string instruction in a method's code.
| typedef struct DexppTypeUse DexppTypeUse |
One instruction in a method's code that names a type.
| typedef struct DexppCatchHandler DexppCatchHandler |
One typed catch clause of a try block.
| typedef struct DexppTryBlock DexppTryBlock |
A range of code covered by exception handlers.
| typedef enum DexppInstructionKind DexppInstructionKind |
The kind of a decoded instruction: one per instruction family, the same families as the C++ and Python APIs.
| typedef struct DexppSwitchCase DexppSwitchCase |
One case of a switch instruction.
| typedef struct DexppInstruction DexppInstruction |
One decoded instruction.
offset, opcode and size are set for every kind; the other members only for the kinds DexppInstructionKind lists for them, and are 0 or NULL otherwise. Offsets are in 16-bit code units. Pool indices (string_index, type_index, ...) are raw indices into the DEX file's tables; dexpp_method_calls() and the other reference functions give resolved names.
| typedef struct DexppCfgEdge DexppCfgEdge |
An edge from one basic block to another.
| typedef struct DexppBasicBlock DexppBasicBlock |
A run of instructions entered at its first and left at its last one.
| typedef struct DexppCallNode DexppCallNode |
A node of the call graph: a method, or an invoke-custom call site.
| typedef struct DexppCallEdge DexppCallEdge |
One call-site edge.
A call site has one DECLARED edge, and an INHERITED_RESOLUTION edge when the named class does not define the method itself.
| typedef struct DexppMethodXref DexppMethodXref |
One invoke instruction that calls a method.
referrer is an index into dexpp_xrefs_referrers().
| typedef struct DexppFieldXref DexppFieldXref |
One instruction that reads or writes a field.
| typedef struct DexppStringXref DexppStringXref |
One const-string instruction.
| typedef struct DexppTypeXref DexppTypeXref |
One instruction that names a type.
| typedef struct DexppMethodRefGroup DexppMethodRefGroup |
The call sites of one method, as found by name.
| typedef struct DexppIntentFilter DexppIntentFilter |
An <intent-filter> of a component.
| typedef struct DexppComponent DexppComponent |
An activity, service, receiver or provider declared in the manifest.
| typedef struct DexppDeclaredPermission DexppDeclaredPermission |
A permission the app declares.
| typedef struct DexppManifest DexppManifest |
The decoded AndroidManifest.xml.
Release with dexpp_manifest_clear().
A boolean or integer attribute may be written as a resource reference, such as android:debuggable="@bool/debug". The value is then the one the APK's resource table gives, in its default configuration, and the matching *_reference member holds the reference id. When the reference cannot be resolved, the value reads as absent (has_* is 0, or -1) while the *_reference member still holds the id: the attribute is set, but its value is unknown. A *_reference member is 0 for a plain value or a missing attribute.
| typedef struct DexppResourceName DexppResourceName |
The full name of a resource: package:type/entry.
Release with dexpp_resource_name_clear().
| typedef struct DexppCertificate DexppCertificate |
An X.509 certificate that signed the APK.
| typedef struct DexppSigningInfo DexppSigningInfo |
Which signature schemes the APK carries, and their certificates.
The signatures are not verified. Release with dexpp_signing_info_clear().
| enum DexppErrorCode |
What went wrong in a failed call.
The names match the Python exceptions.
| enum DexppAccessFlag |
Access flags of a class, a method or a field, as the DEX format stores them.
Two pairs share a bit: VOLATILE/BRIDGE and TRANSIENT/VARARGS.
| enum DexppInvokeKind |
| enum DexppEdgeOrigin |
| enum DexppCallNodeKind |
What a call-graph node stands for.
| enum DexppCfgEdgeKind |
The kind of an edge between two basic blocks.
| enum DexppTypeUseKind |
| enum DexppOperandWidth |
What a method handle does: the method_handle_type codes of the DEX format.
The four field kinds read or write a field; the five invoke kinds call a method.
| enum DexppComponentKind |
| enum DexppValueKind |
The kind of a DexppValue.
| enum DexppInstructionKind |
The kind of a decoded instruction: one per instruction family, the same families as the C++ and Python APIs.
| DexppErrorCode dexpp_error_code | ( | const DexppError * | error | ) |
The kind of the error.
| const char * dexpp_error_message | ( | const DexppError * | error | ) |
The error message.
The string belongs to the error and lives until dexpp_error_free().
| size_t dexpp_error_problem_count | ( | const DexppError * | error | ) |
How many problems an error with code DEXPP_ERROR_INVALID_MODEL lists (0 for every other code).
| const char * dexpp_error_problem_where | ( | const DexppError * | error, |
| size_t | index | ||
| ) |
Where problem index is, e.g. "Lcom/a/B;->run()V, item 12"; empty for a problem with the whole file.
NULL when index is out of range. The string belongs to the error.
| const char * dexpp_error_problem_message | ( | const DexppError * | error, |
| size_t | index | ||
| ) |
What is wrong in problem index.
NULL when index is out of range. The string belongs to the error.
| void dexpp_error_free | ( | DexppError * | error | ) |
Free an error.
Accepts NULL.
| void dexpp_string_free | ( | char * | s | ) |
Free a string returned by any dexpp function.
Accepts NULL.
| void dexpp_string_array_free | ( | char ** | strings, |
| size_t | count | ||
| ) |
Free an array of strings and every string in it.
Accepts NULL.
| void dexpp_text_clear | ( | DexppText * | text | ) |
Free the bytes of one DexppText and set its members to NULL and 0.
| void dexpp_text_array_free | ( | DexppText * | texts, |
| size_t | count | ||
| ) |
Free an array of DexppText and every text in it.
Accepts NULL.
| void dexpp_buffer_free | ( | uint8_t * | buffer | ) |
Free a byte buffer returned by dexpp_apk_read() or dexpp_model_write().
Accepts NULL.
| void dexpp_index_array_free | ( | uint32_t * | indices, |
| size_t | count | ||
| ) |
Free an array of indices (node, edge or block numbers).
Accepts NULL.
| void dexpp_method_id_clear | ( | DexppMethodId * | id | ) |
Free the strings of one DexppMethodId and set them to NULL.
| void dexpp_field_id_clear | ( | DexppFieldId * | id | ) |
Free the strings of one DexppFieldId and set them to NULL.
| void dexpp_method_id_array_free | ( | DexppMethodId * | ids, |
| size_t | count | ||
| ) |
Free an array of DexppMethodId.
Accepts NULL.
| void dexpp_value_clear | ( | DexppValue * | value | ) |
Free everything a DexppValue owns and reset it to a NULL value.
| void dexpp_annotation_array_free | ( | DexppAnnotation * | annotations, |
| size_t | count | ||
| ) |
Free an array of annotations and everything they own.
Accepts NULL.
| DexppContext * dexpp_context_from_dex | ( | const char * | path, |
| DexppError ** | err | ||
| ) |
Load one DEX file.
Errors: FILE_NOT_FOUND, CANNOT_READ, INVALID_DEX.
| DexppContext * dexpp_context_from_dex_files | ( | const char *const * | paths, |
| size_t | count, | ||
| DexppError ** | err | ||
| ) |
Load several DEX files into one context, for example the unpacked files of a multidex app.
Errors as dexpp_context_from_dex().
| DexppContext * dexpp_context_from_apk | ( | const char * | path, |
| uint32_t | threads, | ||
| DexppError ** | err | ||
| ) |
Load every top-level classes*.dex of an APK, in multidex order.
threads is the number of threads for decompressing and, later, for building the call graph: 0 lets the library choose, 1 keeps all work on the calling thread. Errors: FILE_NOT_FOUND, CANNOT_READ, INVALID_APK, INVALID_DEX.
| void dexpp_context_free | ( | DexppContext * | ctx | ) |
Free a context.
Handles that came from it stay valid. Accepts NULL.
| DexppClass ** dexpp_context_classes | ( | const DexppContext * | ctx, |
| size_t * | count | ||
| ) |
Every class of every loaded DEX file, in file order.
Free with dexpp_class_array_free().
| DexppClass * dexpp_context_find_class | ( | const DexppContext * | ctx, |
| const char * | descriptor | ||
| ) |
The class with this descriptor (e.g. "Lcom/example/Foo;"), or NULL when no loaded file defines it.
| DexppText * dexpp_context_strings | ( | const DexppContext * | ctx, |
| size_t * | count | ||
| ) |
Every string of every loaded DEX file's string table, including names of classes and members.
Decodes the whole table. Free with dexpp_text_array_free().
| DexppCallGraph * dexpp_context_call_graph | ( | const DexppContext * | ctx, |
| DexppError ** | err | ||
| ) |
The call graph of the whole program, built on the first call and kept.
Free the handle with dexpp_call_graph_free(). Errors: INTERNAL.
| DexppClassHierarchy * dexpp_context_class_hierarchy | ( | const DexppContext * | ctx, |
| DexppError ** | err | ||
| ) |
The class hierarchy of the whole program, built on the first call and kept.
Free with dexpp_class_hierarchy_free(). Errors: INTERNAL.
| DexppXrefs * dexpp_context_xrefs | ( | const DexppContext * | ctx, |
| DexppError ** | err | ||
| ) |
The cross-reference index of the whole program, built on the first call and kept.
Free with dexpp_xrefs_free(). Errors: INTERNAL.
| char * dexpp_class_descriptor | ( | const DexppClass * | cls | ) |
The class descriptor, e.g. "Lcom/example/Foo;".
| char * dexpp_class_package | ( | const DexppClass * | cls | ) |
The package in Java source form, with dots between its parts, e.g.
"com.example" (the same form as the manifest's package); empty for the default package.
| DexppClassRef * dexpp_class_superclass | ( | const DexppClass * | cls | ) |
The direct superclass, or NULL for java.lang.Object itself.
Free with dexpp_class_ref_free().
| DexppClassRef ** dexpp_class_interfaces | ( | const DexppClass * | cls, |
| size_t * | count | ||
| ) |
The interfaces the class implements directly, in declaration order.
Free with dexpp_class_ref_array_free().
| uint32_t dexpp_class_access_flags | ( | const DexppClass * | cls | ) |
The access flags (see DexppAccessFlag).
| int dexpp_class_is_interface | ( | const DexppClass * | cls | ) |
1 when the class is an interface, otherwise 0.
| int dexpp_class_is_abstract | ( | const DexppClass * | cls | ) |
1 when the class is abstract, otherwise 0.
| char * dexpp_class_source_file | ( | const DexppClass * | cls | ) |
The source file name recorded for the class, or NULL.
| DexppMethod ** dexpp_class_methods | ( | const DexppClass * | cls, |
| size_t * | count | ||
| ) |
The methods the class defines: direct methods first, then virtual ones.
Free with dexpp_method_array_free().
| DexppField ** dexpp_class_fields | ( | const DexppClass * | cls, |
| size_t * | count | ||
| ) |
The fields the class declares: static fields first, then instance fields.
Free with dexpp_field_array_free().
| DexppAnnotation * dexpp_class_annotations | ( | const DexppClass * | cls, |
| size_t * | count | ||
| ) |
The annotations on the class.
Free with dexpp_annotation_array_free().
| void dexpp_class_free | ( | DexppClass * | cls | ) |
Free a class handle.
Accepts NULL.
| void dexpp_class_array_free | ( | DexppClass ** | classes, |
| size_t | count | ||
| ) |
Free an array of class handles and every handle in it.
Accepts NULL. With count 0 it frees the array alone and the handles stay valid.
| char * dexpp_class_ref_descriptor | ( | const DexppClassRef * | ref | ) |
The descriptor the reference names.
| int dexpp_class_ref_is_resolved | ( | const DexppClassRef * | ref | ) |
1 when the class is defined in a loaded DEX file, otherwise 0.
| DexppClass * dexpp_class_ref_resolve | ( | const DexppClassRef * | ref | ) |
The referenced class, or NULL when no loaded file defines it.
| void dexpp_class_ref_free | ( | DexppClassRef * | ref | ) |
Free a class reference.
Accepts NULL.
| void dexpp_class_ref_array_free | ( | DexppClassRef ** | refs, |
| size_t | count | ||
| ) |
Free an array of class references and every reference in it.
Accepts NULL. With count 0 it frees the array alone and the references stay valid.
| char * dexpp_method_name | ( | const DexppMethod * | m | ) |
The method name.
Constructors are <init>, the static initializer is <clinit>.
| char * dexpp_method_proto | ( | const DexppMethod * | m | ) |
The prototype: the parameter types inside parentheses, then the return type, e.g. "(Ljava/lang/String;I)V".
It is the proto of the method's DexppMethodId.
| DexppClassRef * dexpp_method_declaring_class | ( | const DexppMethod * | m | ) |
The class that defines the method.
Free with dexpp_class_ref_free().
| void dexpp_method_id | ( | const DexppMethod * | m, |
| DexppMethodId * | out | ||
| ) |
Fill out with the method's identity: its class, name and prototype (release with dexpp_method_id_clear()).
It is the identity the call graph and the cross-references use.
| char * dexpp_method_return_type | ( | const DexppMethod * | m | ) |
The return type descriptor; "V" for void.
| char ** dexpp_method_parameters | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The declared parameter types, in order (this is not included).
Free with dexpp_string_array_free().
| uint32_t dexpp_method_access_flags | ( | const DexppMethod * | m | ) |
The access flags (see DexppAccessFlag).
| int dexpp_method_has_code | ( | const DexppMethod * | m | ) |
1 when the method has bytecode (it is neither abstract nor native).
| int dexpp_method_is_static | ( | const DexppMethod * | m | ) |
1 when the method is static.
| int dexpp_method_is_constructor | ( | const DexppMethod * | m | ) |
1 for <init> and <clinit>.
| uint16_t dexpp_method_register_count | ( | const DexppMethod * | m | ) |
The number of registers in the method's frame; 0 without code.
| DexppParameterRegister * dexpp_method_parameter_registers | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The incoming arguments and their registers, this first for an instance method.
Free with dexpp_parameter_register_array_free().
| DexppMethodCall * dexpp_method_calls | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
Every call in the method's code, in order.
Free with dexpp_method_call_array_free().
| DexppFieldAccess * dexpp_method_field_accesses | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
Every field read and write in the method's code, in order.
Free with dexpp_field_access_array_free().
| DexppStringLoad * dexpp_method_string_loads | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
Every const-string in the method's code, in order.
Free with dexpp_string_load_array_free().
| DexppTypeUse * dexpp_method_type_uses | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
Every instruction that names a type, in order.
Free with dexpp_type_use_array_free().
| DexppTryBlock * dexpp_method_try_blocks | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The try blocks and their handlers.
Free with dexpp_try_block_array_free().
| DexppAnnotation * dexpp_method_annotations | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The annotations on the method.
Free with dexpp_annotation_array_free().
| void dexpp_method_free | ( | DexppMethod * | m | ) |
Free a method handle.
Accepts NULL.
| void dexpp_method_array_free | ( | DexppMethod ** | methods, |
| size_t | count | ||
| ) |
Free an array of method handles and every handle in it.
Accepts NULL. With count 0 it frees the array alone and the handles stay valid.
| void dexpp_parameter_register_array_free | ( | DexppParameterRegister * | regs, |
| size_t | count | ||
| ) |
Free an array of DexppParameterRegister.
Accepts NULL.
| void dexpp_method_call_array_free | ( | DexppMethodCall * | calls, |
| size_t | count | ||
| ) |
Free an array of DexppMethodCall.
Accepts NULL.
| void dexpp_field_access_array_free | ( | DexppFieldAccess * | accesses, |
| size_t | count | ||
| ) |
Free an array of DexppFieldAccess.
Accepts NULL.
| void dexpp_string_load_array_free | ( | DexppStringLoad * | loads, |
| size_t | count | ||
| ) |
Free an array of DexppStringLoad.
Accepts NULL.
| void dexpp_type_use_array_free | ( | DexppTypeUse * | uses, |
| size_t | count | ||
| ) |
Free an array of DexppTypeUse.
Accepts NULL.
| void dexpp_try_block_array_free | ( | DexppTryBlock * | blocks, |
| size_t | count | ||
| ) |
Free an array of DexppTryBlock and their handlers.
Accepts NULL.
| char * dexpp_field_name | ( | const DexppField * | f | ) |
The field name.
| DexppClassRef * dexpp_field_declaring_class | ( | const DexppField * | f | ) |
The class that declares the field.
Free with dexpp_class_ref_free().
| char * dexpp_field_type | ( | const DexppField * | f | ) |
The field's type descriptor.
| void dexpp_field_id | ( | const DexppField * | f, |
| DexppFieldId * | out | ||
| ) |
Fill out with the field's identity: its class, name and type (release with dexpp_field_id_clear()).
It is the identity the cross-references use.
| uint32_t dexpp_field_access_flags | ( | const DexppField * | f | ) |
The access flags (see DexppAccessFlag).
| DexppAnnotation * dexpp_field_annotations | ( | const DexppField * | f, |
| size_t * | count | ||
| ) |
The annotations on the field.
Free with dexpp_annotation_array_free().
| int dexpp_field_initial_value | ( | const DexppField * | f, |
| DexppValue * | out | ||
| ) |
The constant a static field starts with.
Returns 1 and fills out (release with dexpp_value_clear()) when the field has a recorded value; returns 0 when it has none, which means the type's default (0 or null).
| void dexpp_field_free | ( | DexppField * | f | ) |
Free a field handle.
Accepts NULL.
| void dexpp_field_array_free | ( | DexppField ** | fields, |
| size_t | count | ||
| ) |
Free an array of field handles and every handle in it.
Accepts NULL. With count 0 it frees the array alone and the handles stay valid.
| DexppInstruction * dexpp_method_instructions | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The decoded bytecode of a method, in order.
Free with dexpp_instruction_array_free().
| void dexpp_instruction_array_free | ( | DexppInstruction * | insns, |
| size_t | count | ||
| ) |
Free an array of instructions.
Accepts NULL.
| const char * dexpp_opcode_name | ( | uint8_t | opcode | ) |
The name of a Dalvik opcode byte, such as "invoke-virtual".
An unused opcode gives "unused-XX". The string is static: do not free it.
| char * dexpp_instruction_to_string | ( | const DexppInstruction * | insn | ) |
One instruction as text: the opcode name, then its operands, with pool operands as raw indices (string@12).
A kind this header does not list gives the opcode name alone, and a width other than DEXPP_WIDTH_PAIR counts as DEXPP_WIDTH_SINGLE.
| DexppBasicBlock * dexpp_method_cfg | ( | const DexppMethod * | m, |
| size_t * | count | ||
| ) |
The method's control-flow graph: blocks ordered by offset, block 0 is the entry.
Empty for a method without code. Free with dexpp_basic_block_array_free().
| void dexpp_basic_block_array_free | ( | DexppBasicBlock * | blocks, |
| size_t | count | ||
| ) |
Free an array of basic blocks and the edges they own.
Accepts NULL.
| size_t dexpp_call_graph_node_count | ( | const DexppCallGraph * | g | ) |
Number of nodes.
| size_t dexpp_call_graph_edge_count | ( | const DexppCallGraph * | g | ) |
Number of edges.
| DexppCallNode * dexpp_call_graph_nodes | ( | const DexppCallGraph * | g, |
| size_t * | count | ||
| ) |
Every node, in index order.
Free with dexpp_call_node_array_free().
| int dexpp_call_graph_node | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| DexppCallNode * | out | ||
| ) |
Fill out with node node (release with dexpp_call_node_clear()).
Returns 0 when node is out of range.
| DexppCallEdge * dexpp_call_graph_edges | ( | const DexppCallGraph * | g, |
| size_t * | count | ||
| ) |
Every edge, in index order.
Free with dexpp_call_edge_array_free().
| int dexpp_call_graph_edge | ( | const DexppCallGraph * | g, |
| uint32_t | edge, | ||
| DexppCallEdge * | out | ||
| ) |
Fill out with edge edge.
Returns 0 when it is out of range.
| int64_t dexpp_call_graph_find | ( | const DexppCallGraph * | g, |
| const char * | class_descriptor, | ||
| const char * | name, | ||
| const char * | proto | ||
| ) |
The index of the node with this identity, or -1 when the graph has none.
| uint32_t * dexpp_call_graph_out_edges | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
Indices of the edges that leave node node (its call sites).
Free with dexpp_index_array_free(). Empty when node is out of range.
| uint32_t * dexpp_call_graph_in_edges | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
Indices of the edges that enter node node (the calls into it).
| uint32_t * dexpp_call_graph_dispatch_targets | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
Nodes a virtual or interface call declared against node may dispatch to, besides itself and its own resolution.
| uint32_t * dexpp_call_graph_dispatch_sources | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
The reverse of dexpp_call_graph_dispatch_targets().
| uint32_t * dexpp_call_graph_callees | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
Every node node may call, dispatch targets included; no duplicates.
| uint32_t * dexpp_call_graph_callers | ( | const DexppCallGraph * | g, |
| uint32_t | node, | ||
| size_t * | count | ||
| ) |
Every node that may call node, through dispatch included.
| uint32_t * dexpp_call_graph_edge_dispatch_targets | ( | const DexppCallGraph * | g, |
| uint32_t | edge, | ||
| size_t * | count | ||
| ) |
The dispatch targets that apply at edge edge: those of its callee for a DECLARED virtual or interface edge, none for every other edge.
| uint32_t * dexpp_call_graph_edges_where | ( | const DexppCallGraph * | g, |
| int | origin, | ||
| int | kind, | ||
| size_t * | count | ||
| ) |
Indices of the edges that match both filters.
origin is a DexppEdgeOrigin or -1 for any; kind is a DexppInvokeKind or -1 for any. The filtering runs in C++.
| DexppMethod * dexpp_call_graph_method_for | ( | const DexppCallGraph * | g, |
| uint32_t | node | ||
| ) |
The method behind a DEFINED node, or NULL for an EXTERNAL or CALL_SITE node or an index out of range.
Free with dexpp_method_free().
| void dexpp_call_graph_free | ( | DexppCallGraph * | g | ) |
Free a call-graph handle.
Accepts NULL.
| void dexpp_call_node_clear | ( | DexppCallNode * | node | ) |
Free the strings of one DexppCallNode.
| void dexpp_call_node_array_free | ( | DexppCallNode * | nodes, |
| size_t | count | ||
| ) |
Free an array of DexppCallNode.
Accepts NULL.
| void dexpp_call_edge_array_free | ( | DexppCallEdge * | edges, |
| size_t | count | ||
| ) |
Free an array of DexppCallEdge.
Accepts NULL.
| char ** dexpp_class_hierarchy_supertypes | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
The direct superclass, then the directly implemented interfaces.
Free string arrays with dexpp_string_array_free().
| char * dexpp_class_hierarchy_superclass_of | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor | ||
| ) |
The direct superclass, or NULL when none is recorded (java.lang.Object, a class outside the loaded files, or a descriptor the hierarchy does not know).
| char ** dexpp_class_hierarchy_direct_interfaces | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
The interfaces implemented (or, for an interface, extended) directly.
| char ** dexpp_class_hierarchy_subclasses | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
The classes that directly extend the class.
| char ** dexpp_class_hierarchy_implementers | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
The classes that directly implement the interface.
| char ** dexpp_class_hierarchy_all_supertypes | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
Every ancestor class and interface; the class itself is not included.
| char ** dexpp_class_hierarchy_all_descendants | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
Everything below the class, through extends and implements; the class itself is not included.
| int dexpp_class_hierarchy_is_subtype_of | ( | const DexppClassHierarchy * | h, |
| const char * | sub, | ||
| const char * | super | ||
| ) |
1 when sub is super or has it among its ancestors.
| int dexpp_class_hierarchy_is_loaded | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor | ||
| ) |
1 when the class is defined in a loaded file.
| int dexpp_class_hierarchy_is_interface | ( | const DexppClassHierarchy * | h, |
| const char * | descriptor | ||
| ) |
1 when the class is loaded and is an interface.
| int dexpp_class_hierarchy_empty | ( | const DexppClassHierarchy * | h | ) |
1 when the hierarchy has no classes.
| void dexpp_class_hierarchy_free | ( | DexppClassHierarchy * | h | ) |
Free a class-hierarchy handle.
Accepts NULL.
| size_t dexpp_xrefs_referrer_count | ( | const DexppXrefs * | x | ) |
Number of referrers: methods that contain an indexed instruction.
| DexppMethodId * dexpp_xrefs_referrers | ( | const DexppXrefs * | x, |
| size_t * | count | ||
| ) |
The identity of every referrer, in index order.
Free with dexpp_method_id_array_free().
| int dexpp_xrefs_referrer_id | ( | const DexppXrefs * | x, |
| uint32_t | referrer, | ||
| DexppMethodId * | out | ||
| ) |
Fill out with the identity of one referrer (release with dexpp_method_id_clear()).
Returns 0 when referrer is out of range.
| DexppMethod * dexpp_xrefs_referrer_method | ( | const DexppXrefs * | x, |
| uint32_t | referrer | ||
| ) |
The method of one referrer, or NULL when referrer is out of range.
Free with dexpp_method_free().
| DexppMethodXref * dexpp_xrefs_method_refs | ( | const DexppXrefs * | x, |
| const char * | class_descriptor, | ||
| const char * | name, | ||
| const char * | proto, | ||
| size_t * | count | ||
| ) |
The call sites whose target, as the bytecode names it, is exactly this method.
Free with dexpp_method_xref_array_free().
| DexppMethodRefGroup * dexpp_xrefs_method_refs_by_name | ( | const DexppXrefs * | x, |
| const char * | name, | ||
| size_t * | count | ||
| ) |
The call sites of every method with this name, in any class and with any prototype, grouped by called method.
Free with dexpp_method_ref_group_array_free().
| DexppFieldXref * dexpp_xrefs_field_refs | ( | const DexppXrefs * | x, |
| const char * | class_descriptor, | ||
| const char * | name, | ||
| const char * | type, | ||
| size_t * | count | ||
| ) |
Every read and write of this field.
Free with dexpp_field_xref_array_free().
| DexppFieldXref * dexpp_xrefs_field_reads | ( | const DexppXrefs * | x, |
| const char * | class_descriptor, | ||
| const char * | name, | ||
| const char * | type, | ||
| size_t * | count | ||
| ) |
Only the reads of this field.
| DexppFieldXref * dexpp_xrefs_field_writes | ( | const DexppXrefs * | x, |
| const char * | class_descriptor, | ||
| const char * | name, | ||
| const char * | type, | ||
| size_t * | count | ||
| ) |
Only the writes of this field.
| DexppStringXref * dexpp_xrefs_string_refs | ( | const DexppXrefs * | x, |
| const char * | value, | ||
| size_t | length, | ||
| size_t * | count | ||
| ) |
The const-string instructions that load exactly this string, given as length bytes (it may contain NUL bytes).
Free with dexpp_string_xref_array_free().
| DexppText * dexpp_xrefs_referenced_strings | ( | const DexppXrefs * | x, |
| size_t * | count | ||
| ) |
Every distinct string that some const-string instruction loads.
Free with dexpp_text_array_free().
| DexppTypeXref * dexpp_xrefs_type_refs | ( | const DexppXrefs * | x, |
| const char * | descriptor, | ||
| size_t * | count | ||
| ) |
The instructions that name this type.
Free with dexpp_type_xref_array_free().
| int dexpp_xrefs_empty | ( | const DexppXrefs * | x | ) |
1 when nothing is indexed.
| void dexpp_xrefs_free | ( | DexppXrefs * | x | ) |
Free a cross-reference handle.
Accepts NULL.
| void dexpp_method_xref_array_free | ( | DexppMethodXref * | xrefs, |
| size_t | count | ||
| ) |
Free an array of DexppMethodXref.
Accepts NULL.
| void dexpp_method_ref_group_array_free | ( | DexppMethodRefGroup * | groups, |
| size_t | count | ||
| ) |
Free an array of DexppMethodRefGroup and their sites.
Accepts NULL.
| void dexpp_field_xref_array_free | ( | DexppFieldXref * | xrefs, |
| size_t | count | ||
| ) |
Free an array of DexppFieldXref.
Accepts NULL.
| void dexpp_string_xref_array_free | ( | DexppStringXref * | xrefs, |
| size_t | count | ||
| ) |
Free an array of DexppStringXref.
Accepts NULL.
| void dexpp_type_xref_array_free | ( | DexppTypeXref * | xrefs, |
| size_t | count | ||
| ) |
Free an array of DexppTypeXref.
Accepts NULL.
| DexppApk * dexpp_apk_open | ( | const char * | path, |
| DexppError ** | err | ||
| ) |
Open an APK file.
Errors: FILE_NOT_FOUND, CANNOT_READ, INVALID_APK.
| DexppApk * dexpp_apk_open_buffer | ( | const uint8_t * | bytes, |
| size_t | len, | ||
| const char * | label, | ||
| DexppError ** | err | ||
| ) |
Open an APK from its bytes in memory, for example bytes received over the network.
The len bytes at bytes are copied, so the caller may free them as soon as this returns. They get the same checks as a file given to dexpp_apk_open(), and the APK handle then works the same.
label names the bytes at the start of error messages, where dexpp_apk_open() puts the path, and is also used by the errors of dexpp_apk_analysis(); NULL gives "<apk>". bytes may be NULL when len is 0 (no bytes are not an APK, so this fails with INVALID_APK); NULL with a nonzero len also fails with INVALID_APK. Errors: INVALID_APK.
| void dexpp_apk_free | ( | DexppApk * | apk | ) |
Free an APK handle.
Accepts NULL.
| char ** dexpp_apk_entries | ( | const DexppApk * | apk, |
| size_t * | count | ||
| ) |
The name of every archive entry.
Free with dexpp_string_array_free().
| int dexpp_apk_read | ( | const DexppApk * | apk, |
| const char * | name, | ||
| uint8_t ** | out, | ||
| size_t * | length | ||
| ) |
The uncompressed bytes of the entry name.
Returns 1 and sets out (free with dexpp_buffer_free(); NULL for an empty entry) and length when the entry exists; returns 0 when it does not.
| char * dexpp_apk_package | ( | const DexppApk * | apk | ) |
The manifest's package name, or NULL when there is no decodable manifest.
| int dexpp_apk_manifest | ( | const DexppApk * | apk, |
| DexppManifest * | out | ||
| ) |
Fill out with the decoded manifest.
Returns 0 when the APK has no manifest or it cannot be decoded (then out is untouched).
| void dexpp_manifest_clear | ( | DexppManifest * | manifest | ) |
Free everything a DexppManifest owns.
| int dexpp_apk_has_resources | ( | const DexppApk * | apk | ) |
1 when the APK has a decodable resources.arsc table.
| int dexpp_apk_resources_empty | ( | const DexppApk * | apk | ) |
1 when the APK has no resource table, or the table has no entries.
| int dexpp_apk_resource_name | ( | const DexppApk * | apk, |
| uint32_t | id, | ||
| DexppResourceName * | out | ||
| ) |
Fill out with the name of resource id (release with dexpp_resource_name_clear()).
Returns 0 when there is no such id.
| void dexpp_resource_name_clear | ( | DexppResourceName * | name | ) |
Free the strings of a DexppResourceName.
The value of string resource id: returns 1 and fills out (release with dexpp_text_clear()); returns 0 when the id is missing or its value is not a string.
A resource that refers to another resource is followed to the end.
| int dexpp_apk_resolve_bool | ( | const DexppApk * | apk, |
| uint32_t | id, | ||
| int * | out | ||
| ) |
The value of resource id as a boolean: a bool resource, or any integer-typed value (nonzero is true), as Android reads it.
Returns 1 and sets out to 1 or 0; returns 0 when there is no resource table, the id is missing, or its value is of another type, such as a string. A resource that refers to another resource is followed to the end.
| int dexpp_apk_resolve_int | ( | const DexppApk * | apk, |
| uint32_t | id, | ||
| int64_t * | out | ||
| ) |
The value of resource id as an integer: an integer resource, or any other integer-typed value, read as its signed 32-bit data.
Returns 1 and sets out; returns 0 when there is no resource table, the id is missing, or its value is of another type. A resource that refers to another resource is followed to the end.
| int dexpp_apk_resource_id | ( | const DexppApk * | apk, |
| const char * | type, | ||
| const char * | entry, | ||
| uint32_t * | out | ||
| ) |
The id of the resource with this type and entry name.
Returns 1 and sets out, or 0 when there is none.
| void dexpp_apk_signing | ( | const DexppApk * | apk, |
| DexppSigningInfo * | out | ||
| ) |
Fill out with the signature schemes and certificates (release with dexpp_signing_info_clear()).
An unsigned APK gives all zeros.
| void dexpp_signing_info_clear | ( | DexppSigningInfo * | info | ) |
Free everything a DexppSigningInfo owns.
| DexppContext * dexpp_apk_analysis | ( | const DexppApk * | apk, |
| uint32_t | threads, | ||
| DexppError ** | err | ||
| ) |
A code-analysis context over every classes*.dex of the APK, in multidex order, loaded from the bytes the APK handle already holds.
threads is as for dexpp_context_from_apk(): 0 lets the library choose, 1 keeps all work, the call graph included, on the calling thread.
The analysis is built on the first call and kept, one for each value of threads: a later call with the same value gives a new handle to the same analysis, so its call graph and other structures are built once. A call with another value builds a second analysis, which holds its own copy of the DEX files. So use one value in a program. Free the handle with dexpp_context_free(). Errors: INVALID_APK, INVALID_DEX.