From dbc662486bbd32c4a2651da187674b5728c9653b Mon Sep 17 00:00:00 2001
From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
Date: Thu, 14 Aug 2025 23:18:21 +0800
Subject: [PATCH] Fix correct hook type acquisition
---
kernel/core_hook.c | 42 ++++++++++---------
.../src/main/res/values-zh-rCN/strings.xml | 2 +-
manager/app/src/main/res/values/strings.xml | 2 +-
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/kernel/core_hook.c b/kernel/core_hook.c
index 1e7c2046..fafbabff 100644
--- a/kernel/core_hook.c
+++ b/kernel/core_hook.c
@@ -522,25 +522,6 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
return 0;
}
- // Checking hook usage
- if (arg2 == CMD_HOOK_TYPE) {
- const char *hook_type;
-
-#if defined(CONFIG_KSU_KPROBES_HOOK)
- hook_type = "Kprobes";
-#elif defined(CONFIG_KSU_TRACEPOINT_HOOK)
- hook_type = "Tracepoint";
-#else
- hook_type = "Unknown";
-#endif
-
- size_t len = strlen(hook_type) + 1;
- if (copy_to_user((void __user *)arg3, hook_type, len)) {
- pr_err("hook_type: copy_to_user failed\n");
- return 0;
- }
- }
-
#ifdef CONFIG_KPM
// ADD: 添加KPM模块控制
if(sukisu_is_kpm_control_code(arg2)) {
@@ -561,6 +542,29 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
return 0;
}
+ // Checking hook usage
+ if (arg2 == CMD_HOOK_TYPE) {
+ const char *hook_type;
+
+#ifdef CONFIG_KSU_TRACEPOINT_HOOK
+ hook_type = "Tracepoint";
+#else
+ hook_type = "Kprobes";
+#endif
+
+ size_t len = strlen(hook_type) + 1;
+ if (copy_to_user((void __user *)arg3, hook_type, len)) {
+ pr_err("hook_type: copy_to_user failed\n");
+ return 0;
+ }
+
+ if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) {
+ pr_err("hook_type: prctl reply error\n");
+ }
+ return 0;
+ }
+
+
// all other cmds are for 'root manager'
if (!from_manager) {
return 0;
diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml
index 7096fe3d..ef12dece 100644
--- a/manager/app/src/main/res/values-zh-rCN/strings.xml
+++ b/manager/app/src/main/res/values-zh-rCN/strings.xml
@@ -621,5 +621,5 @@
未知发布者
未经签名的模块可能不完整。为了对设备进行保护,已阻止安装此模块。
未经签名的模块可能不完整。你想安装来自未知发布者的模块吗?
- 钩子类型: %s
+ 钩子类型
diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml
index 9425e62a..234588ea 100644
--- a/manager/app/src/main/res/values/strings.xml
+++ b/manager/app/src/main/res/values/strings.xml
@@ -629,5 +629,5 @@ Important Note:\n
Unknown publisher
Unsigned modules may be incomplete. To protect your device, installation of this module has been blocked.
Unsigned modules may be incomplete. Do you want to allow the following module from an unknown publisher to install in this device?
- Hook type: %s
+ Hook type