|
dex++ 0.3.1
C++ and C API reference
|
Namespaces | |
| namespace | apk |
| APK-level entry point: package metadata that exists independently of the bytecode. | |
| namespace | axml |
| Parser for Android binary XML (AXML), the format of AndroidManifest.xml inside an APK. | |
| namespace | model |
| An editable, in-memory model of one DEX file. | |
Classes | |
| class | AnalysisContext |
| The entry point for analysis. More... | |
| struct | Annotation |
| A resolved annotation instance attached to a class, method, or field. More... | |
| struct | AnnotationElement |
One name = value pair of an annotation. More... | |
| struct | AnnotationValue |
| A fully resolved annotation element value. More... | |
| struct | ApkLoadOptions |
| How an APK's DEX files are loaded by AnalysisContext::from_apk / from_apk_buffer and by apk::Apk::analysis. More... | |
| struct | ArrayLengthInstruction |
array-length (0x21): the length of the array in array_reg. More... | |
| struct | ArrayOpInstruction |
| aget*, aput* (0x44–0x51). More... | |
| struct | BasicBlock |
| A maximal sequence of instructions with a single entry and a single normal exit. More... | |
| struct | BinaryLitInstruction |
| add-int/lit16, rsub-int, ..., ushr-int/lit8 (0xd0–0xe2). More... | |
| struct | BinaryOpInstruction |
| add-int, sub-int, ..., rem-double/2addr (0x90–0xcf). More... | |
| struct | CallEdge |
| A single call-site edge from one method to another. More... | |
| class | CallGraph |
| Whole-program call graph for an AnalysisContext. More... | |
| struct | CallNode |
| A node in the call graph: a defined method, an external method that defined code calls, or an invoke-custom call site (see CallNodeKind). More... | |
| struct | CatchHandler |
| One typed catch clause within a TryBlock. More... | |
| class | Cfg |
| Control-flow graph for a single method. More... | |
| struct | CfgEdge |
| A single outgoing edge from one basic block to another. More... | |
| class | Class |
| A lightweight handle to a single DEX class definition. More... | |
| class | ClassHierarchy |
| Whole-program inheritance and interface-implementation graph. More... | |
| class | ClassRef |
| A reference to a class by its type descriptor, which may or may not be defined in the loaded DEX files: the superclass, the interfaces and the declaring class of a member are ClassRefs, because they can name a class from outside the app, such as "Ljava/lang/Object;". More... | |
| struct | CompareInstruction |
| cmpl-float, cmpg-float, cmpl-double, cmpg-double, cmp-long (0x2d–0x31). More... | |
| struct | ConstClassInstruction |
| const-class (0x1c). More... | |
| struct | ConstInstruction |
| const/4 . More... | |
| struct | ConstMethodHandleInstruction |
| const-method-handle (0xfe): load a java.lang.invoke.MethodHandle. More... | |
| struct | ConstMethodTypeInstruction |
| const-method-type (0xff): load a java.lang.invoke.MethodType. More... | |
| struct | ConstStringInstruction |
| const-string, const-string/jumbo (0x1a–0x1b). More... | |
| struct | Error |
| Why a call failed. More... | |
| class | Field |
| A lightweight handle to a single DEX field. More... | |
| struct | FieldAccess |
| One field read or write in a method's body. More... | |
| struct | FieldId |
| Canonical, DEX-portable identity for a field reference. More... | |
| struct | FieldIdHash |
| Hash functor for FieldId; suitable for std::unordered_map / std::unordered_set. More... | |
| struct | FieldInstruction |
| iget*, iput*, sget*, sput* (0x52–0x6d). More... | |
| struct | FieldXref |
| One field-access instruction (iget* / iput* / sget* / sput*). More... | |
| struct | FillArrayInstruction |
| fill-array-data (0x26). More... | |
| struct | FilledNewArrayInstruction |
filled-new-array, filled-new-array/range (0x24–0x25): build an array of type_index from the element registers, like an invoke's argument list. More... | |
| struct | GotoInstruction |
| goto, goto/16, goto/32 (0x28–0x2a). More... | |
| struct | IfInstruction |
| if-eq . More... | |
| struct | IfZeroInstruction |
| if-eqz . More... | |
| struct | InstructionBase |
| Fields shared by every concrete instruction type. More... | |
| struct | InvalidInstruction |
| An opcode the Dalvik format does not use (0x3e–0x43, 0x73, 0x79–0x7a, 0xe3–0xf9), as found in a damaged or deliberately broken method. More... | |
| struct | InvokeCustomInstruction |
| invoke-custom, invoke-custom/range (0xfc–0xfd). More... | |
| struct | InvokeInstruction |
| invoke-virtual/super/direct/static/interface and their /range variants (0x6e–0x72, 0x74–0x78). More... | |
| struct | InvokePolymorphicInstruction |
| invoke-polymorphic, invoke-polymorphic/range (0xfa–0xfb): a call through a signature-polymorphic method such as MethodHandle.invokeExact. More... | |
| class | Method |
| A lightweight handle to a single DEX method. More... | |
| struct | MethodCall |
| One outgoing call site in a method's body. More... | |
| struct | MethodId |
| Canonical, DEX-portable identity for a method reference. More... | |
| struct | MethodIdHash |
| Hash functor for MethodId; suitable for std::unordered_map / std::unordered_set. More... | |
| struct | MethodXref |
| One invoke instruction referencing a method (by its declared target). More... | |
| struct | MonitorInstruction |
| monitor-enter, monitor-exit (0x1d–0x1e). More... | |
| struct | MoveInstruction |
| move, move-wide, move-object, move-result, move-exception (0x01–0x0d). More... | |
| struct | NopInstruction |
| nop (0x00). More... | |
| struct | ParameterRegister |
| An incoming parameter and the register that holds it on method entry. More... | |
| struct | Problem |
| One rule of the DEX format that a model breaks, and where. More... | |
| struct | ReturnInstruction |
| return-void, return, return-wide, return-object (0x0e–0x11). More... | |
| struct | StringLoad |
| One const-string load in a method's body. More... | |
| struct | StringXref |
| One string-loading instruction (const-string / const-string/jumbo). More... | |
| struct | SwitchCase |
| A single case of a packed-switch / sparse-switch payload. More... | |
| struct | SwitchInstruction |
| packed-switch, sparse-switch (0x2b–0x2c). More... | |
| struct | ThrowInstruction |
| throw (0x27). More... | |
| struct | TryBlock |
| A try region and its handlers, decoded from the method's code item. More... | |
| struct | TypeInstruction |
| check-cast, instance-of, new-instance, new-array (0x1f–0x23). More... | |
| struct | TypeUse |
| One type reference (const-class / check-cast / instance-of / new-instance / new-array / filled-new-array) in a method's body. More... | |
| struct | TypeXref |
| One type-referencing instruction (see TypeUseKind). More... | |
| struct | UnaryOpInstruction |
| neg-int, not-int, int-to-long, long-to-int, etc. More... | |
| class | Xrefs |
| Whole-program cross-reference index for an AnalysisContext. More... | |
Enumerations | |
| enum class | AccessFlags : uint32_t { Public = 0x0001 , Private = 0x0002 , Protected = 0x0004 , Static = 0x0008 , Final = 0x0010 , Synchronized = 0x0020 , Volatile = 0x0040 , Bridge = 0x0040 , Transient = 0x0080 , Varargs = 0x0080 , Native = 0x0100 , Interface = 0x0200 , Abstract = 0x0400 , Strict = 0x0800 , Synthetic = 0x1000 , Annotation = 0x2000 , Enum = 0x4000 , Constructor = 0x10000 , DeclaredSynchronized = 0x20000 } |
| Bitmask of DEX access flags, applicable to classes, methods, and fields. More... | |
| enum class | AnnotationVisibility : uint8_t { Build = 0x00 , Runtime = 0x01 , System = 0x02 } |
| Who can see an annotation at runtime, per the DEX visibility byte. More... | |
| enum class | ErrorCode : uint8_t { FileNotFound , CannotRead , CannotWrite , InvalidApk , InvalidDex , UnsupportedDex , InvalidModel , PoolOverflow , VersionTooLow , InvalidXml , InvalidResources } |
| What went wrong in a call that failed. More... | |
| enum class | InvokeKind : uint8_t { Virtual , Super , Direct , Static , Interface , Polymorphic , Custom } |
| Kind of invoke instruction at a call site, derived from the opcode. More... | |
| enum class | EdgeOrigin : uint8_t { Declared , InheritedResolution } |
| How an edge came to point at its callee. More... | |
| enum class | CallNodeKind : uint8_t { Defined , External , CallSite } |
| What a call-graph node stands for. More... | |
| enum class | CfgEdgeKind : uint8_t { Fallthrough , Goto , BranchTaken , BranchNotTaken , SwitchCase , SwitchDefault , Exception , ExceptionCatchAll } |
| Kind of edge between two basic blocks. More... | |
| enum class | OperandWidth : uint8_t { Single , Pair } |
| Distinguishes 32-bit (single-register) from 64-bit (register-pair) operands. More... | |
| enum class | TypeUseKind : uint8_t { ConstClass , CheckCast , InstanceOf , NewInstance , NewArray , FilledNewArray } |
| What a type-referencing instruction does with its type operand. More... | |
Functions | |
| AccessFlags | operator| (AccessFlags a, AccessFlags b) |
| AccessFlags | operator& (AccessFlags a, AccessFlags b) |
| bool | has_flag (AccessFlags flags, AccessFlags flag) |
Returns true if flag is set in flags. | |
| const InstructionBase & | base_of (const Instruction &insn) |
| Extract the common base fields without std::visit boilerplate. | |
| bool | is_terminator (const Instruction &insn) |
| Returns true for goto / if-* / switch / return / throw (basic block terminators). | |
| std::string_view | opcode_name (uint8_t opcode) |
| Mnemonic for a raw Dalvik opcode byte (e.g. 0x6e -> "invoke-virtual"). | |
| std::string | to_string (const Instruction &insn) |
| Render one decoded instruction as "<mnemonic> <operands>" (no leading code offset). | |
| std::vector< Instruction > | decode_instructions (std::span< const uint16_t > insns) |
| Decode a raw insns[] array (16-bit code units) into typed instructions. | |
A single decoded Dalvik instruction.
|
strong |
Bitmask of DEX access flags, applicable to classes, methods, and fields.
Values mirror the DEX specification (JVMS §4.1, §4.6, §4.7 extended by the Android runtime for Annotation, Enum, Constructor, and DeclaredSynchronized).
|
strong |
|
strong |
What went wrong in a call that failed.
Every function of the library that can fail returns a std::expected with an Error, and Error::code is one of these. The names match the exceptions of the Python binding (InvalidDex is InvalidDexError) and the error codes of the C API (InvalidDex is DEXPP_ERROR_INVALID_DEX).
| Enumerator | |
|---|---|
| FileNotFound | The path does not exist. |
| CannotRead | The path exists but cannot be read: a directory, no permission, an I/O error. |
| CannotWrite | The file cannot be created or written: a missing folder, a directory, no permission, a full disk. |
| InvalidApk | Not a ZIP archive, a damaged entry, or an APK with no classes.dex. |
| InvalidDex | A DEX file that cannot be parsed. |
| UnsupportedDex | A DEX file the editable model does not read: a DEX 041 container or a big-endian file. |
| InvalidModel | A model breaks rules of the DEX format. Error::problems lists every rule it breaks. |
| PoolOverflow | Part of the DEX file to write would be bigger than the format can encode: a table with too many entries (more than 65535 types, for example), a method whose code is too long, or too many try ranges or exception handlers in one method. |
| VersionTooLow | A model uses a feature that its DEX version does not have. |
| InvalidXml | Not an Android binary XML document, or a damaged one (axml::parse). |
| InvalidResources | Not a compiled resource table (resources.arsc), or a damaged one (apk::ResourceTable::parse). |
|
strong |
Kind of invoke instruction at a call site, derived from the opcode.
|
strong |
How an edge came to point at its callee.
|
strong |
What a call-graph node stands for.
| Enumerator | |
|---|---|
| Defined | A method defined in a loaded DEX file. CallGraph::method_for() gives its Method. |
| External | A method that loaded code calls but no loaded DEX file defines, such as a framework method. |
| CallSite | An invoke-custom call site: the target is chosen at runtime by the call site's bootstrap method, so the node is the call site itself. Its |
|
strong |
Kind of edge between two basic blocks.
| Enumerator | |
|---|---|
| Fallthrough | Straight-line continuation; only when the predecessor's last instruction is not a terminator. |
| Goto | Unconditional goto / goto/16 / goto/32. |
| BranchTaken | if-* / if-*z taken edge. |
| BranchNotTaken | if-* / if-*z fall-through edge. |
| SwitchCase | Outgoing edge for one packed/sparse case; CfgEdge::case_key is its key. |
| SwitchDefault | Outgoing edge for switch fall-through (the "default" case). |
| Exception | try-region → handler of one exception class; CfgEdge::catch_type names it. |
| ExceptionCatchAll | try-region → handler that catches every exception (a catch-all, as Java compiles |
|
strong |
|
strong |
What a type-referencing instruction does with its type operand.
|
inline |
|
inline |
|
inline |
Returns true if flag is set in flags.
|
inline |
Extract the common base fields without std::visit boilerplate.
| bool dex::is_terminator | ( | const Instruction & | insn | ) |
Returns true for goto / if-* / switch / return / throw (basic block terminators).
| std::string_view dex::opcode_name | ( | uint8_t | opcode | ) |
Mnemonic for a raw Dalvik opcode byte (e.g. 0x6e -> "invoke-virtual").
Unused / reserved opcodes return "unused-XX". Always a valid, static view.
| std::string dex::to_string | ( | const Instruction & | insn | ) |
Render one decoded instruction as "<mnemonic> <operands>" (no leading code offset).
Constant-pool operands appear as raw indices — string@N, type@N, method@N, field@N, proto@N, method_handle@N, site@N — because this function has no AnalysisContext to resolve them; use the analysis layer when you need resolved names.
| std::vector< Instruction > dex::decode_instructions | ( | std::span< const uint16_t > | insns | ) |
Decode a raw insns[] array (16-bit code units) into typed instructions.
Payload pseudo-instructions (packed-switch/sparse-switch/fill-array-data data blocks) are detected and skipped — they do not appear in the result. An unused opcode becomes an InvalidInstruction one code unit long.
| insns | Raw code units from CodeItem::insns. |