$ show LuckyPray/DexKit
DexKit is a high-performance C++ library for runtime parsing and querying of Android DEX bytecode, primarily used by Xposed module developers to locate obfuscated classes, methods, and fields. It provides a rich DSL in Kotlin/Java for constructing structural queries based on annotations, opcodes, string usage, field/method references, and more. The core engine parses DEX files from APK archives, builds in-memory indexes, and uses algorithms like Aho-Corasick for substring matching and the Hungarian algorithm for unordered set matching. Communication between the native C++ layer and JVM is handled via FlatBuffers serialization. The library also includes an optional caching layer (`DexKitCacheBridge`) for persisting query results across app restarts. It is distributed as an Android AAR via Maven Central and includes a demo app and unit tests.
The LLM identified 3 files worth highlighting for reuse:
Implements the Hungarian algorithm for optimal assignment between two sets of matchers (e.g., methods vs. method matchers). This is a generic bipartite matching utility that can be extracted and reused in any project requiring unordered set matching with cardinality constraints. The implementation is self-contained, operating on iterable ranges and a cost function, and does not depend on DexKit-specific types.
A trie data structure for fast hierarchical string matching, used to filter classes by package inclusion/exclusion. It supports insertion of patterns (e.g., 'com.example.**') and lookup of longest prefix or exact match. The interface is clean and could be reused as a standalone package filter or general-purpose prefix tree for any domain (e.g., URL routing, name filtering).
Provides a generic JVM caching store with generation-based invalidation, single-flight load deduplication, and support for single, list, and map result types. It handles concurrent access with `AtomicInteger` and `ConcurrentHashMap`, and includes partial batch write protection and corruption recovery. This pattern is reusable for any application needing a lightweight, consistent cache layer that can be backed by different stores (e.g., memory, SharedPreferences).