diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2022-06-27 00:36:48 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2022-06-27 00:36:48 +0100 |
commit | e3fd5ad05a7d933d401de431ce2d27a99d3b9995 (patch) | |
tree | 09e302cd63672f2ae1c7bf80a1d5ce164cfcd857 /src/hook.c | |
parent | 37afe67488ed93dc5e39942271dd24481797fe77 (diff) |
Add update detection, clean up minor stuff
Diffstat (limited to 'src/hook.c')
-rw-r--r-- | src/hook.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -29,14 +29,20 @@ #if defined(_WIN32) && !defined(_WIN64) +#if defined(__GNUC__) || defined(__clang__) __attribute__((aligned(4096))) +#elif defined(_MSC_VER) +__declspec(align(4096)) +#else +#error no way to align stuff! +#endif static uchar trampolines[4096]; static uchar *nexttrampoline = trampolines; -__attribute__((constructor)) -static void setrwx(void) { - // PE doesn't support rwx sections, not sure about ELF. Eh, just hack it in - // a constructor instead. If this fails and we segfault later, too bad! - os_mprot(trampolines, sizeof(trampolines), PAGE_EXECUTE_READWRITE); + +bool hook_init(void) { + // PE doesn't support rwx sections, not sure about ELF. Meh, just set it + // here instead. + return os_mprot(trampolines, sizeof(trampolines), PAGE_EXECUTE_READWRITE); } void *hook_inline(void *func_, void *target) { |