更新 KPM 模块,增加对 compact.o 的支持,并调整控制代码定义
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
obj-y += kpm.o
|
obj-y += kpm.o
|
||||||
obj-y += compact.o
|
obj-y += compact.o
|
||||||
|
|
||||||
|
ccflags-y += -flto=thin
|
||||||
@@ -31,34 +31,17 @@ unsigned long sukisu_compact_find_symbol(const char* name);
|
|||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
const char* kpver = "0.10";
|
|
||||||
|
|
||||||
struct CompactAddressSymbol {
|
struct CompactAddressSymbol {
|
||||||
const char* symbol_name;
|
const char* symbol_name;
|
||||||
void* addr;
|
void* addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompactAliasSymbol {
|
static struct CompactAddressSymbol address_symbol [] = {
|
||||||
const char* symbol_name;
|
|
||||||
const char* compact_symbol_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CompactAddressSymbol address_symbol [] = {
|
|
||||||
{ "kallsyms_lookup_name", &kallsyms_lookup_name },
|
{ "kallsyms_lookup_name", &kallsyms_lookup_name },
|
||||||
{ "compact_find_symbol", &sukisu_compact_find_symbol },
|
{ "compact_find_symbol", &sukisu_compact_find_symbol },
|
||||||
{ "compat_copy_to_user", ©_to_user },
|
|
||||||
{ "compat_strncpy_from_user", &strncpy_from_user },
|
|
||||||
{ "kpver", &kpver },
|
|
||||||
{ "is_run_in_sukisu_ultra", (void*)1 }
|
{ "is_run_in_sukisu_ultra", (void*)1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompactAliasSymbol alias_symbol[] = {
|
|
||||||
{"kf_strncat", "strncat"},
|
|
||||||
{"kf_strlen", "strlen" },
|
|
||||||
{"kf_strcpy", "strcpy"},
|
|
||||||
{"compat_copy_to_user", "__arch_copy_to_user"}
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned long sukisu_compact_find_symbol(const char* name) {
|
unsigned long sukisu_compact_find_symbol(const char* name) {
|
||||||
int i;
|
int i;
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
@@ -71,30 +54,13 @@ unsigned long sukisu_compact_find_symbol(const char* name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 如果符号名以 "kf__" 开头,尝试解析去掉前缀的部分 */
|
|
||||||
if (strncmp(name, "kf__", 4) == 0) {
|
|
||||||
const char *real_name = name + 4; // 去掉 "kf__"
|
|
||||||
addr = (unsigned long)kallsyms_lookup_name(real_name);
|
|
||||||
if (addr) {
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通过内核来查
|
// 通过内核来查
|
||||||
addr = kallsyms_lookup_name(name);
|
addr = kallsyms_lookup_name(name);
|
||||||
if(addr) {
|
if(addr) {
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查不到就查查兼容的符号
|
|
||||||
for(i = 0; i < (sizeof(alias_symbol) / sizeof(struct CompactAliasSymbol)); i++) {
|
|
||||||
struct CompactAliasSymbol* symbol = &alias_symbol[i];
|
|
||||||
if(strcmp(name, symbol->symbol_name) == 0) {
|
|
||||||
addr = kallsyms_lookup_name(symbol->compact_symbol_name);
|
|
||||||
if(addr)
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT_SYMBOL(sukisu_compact_find_symbol);
|
||||||
|
|||||||
1302
kernel/kpm/kpm.c
1302
kernel/kpm/kpm.c
File diff suppressed because it is too large
Load Diff
@@ -6,39 +6,39 @@ int sukisu_is_kpm_control_code(unsigned long arg2);
|
|||||||
|
|
||||||
// KPM控制代码
|
// KPM控制代码
|
||||||
#define CMD_KPM_CONTROL 28
|
#define CMD_KPM_CONTROL 28
|
||||||
#define CMD_KPM_CONTROL_MAX 34
|
#define CMD_KPM_CONTROL_MAX 35
|
||||||
|
|
||||||
// 控制代码
|
// 控制代码
|
||||||
|
|
||||||
// prctl(xxx, xxx, 1, "PATH", "ARGS")
|
// prctl(xxx, 28, "PATH", "ARGS")
|
||||||
// success return 0, error return -N
|
// success return 0, error return -N
|
||||||
#define SUKISU_KPM_LOAD 28
|
#define SUKISU_KPM_LOAD 28
|
||||||
|
|
||||||
// prctl(xxx, xxx, 2, "NAME")
|
// prctl(xxx, 29, "NAME")
|
||||||
// success return 0, error return -N
|
// success return 0, error return -N
|
||||||
#define SUKISU_KPM_UNLOAD 29
|
#define SUKISU_KPM_UNLOAD 29
|
||||||
|
|
||||||
// num = prctl(xxx, xxx, 3)
|
// num = prctl(xxx, 30)
|
||||||
// error return -N
|
// error return -N
|
||||||
// success return +num or 0
|
// success return +num or 0
|
||||||
#define SUKISU_KPM_NUM 30
|
#define SUKISU_KPM_NUM 30
|
||||||
|
|
||||||
// prctl(xxx, xxx, 4, Buffer, BufferSize)
|
// prctl(xxx, 31, Buffer, BufferSize)
|
||||||
// success return +out, error return -N
|
// success return +out, error return -N
|
||||||
#define SUKISU_KPM_LIST 31
|
#define SUKISU_KPM_LIST 31
|
||||||
|
|
||||||
// prctl(xxx, xxx, 5, "NAME", Buffer[256])
|
// prctl(xxx, 32, "NAME", Buffer[256])
|
||||||
// success return +out, error return -N
|
// success return +out, error return -N
|
||||||
#define SUKISU_KPM_INFO 32
|
#define SUKISU_KPM_INFO 32
|
||||||
|
|
||||||
// prctl(xxx, xxx, 6, "NAME", "ARGS")
|
// prctl(xxx, 33, "NAME", "ARGS")
|
||||||
// success return KPM's result value
|
// success return KPM's result value
|
||||||
// error return -N
|
// error return -N
|
||||||
#define SUKISU_KPM_CONTROL 33
|
#define SUKISU_KPM_CONTROL 33
|
||||||
|
|
||||||
// prctl(xxx, xxx, 7)
|
// prctl(xxx, 34, buffer, bufferSize)
|
||||||
// success will printf to stdout and return 0
|
// success return KPM's result value
|
||||||
// error will return -1
|
// error return -N
|
||||||
#define SUKISU_KPM_PRINT 34
|
#define SUKISU_KPM_VERSION 34
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user