From a976efe67c5f936eb553a0d61b78a311da7224d9 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 28 Feb 2015 21:54:23 -0500 Subject: Add extra argument to substitute_hook_functions and interpose_imports for use with unhooking. I think we'll need to explicitly record trampoline locations to avoid the possibility of stomping on someone else's stuff if the function was re-patched... Also, document substitute_hook_functions. --- lib/darwin/interpose.c | 7 ++++++- lib/darwin/substrate-compat.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/darwin') diff --git a/lib/darwin/interpose.c b/lib/darwin/interpose.c index dd267ac..c74f747 100644 --- a/lib/darwin/interpose.c +++ b/lib/darwin/interpose.c @@ -147,12 +147,17 @@ static void *off_to_addr(const struct interpose_state *st, uint32_t off) { EXPORT int substitute_interpose_imports(const struct substitute_image *image, const struct substitute_import_hook *hooks, - size_t nhooks, int options) { + size_t nhooks, + struct substitute_import_hook_record **recordp, + int options) { int ret = SUBSTITUTE_OK; if (options != 0) substitute_panic("%s: unrecognized options\n", __func__); + if (recordp) + *recordp = NULL; + struct interpose_state st; st.slide = image->slide; st.nsegments = 0; diff --git a/lib/darwin/substrate-compat.c b/lib/darwin/substrate-compat.c index 3515e44..bb68366 100644 --- a/lib/darwin/substrate-compat.c +++ b/lib/darwin/substrate-compat.c @@ -43,7 +43,7 @@ EXPORT void SubHookFunction(void *symbol, void *replace, void **result) __asm__("SubHookFunction"); void SubHookFunction(void *symbol, void *replace, void **result) { struct substitute_function_hook hook = {symbol, replace, result}; - int ret = substitute_hook_functions(&hook, 1, SUBSTITUTE_NO_THREAD_SAFETY); + int ret = substitute_hook_functions(&hook, 1, NULL, SUBSTITUTE_NO_THREAD_SAFETY); if (ret) { substitute_panic("SubHookFunction: substitute_hook_functions returned %s\n", substitute_strerror(ret)); -- cgit v1.2.3