From 6d87465d0164f281348f8f67c6dd84b0bdccf392 Mon Sep 17 00:00:00 2001 From: aixxe Date: Tue, 14 Nov 2023 17:15:29 +0000 Subject: [PATCH] Wrap Windows.h inclusions to support cross-compiling (#44) --- include/safetyhook/thread_freezer.hpp | 6 ++++++ src/allocator.cpp | 6 ++++++ src/inline_hook.cpp | 6 ++++++ src/thread_freezer.cpp | 6 ++++++ src/utility.cpp | 6 ++++++ src/vmt_hook.cpp | 6 ++++++ tests/test4.cpp | 6 ++++++ 7 files changed, 42 insertions(+) diff --git a/include/safetyhook/thread_freezer.hpp b/include/safetyhook/thread_freezer.hpp index 9f5d45f..04361f2 100644 --- a/include/safetyhook/thread_freezer.hpp +++ b/include/safetyhook/thread_freezer.hpp @@ -6,7 +6,13 @@ #include #include +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif namespace safetyhook { /// @brief Executes a function while all other threads are frozen. Also allows for visiting each frozen thread and diff --git a/src/allocator.cpp b/src/allocator.cpp index 5b496a2..64165bc 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -3,7 +3,13 @@ #include #define NOMINMAX +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #include diff --git a/src/inline_hook.cpp b/src/inline_hook.cpp index 59cb9ac..fb98900 100644 --- a/src/inline_hook.cpp +++ b/src/inline_hook.cpp @@ -1,6 +1,12 @@ #include +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #if __has_include() #include diff --git a/src/thread_freezer.cpp b/src/thread_freezer.cpp index 364ad73..a0438b6 100644 --- a/src/thread_freezer.cpp +++ b/src/thread_freezer.cpp @@ -1,4 +1,10 @@ +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #include #include diff --git a/src/utility.cpp b/src/utility.cpp index 616204a..65d5b57 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -1,4 +1,10 @@ +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #include diff --git a/src/vmt_hook.cpp b/src/vmt_hook.cpp index cec6512..587c6ca 100644 --- a/src/vmt_hook.cpp +++ b/src/vmt_hook.cpp @@ -1,4 +1,10 @@ +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #include diff --git a/tests/test4.cpp b/tests/test4.cpp index 8eef863..f31cd90 100644 --- a/tests/test4.cpp +++ b/tests/test4.cpp @@ -1,4 +1,10 @@ +#if __has_include() #include +#elif __has_include() +#include +#else +#error "Windows.h not found" +#endif #include