diff --git a/unicon/headers.hpp b/unicon/headers.hpp index 69308e8..6b6de3d 100644 --- a/unicon/headers.hpp +++ b/unicon/headers.hpp @@ -13,3 +13,4 @@ #include #include #include +#include diff --git a/unicon/inject.cpp b/unicon/inject.cpp index 66326ef..7723609 100644 --- a/unicon/inject.cpp +++ b/unicon/inject.cpp @@ -65,6 +65,9 @@ inline HMODULE GetCurrentModuleHandle() __declspec(dllexport) void inject(unsigned Pid) { + if (is_windows_11_or_greater()) + return; + BOOL IsWow64{}; if (IsWow64Process(GetCurrentProcess(), &IsWow64) && IsWow64) throw std::runtime_error("WOW64 is not supported. Please use the x64 version."); diff --git a/unicon/utility.cpp b/unicon/utility.cpp index e5282a1..2a5c935 100644 --- a/unicon/utility.cpp +++ b/unicon/utility.cpp @@ -12,3 +12,37 @@ bool is_conhost(const wchar_t* ProcessName) { return ends_with(ProcessName, L"\\conhost.exe"); } + +bool is_windows_11_or_greater() +{ + OSVERSIONINFOEXW osvi + { + sizeof(osvi), + HIBYTE(_WIN32_WINNT_WIN10), + LOBYTE(_WIN32_WINNT_WIN10), + 22000 + }; + + const auto ConditionMask = + VerSetConditionMask( + VerSetConditionMask( + VerSetConditionMask( + 0, + VER_MAJORVERSION, + VER_GREATER_EQUAL + ), + VER_MINORVERSION, + VER_GREATER_EQUAL + ), + VER_BUILDNUMBER, + VER_GREATER_EQUAL + ); + + return VerifyVersionInfoW( + &osvi, + VER_MAJORVERSION | + VER_MINORVERSION | + VER_BUILDNUMBER, + ConditionMask + ) != FALSE; +} diff --git a/unicon/utility.hpp b/unicon/utility.hpp index afe1087..5d3260d 100644 --- a/unicon/utility.hpp +++ b/unicon/utility.hpp @@ -1,3 +1,4 @@ #pragma once bool is_conhost(const wchar_t* ProcessName); +bool is_windows_11_or_greater();