Skip to content

Commit

Permalink
Do nothing on Windows 11
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Feb 3, 2023
1 parent 3717fad commit 4423c63
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions unicon/headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
#include <psapi.h>
#include <rpc.h>
#include <tlhelp32.h>
#include <versionhelpers.h>
3 changes: 3 additions & 0 deletions unicon/inject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
34 changes: 34 additions & 0 deletions unicon/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions unicon/utility.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once

bool is_conhost(const wchar_t* ProcessName);
bool is_windows_11_or_greater();

0 comments on commit 4423c63

Please sign in to comment.