Skip to content

Commit

Permalink
bridgehook: add NULL support to MSFindSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Jul 16, 2024
1 parent 1e7e9b7 commit 6a387c0
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/bridgehook/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,31 @@ MSImageRef MSGetImageByName(const char *file) {
}

BH_EXPORT
void MSCloseImage(const char* file) {
void MSCloseImage(__unused const char* file) {
return;
}

BH_EXPORT
void *MSFindSymbol(MSImageRef image, const char *name) {
uint32_t file_index = 0;
for (uint32_t i = 0; i < _dyld_image_count(); i++) {
if (image == _dyld_get_image_header(i)) {
file_index = i;
break;
if (image) {
uint32_t file_index = 0;
for (uint32_t i = 0; i < _dyld_image_count(); i++) {
if (image == _dyld_get_image_header(i)) {
file_index = i;
break;
}
}
if (file_index)
return DobbySymbolResolver(_dyld_get_image_name(file_index), name);
else
return NULL;
} else {
for (uint32_t i = 0; i < _dyld_image_count(); i++) {
void* sym = DobbySymbolResolver(_dyld_get_image_name(i), name);
if (sym) return sym;
}
}
if (file_index)
return DobbySymbolResolver(_dyld_get_image_name(file_index), name);
else
return NULL;
}
}

BH_EXPORT
Expand Down

0 comments on commit 6a387c0

Please sign in to comment.