mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
All: Use global OS version query functions
This commit is contained in:
parent
a42bb90390
commit
67a6fc00aa
@ -317,6 +317,7 @@
|
|||||||
<ClInclude Include="ep_private.h" />
|
<ClInclude Include="ep_private.h" />
|
||||||
<ClInclude Include="ImmersiveFlyouts.h" />
|
<ClInclude Include="ImmersiveFlyouts.h" />
|
||||||
<ClInclude Include="lvt.h" />
|
<ClInclude Include="lvt.h" />
|
||||||
|
<ClInclude Include="osutility.h" />
|
||||||
<ClInclude Include="queryversion.h" />
|
<ClInclude Include="queryversion.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
<ClInclude Include="SettingsMonitor.h" />
|
<ClInclude Include="SettingsMonitor.h" />
|
||||||
|
@ -129,6 +129,9 @@
|
|||||||
<ClInclude Include="lvt.h">
|
<ClInclude Include="lvt.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="osutility.h">
|
||||||
|
<Filter>Header Files\internal</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="ExplorerPatcher.rc">
|
<ResourceCompile Include="ExplorerPatcher.rc">
|
||||||
|
@ -1224,9 +1224,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
|||||||
p = strstr(line, "%OSVERSIONSTRING%");
|
p = strstr(line, "%OSVERSIONSTRING%");
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW rovi;
|
sprintf_s(p, MAX_PATH, "%d.%d.%d.%d.", global_rovi.dwMajorVersion, global_rovi.dwMinorVersion, global_rovi.dwBuildNumber, global_ubr);
|
||||||
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
|
|
||||||
sprintf_s(p, MAX_PATH, "%d.%d.%d.%d.", rovi.dwMajorVersion, rovi.dwMinorVersion, rovi.dwBuildNumber, ubr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t));
|
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);
|
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
|
||||||
BOOL value = g_darkModeEnabled;
|
BOOL value = g_darkModeEnabled;
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
if (rovi.dwBuildNumber < 18985)
|
if (global_rovi.dwBuildNumber < 18985)
|
||||||
{
|
{
|
||||||
s = -1;
|
s = -1;
|
||||||
}
|
}
|
||||||
@ -3426,10 +3422,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
|||||||
if (bIsCompositionEnabled)
|
if (bIsCompositionEnabled)
|
||||||
{
|
{
|
||||||
BOOL value = (IsThemeActive() && !IsHighContrast() && IsWindows11()) ? 1 : 0;
|
BOOL value = (IsThemeActive() && !IsHighContrast() && IsWindows11()) ? 1 : 0;
|
||||||
if (IsMicaMaterialSupportedInThisBuild())
|
SetMicaMaterialForThisWindow(hWnd, value);
|
||||||
{
|
|
||||||
DwmSetWindowAttribute(hWnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (IsThemeActive() && ShouldAppsUseDarkMode && !IsHighContrast())
|
if (IsThemeActive() && ShouldAppsUseDarkMode && !IsHighContrast())
|
||||||
{
|
{
|
||||||
@ -3440,10 +3433,8 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
|||||||
g_darkModeEnabled = bDarkModeEnabled;
|
g_darkModeEnabled = bDarkModeEnabled;
|
||||||
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
|
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
|
||||||
BOOL value = g_darkModeEnabled;
|
BOOL value = g_darkModeEnabled;
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
if (rovi.dwBuildNumber < 18985)
|
if (global_rovi.dwBuildNumber < 18985)
|
||||||
{
|
{
|
||||||
s = -1;
|
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();
|
locale = GetUserDefaultUILanguage();
|
||||||
dwSize = LOCALE_NAME_MAX_LENGTH;
|
dwSize = LOCALE_NAME_MAX_LENGTH;
|
||||||
if (hKey)
|
if (hKey)
|
||||||
@ -4026,11 +4020,7 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
|
|||||||
{
|
{
|
||||||
if (bIsCompositionEnabled)
|
if (bIsCompositionEnabled)
|
||||||
{
|
{
|
||||||
BOOL value = 1;
|
SetMicaMaterialForThisWindow(hwnd, TRUE);
|
||||||
if (IsMicaMaterialSupportedInThisBuild())
|
|
||||||
{
|
|
||||||
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL));
|
|
||||||
}
|
|
||||||
/*WTA_OPTIONS ops;
|
/*WTA_OPTIONS ops;
|
||||||
ops.dwFlags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
ops.dwFlags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
||||||
ops.dwMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
ops.dwMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
|
||||||
|
@ -39,9 +39,11 @@
|
|||||||
IEPWeather* epw = NULL;
|
IEPWeather* epw = NULL;
|
||||||
SRWLOCK lock_epw = { .Ptr = SRWLOCK_INIT };
|
SRWLOCK lock_epw = { .Ptr = SRWLOCK_INIT };
|
||||||
#endif
|
#endif
|
||||||
|
#include "osutility.h"
|
||||||
|
|
||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
RTL_OSVERSIONINFOW global_rovi;
|
RTL_OSVERSIONINFOW global_rovi;
|
||||||
|
DWORD32 global_ubr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WINX_ADJUST_X 5
|
#define WINX_ADJUST_X 5
|
||||||
@ -4338,8 +4340,7 @@ __int64 __fastcall PeopleBand_DrawTextWithGlowHook(
|
|||||||
COLORREF rgbColor = RGB(0, 0, 0);
|
COLORREF rgbColor = RGB(0, 0, 0);
|
||||||
if (bIsThemeActive)
|
if (bIsThemeActive)
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW rovi;
|
if ((global_rovi.dwBuildNumber < 18985) || (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode()))
|
||||||
if ((VnGetOSVersion(&rovi) && rovi.dwBuildNumber < 18985) || (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode()))
|
|
||||||
{
|
{
|
||||||
rgbColor = RGB(255, 255, 255);
|
rgbColor = RGB(255, 255, 255);
|
||||||
}
|
}
|
||||||
@ -4939,10 +4940,6 @@ DWORD SignalShellReady(DWORD wait)
|
|||||||
printf("Started \"Signal shell ready\" thread.\n");
|
printf("Started \"Signal shell ready\" thread.\n");
|
||||||
//UpdateStartMenuPositioning(MAKELPARAM(TRUE, TRUE));
|
//UpdateStartMenuPositioning(MAKELPARAM(TRUE, TRUE));
|
||||||
|
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
ZeroMemory(&rovi, sizeof(RTL_OSVERSIONINFOW));
|
|
||||||
VnGetOSVersion(&rovi);
|
|
||||||
|
|
||||||
while (!wait && TRUE)
|
while (!wait && TRUE)
|
||||||
{
|
{
|
||||||
HWND hShell_TrayWnd = FindWindowEx(
|
HWND hShell_TrayWnd = FindWindowEx(
|
||||||
@ -4987,7 +4984,7 @@ DWORD SignalShellReady(DWORD wait)
|
|||||||
SetEvent(hEvent);
|
SetEvent(hEvent);
|
||||||
}
|
}
|
||||||
SetEvent(hCanStartSws);
|
SetEvent(hCanStartSws);
|
||||||
if (bOldTaskbar && rovi.dwBuildNumber >= 22567)
|
if (bOldTaskbar && (global_rovi.dwBuildNumber >= 22567))
|
||||||
{
|
{
|
||||||
PatchSndvolsso();
|
PatchSndvolsso();
|
||||||
}
|
}
|
||||||
@ -8293,10 +8290,6 @@ DWORD Inject(BOOL bIsExplorer)
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
ZeroMemory(&rovi, sizeof(RTL_OSVERSIONINFOW));
|
|
||||||
VnGetOSVersion(&rovi);
|
|
||||||
|
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (bIsExplorer)
|
if (bIsExplorer)
|
||||||
@ -8495,6 +8488,10 @@ DWORD Inject(BOOL bIsExplorer)
|
|||||||
return;
|
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
|
#ifdef _WIN64
|
||||||
wszEPWeatherKillswitch = calloc(sizeof(WCHAR), MAX_PATH);
|
wszEPWeatherKillswitch = calloc(sizeof(WCHAR), MAX_PATH);
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
@ -8827,12 +8824,12 @@ DWORD Inject(BOOL bIsExplorer)
|
|||||||
printf("Setup pnidui functions done\n");
|
printf("Setup pnidui functions done\n");
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
if (rovi.dwBuildNumber < 22567)
|
if (global_rovi.dwBuildNumber < 22567)
|
||||||
{
|
{
|
||||||
PatchSndvolsso();
|
PatchSndvolsso();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
HANDLE hShell32 = GetModuleHandleW(L"shell32.dll");
|
HANDLE hShell32 = GetModuleHandleW(L"shell32.dll");
|
||||||
@ -10449,6 +10446,8 @@ HRESULT EntryPoint(DWORD dwMethod)
|
|||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeGlobalVersionAndUBR();
|
||||||
|
|
||||||
TCHAR exePath[MAX_PATH], dllName[MAX_PATH];
|
TCHAR exePath[MAX_PATH], dllName[MAX_PATH];
|
||||||
GetModuleFileNameW(hModule, dllName, MAX_PATH);
|
GetModuleFileNameW(hModule, dllName, MAX_PATH);
|
||||||
PathStripPathW(dllName);
|
PathStripPathW(dllName);
|
||||||
|
58
ExplorerPatcher/osutility.h
Normal file
58
ExplorerPatcher/osutility.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#ifndef _H_OSUTILITY_H_
|
||||||
|
#define _H_OSUTILITY_H_
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <dwmapi.h>
|
||||||
|
#include <valinet/utility/osversion.h>
|
||||||
|
|
||||||
|
// 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
|
@ -3,6 +3,7 @@
|
|||||||
#pragma comment(lib, "Wininet.lib")
|
#pragma comment(lib, "Wininet.lib")
|
||||||
|
|
||||||
RTL_OSVERSIONINFOW global_rovi;
|
RTL_OSVERSIONINFOW global_rovi;
|
||||||
|
DWORD32 global_ubr;
|
||||||
|
|
||||||
#pragma region "Weird stuff"
|
#pragma region "Weird stuff"
|
||||||
INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2)
|
INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2)
|
||||||
|
@ -16,33 +16,17 @@
|
|||||||
#pragma comment(lib, "Rstrtmgr.lib")
|
#pragma comment(lib, "Rstrtmgr.lib")
|
||||||
#define _LIBVALINET_INCLUDE_UNIVERSAL
|
#define _LIBVALINET_INCLUDE_UNIVERSAL
|
||||||
#include <valinet/universal/toast/toast.h>
|
#include <valinet/universal/toast/toast.h>
|
||||||
|
#include "osutility.h"
|
||||||
#include "queryversion.h"
|
#include "queryversion.h"
|
||||||
#pragma comment(lib, "Psapi.lib")
|
#pragma comment(lib, "Psapi.lib")
|
||||||
#include <activscp.h>
|
#include <activscp.h>
|
||||||
#include <netlistmgr.h>
|
#include <netlistmgr.h>
|
||||||
#include <valinet/utility/osversion.h>
|
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
|
||||||
#define WM_MSG_GUI_SECTION WM_USER + 1
|
#define WM_MSG_GUI_SECTION WM_USER + 1
|
||||||
#define WM_MSG_GUI_SECTION_GET 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,
|
DEFINE_GUID(CLSID_ImmersiveShell,
|
||||||
0xc2f03a33,
|
0xc2f03a33,
|
||||||
0x21f5, 0x47fa, 0xb4, 0xbb,
|
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);
|
VOID CALLBACK PleaseWait_TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime);
|
||||||
LRESULT CALLBACK PleaseWait_HookProc(int code, WPARAM wParam, LPARAM lParam);
|
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 DownloadAndInstallWebView2Runtime();
|
||||||
|
|
||||||
BOOL DownloadFile(LPCWSTR wszURL, DWORD dwSize, LPCWSTR wszPath);
|
BOOL DownloadFile(LPCWSTR wszURL, DWORD dwSize, LPCWSTR wszPath);
|
||||||
|
|
||||||
BOOL IsConnectedToInternet();
|
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
|
#endif
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#define DWMWCP_ROUND 2
|
#define DWMWCP_ROUND 2
|
||||||
#define DWMWCP_ROUNDSMALL 3
|
#define DWMWCP_ROUNDSMALL 3
|
||||||
#endif
|
#endif
|
||||||
#define DWMWA_MICA_EFFFECT 1029
|
|
||||||
|
|
||||||
#define ALLOC(x) calloc(1, x)
|
#define ALLOC(x) calloc(1, x)
|
||||||
#define FREE(x) free(x)
|
#define FREE(x) free(x)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include "ep_weather_provider_google_script.h"
|
#include "ep_weather_provider_google_script.h"
|
||||||
#include "ep_weather_error_html.h"
|
#include "ep_weather_error_html.h"
|
||||||
|
|
||||||
|
RTL_OSVERSIONINFOW global_rovi;
|
||||||
|
DWORD32 global_ubr;
|
||||||
EPWeather* EPWeather_Instance = NULL;
|
EPWeather* EPWeather_Instance = NULL;
|
||||||
SRWLOCK Lock_EPWeather_Instance = { .Ptr = SRWLOCK_INIT };
|
SRWLOCK Lock_EPWeather_Instance = { .Ptr = SRWLOCK_INIT };
|
||||||
FARPROC SHRegGetValueFromHKCUHKLMFunc;
|
FARPROC SHRegGetValueFromHKCUHKLMFunc;
|
||||||
@ -900,18 +902,13 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
|
|||||||
{
|
{
|
||||||
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
|
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
|
||||||
}
|
}
|
||||||
if (IsMicaMaterialSupportedInThisBuild())
|
BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0;
|
||||||
{
|
SetMicaMaterialForThisWindow(_this->hWnd, value);
|
||||||
BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0;
|
|
||||||
DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
if (rovi.dwBuildNumber < 18985)
|
if (global_rovi.dwBuildNumber < 18985)
|
||||||
{
|
{
|
||||||
s = -1;
|
s = -1;
|
||||||
}
|
}
|
||||||
@ -1022,7 +1019,7 @@ HRESULT STDMETHODCALLTYPE epw_Weather_IsDarkMode(EPWeather* _this, LONG64 dwDark
|
|||||||
if (!dwDarkMode)
|
if (!dwDarkMode)
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW rovi;
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -1042,10 +1039,8 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetDarkMode(EPWeather* _this, LONG64 dwDar
|
|||||||
if (_this->hWnd)
|
if (_this->hWnd)
|
||||||
{
|
{
|
||||||
AllowDarkModeForWindow(_this->hWnd, bEnabled);
|
AllowDarkModeForWindow(_this->hWnd, bEnabled);
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
if (rovi.dwBuildNumber < 18985)
|
if (global_rovi.dwBuildNumber < 18985)
|
||||||
{
|
{
|
||||||
s = -1;
|
s = -1;
|
||||||
}
|
}
|
||||||
@ -1162,19 +1157,14 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
|||||||
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
|
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
|
||||||
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
|
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
|
||||||
}
|
}
|
||||||
if (IsMicaMaterialSupportedInThisBuild())
|
BOOL value = 1;
|
||||||
{
|
SetMicaMaterialForThisWindow(_this->hWnd, TRUE);
|
||||||
BOOL value = 1;
|
|
||||||
DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOW rovi;
|
|
||||||
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
|
|
||||||
int s = 0;
|
int s = 0;
|
||||||
if (rovi.dwBuildNumber < 18985)
|
if (global_rovi.dwBuildNumber < 18985)
|
||||||
{
|
{
|
||||||
s = -1;
|
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)
|
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)
|
if (bAllocConsole)
|
||||||
{
|
{
|
||||||
FILE* conout;
|
FILE* conout;
|
||||||
|
@ -94,6 +94,7 @@
|
|||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<ForcedIncludeFiles>$(SolutionDir)debug.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>$(SolutionDir)debug.h</ForcedIncludeFiles>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -109,6 +110,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -125,6 +127,7 @@
|
|||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<ForcedIncludeFiles>$(SolutionDir)debug.h</ForcedIncludeFiles>
|
<ForcedIncludeFiles>$(SolutionDir)debug.h</ForcedIncludeFiles>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -140,6 +143,7 @@
|
|||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
#define _H_EP_WEATHER_UTILITY_H_
|
#define _H_EP_WEATHER_UTILITY_H_
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#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(*RefreshImmersiveColorPolicyState)();
|
||||||
extern void(*SetPreferredAppMode)(INT64 bAllowDark);
|
extern void(*SetPreferredAppMode)(INT64 bAllowDark);
|
||||||
extern void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark);
|
extern void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark);
|
||||||
@ -31,135 +30,4 @@ inline BOOL IsHighContrast()
|
|||||||
return highContrast.dwFlags & HCF_HIGHCONTRASTON;
|
return highContrast.dwFlags & HCF_HIGHCONTRASTON;
|
||||||
return FALSE;
|
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
|
#endif
|
2
libs/sws
2
libs/sws
@ -1 +1 @@
|
|||||||
Subproject commit 1778125faba51fa23b500efd2f0404c87b701e23
|
Subproject commit d0ff9fc81d5e90fe4590d179b820e18637cc08cf
|
Loading…
Reference in New Issue
Block a user