KernelPatch Module (KPM)
About 582 wordsAbout 2 min
2025-12-23
FolkPatch is based on secondary development of APatch. APatch depends on KernelPatch, inherits all its features and extends them. Therefore, FolkPatch also supports using KernelPatch Modules (KPM). Below are instructions for using KPM.
What is KPM?
KPM is a module running in kernel space, allowing code to run in kernel space, similar to Loadable Kernel Modules (LKM).
Through KPM, you can implement some functions that APM cannot achieve (such as partition image protection, etc.).
How to Install KPM?
There are three ways to install KPM: Embed, Load, and Install.
About "Install"
Currently, FolkPatch has not implemented the "Install" operation for KPM, because its upstream APatch has not implemented it yet. Therefore, at this stage, FolkPatch's KPM can only be installed via "Embed" and "Load". KernelPatch and APatch developers are working hard to implement related functions, please wait patiently.
Embed
Embed refers to embedding KPM directly into the kernel. KPM installed in this mode will be merged into boot.img together with kernel and loaded during the pre-kernel-init stage.
KPM embedding can be done when patching boot.img using FolkPatch Manager for the first time or after FolkPatch installation is complete. You can also use kptools to manually embed.
Embed at First Patching
Follow the automatic patching process in the Installation Guide. Do not immediately proceed to the next step after step 4.
Click the "Embed Module" button, then select the KPM file you want to embed (suffix is
.kpm).Confirm that the KPM to be embedded is the one you want to use.
Complete the remaining "Automatic Patching" process.
Embed After Installing FolkPatch
After FolkPatch is installed, the way to embed KPM is roughly the same as installing APM. You can click the button in the lower right corner of the "Kernel Module" interface, select "Embed", and the subsequent steps can be carried out with reference to Embed at First Patching.
Load
Load refers to handing KPM over to the kernel for loading immediately. KPM loaded in this way will take effect immediately, but will disappear after the next restart.
The way to load KPM is roughly the same as installing APM, the only difference is that KPM does not need to be restarted after loading.
Install
Note
Currently, KernelPatch and APatch have not yet implemented KPM installation. The following description is only a description of the expected behavior for installing KPM.
Install refers to installing KPM as a module file similar to APM into /data/adb/kpmodules or a similar directory. KPM installed in this way can be loaded at specific events.
Auto Load
FolkPatch currently supports loading KPM into the kernel when the FolkPatch app is launched for the first time. This requires you to select the KPM path. FolkPatch provides two ways:
Use JSON configuration for custom loading, you need to write the KPM path in JSON syntax format.
Use visual selection, FolkPatch will directly call the system file picker, just select the KPM you need.
The rest of the behavior is consistent with Load.
重要
Auto Load does not pass any arguments to KPM by default.
Copyright
Copyright Ownership:Apatch Document
This article is reprint from:https://apatch.dev/zh_CN/kpm-usage-guide.html
License under:Attribution-ShareAlike 4.0 International
