#KernelPatch Module (KPM)

FolkPatch is developed based on APatch, which depends on KernelPatch, inheriting all its features and extending them. Therefore, FolkPatch also supports using KernelPatch Modules (KPM).

#What is KPM?

KPM is a 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 features that APM cannot (such as partition image protection, etc.).

#How to Install KPM?

KPM has three installation methods: Embed, Load, and Install.

#About “Install”

:::warning Currently, FolkPatch has not implemented the “Install” operation for KPM, as its upstream APatch has not implemented it yet. Therefore, FolkPatch’s KPM can currently only be installed through “Embed” and “Load” methods. KernelPatch and APatch developers are working hard to implement related features, please wait patiently. :::

#Embed

Embed means embedding KPM directly into the kernel. KPM installed in this mode will be merged into boot.img together with the kernel and loaded during the pre-kernel-init phase.

KPM embedding can be done when first using FolkPatch manager to patch boot.img or after completing FolkPatch installation. You can also use kptools to embed manually.

#Embed During First Patch

  1. Follow the automatic patching process in Installation Guide, and don’t proceed to the next step immediately after step 4.
  2. Click the “Embed Module” button, then select the KPM file you want to embed (with .kpm extension).
  3. Confirm that the KPM you want to embed is the one you want to use.
  4. 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 bottom right corner of the “Kernel Modules” interface, select “Embed”, and then follow the steps in Embed During First Patch.

#Load

Load means immediately handing KPM to the kernel for loading. KPM loaded this way will take effect immediately but will disappear after the next reboot.

Loading KPM is roughly the same as installing APM, the only difference is that KPM does not need to reboot after loading.

#Install

:::info Currently, KernelPatch and FolkPatch have not implemented KPM installation. The following description is only an expected behavior description for installing KPM. :::

Install means installing KPM as a module file similar to APM to /data/adb/kpmodules or similar directory. KPM installed this way can be loaded at specific events.

#Auto Load

FolkPatch currently supports loading KPM to the kernel when first starting the FolkPatch app. You need to select the KPM path. FolkPatch provides two methods:

  1. Custom Loading with JSON Configuration: You need to write KPM paths that conform to JSON syntax format
  2. Visual Selection: FolkPatch will directly call the system file selector to select the KPM you need

Other behaviors remain consistent with Load.

:::warning Auto load does not pass any parameters to KPM by default :::

Copyright: Apatch Document

This article is reprinted from: https://apatch.dev/zh_CN/kpm-usage-guide.html

License: Attribution-ShareAlike 4.0 International