dexpp 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. dexpp-0.2.0/.clang-format +26 -0
  2. dexpp-0.2.0/.gitignore +53 -0
  3. dexpp-0.2.0/CHANGELOG.md +170 -0
  4. dexpp-0.2.0/CMakeLists.txt +160 -0
  5. dexpp-0.2.0/LICENSE +201 -0
  6. dexpp-0.2.0/PKG-INFO +142 -0
  7. dexpp-0.2.0/README.md +119 -0
  8. dexpp-0.2.0/bindings/c/dexpp.h +111 -0
  9. dexpp-0.2.0/bindings/c/dexpp_c.cpp +269 -0
  10. dexpp-0.2.0/bindings/c/dexpp_model.cpp +310 -0
  11. dexpp-0.2.0/bindings/c/dexpp_model.h +190 -0
  12. dexpp-0.2.0/bindings/go/README.md +111 -0
  13. dexpp-0.2.0/bindings/go/dexpp/dexpp.go +329 -0
  14. dexpp-0.2.0/bindings/go/dexpp/dexpp_test.go +102 -0
  15. dexpp-0.2.0/bindings/go/dexpp/model.go +336 -0
  16. dexpp-0.2.0/bindings/go/dexpp/model_test.go +260 -0
  17. dexpp-0.2.0/bindings/go/example/main.go +55 -0
  18. dexpp-0.2.0/bindings/go/go.mod +3 -0
  19. dexpp-0.2.0/bindings/python/dexpp.pyi +897 -0
  20. dexpp-0.2.0/bindings/python/dexpp_model_py.cpp +304 -0
  21. dexpp-0.2.0/bindings/python/dexpp_module.cpp +1187 -0
  22. dexpp-0.2.0/bindings/python/test_androguard_parity.py +608 -0
  23. dexpp-0.2.0/bindings/python/test_dexpp.py +685 -0
  24. dexpp-0.2.0/pyproject.toml +57 -0
  25. dexpp-0.2.0/src/analysis/access_flags.hpp +5 -0
  26. dexpp-0.2.0/src/analysis/analysis_context.cpp +703 -0
  27. dexpp-0.2.0/src/analysis/analysis_context.hpp +121 -0
  28. dexpp-0.2.0/src/analysis/analysis_context_impl.hpp +174 -0
  29. dexpp-0.2.0/src/analysis/analysis_error.hpp +24 -0
  30. dexpp-0.2.0/src/analysis/annotations.cpp +130 -0
  31. dexpp-0.2.0/src/analysis/annotations.hpp +103 -0
  32. dexpp-0.2.0/src/analysis/call_graph.cpp +1068 -0
  33. dexpp-0.2.0/src/analysis/call_graph.hpp +224 -0
  34. dexpp-0.2.0/src/analysis/cfg.cpp +258 -0
  35. dexpp-0.2.0/src/analysis/cfg.hpp +87 -0
  36. dexpp-0.2.0/src/analysis/class.cpp +130 -0
  37. dexpp-0.2.0/src/analysis/class.hpp +83 -0
  38. dexpp-0.2.0/src/analysis/class_fwd.hpp +5 -0
  39. dexpp-0.2.0/src/analysis/class_hierarchy.cpp +233 -0
  40. dexpp-0.2.0/src/analysis/class_hierarchy.hpp +127 -0
  41. dexpp-0.2.0/src/analysis/class_ref.cpp +37 -0
  42. dexpp-0.2.0/src/analysis/class_ref.hpp +54 -0
  43. dexpp-0.2.0/src/analysis/field.cpp +103 -0
  44. dexpp-0.2.0/src/analysis/field.hpp +64 -0
  45. dexpp-0.2.0/src/analysis/instruction.cpp +657 -0
  46. dexpp-0.2.0/src/analysis/instruction.hpp +284 -0
  47. dexpp-0.2.0/src/analysis/invoke_sites.hpp +27 -0
  48. dexpp-0.2.0/src/analysis/method.cpp +231 -0
  49. dexpp-0.2.0/src/analysis/method.hpp +173 -0
  50. dexpp-0.2.0/src/analysis/type_descriptor.cpp +43 -0
  51. dexpp-0.2.0/src/analysis/type_descriptor.hpp +49 -0
  52. dexpp-0.2.0/src/analysis/xrefs.cpp +212 -0
  53. dexpp-0.2.0/src/analysis/xrefs.hpp +196 -0
  54. dexpp-0.2.0/src/apk/apk.cpp +131 -0
  55. dexpp-0.2.0/src/apk/apk.hpp +71 -0
  56. dexpp-0.2.0/src/apk/axml.cpp +118 -0
  57. dexpp-0.2.0/src/apk/axml.hpp +131 -0
  58. dexpp-0.2.0/src/apk/manifest.cpp +181 -0
  59. dexpp-0.2.0/src/apk/manifest.hpp +131 -0
  60. dexpp-0.2.0/src/apk/resources.cpp +255 -0
  61. dexpp-0.2.0/src/apk/resources.hpp +86 -0
  62. dexpp-0.2.0/src/apk/signing.cpp +379 -0
  63. dexpp-0.2.0/src/apk/signing.hpp +52 -0
  64. dexpp-0.2.0/src/apk/string_pool.cpp +133 -0
  65. dexpp-0.2.0/src/apk/string_pool.hpp +48 -0
  66. dexpp-0.2.0/src/common/access_flags.hpp +48 -0
  67. dexpp-0.2.0/src/common/annotation_visibility.hpp +14 -0
  68. dexpp-0.2.0/src/common/ids.cpp +33 -0
  69. dexpp-0.2.0/src/common/ids.hpp +52 -0
  70. dexpp-0.2.0/src/dex.hpp +33 -0
  71. dexpp-0.2.0/src/main.cpp +42 -0
  72. dexpp-0.2.0/src/model/io.hpp +141 -0
  73. dexpp-0.2.0/src/model/model.hpp +7 -0
  74. dexpp-0.2.0/src/model/read.cpp +967 -0
  75. dexpp-0.2.0/src/model/rename.cpp +531 -0
  76. dexpp-0.2.0/src/model/rules.hpp +96 -0
  77. dexpp-0.2.0/src/model/types.cpp +154 -0
  78. dexpp-0.2.0/src/model/types.hpp +884 -0
  79. dexpp-0.2.0/src/model/validate.cpp +876 -0
  80. dexpp-0.2.0/src/model/write.cpp +2322 -0
  81. dexpp-0.2.0/src/raw/byte_writer.hpp +76 -0
  82. dexpp-0.2.0/src/raw/constants.hpp +42 -0
  83. dexpp-0.2.0/src/raw/descriptors.cpp +269 -0
  84. dexpp-0.2.0/src/raw/descriptors.hpp +78 -0
  85. dexpp-0.2.0/src/raw/digest.cpp +154 -0
  86. dexpp-0.2.0/src/raw/digest.hpp +16 -0
  87. dexpp-0.2.0/src/raw/error.cpp +33 -0
  88. dexpp-0.2.0/src/raw/error.hpp +41 -0
  89. dexpp-0.2.0/src/raw/mutf8.cpp +329 -0
  90. dexpp-0.2.0/src/raw/mutf8.hpp +69 -0
  91. dexpp-0.2.0/src/raw/opcodes.cpp +657 -0
  92. dexpp-0.2.0/src/raw/opcodes.hpp +138 -0
  93. dexpp-0.2.0/src/raw/parser.cpp +1154 -0
  94. dexpp-0.2.0/src/raw/parser.hpp +150 -0
  95. dexpp-0.2.0/src/raw/parsing_utils.cpp +187 -0
  96. dexpp-0.2.0/src/raw/parsing_utils.hpp +76 -0
  97. dexpp-0.2.0/src/raw/types.cpp +62 -0
  98. dexpp-0.2.0/src/raw/types.hpp +468 -0
  99. dexpp-0.2.0/src/raw/zip.cpp +240 -0
  100. dexpp-0.2.0/src/raw/zip.hpp +58 -0
  101. dexpp-0.2.0/src/version.hpp +12 -0
