From 1e2a76d93c2dd17eebb3a14b6f42b091ae85efb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Fr=C3=B6der?= Date: Tue, 21 May 2024 03:02:16 +0200 Subject: [PATCH] Update libundirect headers (#94) --- libundirect/libundirect_dynamic.h | 32 ++++++++++++------------- libundirect/libundirect_hookoverwrite.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libundirect/libundirect_dynamic.h b/libundirect/libundirect_dynamic.h index 1052263..faa7827 100644 --- a/libundirect/libundirect_dynamic.h +++ b/libundirect/libundirect_dynamic.h @@ -16,18 +16,18 @@ #import #import #import +#import +#define LIBUNDIRECT_PATH ROOT_PATH("/usr/lib/libundirect.dylib") #ifdef __cplusplus extern "C" { #endif -#define LU_ROOT_PATH_C(cPath) (access(cPath, F_OK) == 0) ? cPath : "/var/jb" cPath - // dynamic header for when you don't want to link against libundirect // for documentation, check out the non-dynamic header -typedef enum -{ +typedef enum +{ OPTION_DO_NOT_SEEK_BACK = 1 << 0 } libundirect_find_options_t; @@ -37,7 +37,7 @@ static void libundirect_MSHookMessageEx(Class _class, SEL message, IMP hook, IMP static void (*impl_libundirect_MSHookMessageEx)(Class, SEL, IMP, IMP *); if(!impl_libundirect_MSHookMessageEx) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_MSHookMessageEx = (void (*)(Class, SEL, IMP, IMP *))dlsym(handle, "libundirect_MSHookMessageEx"); } if(impl_libundirect_MSHookMessageEx) @@ -56,7 +56,7 @@ static void libundirect_rebind(void* directPtr, Class _class, SEL selector, cons static void (*impl_libundirect_rebind)(void*, Class, SEL, const char*); if(!impl_libundirect_rebind) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_rebind = (void (*)(void*, Class, SEL, const char*))dlsym(handle, "libundirect_rebind"); } if(impl_libundirect_rebind) @@ -71,7 +71,7 @@ static void* libundirect_seek_back(void* startPtr, unsigned char toByte, unsigne static void* (*impl_libundirect_seek_back)(void*, unsigned char, unsigned int); if(!impl_libundirect_seek_back) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_seek_back = (void* (*)(void*, unsigned char, unsigned int))dlsym(handle, "libundirect_seek_back"); } if(impl_libundirect_seek_back) @@ -87,7 +87,7 @@ static void* libundirect_find_with_options_and_mask(NSString* imageName, unsigne static void* (*impl_libundirect_find_with_options_and_mask)(NSString*, unsigned char*, unsigned char*, size_t, unsigned char, unsigned int, libundirect_find_options_t); if(!impl_libundirect_find_with_options_and_mask) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_find_with_options_and_mask = (void* (*)(NSString*, unsigned char*, unsigned char*, size_t, unsigned char, unsigned int, libundirect_find_options_t))dlsym(handle, "libundirect_find_with_options_and_mask"); } if(impl_libundirect_find_with_options_and_mask) @@ -103,7 +103,7 @@ static void* libundirect_find_with_options(NSString* imageName, unsigned char* b static void* (*impl_libundirect_find_with_options)(NSString*, unsigned char*, size_t, unsigned char, unsigned int, libundirect_find_options_t); if(!impl_libundirect_find_with_options) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_find_with_options = (void* (*)(NSString*, unsigned char*, size_t, unsigned char, unsigned int, libundirect_find_options_t))dlsym(handle, "libundirect_find_with_options"); } if(impl_libundirect_find_with_options) @@ -119,7 +119,7 @@ static void* libundirect_find(NSString* imageName, unsigned char* bytesToSearch, static void* (*impl_libundirect_find)(NSString*, unsigned char*, size_t, unsigned char); if(!impl_libundirect_find) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_find = (void* (*)(NSString*, unsigned char*, size_t, unsigned char))dlsym(handle, "libundirect_find"); } if(impl_libundirect_find) @@ -135,7 +135,7 @@ static void* libundirect_dsc_find(NSString* imageName, Class _class, SEL selecto static void* (*impl_libundirect_dsc_find)(NSString*, Class, SEL); if(!impl_libundirect_dsc_find) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_dsc_find = (void* (*)(NSString*, Class, SEL))dlsym(handle, "libundirect_dsc_find"); } if(impl_libundirect_dsc_find) @@ -151,7 +151,7 @@ static void libundirect_dsc_rebind(NSString* imageName, Class _class, SEL select static void (*impl_libundirect_dsc_rebind)(NSString*, Class, SEL, const char*); if(!impl_libundirect_dsc_rebind) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_dsc_rebind = (void (*)(NSString*, Class, SEL, const char*))dlsym(handle, "libundirect_dsc_rebind"); } if(impl_libundirect_dsc_rebind) @@ -166,7 +166,7 @@ static NSArray* libundirect_failedSelectors() static NSArray* (*impl_libundirect_failedSelectors)(); if(!impl_libundirect_failedSelectors) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_failedSelectors = (NSArray* (*)(void))dlsym(handle, "libundirect_failedSelectors"); } if(impl_libundirect_failedSelectors) @@ -182,7 +182,7 @@ static void libundirect_startBatchHooks(void) static void (*impl_libundirect_startBatchHooks)(); if(!impl_libundirect_startBatchHooks) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_startBatchHooks = (void (*)(void))dlsym(handle, "libundirect_startBatchHooks"); } if(impl_libundirect_startBatchHooks) @@ -197,7 +197,7 @@ static void libundirect_applyBatchHooksAndAdditional(const struct LHFunctionHook static void (*impl_libundirect_applyBatchHooksAndAdditional)(const struct LHFunctionHook*, NSUInteger); if(!impl_libundirect_applyBatchHooksAndAdditional) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_applyBatchHooksAndAdditional = (void (*)(const struct LHFunctionHook*, NSUInteger))dlsym(handle, "libundirect_applyBatchHooksAndAdditional"); } if(impl_libundirect_applyBatchHooksAndAdditional) @@ -212,7 +212,7 @@ static void libundirect_applyBatchHooks() static void (*impl_libundirect_applyBatchHooks)(); if(!impl_libundirect_applyBatchHooks) { - void* handle = dlopen(LU_ROOT_PATH_C("/usr/lib/libundirect.dylib"), RTLD_LAZY); + void* handle = dlopen(LIBUNDIRECT_PATH, RTLD_LAZY); impl_libundirect_applyBatchHooks = (void (*)(void))dlsym(handle, "libundirect_failedSelectors"); } if(impl_libundirect_applyBatchHooks) diff --git a/libundirect/libundirect_hookoverwrite.h b/libundirect/libundirect_hookoverwrite.h index 5eba523..e201c07 100644 --- a/libundirect/libundirect_hookoverwrite.h +++ b/libundirect/libundirect_hookoverwrite.h @@ -1,7 +1,7 @@ #ifdef __cplusplus extern "C" { #endif -inline void libundirect_MSHookMessageEx_wrapper(Class _class, SEL message, IMP hook, IMP *old) +inline static void libundirect_MSHookMessageEx_wrapper(Class _class, SEL message, IMP hook, IMP *old) { libundirect_MSHookMessageEx(_class, message, hook, old); }