add classic file picker

This commit is contained in:
Cynthia Foxwell 2023-03-11 15:17:36 -07:00
parent bece87aa6b
commit 42ed283bfe
2 changed files with 72 additions and 21 deletions

View File

@ -0,0 +1,52 @@
// ==WindhawkMod==
// @id classic-file-picker
// @name Classic File Picker
// @description Redirect the Windows Vista+ file picker to the Windows XP one
// @version 0.1
// @author Cynosphere
// @github https://github.com/cynosphere
// @homepage https://c7.pm
// @include *
// @compilerOptions -lole32 -lcomdlg32
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
# Classic File Picker
*/
// ==/WindhawkModReadme==
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);
}
BOOL Wh_ModInit() {
Wh_SetFunctionHook((void*)CoCreateInstance, (void*)CoCreateInstance_Hook,
(void**)&CoCreateInstance_Original);
return TRUE;
}
void Wh_ModUninit() {}

View File

@ -2,7 +2,7 @@
// @id classic-theme-windows // @id classic-theme-windows
// @name Classic Theme Windows // @name Classic Theme Windows
// @description Forces Classic Theme on all Windows // @description Forces Classic Theme on all Windows
// @version 0.1 // @version 0.2
// @author Travis, Cynosphere // @author Travis, Cynosphere
// @include * // @include *
// @exclude wininit.exe // @exclude wininit.exe
@ -13,16 +13,13 @@
// @exclude svchost.exe // @exclude svchost.exe
// @exclude taskhostw.exe // @exclude taskhostw.exe
// @exclude dllhost.exe // @exclude dllhost.exe
// @exclude conhost.exe // @exclude rundll32.exe
// @exclude sihost.exe // @exclude sihost.exe
// @exclude lsass.exe // @exclude lsass.exe
// @exclude C:\Program Files (x86)\Steam\* // @exclude C:\Program Files (x86)\Steam\*
// @exclude Code.exe
// @exclude Code - Insiders.exe
// @exclude msedge.exe // @exclude msedge.exe
// @exclude vmware.exe // @exclude vmware.exe
// @exclude vmware-vmx.exe // @exclude vmware-vmx.exe
// @exclude rundll32.exe
// @exclude Spotify.exe // @exclude Spotify.exe
// @exclude smartscreen.exe // @exclude smartscreen.exe
// @exclude RuntimeBroker.exe // @exclude RuntimeBroker.exe
@ -33,6 +30,7 @@
// @exclude PhoneExperienceHost.exe // @exclude PhoneExperienceHost.exe
// @exclude SecurityHealthTray.exe // @exclude SecurityHealthTray.exe
// @exclude Window Detective.exe // @exclude Window Detective.exe
// @exclude imhex.exe
// @compilerOptions -luxtheme -ldwmapi // @compilerOptions -luxtheme -ldwmapi
// ==/WindhawkMod== // ==/WindhawkMod==
@ -47,7 +45,8 @@ Forces Classic Theme on all Windows
#include <uxtheme.h> #include <uxtheme.h>
#include <dwmapi.h> #include <dwmapi.h>
static const int DisableDWM = DWMNCRP_DISABLED; // BasicThemer2 reimplementation to render classic titlebars
/*static const int DisableDWM = DWMNCRP_DISABLED;
static const int EnableDWM = DWMNCRP_ENABLED; static const int EnableDWM = DWMNCRP_ENABLED;
void BasicThemerEnable(HWND hwnd) { void BasicThemerEnable(HWND hwnd) {
@ -77,45 +76,45 @@ HWND WINAPI CreateWindowExA_Hook(DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWin
} }
BOOL CALLBACK EnableBasicThemerForAll(HWND hWnd, LPARAM lParam) { BOOL CALLBACK EnableBasicThemerForAll(HWND hWnd, LPARAM lParam) {
BasicThemerEnable(hWnd); if (IsWindow(hWnd))
BasicThemerEnable(hWnd);
return TRUE; return TRUE;
} }
BOOL CALLBACK DisableBasicThemerForAll(HWND hWnd, LPARAM lParam) { BOOL CALLBACK DisableBasicThemerForAll(HWND hWnd, LPARAM lParam) {
BasicThemerDisable(hWnd); if (IsWindow(hWnd))
BasicThemerDisable(hWnd);
return TRUE; return TRUE;
} }*/
// Windhawk function
BOOL Wh_ModInit() { BOOL Wh_ModInit() {
//Wh_Log(L"Init"); // Enable classic theme
//Wh_Log(L"Theme properties were: 0x%x", GetThemeAppProperties());
SetThemeAppProperties(0); SetThemeAppProperties(0);
//Wh_Log(L"Theme properties are: 0x%x", GetThemeAppProperties());
Wh_SetFunctionHook((void*)CreateWindowExW, // BasicThemer hooks
/*Wh_SetFunctionHook((void*)CreateWindowExW,
(void*)CreateWindowExW_Hook, (void*)CreateWindowExW_Hook,
(void**)&CreateWindowExW_Orig); (void**)&CreateWindowExW_Orig);
Wh_SetFunctionHook((void*)CreateWindowExA, Wh_SetFunctionHook((void*)CreateWindowExA,
(void*)CreateWindowExA_Hook, (void*)CreateWindowExA_Hook,
(void**)&CreateWindowExA_Orig); (void**)&CreateWindowExA_Orig);
// Iterate every window to enable BasicThemer
DWORD thisPid = GetProcessIdOfThread(GetCurrentThread()); DWORD thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(EnableBasicThemerForAll, thisPid); EnumWindows(EnableBasicThemerForAll, thisPid);*/
return TRUE; return TRUE;
} }
void Wh_ModUninit() { void Wh_ModUninit() {
//Wh_Log(L"Uninit"); // Disable classic theme
//Wh_Log(L"Theme properties were: 0x%x", GetThemeAppProperties());
if (GetThemeAppProperties() == 0) { if (GetThemeAppProperties() == 0) {
SetThemeAppProperties(3); SetThemeAppProperties(3);
} }
//Wh_Log(L"Theme properties are: 0x%x", GetThemeAppProperties());
DWORD thisPid = GetProcessIdOfThread(GetCurrentThread()); // Iterate every window to disable BasicThemer
EnumWindows(DisableBasicThemerForAll, thisPid); /*DWORD thisPid = GetProcessIdOfThread(GetCurrentThread());
EnumWindows(DisableBasicThemerForAll, thisPid);*/
} }