From 670488716dde7ba7813dd281f24403a0b24d8690 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 21 Jan 2024 21:59:23 +0000 Subject: Rethink mem_loadoffset, and consequently, kill it Suggested by bill. Having something semantically pointer-sized that's only ever used for stuff that's always 32-bit doesn't really make sense. Note that I intentionally did not add a copyright line for myself in hud.c because, I mean, come on. I'll just say I waive any claim to that tiny trivial change. --- src/hook.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/hook.c') diff --git a/src/hook.c b/src/hook.c index ba02461..eb64cbe 100644 --- a/src/hook.c +++ b/src/hook.c @@ -1,5 +1,5 @@ /* - * Copyright © 2023 Michael Smith + * Copyright © 2024 Michael Smith * Copyright © 2022 Willian Henrique * * Permission to use, copy, modify, and/or distribute this software for any @@ -59,7 +59,7 @@ void *hook_inline(void *func_, void *target) { uchar *func = func_; // dumb hack: if we hit some thunk that immediately jumps elsewhere (which // seems common for win32 API functions), hook the underlying thing instead. - while (*func == X86_JMPIW) func += mem_loadoffset(func + 1) + 5; + while (*func == X86_JMPIW) func += mem_loads32(func + 1) + 5; if (!os_mprot(func, 5, PAGE_EXECUTE_READWRITE)) return false; int len = 0; for (;;) { @@ -105,7 +105,7 @@ void *hook_inline(void *func_, void *target) { void unhook_inline(void *orig) { uchar *p = orig; int len = p[-1]; - int off = mem_load32(p + len + 1); + int off = mem_loads32(p + len + 1); uchar *q = p + off + 5; memcpy(q, p, 5); // XXX: not atomic atm! (does any of it even need to be?) iflush(q, 5); -- cgit v1.2.3