Skip to content

Commit fefa542

Browse files
committed
Namespace all fishhook functions to avoid collisions
I know not all of them needed to be namespaced as the private functions are static, but I did it anyway for consistency.
1 parent 700c50a commit fefa542

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

Classes/GlobalStateExplorers/SystemLog/FLEXSystemLogViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ + (void)load {
5656
return;
5757
}
5858

59-
FLEXDidHookNSLog = rebind_symbols((struct rebinding[1]) {{
59+
FLEXDidHookNSLog = flex_rebind_symbols((struct rebinding[1]) {{
6060
"os_log_shim_enabled",
6161
(void *)my_os_log_shim_enabled,
6262
(void **)&orig_os_log_shim_enabled

Classes/Utility/Runtime/flex_fishhook.c

+29-29
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ struct rebindings_entry {
6060
struct rebindings_entry *next;
6161
};
6262

63-
static struct rebindings_entry *_rebindings_head;
63+
static struct rebindings_entry *_flex_rebindings_head;
6464

6565
/// @return 0 on success
66-
static int prepend_rebindings(struct rebindings_entry **rebindings_head,
66+
static int flex_prepend_rebindings(struct rebindings_entry **rebindings_head,
6767
struct rebinding rebindings[],
6868
size_t nel) {
6969
struct rebindings_entry *new_entry = (struct rebindings_entry *) malloc(sizeof(struct rebindings_entry));
@@ -85,7 +85,7 @@ static int prepend_rebindings(struct rebindings_entry **rebindings_head,
8585
return 0;
8686
}
8787

88-
static vm_prot_t get_protection(void *sectionStart) {
88+
static vm_prot_t flex_get_protection(void *sectionStart) {
8989
mach_port_t task = mach_task_self();
9090
vm_size_t size = 0;
9191
vm_address_t address = (vm_address_t)sectionStart;
@@ -110,19 +110,19 @@ static vm_prot_t get_protection(void *sectionStart) {
110110
return VM_PROT_READ;
111111
}
112112
}
113-
static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
114-
section_t *section,
115-
intptr_t slide,
116-
nlist_t *symtab,
117-
char *strtab,
118-
uint32_t *indirect_symtab) {
113+
static void flex_perform_rebinding_with_section(struct rebindings_entry *rebindings,
114+
section_t *section,
115+
intptr_t slide,
116+
nlist_t *symtab,
117+
char *strtab,
118+
uint32_t *indirect_symtab) {
119119
const bool isDataConst = strcmp(section->segname, "__DATA_CONST") == 0;
120120
uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
121121
void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
122122
vm_prot_t oldProtection = VM_PROT_READ;
123123

124124
if (isDataConst) {
125-
oldProtection = get_protection(rebindings);
125+
oldProtection = flex_get_protection(rebindings);
126126
mprotect(indirect_symbol_bindings, section->size, PROT_READ | PROT_WRITE);
127127
}
128128

@@ -177,9 +177,9 @@ static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
177177
}
178178
}
179179

180-
static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
181-
const struct mach_header *header,
182-
intptr_t slide) {
180+
static void flex_rebind_symbols_for_image(struct rebindings_entry *rebindings,
181+
const struct mach_header *header,
182+
intptr_t slide) {
183183
Dl_info info;
184184
if (dladdr(header, &info) == 0) {
185185
return;
@@ -232,12 +232,12 @@ static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
232232
section_t *sect = (section_t *)(cur + sizeof(segment_command_t)) + j;
233233

234234
if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) {
235-
perform_rebinding_with_section(
235+
flex_perform_rebinding_with_section(
236236
rebindings, sect, slide, symtab, strtab, indirect_symtab
237237
);
238238
}
239239
if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) {
240-
perform_rebinding_with_section(
240+
flex_perform_rebinding_with_section(
241241
rebindings, sect, slide, symtab, strtab, indirect_symtab
242242
);
243243
}
@@ -246,19 +246,19 @@ static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
246246
}
247247
}
248248

249-
static void _rebind_symbols_for_image(const struct mach_header *header,
250-
intptr_t slide) {
251-
rebind_symbols_for_image(_rebindings_head, header, slide);
249+
static void _flex_rebind_symbols_for_image(const struct mach_header *header,
250+
intptr_t slide) {
251+
flex_rebind_symbols_for_image(_flex_rebindings_head, header, slide);
252252
}
253253

254-
int rebind_symbols_image(void *header,
255-
intptr_t slide,
256-
struct rebinding rebindings[],
257-
size_t rebindings_nel) {
254+
int flex_rebind_symbols_image(void *header,
255+
intptr_t slide,
256+
struct rebinding rebindings[],
257+
size_t rebindings_nel) {
258258
struct rebindings_entry *rebindings_head = NULL;
259259

260-
int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
261-
rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
260+
int retval = flex_prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
261+
flex_rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
262262

263263
if (rebindings_head) {
264264
free(rebindings_head->rebindings);
@@ -269,20 +269,20 @@ int rebind_symbols_image(void *header,
269269
}
270270

271271
/// @return 0 on success
272-
int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) {
273-
int retval = prepend_rebindings(&_rebindings_head, rebindings, rebindings_nel);
272+
int flex_rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) {
273+
int retval = flex_prepend_rebindings(&_flex_rebindings_head, rebindings, rebindings_nel);
274274
if (retval < 0) {
275275
return retval;
276276
}
277277

278278
// If this was the first call, register callback for image additions (which is also invoked for
279279
// existing images, otherwise, just run on existing images
280-
if (!_rebindings_head->next) {
281-
_dyld_register_func_for_add_image(_rebind_symbols_for_image);
280+
if (!_flex_rebindings_head->next) {
281+
_dyld_register_func_for_add_image(_flex_rebind_symbols_for_image);
282282
} else {
283283
uint32_t c = _dyld_image_count();
284284
for (uint32_t i = 0; i < c; i++) {
285-
_rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i));
285+
_flex_rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i));
286286
}
287287
}
288288

Classes/Utility/Runtime/flex_fishhook.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ struct rebinding {
5757
* @return 0 on success
5858
*/
5959
FISHHOOK_VISIBILITY
60-
int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel);
60+
int flex_rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel);
6161

6262
/**
6363
* Rebinds as above, but only in the specified image. The header should point
6464
* to the mach-o header, the slide should be the slide offset. Others as above.
6565
* @return 0 on success
6666
*/
6767
FISHHOOK_VISIBILITY
68-
int rebind_symbols_image(void *header,
69-
intptr_t slide,
70-
struct rebinding rebindings[],
71-
size_t rebindings_nel);
68+
int flex_rebind_symbols_image(void *header,
69+
intptr_t slide,
70+
struct rebinding rebindings[],
71+
size_t rebindings_nel);
7272

7373
#ifdef __cplusplus
7474
}

FLEX.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = "FLEX"
3-
spec.version = "4.1.0"
3+
spec.version = "4.1.1"
44
spec.summary = "A set of in-app debugging and exploration tools for iOS"
55
spec.description = <<-DESC
66
- Inspect and modify views in the hierarchy.

0 commit comments

Comments
 (0)