Skip to content

Commit

Permalink
Wrap Windows.h inclusions to support cross-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
aixxe committed Nov 14, 2023
1 parent d952426 commit 3734e64
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/safetyhook/thread_freezer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
#include <cstdint>
#include <functional>

#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#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
Expand Down
6 changes: 6 additions & 0 deletions src/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
#include <limits>

#define NOMINMAX
#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif

#include <safetyhook/allocator.hpp>

Expand Down
6 changes: 6 additions & 0 deletions src/inline_hook.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <iterator>

#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif

#if __has_include(<Zydis/Zydis.h>)
#include <Zydis/Zydis.h>
Expand Down
6 changes: 6 additions & 0 deletions src/thread_freezer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif
#include <winternl.h>

#include <safetyhook/thread_freezer.hpp>
Expand Down
6 changes: 6 additions & 0 deletions src/utility.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif

#include <safetyhook/utility.hpp>

Expand Down
6 changes: 6 additions & 0 deletions src/vmt_hook.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif

#include <safetyhook/thread_freezer.hpp>

Expand Down
6 changes: 6 additions & 0 deletions tests/test4.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#if __has_include(<Windows.h>)
#include <Windows.h>
#elif __has_include(<windows.h>)
#include <windows.h>
#else
#error "Windows.h not found"
#endif

#include <safetyhook.hpp>

Expand Down

0 comments on commit 3734e64

Please sign in to comment.