KernelPatch Module (KPM)
About 575 wordsAbout 2 min
2025-12-23
FolkPatch is developed based on APatch. Apatch depends on KernelPatch, inheriting all its functions and expanding them. Therefore, FolkPatch also supports using KernelPatch Modules (KPM). Below is the usage instructions for KPM.
What is KPM?
KPM is a type of module that runs 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 implement (such as partition image protection, etc.).
How to install KPM?
There are three installation methods for KPM: embed, load, and install.
About "Installation"
Currently, FolkPatch has not implemented the "installation" operation for KPM, because its upstream APatch has not implemented it. Therefore, at this stage, FolkPatch's KPM can only be installed through "embed" and "load" methods. KernelPatch and APatch developers are working hard to implement related functions. Please be patient.
Embed
Embed refers to directly embedding KPM into the kernel. KPMs installed in this mode will be merged into boot.img together with kernel and loaded at the pre-kernel-init stage.
KPM embedding can be done when first using FolkPatch manager to patch boot.img or after completing FolkPatch installation. You can also manually embed using kptools.
Embed when first patching
Follow the automatic patching process in the Installation Guide. After completing step 4, DO NOT proceed to the next step immediately.
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 and you're done.
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 remaining steps can refer to Embed when first patching.
Load
Load refers to immediately handing over KPM to the kernel for loading. KPMs loaded in this way will take effect immediately but will disappear after the next reboot.
The way to load KPM is roughly the same as installing APM, with the only difference being that KPM does not need to restart 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 of installing KPM.
Install refers to installing KPM as a module file similar to APM to /data/adb/kpmodules or similar directories. KPMs installed in this way can be loaded during specific events.
Auto-load
FolkPatch currently supports loading KPM into the kernel when starting the FolkPatch application for the first time. This requires you to select the KPM path. FolkPatch provides two methods:
Use JSON configuration to customize loading. You need to write the KPM path in JSON syntax format.
Use visual selection. FolkPatch will directly call the system file selector. Select the KPM you need.
The remaining behavior is consistent with Load
重要
Auto-load does not pass any parameters 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
