Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
natsumerinchan committed Mar 24, 2023
0 parents commit a640a24
Show file tree
Hide file tree
Showing 10 changed files with 478 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

*.ko
*.zip
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/sbin/sh

#################
# Initialization
#################

umask 022

# echo before loading util_functions
ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}

#########################
# Load util_functions.sh
#########################

OUTFD=$2
ZIPFILE=$3

mount /data 2>/dev/null

[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk

install_module
exit 0
1 change: 1 addition & 0 deletions META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#MAGISK
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Kernel Module Loader
利用Magisk/KernelSU在开机后加载内核模块

## 使用方法

### 1、克隆本仓库
```
git clone https://github.com/natsumerinchan/Kernel_Module_Loader.git
```

### 2、将内核模块放入kernel_module目录

### 3、修改customize.sh

- `MODULES_ARCH` 此项可限制模块的cpu架构

- 限定内核版本
```
# Check Kernel Version
kernel_version=$(uname -r | awk -F '-' '{print $1}')
case "$kernel_version" in
5.4.*) supported=true ;;
4.19.*) supported=true ;;
*) supported=false ;;
esac
```

- 要求内核开启某些配置
```
config_list="
CONFIG_MODULES
CONFIG_KPROBES
CONFIG_HAVE_KPROBES
CONFIG_KPROBE_EVENTS
"
```

### 4、修改module.prop
这个无需多讲,爱怎么改就怎么改

### 5、制作模块
```
zip -r MODULE_NAME.zip * -x .git ./kernel_module/.placeholder .gitattributes .gitgnore
```
38 changes: 38 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SKIPUNZIP=0
MODULES_ARCH=arm64

# Check Device Platform
if [ "$ARCH" != "$MODULES_ARCH" ]; then
abort "! Unsupport platform: $ARCH"
else
ui_print "- Device platform: $ARCH"
fi

ui_print "- API Level: $API"

# Check Kernel Version
kernel_version=$(uname -r | awk -F '-' '{print $1}')
case "$kernel_version" in
5.4.*) supported=true ;;
4.19.*) supported=true ;;
*) supported=false ;;
esac

if [ ! $supported ]; then
abort "! Unsupport Kernel Version: $kernel_version"
else
ui_print "- Kernel Version: $kernel_version"
fi

# Check Kernel Configs
ui_print "- Check Kernel Configs..."
config_list="
CONFIG_MODULES
CONFIG_KPROBES
CONFIG_HAVE_KPROBES
CONFIG_KPROBE_EVENTS
"
for config_name in $config_list
do
(zcat /proc/config.gz | grep "$config_name=y") || abort "! Your Kernel has not enabled $config_name !"
done
Empty file added kernel_module/.placeholder
Empty file.
6 changes: 6 additions & 0 deletions module.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=Kernel_Module_Loader
name=Kernel Module Loader
version=v1.0.0
versionCode=100
author=natsumerinchan
description=利用Magisk/KernelSU在开机后加载内核模块
12 changes: 12 additions & 0 deletions service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/system/bin/sh
MODDIR=${0%/*}
MODULE_DIR=$MODDIR/kernel_module
while [ "$(getprop sys.boot_completed)" != "1" ] || [ ! -e "$MODULE_DIR" ]; do
sleep 3
done

module_list=$(ls $MODULE_DIR)
for module_name in $module_list
do
insmod $MODULE_DIR/$module_name
done

0 comments on commit a640a24

Please sign in to comment.