Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
mv kpimg.elf kpimg.elf-android
make clean

make kpimg NO_ROOT=1
mv kpimg kpimg-android-no-root
mv kpimg.elf kpimg.elf-android-no-root
make clean

unset ANDROID
make
mv kpimg kpimg-linux
Expand Down Expand Up @@ -116,6 +121,7 @@ jobs:
artifacts: |
kernel/kpimg-linux
kernel/kpimg-android
kernel/kpimg-android-no-root
kernel/kpimg-x86
kpms/demo-hello/demo-hello.kpm
kpms/demo-inlinehook/demo-inlinehook.kpm
Expand Down
18 changes: 18 additions & 0 deletions doc/en/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ export TARGET_COMPILE=aarch64-none-elf-
cd kernel
export ANDROID=1 # Android version, including support for the 'su' command
make

# Or build without built-in root
make NO_ROOT=1
# Or Android version without built-in root
make ANDROID=1 NO_ROOT=1

# Optional manager flags:
# When NO_ROOT=1, official manager rename hooks and APK scans are disabled by default.
# To enable official manager package monitoring in NO_ROOT builds:
make ANDROID=1 NO_ROOT=1 OFFICIAL_MANAGER=1
# To disable official manager rename hooks in a standard root build:
make ANDROID=1 NO_MANAGER=1

# Autoload KPM modules (for builds without official manager or with NO_ROOT):
# Automatically load KPM modules from /data/adb/kpm or /data/adb/ap/kpm once /data is mounted (post-fs-data, before Zygote):
make ANDROID=1 NO_ROOT=1 AUTOLOAD_KPM=1
# Or in a standard root build without official manager:
make ANDROID=1 NO_MANAGER=1 AUTOLOAD_KPM=1
```

## Build kptools
Expand Down
18 changes: 18 additions & 0 deletions doc/zh-CN/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ export TARGET_COMPILE=aarch64-none-elf-
cd kernel
export ANDROID=1 # Android 版本,包含 su 命令支持
make

# 或者在不包含内置 root 的情况下编译
make NO_ROOT=1
# 或 Android 版本不包含内置 root
make ANDROID=1 NO_ROOT=1

# Manager 可选标志:
# 当 NO_ROOT=1 时,官方 Manager 的 rename hook 和 APK 扫描默认处于禁用状态。
# 在 NO_ROOT 构建中启用官方 Manager 包监控:
make ANDROID=1 NO_ROOT=1 OFFICIAL_MANAGER=1
# 在标准 root 构建中禁用官方 Manager rename hook:
make ANDROID=1 NO_MANAGER=1

# 自动加载 KPM 模块(适用于无官方 Manager 或启用 NO_ROOT 的构建):
# 在 /data 分区挂载后(post-fs-data 阶段,Zygote 启动前)自动从 /data/adb/kpm 或 /data/adb/ap/kpm 加载 KPM 模块:
make ANDROID=1 NO_ROOT=1 AUTOLOAD_KPM=1
# 或在无官方 Manager 的标准 root 构建中:
make ANDROID=1 NO_MANAGER=1 AUTOLOAD_KPM=1
```

## 编译 kptools
Expand Down
56 changes: 56 additions & 0 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,51 @@ ifdef ANDROID
X86_CFLAGS += -DANDROID
endif

ENABLE_ROOT ?= 1
ifeq ($(NO_ROOT),1)
ENABLE_ROOT := 0
endif
ifeq ($(DISABLE_ROOT),1)
ENABLE_ROOT := 0
endif

ifeq ($(ENABLE_ROOT),0)
CFLAGS += -DCONFIG_KP_NO_ROOT
X86_CFLAGS += -DCONFIG_KP_NO_ROOT
endif

ENABLE_OFFICIAL_MANAGER ?= $(ENABLE_ROOT)
ifeq ($(OFFICIAL_MANAGER),1)
ENABLE_OFFICIAL_MANAGER := $(OFFICIAL_MANAGER)
endif
ifeq ($(NO_MANAGER),1)
ENABLE_OFFICIAL_MANAGER := 0
endif
ifeq ($(NO_OFFICIAL_MANAGER),1)
ENABLE_OFFICIAL_MANAGER := 0
endif

ifeq ($(ENABLE_OFFICIAL_MANAGER),0)
CFLAGS += -DCONFIG_KP_NO_OFFICIAL_MANAGER
X86_CFLAGS += -DCONFIG_KP_NO_OFFICIAL_MANAGER
endif

ENABLE_AUTOLOAD_KPM ?= 0
ifeq ($(AUTOLOAD_KPM),1)
ENABLE_AUTOLOAD_KPM := 1
endif
ifeq ($(CONFIG_KP_AUTOLOAD_KPM),1)
ENABLE_AUTOLOAD_KPM := 1
endif
ifeq ($(NO_AUTOLOAD_KPM),1)
ENABLE_AUTOLOAD_KPM := 0
endif

ifeq ($(ENABLE_AUTOLOAD_KPM),1)
CFLAGS += -DCONFIG_KP_AUTOLOAD_KPM
X86_CFLAGS += -DCONFIG_KP_AUTOLOAD_KPM
endif

INCLUDE := -I. -Iinclude -Ipatch/include -Ilinux -Ilinux/include -Ilinux/arch/arm64/include -Ilinux/tools/arch/arm64/include

X86_INCLUDE := -I. -Iinclude -Ipatch/include -Ilinux/include -Ilinux/include/uapi/asm-generic -Ilinux/tools/arch/arm64/include
Expand Down Expand Up @@ -76,6 +121,17 @@ ifdef ANDROID
BASE_SRCS += $(wildcard patch/android/*.c)
endif

ifeq ($(ENABLE_ROOT),0)
ROOT_SRCS := \
patch/common/selinux_hide.c \
patch/common/selinux_sepolicy.c \
patch/common/sucompat.c \
patch/common/supercmd.c \
patch/common/user_event.c

BASE_SRCS := $(filter-out $(ROOT_SRCS),$(BASE_SRCS))
endif

SRCS += $(BASE_SRCS)
SRCS += $(LINUX_SRCS)

Expand Down
Loading