forked from khanhduytran0/LiveContainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FixCydiaSubstrate.c
33 lines (31 loc) · 1.09 KB
/
FixCydiaSubstrate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <mach-o/dyld.h>
#include <mach-o/dyld_images.h>
#include "fishhook/fishhook.h"
// Provide _dyld_get_all_image_infos for CydiaSubstrate
struct dyld_all_image_infos *_alt_dyld_get_all_image_infos() {
static struct dyld_all_image_infos *result;
if (result) {
return result;
}
struct task_dyld_info dyld_info;
mach_vm_address_t image_infos;
mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
kern_return_t ret;
ret = task_info(mach_task_self_,
TASK_DYLD_INFO,
(task_info_t)&dyld_info,
&count);
if (ret != KERN_SUCCESS) {
return NULL;
}
image_infos = dyld_info.all_image_info_addr;
result = (struct dyld_all_image_infos *)image_infos;
return result;
}
void init_fixCydiaSubstrate(void) {
void *orig__dyld_get_all_image_infos;
struct rebinding rebindings[] = (struct rebinding[]){
{"_dyld_get_all_image_infos", _alt_dyld_get_all_image_infos, (void *)&orig__dyld_get_all_image_infos}
};
rebind_symbols(rebindings, sizeof(rebindings)/sizeof(struct rebinding));
}