← ClaudeAtlas

kpmlisted

Write, build and load KernelPatch Modules (KPM) — ELF objects that KernelPatch (and APatch) load and run inside the arm64 Linux kernel to inline-hook kernel functions, hook syscalls, or call arbitrary kernel functions without kernel source. Use when creating a .kpm, writing KPM_INIT / KPM_CTL0 / KPM_EXIT callbacks, using hook_wrap / fp_hook_syscalln / inline_hook_syscalln / kallsyms_lookup_name, setting up the aarch64-none-elf build, or loading a module with sc_kpm_load / the APatch KPM screen. Triggers on "KPM", "KernelPatch module", "kpm_init", "hook_wrap", "fp_hook_syscalln", "写一个 KPM", "内核模块 hook".
yspbwx2010/skills · ★ 2 · Web & Frontend · score 74
Install: claude install-skill yspbwx2010/skills
# KernelPatch Module (KPM) A KPM is a **partially-linked arm64 ELF relocatable object** (`.kpm`) that KernelPatch loads and executes **in kernel space**. It is not a normal Linux `.ko` — it depends on nothing but the symbols KernelPatch exports, so the same `.kpm` runs on many kernels without their source or `Module.symvers`. Use a KPM to inline-hook a kernel function, hook a syscall, or reach arbitrary kernel functions found by name at runtime. This skill is written against **KernelPatch 0.13.9**. Everything here is verified against that source; APIs on `main` may differ. ## Before you write anything 1. **You need the KernelPatch source** for its headers (the build `-I`s into it). Clone the release tag, not `main`: ```sh git clone --depth 1 --branch 0.13.9 https://github.com/bmax121/KernelPatch ``` Set `KP_DIR` to that checkout (the demo Makefiles default it to `../..`). 2. **You need an arm64 bare-metal toolchain.** The upstream, CI-blessed one is `aarch64-none-elf-` from ARM. `clang --target=aarch64-none-elf` also works. **Not** `aarch64-linux-gnu-` for the link step — a KPM is `-r` partially linked, freestanding. 3. **Decide what the module does** before choosing an API: react to load/unload only (init/exit), answer userspace control messages (ctl0), inline-hook a function (`hook_wrap`), or hook a syscall (`fp_hook_syscalln` / `inline_hook_syscalln`). Read `references/api.md` for the one you need. ## Anatomy of a KPM Every KPM is one or mo