How kulipai/luahook works
Project type and purpose
• From the file tree and README, this is an Android application module that integrates with the Xposed framework to let end users write and load Xposed hooks using Lua scripts at runtime.
• It bundles an embedded Lua VM (luaj), a custom code editor (TextWarrior), and a UI built in Kotlin/Java with MVVM patterns.
File structure
• Top-level “app” folder: standard Android module (Gradle, src/main/java, res, assets, libs).
• Key code under src/main/java/com/kulipai/luahook: Activities, Fragments, ViewModel, MainHook (entry point for Xposed), LuaLib (hook-exposed APIs).
• Embedded dependencies:
• luaj-jse.jar under app/libs → Lua VM
• compileOnly/xposed-api → Xposed bridge integration
• Assets under src/main/assets/textmate & language.json → syntax-highlighting data for the Lua editor.
• TextWarrior code under com/myopicmobile/textwarrior → custom code editor component.
README for additional insights
• Core features: dynamic loading of Lua scripts, seamless Xposed integration, no need to recompile APK when scripts change.
• Under development—focus on dynamic script load and hook API surface.
– Android Framework (OS + app lifecycle)
– Xposed Bridge (injected into target app process)
– LuaHook Module (the .apk loaded by Xposed)
– MainHook (Xposed entry class)
– Hook Engine (LuaLib package)
– Lua VM (luaj)
– Script Storage & Loader (file system on device)
– UI Layer (Activities & Fragments)
– ViewModel Layer (AppListViewModel, etc.)
– Text Editor Component (TextWarrior)
– Assets & Syntax Data (textmate JSON)
– Android OS launches your LuaHook module’s Activities → UI Layer
– UI Layer ↔ ViewModel Layer (data binding)
– ViewModel issues commands to Hook Engine (load/enable scripts)
– Script Loader reads .lua files from storage → passes code to Lua VM
– MainHook (invoked by Xposed at app startup) registers hook callbacks via Hook Engine
– Hook Engine uses Lua VM to interpret user scripts at hook points in the target process
– Xposed Bridge wires your MainHook into third-party app processes
c. Architectural patterns & principles
– MVVM for UI: Activities/Fragments ←→ ViewModels ←→ data stores
– Plugin-style hook engine: decoupling between script definitions and hook registration
– Separation of concerns: UI vs. interpreter vs. hooking core
d. Technologies & libraries
– Kotlin & Java for app code
– Android Jetpack components (ViewModel)
– Xposed API for hooking
– luaj for embedded Lua VM
– TextWarrior for in-app code editing
– Gradle/Kotlin DSL for build
Elements
• Blue for UI/ViewModel
• Green for Hook Engine/Lua VM
• Orange for storage/assets
• Red for external (Xposed Bridge)