Skip to content

Commit ba43ece

Browse files
committed
added macros for old symbol resolvers
1 parent 3344627 commit ba43ece

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

include/tinyhook.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ TH_VIS int write_mem(void *destination, const void *source, size_t len);
5454
/* symbol resolve */
5555
TH_VIS void *symbol_resolve(uint32_t image_index, const char *symbol_name, uint resolve_type);
5656

57+
#define symtbl_solve(image_index, symbol_name) symbol_resolve(image_index, symbol_name, RESOLVE_SYMTAB)
58+
#define symexp_solve(image_index, symbol_name) symbol_resolve(image_index, symbol_name, RESOLVE_EXPORT)
59+
#define symstub_solve(image_index, symbol_name) symbol_resolve(image_index, symbol_name, RESOLVE_STUB)
60+
5761
#ifdef __cplusplus
5862
}
5963
#endif

src/interpose.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ int tiny_interpose(uint32_t image_index, const char *symbol_name, void *replacem
1717
intptr_t image_slide = _dyld_get_image_vmaddr_slide(image_index);
1818
struct mach_header_64 *mh_header = (struct mach_header_64 *)_dyld_get_image_header(image_index);
1919
struct load_command *ld_command = (void *)mh_header + sizeof(struct mach_header_64);
20+
if (mh_header == NULL) {
21+
LOG_ERROR("parse_macho: image_index %d out of range!", image_index);
22+
return -1;
23+
}
2024

2125
int nsym_sect = 0;
2226
bool sect_isconst[5];

src/objcrt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ Method ocrt_method(char type, const char *cls, const char *sel) {
2626
void *ocrt_impl(char type, const char *cls, const char *sel) {
2727
ARG_CHECK(cls != NULL);
2828
ARG_CHECK(sel != NULL);
29-
return method_getImplementation(ocrt_method(type, cls, sel));
29+
Method method = ocrt_method(type, cls, sel);
30+
if (method == NULL) return NULL;
31+
return method_getImplementation(method);
3032
}
3133

3234
static Method ensure_method(const char *cls, const char *sel) {

0 commit comments

Comments
 (0)