lsposed-health-check.md 4.25 KB

LSPosed / Vector Health Check (Quick Diagnostic)

Use this when the user asks "is LSPosed working?" or you need to assess module state.

1. Daemon + Zygisk

# Is lspd running?
su -c 'pidof lspd'

# Is Zygisk enabled in Magisk?
su -c 'magisk --sqlite "SELECT value FROM settings WHERE key=\"zygisk\""'
# Should show: value=1

2. Module inventory

# List installed Magisk modules
su -c 'ls /data/adb/modules/'
# Look for: zygisk_lsposed (official) or zygisk_vector (JingMatrix fork)

# List configured LSPosed modules
su -c 'ls /data/adb/lspd/config/modules/'
# Each directory = one Xposed module

# Check module scope (which apps it targets)
su -c 'cat /data/adb/lspd/config/modules/<module>/scope'

3. Injection verification

# Framework injected into system_server?
su -c 'cat /proc/$(pidof system_server | cut -d" " -f1)/maps | grep -i "zygisk\|lspd\|vector" | head -5'

# Zygisk injected into zygote?
su -c 'cat /proc/$(pidof zygote64 | cut -d" " -f1)/maps | grep -i zygisk | head -3'

# Module injected into target app? (need app running)
su -c 'cat /proc/$(pidof com.tencent.mm)/maps | grep wechathook'

4. Crash forensics

If pidof lspd returns nothing or modules aren't injecting:

# Check for zygote JNI crash (A15/A16 signature)
su -c 'logcat -d 2>/dev/null | grep -i "JNI DETECTED ERROR.*NewDirectByteBuffer"' | head -3

# Check if Magisk rolled back Zygisk
su -c 'logcat -d 2>/dev/null | grep "zygote crashed too many times"'

# Read lspd daemon logs
su -c 'cat $(ls -t /data/adb/lspd/log/verbose_*.log | head -1) | grep -iE "error|fail|crash|start|inject" | tail -20'

5. Module config: filesystem vs database (CRITICAL)

LSPosed stores module configuration in two places, and the database is the source of truth:

Location Purpose Check
/data/adb/lspd/config/modules/<pkg>/scope Filesystem scope file Exists but may be stale/ignored
/data/adb/lspd/config/modules_config.db → table modules + scope Runtime source of truth The only config LSPosed reads at injection time

Symptom: Module installed, scope file present, but no "Loading legacy" entries in verbose log.

Diagnose:

# Check what LSPosed actually knows about
su -c 'sqlcipher /data/adb/lspd/config/modules_config.db "SELECT * FROM modules;"'

# If your module is MISSING from the modules table, LSPosed will NEVER load it,
# regardless of what's in the filesystem config directory.

Fix — insert the missing module + scope:

# 1. Get the current APK path
su -c 'pm path com.example.yourmodule'

# 2. Insert module entry
su -c 'sqlcipher /data/adb/lspd/config/modules_config.db \
  "INSERT INTO modules (module_pkg_name, apk_path, enabled) \
   VALUES ('\''com.example.yourmodule'\'', \
           '\''/data/app/~~hash==/com.example.yourmodule-xxx==/base.apk'\'', 1);"'

# 3. Get the new mid
su -c 'sqlcipher /data/adb/lspd/config/modules_config.db \
  "SELECT mid FROM modules WHERE module_pkg_name='\''com.example.yourmodule'\'';"'

# 4. Insert scope for target app(s)
su -c 'sqlcipher /data/adb/lspd/config/modules_config.db \
  "INSERT INTO scope (mid, app_pkg_name, user_id) VALUES (42, '\''com.target.app'\'', 0);"'

# 5. REBOOT — DB changes are only picked up at next zygote init
su -c 'reboot'

Pitfall: After inserting into the DB, do NOT kill lspd to "reload config." LSPosed reads modules_config.db once at startup (zygote init), not on process spawn. The only way to pick up DB changes is a full device reboot.

6. Recovery options

Situation Fix
lspd dead, Zygisk alive Reboot device (cleanest)
Zygisk rolled back Re-enable in Magisk app → reboot
Module not in scope Add app package to /data/adb/lspd/config/modules/<module>/scope → reboot
A16 crash (JNI error) Apply references/a16-jninterface-fix.md patch + rebuild zygisk .so
Manager APK missing Reinstall manager.apk from module zip to /data/adb/lspd/

Pitfall: lspd = NOT restarted

Killing lspd (killall lspd) does NOT cause restart. Recovery requires:

  • Zygote restart (kill -TERM $(pidof zygote64)) — destructive, kills all apps
  • Full device reboot — preferred

Never kill lspd as a troubleshooting step. Check logs + Zygisk status first.