capacitor-dex-editor 0.0.68 → 0.0.70

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 (40) hide show
  1. package/android/build.gradle +22 -0
  2. package/android/src/main/cpp/CMakeLists.txt +57 -0
  3. package/android/src/main/cpp/apk/apk_handler.cpp +121 -0
  4. package/android/src/main/cpp/apk/zip_utils.cpp +425 -0
  5. package/android/src/main/cpp/arsc/arsc_parser.cpp +390 -0
  6. package/android/src/main/cpp/dex/dex_builder.cpp +752 -0
  7. package/android/src/main/cpp/dex/dex_parser.cpp +620 -0
  8. package/android/src/main/cpp/dex/smali_disasm.cpp +1223 -0
  9. package/android/src/main/cpp/dex/smali_to_java.cpp +576 -0
  10. package/android/src/main/cpp/include/apk/apk_handler.h +41 -0
  11. package/android/src/main/cpp/include/apk/zip_utils.h +57 -0
  12. package/android/src/main/cpp/include/arsc/arsc_parser.h +98 -0
  13. package/android/src/main/cpp/include/dex/dex_builder.h +189 -0
  14. package/android/src/main/cpp/include/dex/dex_parser.h +137 -0
  15. package/android/src/main/cpp/include/dex/smali_disasm.h +127 -0
  16. package/android/src/main/cpp/include/dex/smali_to_java.h +50 -0
  17. package/android/src/main/cpp/include/xml/android_resources.h +495 -0
  18. package/android/src/main/cpp/include/xml/axml_parser.h +147 -0
  19. package/android/src/main/cpp/jni_bridge.cpp +872 -0
  20. package/android/src/main/cpp/third_party/miniz.c +646 -0
  21. package/android/src/main/cpp/third_party/miniz.h +605 -0
  22. package/android/src/main/cpp/third_party/miniz_common.h +97 -0
  23. package/android/src/main/cpp/third_party/miniz_export.h +6 -0
  24. package/android/src/main/cpp/third_party/miniz_tdef.c +1597 -0
  25. package/android/src/main/cpp/third_party/miniz_tdef.h +199 -0
  26. package/android/src/main/cpp/third_party/miniz_tinfl.c +770 -0
  27. package/android/src/main/cpp/third_party/miniz_tinfl.h +150 -0
  28. package/android/src/main/cpp/third_party/miniz_zip.c +4895 -0
  29. package/android/src/main/cpp/third_party/miniz_zip.h +454 -0
  30. package/android/src/main/cpp/third_party/nlohmann_json/CMakeLists.txt +0 -0
  31. package/android/src/main/cpp/third_party/nlohmann_json/single_include/nlohmann/json.hpp +24765 -0
  32. package/android/src/main/cpp/xml/axml_parser.cpp +1701 -0
  33. package/android/src/main/java/com/aetherlink/dexeditor/CppDex.java +295 -0
  34. package/android/src/main/java/com/aetherlink/dexeditor/DexManager.java +20 -20
  35. package/package.json +1 -1
  36. package/android/src/main/java/com/aetherlink/dexeditor/RustDex.java +0 -108
  37. package/android/src/main/jniLibs/arm64-v8a/libdex_rust.so +0 -0
  38. package/android/src/main/jniLibs/armeabi-v7a/libdex_rust.so +0 -0
  39. package/android/src/main/jniLibs/x86/libdex_rust.so +0 -0
  40. package/android/src/main/jniLibs/x86_64/libdex_rust.so +0 -0
