Browse Source

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

pull/2488/head 22621.2506.60.1_3b902d0
Amrsatrio 2 years ago
parent
commit
3b902d0ae7
  1. 4
      CHANGELOG.md
  2. 2
      ExplorerPatcher-L10N
  3. 6
      ExplorerPatcher/dllmain.c
  4. 11
      ExplorerPatcher/utility.h
  5. 1
      ep_gui/GUI.c

4
CHANGELOG.md

@ -14,7 +14,9 @@ Tested on OS builds 22000.2416, 22621.2361, 22621.2506, and 23585.1001. @@ -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.

2
ExplorerPatcher-L10N

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

6
ExplorerPatcher/dllmain.c

@ -3906,7 +3906,7 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook( @@ -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( @@ -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));
}
}
}

11
ExplorerPatcher/utility.h

@ -24,6 +24,7 @@ @@ -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); @@ -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);

1
ep_gui/GUI.c

@ -11,7 +11,6 @@ void* GUI_FileMapping = NULL; @@ -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;

Loading…
Cancel
Save