lsposed-module-config.md 3.39 KB

LSPosed Module Configuration (Direct DB Method)

Date: 2026-06-30 Device: JingMatrix/Vector LSPosed fork on Android 16

Problem

LSPosed Manager UI may not be accessible (parasitic mode issues on A16). Modules must be enabled + scoped via direct database manipulation.

Database Location

/data/adb/lspd/config/modules_config.db

Schema

CREATE TABLE modules (
    mid              INTEGER PRIMARY KEY AUTOINCREMENT,
    module_pkg_name  TEXT UNIQUE NOT NULL,     -- e.g., 'com.example.wechathook'
    apk_path         TEXT NOT NULL DEFAULT '', -- MUST be set to actual APK path
    enabled          INTEGER NOT NULL DEFAULT 1
);

CREATE TABLE scope (
    mid          INTEGER NOT NULL,
    app_pkg_name TEXT NOT NULL,               -- target app, e.g., 'com.tencent.mm'
    user_id      INTEGER NOT NULL,            -- usually 0
    PRIMARY KEY (mid, app_pkg_name, user_id),
    FOREIGN KEY (mid) REFERENCES modules(mid) ON DELETE CASCADE
);

Registration Procedure

Step 1: Find APK path

su -c 'pm path com.example.wechathook'
# → /data/app/~~XXXX==/com.example.wechathook-YYYY==/base.apk

Step 2: Copy DB to writable location

su -c 'cp /data/adb/lspd/config/modules_config.db /data/data/com.termux/files/home/tmp/'
su -c 'chown u0_a329:u0_a329 /data/data/com.termux/files/home/tmp/modules_config.db'

Step 3: Insert module + scope via Python

import sqlite3, subprocess

db = '/data/data/com.termux/files/home/tmp/modules_config.db'
apk_path = '/data/app/~~XXXX==/com.example.wechathook-YYYY==/base.apk'

conn = sqlite3.connect(db)
c = conn.cursor()

# Insert or update module
c.execute("SELECT mid FROM modules WHERE module_pkg_name='com.example.wechathook'")
row = c.fetchone()

if row:
    mid = row[0]
    c.execute("UPDATE modules SET enabled=1, apk_path=? WHERE mid=?", (apk_path, mid))
else:
    c.execute("INSERT INTO modules (module_pkg_name, apk_path, enabled) VALUES (?, ?, 1)",
              ('com.example.wechathook', apk_path))
    mid = c.lastrowid

# Add scope for target app
c.execute("INSERT OR IGNORE INTO scope (mid, app_pkg_name, user_id) VALUES (?, 'com.tencent.mm', 0)", (mid,))
# Self-scope (module itself)
c.execute("INSERT OR IGNORE INTO scope (mid, app_pkg_name, user_id) VALUES (?, 'com.example.wechathook', 0)", (mid,))

conn.commit()
conn.close()

# Copy back
subprocess.run(['su', '-c', 'cp /data/data/com.termux/files/home/tmp/modules_config.db /data/adb/lspd/config/modules_config.db'], check=True)
subprocess.run(['su', '-c', 'rm -f /data/adb/lspd/config/modules_config.db-wal /data/adb/lspd/config/modules_config.db-shm'], check=False)

Step 4: Restart lspd daemon or reboot

# Kill daemon → Magisk service.sh should restart it
su -c 'killall lspd'
sleep 3

# If it doesn't restart, reboot:
su -c 'reboot'

Critical Pitfall

apk_path MUST be set! If left as empty string (default), LSPosed cannot find the module APK and will silently skip it. Always set this column.

Verify with:

c.execute("SELECT module_pkg_name, apk_path FROM modules")
for row in c.fetchall():
    assert row[1], f"MISSING apk_path for {row[0]}"

Verification

After reboot, check module loaded:

# Check lspd is running
su -c 'ps -A | grep lspd'

# Check WeChat process for module classes  
su -c "cat /proc/\$(pidof com.tencent.mm)/maps | grep wechathook"

# Check logcat for module tag
su -c 'logcat -d -s WeChatHook:*'