@@ -0,0 +1,199 @@
1
+ #pragma once
2
+ #include "miniz_common.h"
3
+
4
+ #ifndef MINIZ_NO_DEFLATE_APIS
5
+
6
+ #ifdef __cplusplus
7
+ extern "C"
8
+ {
9
+ #endif
10
+ /* ------------------- Low-level Compression API Definitions */
11
+
12
+ /* Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). */
13
+ #ifndef TDEFL_LESS_MEMORY
14
+ #define TDEFL_LESS_MEMORY 0
15
+ #endif
16
+
17
+ /* tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): */
18
+ /* TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). */
19
+ enum
20
+ {
21
+ TDEFL_HUFFMAN_ONLY = 0,
22
+ TDEFL_DEFAULT_MAX_PROBES = 128,
23
+ TDEFL_MAX_PROBES_MASK = 0xFFF
24
+ };
25
+
26
+ /* TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. */
27
+ /* TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). */
28
+ /* TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. */
29
+ /* TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). */
30
+ /* TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) */
31
+ /* TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. */
32
+ /* TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. */
33
+ /* TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. */
34
+ /* The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). */
35
+ enum
36
+ {
37
+ TDEFL_WRITE_ZLIB_HEADER = 0x01000,
38
+ TDEFL_COMPUTE_ADLER32 = 0x02000,
39
+ TDEFL_GREEDY_PARSING_FLAG = 0x04000,
40
+ TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,
41
+ TDEFL_RLE_MATCHES = 0x10000,
42
+ TDEFL_FILTER_MATCHES = 0x20000,
43
+ TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,
44
+ TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
45
+ };
46
+
47
+ /* High level compression functions: */
48
+ /* tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). */
49
+ /* On entry: */
50
+ /* pSrc_buf, src_buf_len: Pointer and size of source block to compress. */
51
+ /* flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. */
52
+ /* On return: */
53
+ /* Function returns a pointer to the compressed data, or NULL on failure. */
54
+ /* *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */
55
+ /* The caller must free() the returned block when it's no longer needed. */
56
+ MINIZ_EXPORT void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
57
+
58
+ /* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */
59
+ /* Returns 0 on failure. */
60
+ MINIZ_EXPORT size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
61
+
62
+ /* Compresses an image to a compressed PNG file in memory. */
63
+ /* On entry: */
64
+ /* pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. */
65
+ /* The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. */
66
+ /* level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL */
67
+ /* If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). */
68
+ /* On return: */
69
+ /* Function returns a pointer to the compressed data, or NULL on failure. */
70
+ /* *pLen_out will be set to the size of the PNG image file. */
71
+ /* The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */
72
+ MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
73
+ MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
74
+
75
+ /* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */
76
+ typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
77
+
78
+ /* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */
79
+ MINIZ_EXPORT mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
80
+
81
+ enum
82
+ {
83
+ TDEFL_MAX_HUFF_TABLES = 3,
84
+ TDEFL_MAX_HUFF_SYMBOLS_0 = 288,
85
+ TDEFL_MAX_HUFF_SYMBOLS_1 = 32,
86
+ TDEFL_MAX_HUFF_SYMBOLS_2 = 19,
87
+ TDEFL_LZ_DICT_SIZE = 32768,
88
+ TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1,
89
+ TDEFL_MIN_MATCH_LEN = 3,
90
+ TDEFL_MAX_MATCH_LEN = 258
91
+ };
92
+
93
+ /* TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). */
94
+ #if TDEFL_LESS_MEMORY
95
+ enum
96
+ {
97
+ TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024,
98
+ TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10,
99
+ TDEFL_MAX_HUFF_SYMBOLS = 288,
100
+ TDEFL_LZ_HASH_BITS = 12,
101
+ TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
102
+ TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
103
+ TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
104
+ };
105
+ #else
106
+ enum
107
+ {
108
+ TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024,
109
+ TDEFL_OUT_BUF_SIZE = (mz_uint)((TDEFL_LZ_CODE_BUF_SIZE * 13) / 10),
110
+ TDEFL_MAX_HUFF_SYMBOLS = 288,
111
+ TDEFL_LZ_HASH_BITS = 15,
112
+ TDEFL_LEVEL1_HASH_SIZE_MASK = 4095,
113
+ TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3,
114
+ TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS
115
+ };
116
+ #endif
117
+
118
+ /* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */
119
+ typedef enum
120
+ {
121
+ TDEFL_STATUS_BAD_PARAM = -2,
122
+ TDEFL_STATUS_PUT_BUF_FAILED = -1,
123
+ TDEFL_STATUS_OKAY = 0,
124
+ TDEFL_STATUS_DONE = 1
125
+ } tdefl_status;
126
+
127
+ /* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */
128
+ typedef enum
129
+ {
130
+ TDEFL_NO_FLUSH = 0,
131
+ TDEFL_SYNC_FLUSH = 2,
132
+ TDEFL_FULL_FLUSH = 3,
133
+ TDEFL_FINISH = 4
134
+ } tdefl_flush;
135
+
136
+ /* tdefl's compression state structure. */
137
+ typedef struct
138
+ {
139
+ tdefl_put_buf_func_ptr m_pPut_buf_func;
140
+ void *m_pPut_buf_user;
141
+ mz_uint m_flags, m_max_probes[2];
142
+ int m_greedy_parsing;
143
+ mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;
144
+ mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;
145
+ mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer;
146
+ mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish;
147
+ tdefl_status m_prev_return_status;
148
+ const void *m_pIn_buf;
149
+ void *m_pOut_buf;
150
+ size_t *m_pIn_buf_size, *m_pOut_buf_size;
151
+ tdefl_flush m_flush;
152
+ const mz_uint8 *m_pSrc;
153
+ size_t m_src_buf_left, m_out_buf_ofs;
154
+ mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];
155
+ mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
156
+ mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
157
+ mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
158
+ mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];
159
+ mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];
160
+ mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];
161
+ mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
162
+ } tdefl_compressor;
163
+
164
+ /* Initializes the compressor. */
165
+ /* There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. */
166
+ /* pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. */
167
+ /* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */
168
+ /* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */
169
+ MINIZ_EXPORT tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
170
+
171
+ /* Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. */
172
+ MINIZ_EXPORT tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
173
+
174
+ /* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */
175
+ /* tdefl_compress_buffer() always consumes the entire input buffer. */
176
+ MINIZ_EXPORT tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
177
+
178
+ MINIZ_EXPORT tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
179
+ MINIZ_EXPORT mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
180
+
181
+ /* Create tdefl_compress() flags given zlib-style compression parameters. */
182
+ /* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */
183
+ /* window_bits may be -15 (raw deflate) or 15 (zlib) */
184
+ /* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */
185
+ MINIZ_EXPORT mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
186
+
187
+ #ifndef MINIZ_NO_MALLOC
188
+ /* Allocate the tdefl_compressor structure in C so that */
189
+ /* non-C language bindings to tdefl_ API don't need to worry about */
190
+ /* structure size and allocation mechanism. */
191
+ MINIZ_EXPORT tdefl_compressor *tdefl_compressor_alloc(void);
192
+ MINIZ_EXPORT void tdefl_compressor_free(tdefl_compressor *pComp);
193
+ #endif
194
+
195
+ #ifdef __cplusplus
196
+ }
197
+ #endif
198
+
199
+ #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/