diff --git a/kernel/kpm/Makefile b/kernel/kpm/Makefile index 10cf7d44..3f75542d 100644 --- a/kernel/kpm/Makefile +++ b/kernel/kpm/Makefile @@ -1,2 +1,6 @@ obj-y += kpm.o -obj-y += compact.o \ No newline at end of file +obj-y += compact.o +obj-y += super_access.o + +ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat +ccflags-y += -Wno-declaration-after-statement -Wno-unused-function \ No newline at end of file diff --git a/kernel/kpm/compact.c b/kernel/kpm/compact.c index 01f00e80..9bece752 100644 --- a/kernel/kpm/compact.c +++ b/kernel/kpm/compact.c @@ -27,6 +27,7 @@ #include "kpm.h" #include "compact.h" #include "../allowlist.h" +#include "../manager.h" unsigned long sukisu_compact_find_symbol(const char* name); @@ -49,6 +50,16 @@ int sukisu_is_uid_should_umount(uid_t uid) { return ksu_uid_should_umount(uid) ? 1 : 0; } +static +int sukisu_is_current_uid_manager() { + return is_manager(); +} + +static +uid_t sukisu_get_manager_uid() { + return ksu_manager_uid; +} + // ====================================================================== struct CompactAddressSymbol { @@ -62,7 +73,9 @@ static struct CompactAddressSymbol address_symbol [] = { { "is_run_in_sukisu_ultra", (void*)1 }, { "is_su_allow_uid", &sukisu_is_su_allow_uid }, { "get_ap_mod_exclude", &sukisu_get_ap_mod_exclude }, - { "is_uid_should_umount", &sukisu_is_uid_should_umount } + { "is_uid_should_umount", &sukisu_is_uid_should_umount }, + { "is_current_uid_manager", &sukisu_is_current_uid_manager }, + { "get_manager_uid", &sukisu_get_manager_uid } }; unsigned long sukisu_compact_find_symbol(const char* name) { diff --git a/kernel/kpm/super_access.h b/kernel/kpm/super_access.h index e69de29b..2514be89 100644 --- a/kernel/kpm/super_access.h +++ b/kernel/kpm/super_access.h @@ -0,0 +1,39 @@ +#ifndef __SUKISU_SUPER_ACCESS_H +#define __SUKISU_SUPER_ACCESS_H + +#include +#include +#include "kpm.h" +#include "compact.h" + +// return 0 if successful +// return -1 if struct not defined +int sukisu_super_find_struct( + const char* struct_name, + size_t* out_size, + int* out_members +); + +// Dynamic access struct +// return 0 if successful +// return -1 if struct not defined +// return -2 if member not defined +int sukisu_super_access ( + const char* struct_name, + const char* member_name, + size_t* out_offset, + size_t* out_size +); + +// Dynamic container_of +// return 0 if success +// return -1 if current struct not defined +// return -2 if target member not defined +int sukisu_super_container_of( + const char* struct_name, + const char* member_name, + void* ptr, + void** out_ptr +); + +#endif \ No newline at end of file