Classic Theme Windows: merge classic file picker, fixup dwm disabler

This commit is contained in:
Cynthia Foxwell 2023-03-17 09:53:20 -06:00
parent 3969dbbb43
commit 81b37cd193
2 changed files with 62 additions and 15 deletions

View file

@ -9,7 +9,9 @@ Based on [SimpleClassicTheme.FileExplorerHook](https://github.com/AEAEAEAE4343/S
## Classic Theme Windows
Forces Classic Theme on all Windows
Originally written by WinClassic user Travis. ~~Added DWM disabler from BasicThemer2 for classic titlebars.~~ Built-in BasicThemer2 support needs to be reworked.
Originally written by WinClassic user Travis. Added DWM disabler from BasicThemer2 for classic titlebars and Classic File Picker.
## Classic File Picker
Restores pre-Vista file picker. Requires Classic Theme Windows mod or else Windows just upgrades the dialog.
## ~~Classic File Picker~~
~~Restores pre-Vista file picker. Requires Classic Theme Windows mod or else Windows just upgrades the dialog.~~
Merged into Classic Theme Windows since its required to work anyways.

View file

@ -2,7 +2,7 @@
// @id classic-theme-windows
// @name Classic Theme Windows
// @description Forces Classic Theme on all Windows
// @version 0.2
// @version 0.3
// @author Travis, Cynosphere
// @include *
// @exclude wininit.exe
@ -30,7 +30,7 @@
// @exclude PhoneExperienceHost.exe
// @exclude SecurityHealthTray.exe
// @exclude Window Detective.exe
// @compilerOptions -luxtheme -ldwmapi
// @compilerOptions -luxtheme -ldwmapi -lole32 -lcomdlg32
// ==/WindhawkMod==
// ==WindhawkModReadme==
@ -44,8 +44,10 @@ Forces Classic Theme on all Windows
#include <uxtheme.h>
#include <dwmapi.h>
DWORD thisPid = -1;
// BasicThemer2 reimplementation to render classic titlebars
/*static const int DisableDWM = DWMNCRP_DISABLED;
static const int DisableDWM = DWMNCRP_DISABLED;
static const int EnableDWM = DWMNCRP_ENABLED;
void BasicThemerEnable(HWND hwnd) {
@ -60,7 +62,13 @@ CreateWindowExW_t CreateWindowExW_Orig;
HWND WINAPI CreateWindowExW_Hook(DWORD dwExStyle,LPCWSTR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam) {
HWND res = CreateWindowExW_Orig(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
BasicThemerEnable(res);
if (thisPid != -1) {
DWORD targetPid;
GetWindowThreadProcessId(res, &targetPid);
if (targetPid == thisPid) {
BasicThemerEnable(res);
}
}
return res;
}
@ -69,7 +77,13 @@ CreateWindowExA_t CreateWindowExA_Orig;
HWND WINAPI CreateWindowExA_Hook(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam) {
HWND res = CreateWindowExA_Orig(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
BasicThemerEnable(res);
if (thisPid != -1) {
DWORD targetPid;
GetWindowThreadProcessId(res, &targetPid);
if (targetPid == thisPid) {
BasicThemerEnable(res);
}
}
return res;
}
@ -85,15 +99,42 @@ BOOL CALLBACK DisableBasicThemerForAll(HWND hWnd, LPARAM lParam) {
BasicThemerDisable(hWnd);
return TRUE;
}*/
}
// Windhawk function
// File picker
template<class S>
CLSID CreateGUID(const S& hexString)
{
CLSID clsid;
CLSIDFromString(hexString, &clsid);
return clsid;
}
const CLSID CLSID_FileOpenDialog = CreateGUID(L"{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}");
const CLSID CLSID_FileOpenDialogLegacy = CreateGUID(L"{725F645B-EAED-4fc5-B1C5-D9AD0ACCBA5E}");
const CLSID CLSID_FileSaveDialog = CreateGUID(L"{c0b4e2f3-ba21-4773-8dba-335ec946eb8b}");
const CLSID CLSID_FileSaveDialogLegacy = CreateGUID(L"{AF02484C-A0A9-4669-9051-058AB12B9195}");
using CoCreateInstance_t = decltype(&CoCreateInstance);
CoCreateInstance_t CoCreateInstance_Original;
HRESULT WINAPI CoCreateInstance_Hook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv) {
if (rclsid == CLSID_FileOpenDialog) {
return CoCreateInstance_Original(CLSID_FileOpenDialogLegacy, pUnkOuter, dwClsContext, riid, ppv);
} else if (rclsid == CLSID_FileSaveDialog) {
return CoCreateInstance_Original(CLSID_FileSaveDialogLegacy, pUnkOuter, dwClsContext, riid, ppv);
}
return CoCreateInstance_Original(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}
// Windhawk functions
BOOL Wh_ModInit() {
// Enable classic theme
SetThemeAppProperties(0);
// BasicThemer hooks
/*Wh_SetFunctionHook((void*)CreateWindowExW,
Wh_SetFunctionHook((void*)CreateWindowExW,
(void*)CreateWindowExW_Hook,
(void**)&CreateWindowExW_Orig);
Wh_SetFunctionHook((void*)CreateWindowExA,
@ -101,8 +142,12 @@ BOOL Wh_ModInit() {
(void**)&CreateWindowExA_Orig);
// Iterate every window to enable BasicThemer
DWORD thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(EnableBasicThemerForAll, thisPid);*/
thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(EnableBasicThemerForAll, thisPid);
// File picker
Wh_SetFunctionHook((void*)CoCreateInstance, (void*)CoCreateInstance_Hook,
(void**)&CoCreateInstance_Original);
return TRUE;
}
@ -114,6 +159,6 @@ void Wh_ModUninit() {
}
// Iterate every window to disable BasicThemer
/*DWORD thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(DisableBasicThemerForAll, thisPid);*/
thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(DisableBasicThemerForAll, thisPid);
}