兼容修复

This commit is contained in:
liankong
2025-03-30 17:21:33 +08:00
parent c6664af45b
commit 470aaa29dc

View File

@@ -49,7 +49,7 @@ struct CompactProxySymbol {
void* cached_address; void* cached_address;
}; };
struct CompactAddressSymbol address_symbol [] = { static 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", &copy_to_user }, { "compat_copy_to_user", &copy_to_user },
@@ -58,21 +58,21 @@ struct CompactAddressSymbol address_symbol [] = {
{ "is_run_in_sukisu_ultra", (void*)1 } { "is_run_in_sukisu_ultra", (void*)1 }
}; };
struct CompactAliasSymbol alias_symbol[] = { static struct CompactAliasSymbol alias_symbol[] = {
{"compat_copy_to_user", "__arch_copy_to_user"} {"compat_copy_to_user", "__arch_copy_to_user"}
}; };
struct CompactProxySymbol proxy_symbol[] = { static struct CompactProxySymbol proxy_symbol[] = {
{"kf_strncat", "strncat", NULL }, {"kf_strncat", "strncat", NULL },
{"kf_strlen", "strlen", NULL }, {"kf_strlen", "strlen", NULL },
{"kf_strcpy", "strcpy", NULL }, {"kf_strcpy", "strcpy", NULL },
}; };
static unsigned long sukisu_find_proxy_symbol(const char* name) { static unsigned long sukisu_find_proxy_symbol(const char* name) {
// 查不到就查查兼容的符号 // 查找proxy符号
int i; int i;
for(i = 0; i < (sizeof(proxy_symbol) / sizeof(struct CompactProxySymbol)); i++) { for(i = 0; i < (sizeof(proxy_symbol) / sizeof(struct CompactProxySymbol)); i++) {
struct CompactProxySymbol* symbol = &alias_symbol[i]; struct CompactProxySymbol* symbol = &proxy_symbol[i];
if(strcmp(name, symbol->symbol_name) == 0) { if(strcmp(name, symbol->symbol_name) == 0) {
if(symbol->cached_address == NULL) { if(symbol->cached_address == NULL) {
symbol->cached_address = (void*) kallsyms_lookup_name(name); symbol->cached_address = (void*) kallsyms_lookup_name(name);
@@ -88,6 +88,7 @@ static unsigned long sukisu_find_proxy_symbol(const char* name) {
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;
char isFoundedProxy = 0;
// 先自己在地址表部分查出来 // 先自己在地址表部分查出来
for(i = 0; i < (sizeof(address_symbol) / sizeof(struct CompactAddressSymbol)); i++) { for(i = 0; i < (sizeof(address_symbol) / sizeof(struct CompactAddressSymbol)); i++) {
@@ -100,6 +101,7 @@ unsigned long sukisu_compact_find_symbol(const char* name) {
/* 如果符号名以 "kf__" 开头,尝试解析去掉前缀的部分 */ /* 如果符号名以 "kf__" 开头,尝试解析去掉前缀的部分 */
if (strncmp(name, "kf__", 4) == 0) { if (strncmp(name, "kf__", 4) == 0) {
addr = sukisu_find_proxy_symbol(name); addr = sukisu_find_proxy_symbol(name);
isFoundedProxy = 1;
if(addr != 0) { if(addr != 0) {
return addr; return addr;
} }
@@ -121,5 +123,9 @@ unsigned long sukisu_compact_find_symbol(const char* name) {
} }
} }
if(!isFoundedProxy) {
return sukisu_find_proxy_symbol(name);
}
return 0; return 0;
} }