GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: 更新Pro版本4.2.5 新增大量功能 · CrackerCat/linuxKernelRoot@055a6ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Pro(众测开放中)/sources/testModule
    • kernel_module_kit/include
      • module_base_kernel_func_hook.h
    • module_fake_thermal
      • jni
        • Android.mk
        • Application.mk
        • build_macros.mk
      • module_fake_thermal.cpp
      • patch_base.cpp
      • patch_base.h
      • patch_thermal_zone_get_temp.cpp
      • patch_thermal_zone_get_temp.h
    • module_hide_data_dir
      • module_hide_data_dir.cpp
    • 目录清单.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Pro(众测开放中)/sources/testModule/kernel_module_kit/include/module_base_kernel_func_hook.h‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/sources/testModule/kernel_module_kit/include/module_base_kernel_func_hook.h
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ void arm64_before_hook_end(asmjit::a64::Assembler* a, bool continue_original);
3232
* hook_handler_code Hook 处理函数的机器码(shellcode)。
3333
* (注意:Hook处理函数开头必须调用 arm64_before_hook_start,结尾必须调用 arm64_before_hook_end,否则不合法。)
3434
* 返回: OK 表示成功,其他值为错误码。
35-
*
3635
* 工作原理:仅将 kaddr 位置的 1 条指令(4 字节)替换为单条 B 跳转指令,无任何性能损耗。
3736
*
3837
* Hook处理函数示例:
@@ -62,7 +61,6 @@ void arm64_after_hook_end(asmjit::a64::Assembler* a);
6261
* hook_handler_code Hook 处理函数的机器码(shellcode)。
6362
* (注意:Hook处理函数开头必须调用 arm64_after_hook_start,结尾必须调用 arm64_after_hook_end,否则不合法。)
6463
* 返回: OK 表示成功,其他值为错误码
65-
*
6664
* 工作原理:仅将 kaddr 位置的 1 条指令(4 字节)替换为单条 B 跳转指令,无任何性能损耗。
6765
*
6866
* Hook处理函数示例:
@@ -89,13 +87,22 @@ KModErr install_kernel_function_after_hook(uint64_t target_func_kaddr, const std
8987
* 用法示例1:
9088
* arm64_before_hook_start(a);
9189
* arm64hook_emit_load_original_func(a, x16);
92-
* a->blr(x16); // blr 会按 AAPCS64 调用约定破坏寄存器;如需保留寄存器,请在 blr 前保存寄存器(可使用 RegProtectGuard 等方式)。
90+
* a->blr(x16);
91+
* arm64_before_hook_end(a, false);
92+
*
93+
* 用法示例2:
94+
* arm64_before_hook_start(a);
95+
* arm64hook_emit_load_original_func(a, x16);
96+
* {
97+
* RegProtectGuard g1(a, x0, x1, x2); // 提前保存自己需要的参数,因为blr后会破坏寄存器值。
98+
* a->blr(x16);
99+
* }
93100
* arm64_before_hook_end(a, false);
94101
*
95102
* 用法示例2:
96103
* arm64_after_hook_start(a);
97104
* arm64hook_emit_load_original_func(a, x16);
98-
* a->blr(x16); // blr 会按 AAPCS64 调用约定破坏寄存器;如需保留寄存器,请在 blr 前保存寄存器(可使用 RegProtectGuard 等方式)。
105+
* a->blr(x16);
99106
* arm64_after_hook_end(a, false);
100107
***************************************************************************/
101108
void arm64hook_emit_load_original_func(asmjit::a64::Assembler* a, asmjit::a64::GpX xReg);
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/jni/Android.mk‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
LOCAL_MODULE := module_fake_thermal
5+
6+
LOCAL_SRC_FILES := ../module_fake_thermal.cpp ../patch_base.cpp ../patch_thermal_zone_get_temp.cpp
7+
8+
KERNEL_MODULE_KIT := $(LOCAL_PATH)/../../kernel_module_kit
9+
LOCAL_C_INCLUDES += $(KERNEL_MODULE_KIT)/include
10+
LOCAL_LDFLAGS += $(KERNEL_MODULE_KIT)/lib/libkernel_module_kit_static.a
11+
12+
include $(LOCAL_PATH)/build_macros.mk
13+
14+
include $(BUILD_SHARED_LIBRARY)
15+
16+
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/jni/Application.mk‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APP_ABI := arm64-v8a
2+
APP_STL := c++_static
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/jni/build_macros.mk‎

Copy file name to clipboard
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
COMMON_CPPFLAGS := \
2+
-std=c++20 \
3+
-fPIC \
4+
-fvisibility=hidden \
5+
-fno-stack-protector \
6+
-ffunction-sections \
7+
-fdata-sections \
8+
-flto=thin
9+
10+
COMMON_LDFLAGS := \
11+
-Wl,-O2 \
12+
-Wl,--gc-sections \
13+
-Wl,-s \
14+
-flto=thin
15+
16+
COMMON_INCLUDES := \
17+
$(LOCAL_PATH)/../../../
18+
19+
LOCAL_CPPFLAGS += $(COMMON_CPPFLAGS)
20+
LOCAL_LDFLAGS += $(COMMON_LDFLAGS)
21+
LOCAL_C_INCLUDES += $(COMMON_INCLUDES)
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/module_fake_thermal.cpp‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "patch_thermal_zone_get_temp.h"
2+
#include "kernel_module_kit_umbrella.h"
3+
4+
// 开始修补内核
5+
static KModErr patch_kernel_handler() {
6+
uint64_t thermal_zone_get_temp = 0;
7+
RETURN_IF_ERROR(kernel_module::kallsyms_lookup_name("thermal_zone_get_temp", thermal_zone_get_temp));
8+
printf("thermal_zone_get_temp, addr: %p\n", (void*)thermal_zone_get_temp);
9+
10+
PatchBase patchBase;
11+
PatchThermalZoneGetTemp patchThermalZoneGetTemp(patchBase, thermal_zone_get_temp);
12+
KModErr err = patchThermalZoneGetTemp.patch_thermal_zone_get_temp();
13+
printf("patch thermal_zone_get_temp ret: %s\n", to_string(err).c_str());
14+
return err;
15+
}
16+
17+
// SKRoot模块入口函数
18+
int skroot_module_main(const char* root_key, const char* module_private_dir) {
19+
printf("Hello! module_fake_thermal!\n");
20+
KModErr err = patch_kernel_handler();
21+
printf("patch_kernel_handler ret:%s\n", to_string(err).c_str());
22+
return 0;
23+
}
24+
25+
// SKRoot 模块名片
26+
SKROOT_MODULE_NAME("温控解除")
27+
SKROOT_MODULE_VERSION("1.0.0")
28+
SKROOT_MODULE_DESC("内核级伪装处理器温度曲线,实现去除温控降频,安全可靠。")
29+
SKROOT_MODULE_AUTHOR("SKRoot")
30+
SKROOT_MODULE_UUID32("kO8hT9tT2fB0hY9hV2bB4eJ6aY2nQ6kL")
31+
SKROOT_MODULE_UPDATE_JSON("https://abcz316.github.io/SKRoot-linuxKernelRoot/module_fake_thermal/update.json")
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/patch_base.cpp‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "patch_base.h"
2+
using namespace asmjit;
3+
using namespace asmjit::a64;
4+
using namespace asmjit::a64::Predicate;
5+
6+
PatchBase::PatchBase() {}
7+
8+
PatchBase::PatchBase(const PatchBase& other) {}
9+
10+
PatchBase::~PatchBase() {}
11+
12+
KModErr PatchBase::patch_kernel_before_hook(uint64_t kaddr, const Assembler* a) {
13+
std::vector<uint8_t> bytes = aarch64_asm_to_bytes(a);
14+
RETURN_IF_ERROR(kernel_module::install_kernel_function_before_hook(kaddr, bytes));
15+
return KModErr::OK;
16+
}
17+
18+
KModErr PatchBase::patch_kernel_after_hook(uint64_t kaddr, const Assembler* a) {
19+
std::vector<uint8_t> bytes = aarch64_asm_to_bytes(a);
20+
RETURN_IF_ERROR(kernel_module::install_kernel_function_after_hook(kaddr, bytes));
21+
return KModErr::OK;
22+
}
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/patch_base.h‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
#include <iostream>
3+
#include <vector>
4+
#include "kernel_module_kit_umbrella.h"
5+
6+
class PatchBase {
7+
public:
8+
PatchBase();
9+
PatchBase(const PatchBase& other);
10+
~PatchBase();
11+
protected:
12+
KModErr patch_kernel_before_hook(uint64_t kaddr, const asmjit::a64::Assembler* a);
13+
KModErr patch_kernel_after_hook(uint64_t kaddr, const asmjit::a64::Assembler* a);
14+
};
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/patch_thermal_zone_get_temp.cpp‎

Copy file name to clipboard
+90Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include "patch_thermal_zone_get_temp.h"
2+
#include <vector>
3+
using namespace asmjit;
4+
using namespace asmjit::a64;
5+
using namespace asmjit::a64::Predicate;
6+
7+
/*
8+
在 AArch64(ARM64)架构中, 根据 AAPCS64 调用约定:
9+
X0–X7:传递参数和返回值
10+
X8:系统调用号或临时
11+
X9–X15:调用者易失(caller‑saved)临时寄存器
12+
X16–X17(IP0/IP1):过程内调用临时寄存器,用于短期跳转代码
13+
X18:平台保留寄存器(platform register),arm64内核启用SCS时,会x18作为shadow call stack指针
14+
X19–X28:被调用者保存寄存器(callee‑saved)
15+
X29(FP):帧指针
16+
X30(LR):链接寄存器
17+
SP:栈指针
18+
19+
在HOOK内核函数中:
20+
1.必须要保存、恢复的寄存器:x0–x7、X19–X28、X29-X30
21+
2.能自由修改、无需额外保存/恢复的寄存器是:x9–x15 或 x16–x17(IP0/IP1)
22+
3.尽量避开使用的寄存器:x18
23+
24+
简而言之:X9到X15之间的寄存器可以随便用,其他寄存器需要先保存再用,用完需恢复。
25+
26+
ABI 规定哪些寄存器需要保存?
27+
caller-saved(会被调用者破坏):X0..X17、Q0..Q7
28+
callee-saved(必须由被调函数保存):X19..X29、Q8..Q15、SP、FP、LR
29+
也就是说,像 get_task_mm 这种标准C函数,它自己保证不会破坏 callee-saved 寄存器。
30+
*/
31+
32+
PatchThermalZoneGetTemp::PatchThermalZoneGetTemp(const PatchBase& patch_base, uint64_t thermal_zone_get_temp) : PatchBase(patch_base), m_thermal_zone_get_temp(thermal_zone_get_temp) {}
33+
34+
PatchThermalZoneGetTemp::~PatchThermalZoneGetTemp() {}
35+
36+
KModErr PatchThermalZoneGetTemp::patch_thermal_zone_get_temp() {
37+
KModErr err = KModErr::OK;
38+
aarch64_asm_ctx asm_ctx = init_aarch64_asm();
39+
auto a = asm_ctx.assembler();
40+
Label L_end = a->newLabel();
41+
kernel_module::arm64_before_hook_start(a);
42+
43+
kernel_module::arm64hook_emit_load_original_func(a, x10);
44+
{
45+
RegProtectGuard g1(a, x1);
46+
a->blr(x10); // 手动调用一次内核原始获取温度函数。
47+
}
48+
a->cbnz(w0, L_end); // 返回值非0,代表不成功,则直接结束。
49+
50+
a->ldr(w10, ptr(x1)); // 读取内核即将要输出的温度。
51+
52+
aarch64_asm_mov_w(a, w11, 38000); // 低温区放行
53+
a->cmp(w10, w11);
54+
a->b(CondCode::kLE, L_end);
55+
56+
aarch64_asm_mov_w(a, w11, 95000); // 熔断保护 (通用版底线 95度)
57+
a->cmp(w10, w11);
58+
a->b(CondCode::kGE, L_end);
59+
60+
// 精细化系数 0.37 (37%)
61+
// 逻辑:(Real - 38) * 0.37 + 38
62+
// 效果:95度(真实) -> 59.1度(伪装)。
63+
// 这是一个巧妙的数值:平时奔放,极限时触发轻度温控保护主板。
64+
// int fake = 38000 + ((real - 38000) * 37 / 100);
65+
// kernel_module::export_symbol::printk(a, err, "[!!!] thermal_zone_get_temp real val: %d\n", w10);
66+
67+
// (real - 38000)
68+
aarch64_asm_mov_w(a, w11, 38000);
69+
a->sub(w12, w10, w11);
70+
71+
// (real - 38000) * 35
72+
aarch64_asm_mov_w(a, w11, 35);
73+
a->mul(w12, w12, w11);
74+
75+
// (real - 38000) * 35 / 100
76+
aarch64_asm_mov_w(a, w11, 100);
77+
a->sdiv(w12, w12, w11);
78+
79+
// 38000 + ((real - 38000) * 35 / 100)
80+
aarch64_asm_mov_w(a, w11, 38000);
81+
a->add(w12, w12, w11);
82+
83+
// kernel_module::export_symbol::printk(a, err, "[!!!] thermal_zone_get_temp fake val: %d\n", w12);
84+
85+
a->str(w12, ptr(x1));
86+
87+
a->bind(L_end);
88+
kernel_module::arm64_before_hook_end(a, false);
89+
return patch_kernel_before_hook(m_thermal_zone_get_temp, a);
90+
}
Collapse file

‎Pro(众测开放中)/sources/testModule/module_fake_thermal/patch_thermal_zone_get_temp.h‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
#include <iostream>
3+
#include <set>
4+
#include "patch_base.h"
5+
6+
class PatchThermalZoneGetTemp : public PatchBase {
7+
public:
8+
PatchThermalZoneGetTemp(const PatchBase& patch_base, uint64_t thermal_zone_get_temp);
9+
~PatchThermalZoneGetTemp();
10+
11+
KModErr patch_thermal_zone_get_temp();
12+
private:
13+
uint64_t m_thermal_zone_get_temp = 0;
14+
};
Collapse file

‎Pro(众测开放中)/sources/testModule/module_hide_data_dir/module_hide_data_dir.cpp‎

Copy file name to clipboardExpand all lines: Pro(众测开放中)/sources/testModule/module_hide_data_dir/module_hide_data_dir.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <set>
22

33
#include "module_hide_data_dir.h"
4+
#include "patch_filldir64.h"
45
#include "kernel_module_kit_umbrella.h"
56

6-
#include "patch_filldir64.h"
77
#include "cJSON.h"
88

99
#define MOD_VER "1.0.4"

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.