1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-12-18 02:16:00 +01:00

File Explorer: Fixed UB caused by wrong ShouldAppsUseDarkMode signature (#2429, #2431)

This commit is contained in:
Amrsatrio 2023-11-13 00:36:56 +07:00
parent c5bb636f1e
commit 3b902d0ae7
5 changed files with 12 additions and 12 deletions

View File

@ -14,7 +14,9 @@ Tested on OS builds 22000.2416, 22621.2361, 22621.2506, and 23585.1001.
* Changing the taskbar alignment requires restarting `explorer.exe` in order to take effect.
* File Explorer: Added option to disable the modern navigation bar of Moment 4. (2dc1340)
* File Explorer: Restored "Apply Mica" functionality on OS builds 22621+. (f62c532)
* Localization: Officially added Japanese translations. (Thanks @creeper-0910, @reindex-ot, and @Rukoto!)
* Localization: Officially added translations for the following languages:
* Chinese, Simplified (Thanks @zetaloop!)
* Japanese (Thanks @creeper-0910, @reindex-ot, and @Rukoto!)
* GUI: Decoupled the Properties window into `ep_gui.dll` from the main DLL in order to reduce the main DLL size and to allow scalable localization. (f6f6d89, 639d7aa)
* `rundll32 C:\Windows\dxgi.dll,ZZGUI` will continue to work as before.

@ -1 +1 @@
Subproject commit 3895993c18effe2f10f101aa2139f6ef2abfc9bc
Subproject commit b358f5caf8bae8314d2a5c1611eae31c48a07c39

View File

@ -3906,7 +3906,7 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook(
{
SetWindowSubclass(hWndParent, HideExplorerSearchBarSubClass, HideExplorerSearchBarSubClass, 0);
}
if (bIsExplorerProcess && dwFileExplorerCommandUI != 0 && IsWindows11Version22H2OrHigher())
if (bIsExplorerProcess && (dwFileExplorerCommandUI == 1 || dwFileExplorerCommandUI == 2 || dwFileExplorerCommandUI == 3) && IsWindows11Version22H2OrHigher())
{
// Fix initial title bar style after disabling TIFE
// If we don't do this, it will only fix itself once the user changes the system color scheme or toggling transparency effects
@ -3917,8 +3917,8 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook(
}
if (ShouldAppsUseDarkMode)
{
BOOL value = ShouldAppsUseDarkMode();
DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
BOOL bDarkMode = ShouldAppsUseDarkMode() && !IsHighContrast();
DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &bDarkMode, sizeof(BOOL));
}
}
}

View File

@ -24,6 +24,7 @@
#include <activscp.h>
#include <netlistmgr.h>
#include <Psapi.h>
#include <stdbool.h>
#include "def.h"
@ -367,18 +368,16 @@ BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
INT64(*SetWindowCompositionAttribute)(HWND, void*);
static void(*SetPreferredAppMode)(INT64 bAllowDark);
static void(*SetPreferredAppMode)(bool bAllowDark);
static void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark);
static void(*AllowDarkModeForWindow)(HWND hWnd, bool bAllowDark);
static BOOL(*ShouldAppsUseDarkMode)();
static bool(*ShouldAppsUseDarkMode)();
static BOOL(*ShouldSystemUseDarkMode)();
static bool(*ShouldSystemUseDarkMode)();
static void(*GetThemeName)(void*, void*, void*);
static BOOL AppsShouldUseDarkMode() { return TRUE; }
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize);
int ComputeFileHash(LPCWSTR filename, LPSTR hash, DWORD dwHash);

View File

@ -11,7 +11,6 @@ void* GUI_FileMapping = NULL;
DWORD GUI_FileSize = 0;
BOOL g_darkModeEnabled = FALSE;
static void(*RefreshImmersiveColorPolicyState)() = NULL;
// static BOOL(*ShouldAppsUseDarkMode)() = nullptr; // Already defined in utility.h
DWORD dwTaskbarPosition = 3;
BOOL gui_bOldTaskbar = TRUE;