How backslashxx/ksu_toolkit works
Project type & purpose (what you’re diagramming)
This repo is not a typical web/backend app. It’s an Android KernelSU v3 “toolkit” module intended for testing/debugging KernelSU kernel extensions. The key architectural reality is:
• The “core platform” is the Android device + KernelSU-enabled kernel (with specific extra kernel commits listed in README).
• This repo provides:
1) A KernelSU module (shell scripts + module metadata) that runs on-device.
2) A userspace native toolkit (src/toolkit.c, src/small_rt.h) that likely invokes KernelSU supercalls / interfaces enabled by the required kernel patches.
module/ (KernelSU module packaging + lifecycle)
• module.prop: module metadata (name, version, description).
• customize.sh: install-time customization/logic.
• service.sh: boot/service entrypoint (runs at boot in module environment).
• uninstall.sh: cleanup.
src/ (native userspace toolkit)
• toolkit.c: core executable/library logic for calling kernel interfaces.
• small_rt.h: small runtime helpers (likely to avoid bionic/size overhead).
webui/ (static UI + JS modules)
• index.html, index.js, styles.css, theme.css.
• Feature-like JS modules: sulog.js, uname.js, uid.js, umount.js (strong hint each corresponds to a kernel/user feature being debugged).
• Build tooling: vite.config.js, package.json, pnpm-lock.yaml, pnpm-workspace.yaml.
.github/workflows/*
• tests.yml, module.yml: CI pipeline to run tests/build module artifacts.
Kernel dependencies (from README) — must appear
• Expose ksu_set_manager_appid to sys_reboot
• Allow userspace to pull list entries
• sulog ringbuffer (timestamped su log)
• Expose ksuver override
• Expose spoof uname function to userspace
This is important because the toolkit module is meaningless without these kernel surfaces; they are first-class architectural components.
KernelSU Module: ksu_toolkit (module/)
• Installer (customize.sh)
• Boot service (service.sh)
• Uninstaller (uninstall.sh)
• Module metadata (module.prop)
Native Toolkit Binary (src/toolkit.c)
• Runs under module/service context
• Calls KernelSU supercalls / reads sulog ringbuffer / triggers overrides
Web UI (Vite-built static assets from webui/)
• Option A: “KernelSU Manager WebView”
• Option B: “Local HTTP server started by service.sh”
• Option C: “Opened via file:// from storage”
• JS feature modules: sulog.js, uname.js, uid.js, umount.js
CI/Build System (GitHub Actions)
• Builds module zip/artifacts
• Builds webui bundle
• Runs tests (if any)
• service.sh → launches → toolkit binary
• toolkit binary ↔ kernel interfaces (supercalls/syscalls)
• Web UI ↔ toolkit/service (define the transport: CLI invocation, local HTTP endpoints, reading files, etc.)
• (If unknown) annotate with “TBD transport” instead of guessing silently
Inside each container, break down further.
• sys_reboot hook for ksu_set_manager_appid
• Supercall: list entries retrieval
• sulog ringbuffer + timestamp
• ksuver override interface
• spoof uname interface
• Install-time configuration (customize.sh)
• Boot-time service supervisor (service.sh)
• Cleanup (uninstall.sh)
• Any file placements (e.g., where toolkit binary + webui assets are stored) — if not visible in repo, note “installed paths defined in scripts”.
Inside Toolkit (src/):
• “KernelSU Interface Layer” (wrappers around syscalls/supercalls)
• “Commands/Operations”
• Set manager appid
• Pull list entries
• Read sulog ringbuffer
• Override ksuver
• Spoof uname
• “Output Layer”
• stdout/stderr CLI
• file output (if applicable)
• IPC endpoints (if applicable)
Inside Web UI (webui/):
• index.js as entrypoint/router
• Feature modules:
• sulog.js (log viewing)
• uname.js (uname spoof controls)
• uid.js (UID-related tooling)
• umount.js (mount/unmount tooling)
• The “transport” module (if any exists; otherwise show “fetch/exec abstraction”)
• Styling/theme (theme.css, styles.css)
Control flows (commands)
• Web UI action → (transport) → toolkit/service → kernel interface (supercall) → kernel state change
Examples to label:
• “Set manager appid”
• “Override ksuver”
• “Spoof uname”
Data flows (observability)
• Kernel sulog ringbuffer → toolkit reads → Web UI displays
Also include:
• “userspace pulls list entries” as a read/query flow
Clear labels
Use explicit labels like:
• “Kernel space: KernelSU v3 + required patches”
• “Userspace: KernelSU module service (root context)”
• “Static Web UI bundle (Vite)”
• “Native toolkit (C)”
• syscall/supercall
• file read
• stdout parsing
• HTTP localhost
• WebView bridge
(If not confirmed, label “(unknown/TBD)” rather than omitting.)
What “most accurate” means here (and how to avoid common mistakes)
2. Make kernel patches first-class: they are effectively external dependencies and define the usable feature set.
• read module/service.sh to confirm, or
• An “UI Host/Bridge (KernelSU Manager / local server / file)” component with a note.
System Context: device + kernel + module + UI host + developer.
• Install (customize.sh) → boot (service.sh) → run toolkit → uninstall (uninstall.sh)
This set will capture both architecture and operational reality without overthinking: it simply decomposes what’s in the repo into explicit runtime and build-time components and draws every interaction surface.