Skip to content

Commit

Permalink
Update libundirect headers (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 authored May 21, 2024
1 parent 34ee082 commit 1e2a76d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions libundirect/libundirect_dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
#import <Foundation/NSString.h>
#import <substrate.h>
#import <libhooker/libhooker.h>
#import <rootless.h>
#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;

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libundirect/libundirect_hookoverwrite.h
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down

0 comments on commit 1e2a76d

Please sign in to comment.