diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index fa95f09..57cc7c0 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -317,6 +317,7 @@ + diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters index b775f65..687be01 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters @@ -129,6 +129,9 @@ Header Files + + Header Files\internal + diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index 2de1ca9..12598dd 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -1224,9 +1224,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) p = strstr(line, "%OSVERSIONSTRING%"); if (p) { - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); - sprintf_s(p, MAX_PATH, "%d.%d.%d.%d.", rovi.dwMajorVersion, rovi.dwMinorVersion, rovi.dwBuildNumber, ubr); + sprintf_s(p, MAX_PATH, "%d.%d.%d.%d.", global_rovi.dwMajorVersion, global_rovi.dwMinorVersion, global_rovi.dwBuildNumber, global_ubr); } } ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t)); @@ -3364,10 +3362,8 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR { AllowDarkModeForWindow(hWnd, g_darkModeEnabled); BOOL value = g_darkModeEnabled; - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); int s = 0; - if (rovi.dwBuildNumber < 18985) + if (global_rovi.dwBuildNumber < 18985) { s = -1; } @@ -3426,10 +3422,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR if (bIsCompositionEnabled) { BOOL value = (IsThemeActive() && !IsHighContrast() && IsWindows11()) ? 1 : 0; - if (IsMicaMaterialSupportedInThisBuild()) - { - DwmSetWindowAttribute(hWnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL)); - } + SetMicaMaterialForThisWindow(hWnd, value); } if (IsThemeActive() && ShouldAppsUseDarkMode && !IsHighContrast()) { @@ -3440,10 +3433,8 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR g_darkModeEnabled = bDarkModeEnabled; AllowDarkModeForWindow(hWnd, g_darkModeEnabled); BOOL value = g_darkModeEnabled; - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); int s = 0; - if (rovi.dwBuildNumber < 18985) + if (global_rovi.dwBuildNumber < 18985) { s = -1; } @@ -3815,6 +3806,9 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin ); } } + + wprintf(L"Running on Windows %d, OS Build %d.%d.%d.%d.\n", IsWindows11() ? 11 : 10, global_rovi.dwMajorVersion, global_rovi.dwMinorVersion, global_rovi.dwBuildNumber, global_ubr); + locale = GetUserDefaultUILanguage(); dwSize = LOCALE_NAME_MAX_LENGTH; if (hKey) @@ -4026,11 +4020,7 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin { if (bIsCompositionEnabled) { - BOOL value = 1; - if (IsMicaMaterialSupportedInThisBuild()) - { - DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL)); - } + SetMicaMaterialForThisWindow(hwnd, TRUE); /*WTA_OPTIONS ops; ops.dwFlags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON; ops.dwMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON; diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 617557c..bee7b68 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -39,9 +39,11 @@ IEPWeather* epw = NULL; SRWLOCK lock_epw = { .Ptr = SRWLOCK_INIT }; #endif +#include "osutility.h" #ifndef _WIN64 RTL_OSVERSIONINFOW global_rovi; +DWORD32 global_ubr; #endif #define WINX_ADJUST_X 5 @@ -4338,8 +4340,7 @@ __int64 __fastcall PeopleBand_DrawTextWithGlowHook( COLORREF rgbColor = RGB(0, 0, 0); if (bIsThemeActive) { - RTL_OSVERSIONINFOW rovi; - if ((VnGetOSVersion(&rovi) && rovi.dwBuildNumber < 18985) || (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode())) + if ((global_rovi.dwBuildNumber < 18985) || (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode())) { rgbColor = RGB(255, 255, 255); } @@ -4939,10 +4940,6 @@ DWORD SignalShellReady(DWORD wait) printf("Started \"Signal shell ready\" thread.\n"); //UpdateStartMenuPositioning(MAKELPARAM(TRUE, TRUE)); - RTL_OSVERSIONINFOW rovi; - ZeroMemory(&rovi, sizeof(RTL_OSVERSIONINFOW)); - VnGetOSVersion(&rovi); - while (!wait && TRUE) { HWND hShell_TrayWnd = FindWindowEx( @@ -4987,7 +4984,7 @@ DWORD SignalShellReady(DWORD wait) SetEvent(hEvent); } SetEvent(hCanStartSws); - if (bOldTaskbar && rovi.dwBuildNumber >= 22567) + if (bOldTaskbar && (global_rovi.dwBuildNumber >= 22567)) { PatchSndvolsso(); } @@ -8293,10 +8290,6 @@ DWORD Inject(BOOL bIsExplorer) ); #endif - RTL_OSVERSIONINFOW rovi; - ZeroMemory(&rovi, sizeof(RTL_OSVERSIONINFOW)); - VnGetOSVersion(&rovi); - int rv; if (bIsExplorer) @@ -8495,6 +8488,10 @@ DWORD Inject(BOOL bIsExplorer) return; } +#ifdef _WIN64 + wprintf(L"Running on Windows %d, OS Build %d.%d.%d.%d.\n", IsWindows11() ? 11 : 10, global_rovi.dwMajorVersion, global_rovi.dwMinorVersion, global_rovi.dwBuildNumber, global_ubr); +#endif + #ifdef _WIN64 wszEPWeatherKillswitch = calloc(sizeof(WCHAR), MAX_PATH); srand(time(NULL)); @@ -8827,12 +8824,12 @@ DWORD Inject(BOOL bIsExplorer) printf("Setup pnidui functions done\n"); - - if (rovi.dwBuildNumber < 22567) +#ifdef _WIN64 + if (global_rovi.dwBuildNumber < 22567) { PatchSndvolsso(); } - +#endif HANDLE hShell32 = GetModuleHandleW(L"shell32.dll"); @@ -10449,6 +10446,8 @@ HRESULT EntryPoint(DWORD dwMethod) return E_NOINTERFACE; } + InitializeGlobalVersionAndUBR(); + TCHAR exePath[MAX_PATH], dllName[MAX_PATH]; GetModuleFileNameW(hModule, dllName, MAX_PATH); PathStripPathW(dllName); diff --git a/ExplorerPatcher/osutility.h b/ExplorerPatcher/osutility.h new file mode 100644 index 0000000..a745c3a --- /dev/null +++ b/ExplorerPatcher/osutility.h @@ -0,0 +1,58 @@ +#ifndef _H_OSUTILITY_H_ +#define _H_OSUTILITY_H_ +#include +#include +#include + +// This allows compiling with older Windows SDKs as well +#ifndef NTDDI_WIN10_CO +#define DWMWA_USE_HOSTBACKDROPBRUSH 17 // [set] BOOL, Allows the use of host backdrop brushes for the window. +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 // [set] BOOL, Allows a window to either use the accent color, or dark, according to the user Color Mode preferences. +#define DWMWA_WINDOW_CORNER_PREFERENCE 33 // [set] WINDOW_CORNER_PREFERENCE, Controls the policy that rounds top-level window corners +#define DWMWA_BORDER_COLOR 34 // [set] COLORREF, The color of the thin border around a top-level window +#define DWMWA_CAPTION_COLOR 35 // [set] COLORREF, The color of the caption +#define DWMWA_TEXT_COLOR 36 // [set] COLORREF, The color of the caption text +#define DWMWA_VISIBLE_FRAME_BORDER_THICKNESS 37 // [get] UINT, width of the visible border around a thick frame window +#define DWMWCP_DEFAULT 0 +#define DWMWCP_DONOTROUND 1 +#define DWMWCP_ROUND 2 +#define DWMWCP_ROUNDSMALL 3 +#endif +#define DWMWA_MICA_EFFFECT 1029 + +extern RTL_OSVERSIONINFOW global_rovi; +extern DWORD32 global_ubr; + +inline void InitializeGlobalVersionAndUBR() +{ + global_ubr = VnGetOSVersionAndUBR(&global_rovi); +} + +inline BOOL IsWindows11() +{ + if (!global_rovi.dwMajorVersion) global_ubr = VnGetOSVersionAndUBR(&global_rovi); + if (global_rovi.dwBuildNumber >= 21996) return TRUE; + return FALSE; +} + +inline BOOL IsDwmExtendFrameIntoClientAreaBrokenInThisBuild() +{ + if (!IsWindows11()) + { + return FALSE; + } + if ((global_rovi.dwBuildNumber >= 21996 && global_rovi.dwBuildNumber < 22000) || (global_rovi.dwBuildNumber == 22000 && (global_ubr >= 1 && global_ubr <= 51))) + { + return TRUE; + } + return FALSE; +} + +inline HRESULT SetMicaMaterialForThisWindow(HWND hWnd, BOOL bApply) +{ + if (!IsWindows11() || IsDwmExtendFrameIntoClientAreaBrokenInThisBuild()) return S_FALSE; + DWORD dwAttribute = (global_rovi.dwBuildNumber >= 22523) ? 38 : DWMWA_MICA_EFFFECT; + DWORD dwProp = (bApply ? ((global_rovi.dwBuildNumber >= 22523) ? 2 : 1) : 0); + return DwmSetWindowAttribute(hWnd, dwAttribute, &dwProp, sizeof(DWORD)); +} +#endif \ No newline at end of file diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 50766a2..96985fb 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -3,6 +3,7 @@ #pragma comment(lib, "Wininet.lib") RTL_OSVERSIONINFOW global_rovi; +DWORD32 global_ubr; #pragma region "Weird stuff" INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2) diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 380962f..a9384a7 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -16,33 +16,17 @@ #pragma comment(lib, "Rstrtmgr.lib") #define _LIBVALINET_INCLUDE_UNIVERSAL #include +#include "osutility.h" #include "queryversion.h" #pragma comment(lib, "Psapi.lib") #include #include -#include #include "def.h" #define WM_MSG_GUI_SECTION WM_USER + 1 #define WM_MSG_GUI_SECTION_GET 1 -// This allows compiling with older Windows SDKs as well -#ifndef NTDDI_WIN10_CO -#define DWMWA_USE_HOSTBACKDROPBRUSH 17 // [set] BOOL, Allows the use of host backdrop brushes for the window. -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 // [set] BOOL, Allows a window to either use the accent color, or dark, according to the user Color Mode preferences. -#define DWMWA_WINDOW_CORNER_PREFERENCE 33 // [set] WINDOW_CORNER_PREFERENCE, Controls the policy that rounds top-level window corners -#define DWMWA_BORDER_COLOR 34 // [set] COLORREF, The color of the thin border around a top-level window -#define DWMWA_CAPTION_COLOR 35 // [set] COLORREF, The color of the caption -#define DWMWA_TEXT_COLOR 36 // [set] COLORREF, The color of the caption text -#define DWMWA_VISIBLE_FRAME_BORDER_THICKNESS 37 // [get] UINT, width of the visible border around a thick frame window -#define DWMWCP_DEFAULT 0 -#define DWMWCP_DONOTROUND 1 -#define DWMWCP_ROUND 2 -#define DWMWCP_ROUNDSMALL 3 -#endif -#define DWMWA_MICA_EFFFECT 1029 - DEFINE_GUID(CLSID_ImmersiveShell, 0xc2f03a33, 0x21f5, 0x47fa, 0xb4, 0xbb, @@ -571,44 +555,9 @@ BOOL PleaseWait_UpdateTimeout(int timeout); VOID CALLBACK PleaseWait_TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime); LRESULT CALLBACK PleaseWait_HookProc(int code, WPARAM wParam, LPARAM lParam); -extern RTL_OSVERSIONINFOW global_rovi; -inline BOOL IsWindows11() -{ - if (!global_rovi.dwMajorVersion) VnGetOSVersion(&global_rovi); - if (global_rovi.dwBuildNumber >= 21996) - { - return TRUE; - } - return FALSE; -} - BOOL DownloadAndInstallWebView2Runtime(); BOOL DownloadFile(LPCWSTR wszURL, DWORD dwSize, LPCWSTR wszPath); BOOL IsConnectedToInternet(); - -inline BOOL IsDwmExtendFrameIntoClientAreaBrokenInThisBuild() -{ - if (!IsWindows11()) - { - return FALSE; - } - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = VnGetOSVersionAndUBR(&rovi); - if ((rovi.dwBuildNumber >= 21996 && rovi.dwBuildNumber < 22000) || (rovi.dwBuildNumber == 22000 && (ubr >= 1 && ubr <= 51))) - { - return TRUE; - } - return FALSE; -} - -inline BOOL IsMicaMaterialSupportedInThisBuild() -{ - if (!IsWindows11()) - { - return FALSE; - } - return !IsDwmExtendFrameIntoClientAreaBrokenInThisBuild(); -} #endif diff --git a/ep_weather_host/ep_weather.h b/ep_weather_host/ep_weather.h index 4d35e38..9974e47 100644 --- a/ep_weather_host/ep_weather.h +++ b/ep_weather_host/ep_weather.h @@ -21,7 +21,6 @@ #define DWMWCP_ROUND 2 #define DWMWCP_ROUNDSMALL 3 #endif -#define DWMWA_MICA_EFFFECT 1029 #define ALLOC(x) calloc(1, x) #define FREE(x) free(x) diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index 3328ea9..658014e 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -3,6 +3,8 @@ #include "ep_weather_provider_google_script.h" #include "ep_weather_error_html.h" +RTL_OSVERSIONINFOW global_rovi; +DWORD32 global_ubr; EPWeather* EPWeather_Instance = NULL; SRWLOCK Lock_EPWeather_Instance = { .Ptr = SRWLOCK_INIT }; FARPROC SHRegGetValueFromHKCUHKLMFunc; @@ -900,18 +902,13 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA { DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset); } - if (IsMicaMaterialSupportedInThisBuild()) - { - BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0; - DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL)); - } + BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0; + SetMicaMaterialForThisWindow(_this->hWnd, value); } else { - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = GetOSVersionAndUBR(&rovi); int s = 0; - if (rovi.dwBuildNumber < 18985) + if (global_rovi.dwBuildNumber < 18985) { s = -1; } @@ -1022,7 +1019,7 @@ HRESULT STDMETHODCALLTYPE epw_Weather_IsDarkMode(EPWeather* _this, LONG64 dwDark if (!dwDarkMode) { RTL_OSVERSIONINFOW rovi; - *bEnabled = bIsCompositionEnabled && ((GetOSVersion(&rovi) && rovi.dwBuildNumber < 18985) ? TRUE : (ShouldSystemUseDarkMode ? ShouldSystemUseDarkMode() : FALSE)) && !IsHighContrast(); + *bEnabled = bIsCompositionEnabled && ((global_rovi.dwBuildNumber < 18985) ? TRUE : (ShouldSystemUseDarkMode ? ShouldSystemUseDarkMode() : FALSE)) && !IsHighContrast(); } else { @@ -1042,10 +1039,8 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetDarkMode(EPWeather* _this, LONG64 dwDar if (_this->hWnd) { AllowDarkModeForWindow(_this->hWnd, bEnabled); - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = GetOSVersionAndUBR(&rovi); int s = 0; - if (rovi.dwBuildNumber < 18985) + if (global_rovi.dwBuildNumber < 18985) { s = -1; } @@ -1162,19 +1157,14 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this) MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset); } - if (IsMicaMaterialSupportedInThisBuild()) - { - BOOL value = 1; - DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL)); - } + BOOL value = 1; + SetMicaMaterialForThisWindow(_this->hWnd, TRUE); } } else { - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = GetOSVersionAndUBR(&rovi); int s = 0; - if (rovi.dwBuildNumber < 18985) + if (global_rovi.dwBuildNumber < 18985) { s = -1; } @@ -1344,6 +1334,8 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this) HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName[MAX_PATH], BOOL bAllocConsole, LONG64 dwProvider, LONG64 cbx, LONG64 cby, LONG64 dwTemperatureUnit, LONG64 dwUpdateSchedule, RECT rc, LONG64 dwDarkMode, LONG64 dwGeolocationMode, HWND* hWnd) { + InitializeGlobalVersionAndUBR(); + if (bAllocConsole) { FILE* conout; diff --git a/ep_weather_host/ep_weather_host.vcxproj b/ep_weather_host/ep_weather_host.vcxproj index 1e8109a..785f1f8 100644 --- a/ep_weather_host/ep_weather_host.vcxproj +++ b/ep_weather_host/ep_weather_host.vcxproj @@ -94,6 +94,7 @@ true MultiThreadedDebug $(SolutionDir)debug.h + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) Windows @@ -109,6 +110,7 @@ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) Windows @@ -125,6 +127,7 @@ true MultiThreadedDebug $(SolutionDir)debug.h + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) Windows @@ -140,6 +143,7 @@ NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded + $(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories) Windows diff --git a/ep_weather_host/ep_weather_utility.h b/ep_weather_host/ep_weather_utility.h index dfacab7..ed5393a 100644 --- a/ep_weather_host/ep_weather_utility.h +++ b/ep_weather_host/ep_weather_utility.h @@ -2,10 +2,9 @@ #define _H_EP_WEATHER_UTILITY_H_ #include #include +#include "../ExplorerPatcher/queryversion.h" +#include "../ExplorerPatcher/osutility.h" -#ifndef NTDDI_WIN10_CO -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif extern void(*RefreshImmersiveColorPolicyState)(); extern void(*SetPreferredAppMode)(INT64 bAllowDark); extern void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark); @@ -31,135 +30,4 @@ inline BOOL IsHighContrast() return highContrast.dwFlags & HCF_HIGHCONTRASTON; return FALSE; } -inline void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost, DWORD* dwSecondLeft, DWORD* dwSecondRight, DWORD* dwRightMost) -{ - HRSRC hResInfo; - DWORD dwSize; - HGLOBAL hResData; - LPVOID pRes, pResCopy; - UINT uLen; - VS_FIXEDFILEINFO* lpFfi; - - hResInfo = FindResource(hModule, MAKEINTRESOURCE(Resource), RT_VERSION); - dwSize = SizeofResource(hModule, hResInfo); - hResData = LoadResource(hModule, hResInfo); - pRes = LockResource(hResData); - pResCopy = LocalAlloc(LMEM_FIXED, dwSize); - CopyMemory(pResCopy, pRes, dwSize); - FreeResource(hResData); - - VerQueryValue(pResCopy, TEXT("\\"), (LPVOID*)&lpFfi, &uLen); - - DWORD dwFileVersionMS = lpFfi->dwFileVersionMS; - DWORD dwFileVersionLS = lpFfi->dwFileVersionLS; - - *dwLeftMost = HIWORD(dwFileVersionMS); - *dwSecondLeft = LOWORD(dwFileVersionMS); - *dwSecondRight = HIWORD(dwFileVersionLS); - *dwRightMost = LOWORD(dwFileVersionLS); - - LocalFree(pResCopy); -} - -#define OSVERSION_INVALID 0xffffffff - -typedef LONG NTSTATUS, * PNTSTATUS; -#define STATUS_SUCCESS (0x00000000) - -typedef NTSTATUS(WINAPI* VnRtlGetVersionPtr)(PRTL_OSVERSIONINFOW); - -// https://stackoverflow.com/questions/36543301/detecting-windows-10-version/36543774#36543774 -inline BOOL GetOSVersion(PRTL_OSVERSIONINFOW lpRovi) -{ - HMODULE hMod = GetModuleHandleW(L"ntdll.dll"); - if (hMod != NULL) - { - VnRtlGetVersionPtr fxPtr = (VnRtlGetVersionPtr)GetProcAddress( - hMod, - "RtlGetVersion" - ); - if (fxPtr != NULL) - { - lpRovi->dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW); - if (STATUS_SUCCESS == fxPtr(lpRovi)) - { - return TRUE; - } - } - } - return FALSE; -} - -// https://stackoverflow.com/questions/47926094/detecting-windows-10-os-build-minor-version -inline DWORD32 GetUBR() -{ - DWORD32 ubr = 0, ubr_size = sizeof(DWORD32); - HKEY hKey; - LONG lRes = RegOpenKeyExW( - HKEY_LOCAL_MACHINE, - wcschr( - wcschr( - wcschr( - UNIFIEDBUILDREVISION_KEY, - '\\' - ) + 1, - '\\' - ) + 1, - '\\' - ) + 1, - 0, - KEY_READ, - &hKey - ); - if (lRes == ERROR_SUCCESS) - { - RegQueryValueExW( - hKey, - UNIFIEDBUILDREVISION_VALUE, - 0, - NULL, - &ubr, - &ubr_size - ); - } -} - -inline DWORD32 GetOSVersionAndUBR(PRTL_OSVERSIONINFOW lpRovi) -{ - if (!GetOSVersion(lpRovi)) - { - return OSVERSION_INVALID; - } - return GetUBR(); -} - -inline BOOL IsWindows11() -{ - RTL_OSVERSIONINFOW rovi; - if (GetOSVersion(&rovi) && rovi.dwBuildNumber >= 21996) - { - return TRUE; - } - return FALSE; -} - -inline BOOL IsDwmExtendFrameIntoClientAreaBrokenInThisBuild() -{ - RTL_OSVERSIONINFOW rovi; - DWORD32 ubr = GetOSVersionAndUBR(&rovi); - if ((rovi.dwBuildNumber >= 21996 && rovi.dwBuildNumber < 22000) || (rovi.dwBuildNumber == 22000 && (ubr >= 1 && ubr <= 51))) - { - return TRUE; - } - return FALSE; -} - -inline BOOL IsMicaMaterialSupportedInThisBuild() -{ - if (!IsWindows11()) - { - return FALSE; - } - return !IsDwmExtendFrameIntoClientAreaBrokenInThisBuild(); -} #endif \ No newline at end of file diff --git a/libs/sws b/libs/sws index 1778125..d0ff9fc 160000 --- a/libs/sws +++ b/libs/sws @@ -1 +1 @@ -Subproject commit 1778125faba51fa23b500efd2f0404c87b701e23 +Subproject commit d0ff9fc81d5e90fe4590d179b820e18637cc08cf