@@ -0,0 +1,26 @@
1
+ BasedOnStyle: LLVM
2
+
3
+ IndentWidth: 4
4
+ TabWidth: 4
5
+ UseTab: Never
6
+
7
+ BreakBeforeBraces: Custom
8
+ BraceWrapping:
9
+ AfterClass: true
10
+ AfterControlStatement: false
11
+ AfterFunction: true
12
+ AfterNamespace: false
13
+ AfterStruct: true
14
+ AfterUnion: true
15
+ BeforeCatch: true
16
+ BeforeElse: true
17
+
18
+ AlignAfterOpenBracket: Align
19
+ AlignConsecutiveAssignments: false
20
+ AlignConsecutiveDeclarations: false
21
+
22
+ ColumnLimit: 100
23
+
24
+ ReflowComments: true
25
+
26
+ InsertNewlineAtEOF: true
dexpp-0.2.0/.gitignore ADDED
@@ -0,0 +1,53 @@
1
+ # IDE files
2
+ .idea/
3
+ *.iml
4
+ *.ipr
5
+ *.iws
6
+
7
+ # Build directories
8
+ build/
9
+ build-*/
10
+ cmake-build-debug/
11
+ cmake-build-release/
12
+
13
+ # Compiled output
14
+ *.o
15
+ *.obj
16
+ *.exe
17
+ *.out
18
+ *.app
19
+
20
+ # CMake
21
+ CMakeCache.txt
22
+ CMakeFiles/
23
+ cmake_install.cmake
24
+ Makefile
25
+ compile_commands.json
26
+ CTestTestfile.cmake
27
+ _deps/
28
+
29
+ # Local files
30
+ .local/
31
+
32
+ # OS files
33
+ .DS_Store
34
+ Thumbs.db
35
+
36
+ # Backup files
37
+ *~
38
+ *.bak
39
+ *.swp
40
+ *.swo
41
+
42
+ # Locally generated benchmark APK (not a test fixture)
43
+ tests/data/bench.apk
44
+
45
+ # Python packaging
46
+ *.egg-info/
47
+ dist/
48
+ wheelhouse/
49
+ __pycache__/
50
+
51
+ # Stray build artifacts
52
+ TestDex.class
53
+ cmake_test_discovery_*.json
@@ -0,0 +1,170 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ ### Editable DEX model (new)
6
+
7
+ `dex::model` (include `model/model.hpp`, or `dex.hpp`) reads a DEX file into
8
+ plain C++ structs, lets you change them or build new ones from scratch, and
9
+ writes a valid DEX file again.
10
+
11
+ - The model holds no pool indices and no byte offsets. References are written
12
+ out in full (type descriptors, prototypes, `MethodId`, `FieldId`) and
13
+ branches point at labels. `write()` collects the references, sorts and
14
+ numbers the pools, and picks each instruction's encoding (`Const` becomes
15
+ `const/4`, `const/16`, `const/high16` or `const`; a branch grows to
16
+ `goto/16`, `goto/32`, or a reversed `if` around a `goto/32` when it does not
17
+ reach). So splitting a file, merging files, renaming classes and generating
18
+ code are ordinary edits followed by `write()`.
19
+ - `read()` / `read_file()`, `write()` / `write_file()`, `validate()` (the
20
+ rules of ART's DEX file verifier that apply, plus what the encoding needs),
21
+ `required_version()`, `pool_stats()` and `rename_types()` (every type
22
+ reference, including the class names inside generic signatures).
23
+ - Strings keep unpaired surrogates (as WTF-8), floats keep their exact bits,
24
+ and values keep their exact type (a `char` stays a `char`), so a file
25
+ survives a read and a write unchanged in meaning. Writing is deterministic,
26
+ and writing a re-read output gives the same bytes again.
27
+ - Checked on 776 DEX files from 253 real apps: all but one round-trip (the
28
+ exception is a corrupt file that ART also rejects), and ART's verifier
29
+ (through the SDK's `dexdump`) accepts every written file.
30
+ - Speed and memory on the largest of them (42 MB, 6.9M instructions): read in
31
+ 0.6 s, write in 1.6 s; the model takes about 15 times the file size.
32
+
33
+ From Python and Go, the model works a whole class at a time. Building or
34
+ editing a class instruction by instruction stays in C++.
35
+
36
+ - Python: `dexpp.Model` reads a DEX file (`Model.read`, `Model.read_file`) or
37
+ starts empty (`Model(version)`). It lists and inspects classes
38
+ (`class_descriptors`, `class_info`, `class_interfaces`), copies, moves and
39
+ removes whole classes between models (`copy_class`, `move_class`,
40
+ `remove_class`), renames types (`rename_types`), and checks and writes the
41
+ result (`validate`, `pool_stats`, `required_version`, `write`,
42
+ `write_file`). Errors raise `FileNotFoundError` or `ValueError`.
43
+ - C and Go: `bindings/c/dexpp_model.h` gives the same operations on an opaque
44
+ `DexppModelDex` handle, and the Go package wraps them as `Model`
45
+ (`ReadModel`, `ReadModelFile`, `NewModel`, `CopyClass`, `MoveClass`,
46
+ `RemoveClass`, `RenameTypes`, `Validate`, `PoolStats`, `Write`, ...).
47
+
48
+ ### Packaging
49
+
50
+ - dexpp is now on PyPI: `pip install dexpp`. The wheels are also still
51
+ attached to each GitHub release.
52
+ - dexpp now needs Python 3.14 or newer (breaking: 0.1.0 worked with 3.9 and
53
+ newer). The wheels are built for CPython 3.14 only.
54
+
55
+ ### Smaller changes
56
+
57
+ - `MethodId`, `FieldId` (and their hashes), `AccessFlags` and
58
+ `AnnotationVisibility` moved to `src/common/`, so the analysis layer and
59
+ the model share them. Their names and namespace are unchanged, and the old
60
+ headers still work. `AccessFlags` gained `Bridge` and `Varargs`.
61
+ - `dex::raw` gained what writing needs: one opcode table for all 256 opcodes
62
+ with an instruction decoder and encoder (`raw/opcodes.hpp`; the analysis
63
+ decoder now uses it too), lossless MUTF-8 decoding and encoding
64
+ (`raw/mutf8.hpp`), name and descriptor rules (`raw/descriptors.hpp`),
65
+ SHA-1 / SHA-256 (`raw/digest.hpp`, moved from APK signing), a debug-info
66
+ parser (`parse_debug_info`), and a byte writer (`raw/byte_writer.hpp`).
67
+ - `raw::parser::compute_signature` is now implemented. `verify_offsets`, which
68
+ was declared but never implemented, is removed.
69
+ - `compute_checksum` is several times faster.
70
+ - The raw parser no longer negates `INT32_MIN` (undefined behavior) when a
71
+ catch handler declares that size.
72
+
73
+ ### Call graph: virtual dispatch is stored once per method (breaking)
74
+
75
+ A virtual or interface call can reach every override of the called method in
76
+ the app. These possible targets depend only on the called method, but the
77
+ call graph used to store them again at every call site, as one edge per site
78
+ and per target. On large apps that came to tens or hundreds of millions of
79
+ edges, and on the largest (for example the Facebook APK, 164K classes) the
80
+ call graph ran out of memory.
81
+
82
+ They are now stored once per called method, and the graph is built with
83
+ integer ids instead of strings. It holds the same information, in far less
84
+ time and memory (building the call graph after loading the APK; peak memory
85
+ includes the loaded APK):
86
+
87
+ | App | Stored before | Stored now | Build time before → now | Peak memory before → now |
88
+ | --- | --- | --- | --- | --- |
89
+ | Facebook | 181M edges | 3.7M edges + 206K dispatch entries | ran out of memory → 0.54 s | over 10.9 GB → 1.05 GB |
90
+ | GitHub | 89M edges | 0.76M edges + 74K dispatch entries | 4.4 s → 0.13 s | 5.8 GB → 0.21 GB |
91
+ | Instagram | 89M edges | 2.3M edges + 168K dispatch entries | 8.0 s → 0.36 s | 5.9 GB → 0.68 GB |
92
+ | YouTube | 31M edges | 1.4M edges + 105K dispatch entries | 3.9 s → 0.23 s | 2.8 GB → 0.46 GB |
93
+
94
+ Building the call graph also no longer decodes every instruction into the
95
+ context's instruction cache, and no longer builds the class hierarchy.
96
+
97
+ For an app split over several large DEX files, part of the build runs on one
98
+ thread per DEX file. `ApkLoadOptions::threads` (Python: `from_apk(threads=...)`)
99
+ now also sets these threads: `1` keeps the whole build on the calling thread.
100
+ The result never depends on the number of threads.
101
+
102
+ API changes, in C++ (`dex::CallGraph`) and Python (`dexpp.CallGraph`):
103
+
104
+ - `edges()` holds one `Declared` edge per call site, plus the
105
+ `InheritedResolution` edge when there is one. `EdgeOrigin::ChaOverride`
106
+ (`EdgeOrigin.CHA_OVERRIDE`) is removed.
107
+ - `dispatch_targets(node)` lists the overrides a virtual or interface call to
108
+ that method may reach, and `dispatch_sources(node)` is the reverse.
109
+ `dispatch_targets(edge)` gives the targets that apply at one call site (empty
110
+ for super, direct and static calls). Python: `CallNode.dispatch_targets`,
111
+ `CallNode.dispatch_sources`, `CallEdge.dispatch_targets`.
112
+ - `callees(node)` and `callers(node)` list every method a method may call, or
113
+ be called by, with virtual dispatch included. Python: `CallNode.callees`,
114
+ `CallNode.callers`.
115
+ - `CallNode.outgoing` / `incoming` (and `out_edges` / `in_edges` in Python) no
116
+ longer include dispatch targets. Use `callees` / `callers` for those.
117
+ - The deprecated Python property `CallEdge.via_override` is removed.
118
+
119
+ ## 0.1.0 — first release
120
+
121
+ The first public release. The API is still alpha: it may change in later
122
+ 0.x releases.
123
+
124
+ ### APK metadata (`dex::apk` / `dexpp.Apk`)
125
+
126
+ - Archive listing and entry extraction (stored and deflate entries; no ZIP64).
127
+ - Binary `AndroidManifest.xml` decoding: package, version, SDK levels,
128
+ permissions, declared permissions and their protection levels, components
129
+ with their exported / intent-filter / permission attributes, launcher
130
+ activity, `debuggable`, `allowBackup`.
131
+ - `Component.is_reachable`: exported and not gated behind an app-declared
132
+ `signature` permission.
133
+ - `resources.arsc` decoding: string resolution, resource names, reverse
134
+ lookup.
135
+ - Signing scheme detection (v1, v2, v3/v3.1) and X.509 certificate details
136
+ with SHA-1 / SHA-256 fingerprints. Signatures are identified, not verified.
137
+
138
+ ### Code analysis (`dex` / `dexpp.AnalysisContext`)
139
+
140
+ - Load a single DEX, several DEX files, or every `classes*.dex` of an APK.
141
+ Loading is lazy: the file is memory-mapped and only what a query touches is
142
+ decoded. Multidex APKs are decompressed in parallel.
143
+ - Classes, methods, fields, access flags, annotations, and static field
144
+ initial values.
145
+ - Decoded bytecode with mnemonics, try/catch blocks, register frames, and a
146
+ control-flow graph per method.
147
+ - Per-method forward references: calls, field accesses, string loads, type
148
+ uses.
149
+ - Whole-program call graph with class-hierarchy-aware virtual dispatch, a
150
+ class hierarchy, and a cross-reference index (who calls / reads / writes /
151
+ loads what).
152
+
153
+ ### Python bindings
154
+
155
+ - One extension module with type stubs (`mypy` and `pyright`).
156
+ - The call graph, xrefs, and CFG tables are zero-copy views; call-graph nodes
157
+ and edges can be navigated directly.
158
+ - `dexpp.__version__`.
159
+
160
+ ### Packaging
161
+
162
+ - Prebuilt wheels for Linux x86_64 (glibc and musl), attached to the GitHub
163
+ release. The C++ library and the C / Go bindings are source-only
164
+ for now.
165
+ - No system dependencies: DEFLATE decoding uses libdeflate, compiled in.
166
+
167
+ ### Robustness
168
+
169
+ - The parsers are hardened against malformed and hostile input (bounds
170
+ checks, allocation limits against oversized counts and zip bombs).
@@ -0,0 +1,160 @@
1
+ cmake_minimum_required(VERSION 3.18)
2
+
3
+ # The version lives in src/version.hpp (shared with the Python package metadata).
4
+ file(STRINGS src/version.hpp DEXPP_VERSION_LINE REGEX "^#define DEXPP_VERSION \"")
5
+ string(REGEX REPLACE "^#define DEXPP_VERSION \"([^\"]+)\".*" "\\1" DEXPP_VERSION "${DEXPP_VERSION_LINE}")
6
+ project(dex++ VERSION ${DEXPP_VERSION})
7
+
8
+ set(CMAKE_CXX_STANDARD 23)
9
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
10
+
11
+ option(DEXPP_BUILD_PYTHON "Build the dexpp Python extension module" OFF)
12
+ option(DEXPP_BUILD_TESTS "Build the unit tests and demo CLI" ON)
13
+ option(DEXPP_BUILD_C "Build the C ABI shim (bindings/c, for Go/cgo and other FFI)" ON)
14
+ set(DEXPP_SANITIZE "" CACHE STRING
15
+ "Sanitizers to build everything with, e.g. 'address,undefined' (empty = off)")
16
+
17
+ # SKBUILD is set by scikit-build-core during `pip install` / wheel builds:
18
+ # build only the Python module there, no tests, demo CLI, or C shim.
19
+ if(SKBUILD)
20
+ set(DEXPP_BUILD_PYTHON ON)
21
+ set(DEXPP_BUILD_TESTS OFF)
22
+ set(DEXPP_BUILD_C OFF)
23
+ endif()
24
+
25
+ # Sanitizer instrumentation is applied directory-wide (before any target is
26
+ # declared) so the library and the fetched test frameworks are built
27
+ # consistently.
28
+ if(DEXPP_SANITIZE)
29
+ add_compile_options(-fsanitize=${DEXPP_SANITIZE}
30
+ -fno-sanitize-recover=all -fno-omit-frame-pointer -g)
31
+ add_link_options(-fsanitize=${DEXPP_SANITIZE})
32
+ endif()
33
+
34
+ include(FetchContent)
35
+
36
+ # libdeflate decompresses the APK's DEX entries. Its decompression sources are
37
+ # compiled straight into dexpp_core rather than linked as a separate library, so
38
+ # libdexpp_core.a stays self-contained: the Go static link and the Python wheel
39
+ # need no extra system library. SOURCE_SUBDIR points at a directory with no
40
+ # CMakeLists.txt so libdeflate's own build (and its targets) is never added.
41
+ FetchContent_Declare(
42
+ libdeflate
43
+ URL https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.26.tar.gz
44
+ URL_HASH SHA256=bba03fffc5538576213675ce6968fcff6ce2e67d82e4d5febea2d05f9f13cf85
45
+ SOURCE_SUBDIR not-a-cmake-project
46
+ )
47
+ FetchContent_MakeAvailable(libdeflate)
48
+ set(LIBDEFLATE_SOURCES
49
+ ${libdeflate_SOURCE_DIR}/lib/deflate_decompress.c
50
+ ${libdeflate_SOURCE_DIR}/lib/utils.c
51
+ ${libdeflate_SOURCE_DIR}/lib/x86/cpu_features.c
52
+ ${libdeflate_SOURCE_DIR}/lib/arm/cpu_features.c
53
+ )
54
+ set_source_files_properties(${LIBDEFLATE_SOURCES} PROPERTIES COMPILE_OPTIONS "-std=c11")
55
+
56
+ add_library(dexpp_core STATIC
57
+ src/common/ids.cpp
58
+ src/raw/error.cpp
59
+ src/raw/parser.cpp
60
+ src/raw/types.cpp
61
+ src/raw/parsing_utils.cpp
62
+ src/raw/zip.cpp
63
+ src/raw/mutf8.cpp
64
+ src/raw/descriptors.cpp
65
+ src/raw/digest.cpp
66
+ src/raw/opcodes.cpp
67
+ src/model/types.cpp
68
+ src/model/read.cpp
69
+ src/model/write.cpp
70
+ src/model/validate.cpp
71
+ src/model/rename.cpp
72
+ src/analysis/analysis_context.cpp
73
+ src/analysis/class.cpp
74
+ src/analysis/class_ref.cpp
75
+ src/analysis/method.cpp
76
+ src/analysis/field.cpp
77
+ src/analysis/type_descriptor.cpp
78
+ src/analysis/instruction.cpp
79
+ src/analysis/cfg.cpp
80
+ src/analysis/call_graph.cpp
81
+ src/analysis/class_hierarchy.cpp
82
+ src/analysis/xrefs.cpp
83
+ src/analysis/annotations.cpp
84
+ src/apk/string_pool.cpp
85
+ src/apk/axml.cpp
86
+ src/apk/resources.cpp
87
+ src/apk/manifest.cpp
88
+ src/apk/signing.cpp
89
+ src/apk/apk.cpp
90
+ ${LIBDEFLATE_SOURCES}
91
+ )
92
+
93
+ target_include_directories(dexpp_core PUBLIC src)
94
+ target_include_directories(dexpp_core PRIVATE ${libdeflate_SOURCE_DIR})
95
+ # Required for linking into the Python shared module.
96
+ set_target_properties(dexpp_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
97
+
98
+ # C ABI shim: a static library (libdexpp_c.a) exposing bindings/c/dexpp.h, for
99
+ # consumers that speak C rather than C++ (e.g. Go via cgo). Bundles dexpp_core.
100
+ if(DEXPP_BUILD_C)
101
+ add_library(dexpp_c STATIC bindings/c/dexpp_c.cpp bindings/c/dexpp_model.cpp)
102
+ target_include_directories(dexpp_c PUBLIC bindings/c)
103
+ target_link_libraries(dexpp_c PUBLIC dexpp_core)
104
+ set_target_properties(dexpp_c PROPERTIES POSITION_INDEPENDENT_CODE ON)
105
+ endif()
106
+
107
+ if(DEXPP_BUILD_TESTS)
108
+ FetchContent_Declare(
109
+ googletest
110
+ URL https://github.com/google/googletest/archive/52eb8108c5bdec04579160ae17225d66034bd723.zip
111
+ )
112
+ FetchContent_MakeAvailable(googletest)
113
+
114
+ add_executable(main_test
115
+ src/main.cpp
116
+ )
117
+
118
+ target_link_libraries(main_test PRIVATE dexpp_core)
119
+
120
+ enable_testing()
121
+
122
+ file(GLOB_RECURSE TEST_SOURCES
123
+ tests/*.cc
124
+ )
125
+
126
+ add_executable(unit_tests
127
+ ${TEST_SOURCES}
128
+ )
129
+
130
+ target_link_libraries(unit_tests
131
+ dexpp_core
132
+ GTest::gtest_main
133
+ )
134
+
135
+ include(GoogleTest)
136
+ gtest_discover_tests(unit_tests WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
137
+ endif()
138
+
139
+ if(DEXPP_BUILD_PYTHON)
140
+ FetchContent_Declare(
141
+ pybind11
142
+ URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.zip
143
+ )
144
+ FetchContent_MakeAvailable(pybind11)
145
+
146
+ pybind11_add_module(dexpp bindings/python/dexpp_module.cpp bindings/python/dexpp_model_py.cpp)
147
+ target_link_libraries(dexpp PRIVATE dexpp_core)
148
+
149
+ if(SKBUILD)
150
+ install(TARGETS dexpp DESTINATION .)
151
+ # Both stub layouts: a sibling .pyi (pyright) and a PEP 561 stub-only
152
+ # package (mypy).
153
+ install(FILES bindings/python/dexpp.pyi DESTINATION .)
154
+ install(FILES bindings/python/dexpp.pyi DESTINATION dexpp-stubs RENAME __init__.pyi)
155
+ # libdeflate is built into the module; its MIT license ships in the
156
+ # wheel's .dist-info/licenses directory.
157
+ install(FILES ${libdeflate_SOURCE_DIR}/COPYING
158
+ DESTINATION ${SKBUILD_METADATA_DIR}/licenses RENAME libdeflate-COPYING)
159
+ endif()
160
+ endif()
dexpp-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.