Skip to content

Commit 3b902d0

Browse files
committed
File Explorer: Fixed UB caused by wrong ShouldAppsUseDarkMode signature (#2429, #2431)
1 parent c5bb636 commit 3b902d0

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Tested on OS builds 22000.2416, 22621.2361, 22621.2506, and 23585.1001.
1414
* Changing the taskbar alignment requires restarting `explorer.exe` in order to take effect.
1515
* File Explorer: Added option to disable the modern navigation bar of Moment 4. (2dc1340)
1616
* File Explorer: Restored "Apply Mica" functionality on OS builds 22621+. (f62c532)
17-
* Localization: Officially added Japanese translations. (Thanks @creeper-0910, @reindex-ot, and @Rukoto!)
17+
* Localization: Officially added translations for the following languages:
18+
* Chinese, Simplified (Thanks @zetaloop!)
19+
* Japanese (Thanks @creeper-0910, @reindex-ot, and @Rukoto!)
1820
* 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)
1921
* `rundll32 C:\Windows\dxgi.dll,ZZGUI` will continue to work as before.
2022

ExplorerPatcher/dllmain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,7 +3906,7 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook(
39063906
{
39073907
SetWindowSubclass(hWndParent, HideExplorerSearchBarSubClass, HideExplorerSearchBarSubClass, 0);
39083908
}
3909-
if (bIsExplorerProcess && dwFileExplorerCommandUI != 0 && IsWindows11Version22H2OrHigher())
3909+
if (bIsExplorerProcess && (dwFileExplorerCommandUI == 1 || dwFileExplorerCommandUI == 2 || dwFileExplorerCommandUI == 3) && IsWindows11Version22H2OrHigher())
39103910
{
39113911
// Fix initial title bar style after disabling TIFE
39123912
// 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(
39173917
}
39183918
if (ShouldAppsUseDarkMode)
39193919
{
3920-
BOOL value = ShouldAppsUseDarkMode();
3921-
DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
3920+
BOOL bDarkMode = ShouldAppsUseDarkMode() && !IsHighContrast();
3921+
DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &bDarkMode, sizeof(BOOL));
39223922
}
39233923
}
39243924
}

ExplorerPatcher/utility.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <activscp.h>
2525
#include <netlistmgr.h>
2626
#include <Psapi.h>
27+
#include <stdbool.h>
2728

2829
#include "def.h"
2930

@@ -367,18 +368,16 @@ BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
367368

368369
INT64(*SetWindowCompositionAttribute)(HWND, void*);
369370

370-
static void(*SetPreferredAppMode)(INT64 bAllowDark);
371+
static void(*SetPreferredAppMode)(bool bAllowDark);
371372

372-
static void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark);
373+
static void(*AllowDarkModeForWindow)(HWND hWnd, bool bAllowDark);
373374

374-
static BOOL(*ShouldAppsUseDarkMode)();
375+
static bool(*ShouldAppsUseDarkMode)();
375376

376-
static BOOL(*ShouldSystemUseDarkMode)();
377+
static bool(*ShouldSystemUseDarkMode)();
377378

378379
static void(*GetThemeName)(void*, void*, void*);
379380

380-
static BOOL AppsShouldUseDarkMode() { return TRUE; }
381-
382381
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize);
383382

384383
int ComputeFileHash(LPCWSTR filename, LPSTR hash, DWORD dwHash);

ep_gui/GUI.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ void* GUI_FileMapping = NULL;
1111
DWORD GUI_FileSize = 0;
1212
BOOL g_darkModeEnabled = FALSE;
1313
static void(*RefreshImmersiveColorPolicyState)() = NULL;
14-
// static BOOL(*ShouldAppsUseDarkMode)() = nullptr; // Already defined in utility.h
1514
DWORD dwTaskbarPosition = 3;
1615
BOOL gui_bOldTaskbar = TRUE;
1716

0 commit comments

Comments
 (0)