diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2022-06-02 01:26:45 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2022-06-02 01:30:26 +0100 |
commit | 3ebe43eb75806990a402aafd5858de615d5c1cca (patch) | |
tree | 16edcb4b560520ad5225673e1a8ad45facc20c40 /src/hook.c | |
parent | 74563bfb8c506150172b9bbf73d828372add3394 (diff) |
Solve the error logging situation
Diffstat (limited to 'src/hook.c')
-rw-r--r-- | src/hook.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -48,20 +48,24 @@ void *hook_inline(void *func_, void *target) { if (!os_mprot(func, 5, PAGE_EXECUTE_READWRITE)) return false; int len = 0; for (;;) { + // FIXME: these cases may result in somewhat dodgy error messaging. They + // shouldn't happen anyway though. Maybe if we're confident we just + // compile 'em out of release builds some day, but that sounds a little + // scary. For now prefering confusing messages over crashes, I guess. if (func[len] == X86_CALL) { con_warn("hook_inline: can't trampoline call instructions\n"); - return false; + return 0; } int ilen = x86_len(func + len); if (ilen == -1) { con_warn("hook_inline: unknown or invalid instruction\n"); - return false; + return 0; } len += ilen; if (len >= 5) break; if (func[len] == X86_JMPIW) { con_warn("hook_inline: can't trampoline jmp instructions\n"); - return false; + return 0; } } // for simplicity, just bump alloc the trampoline. no need to free anyway |