From 8f5197d2e7589c60aa12ec04fb79110f254410d5 Mon Sep 17 00:00:00 2001 From: okhsunrog Date: Sun, 28 Jun 2026 03:36:42 +0300 Subject: [PATCH] codegen: don't emit the hook registry into lsposed/native MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lsposed/native is the uniffi diagnostic-probe library, not a protocol participant — it consumes iface_lists (VPN-name matching) but never the hook registry / config masks. Drop it from the hook-ids codegen targets; the registry goes only to the actual protocol parsers: kmod/KPM (C), Zygisk (Rust), and the app + system_server hook (Kotlin) per §1.4. --- lsposed/native/src/generated/hook_ids.rs | 65 ------------------------ lsposed/native/src/generated/mod.rs | 3 +- scripts/codegen-hooks.py | 6 ++- 3 files changed, 5 insertions(+), 69 deletions(-) delete mode 100644 lsposed/native/src/generated/hook_ids.rs diff --git a/lsposed/native/src/generated/hook_ids.rs b/lsposed/native/src/generated/hook_ids.rs deleted file mode 100644 index 21b4837..0000000 --- a/lsposed/native/src/generated/hook_ids.rs +++ /dev/null @@ -1,65 +0,0 @@ -// AUTO-GENERATED from data/hooks.toml — do not edit by hand. Regenerate with: uv run scripts/codegen-hooks.py - -#![allow(dead_code)] - -/// Global hook id space (data/hooks.toml). bit N == hook id N. -#[repr(u32)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub enum Hook { - /// /proc/net/route — IPv4 route lines - FibRouteSeqShow = 0, - /// /proc/net/ipv6_route — IPv6 route lines - Ipv6RouteSeqShow = 1, - /// RTM_NEWLINK — getifaddrs() link enumeration - RtnlFillIfinfo = 2, - /// RTM_GETADDR — IPv4 address dump - InetFillIfaddr = 3, - /// RTM_GETADDR — IPv6 address dump - Inet6FillIfaddr = 4, - /// SIOCGIF* by name (per-interface ioctls) - DevIoctl = 5, - /// SIOCGIFCONF — interface list ioctl - SockIoctl = 6, - /// RTM_GETROUTE — IPv4 route dump (issue #86) - FibDumpInfo = 7, - /// RTM_GETROUTE — IPv6 route dump - Rt6FillNode = 8, - /// RTM_GETRULE — policy routing rules - FibNlFillRule = 9, -} - -pub const HOOK_COUNT: u32 = 10; - -/// Hooks owned by each backend: apply `mask & own`. -pub const KERNEL_HOOK_MASK: u32 = 0x3ff; -pub const ZYGISK_HOOK_MASK: u32 = 0x0; -pub const LSPOSED_HOOK_MASK: u32 = 0x0; - -/// status error codes (protocol §5.1). -#[repr(u32)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub enum StatusError { - /// healthy; every requested, owned hook installed - Ok = 0, - /// no offset table for the running kernel — refused, no hooks - UnsupportedKver = 1, - /// the other kernel backend (.ko<->KPM) is loaded — refused (protocol §1.2) - ConflictingBackend = 2, - /// a required kallsyms symbol was missing — refused - SymbolResolutionFailed = 3, - /// installed, but some owned hooks did not resolve (see the hooks mask) - PartialHooks = 4, -} - -pub const HOOK_NAMES: [&str; 10] = [ - "fib_route_seq_show", - "ipv6_route_seq_show", - "rtnl_fill_ifinfo", - "inet_fill_ifaddr", - "inet6_fill_ifaddr", - "dev_ioctl", - "sock_ioctl", - "fib_dump_info", - "rt6_fill_node", - "fib_nl_fill_rule", -]; diff --git a/lsposed/native/src/generated/mod.rs b/lsposed/native/src/generated/mod.rs index 4bd79ea..7539c9f 100644 --- a/lsposed/native/src/generated/mod.rs +++ b/lsposed/native/src/generated/mod.rs @@ -1,5 +1,4 @@ //! Auto-generated modules. Hand-edit nothing under here — see -//! `scripts/codegen-interfaces.py` and `scripts/codegen-hooks.py`. +//! `scripts/codegen-interfaces.py`. -pub mod hook_ids; pub mod iface_lists; diff --git a/scripts/codegen-hooks.py b/scripts/codegen-hooks.py index 70cdf2f..0f30ea2 100755 --- a/scripts/codegen-hooks.py +++ b/scripts/codegen-hooks.py @@ -34,9 +34,12 @@ from typing import Any REPO_ROOT = Path(__file__).resolve().parent.parent TOML_PATH = REPO_ROOT / "data" / "hooks.toml" +# Targets are only the protocol participants (§1.4): the kernel backends (C), +# the Zygisk backend (Rust), and the app + system_server hook (Kotlin). NOT +# lsposed/native — that Rust crate is the uniffi diagnostic-probe library; it +# consumes iface_lists (VPN-name matching) but never the protocol/registry. OUT_KMOD = REPO_ROOT / "kmod" / "generated" / "hook_ids.h" OUT_ZYGISK = REPO_ROOT / "zygisk" / "src" / "generated" / "hook_ids.rs" -OUT_LSP_NATIVE = REPO_ROOT / "lsposed" / "native" / "src" / "generated" / "hook_ids.rs" OUT_LSP_KT = ( REPO_ROOT / "lsposed" @@ -250,7 +253,6 @@ def main() -> None: outputs = { OUT_KMOD: emit_kmod(hooks, errs), OUT_ZYGISK: emit_rust(hooks, errs), - OUT_LSP_NATIVE: emit_rust(hooks, errs), OUT_LSP_KT: emit_kotlin(hooks, errs), } for path, text in outputs.items():