aboutsummaryrefslogtreecommitdiff
path: root/lib/darwin
diff options
context:
space:
mode:
authorcomex2015-02-28 21:54:23 -0500
committercomex2015-02-28 21:54:23 -0500
commita976efe67c5f936eb553a0d61b78a311da7224d9 (patch)
tree759de2adb9ad10a80b0373b5dbefdacbc04c9c18 /lib/darwin
parentfix accidental usage of panic() from mach/mach.h instead of substitute_panic (diff)
downloadsubstitute-a976efe67c5f936eb553a0d61b78a311da7224d9.tar.gz
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.
Diffstat (limited to 'lib/darwin')
-rw-r--r--lib/darwin/interpose.c7
-rw-r--r--lib/darwin/substrate-compat.c2
2 files changed, 7 insertions, 2 deletions
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));