mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-27 17:00:59 +01:00
All: Added option to enable UI sounds on explorer.exe
's XAML views
Please treat this feature as a novelty or proof of concept, quirks related to this will never be mitigated.
This commit is contained in:
parent
3b902d0ae7
commit
d6cdb5d8ed
@ -1 +1 @@
|
||||
Subproject commit b358f5caf8bae8314d2a5c1611eae31c48a07c39
|
||||
Subproject commit 6012fe38c9220ebfc685e3a2f65ea6d8262717a5
|
@ -1917,6 +1917,43 @@ DWORD FixTaskbarAutohide(DWORD unused)
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region "Allow enabling XAML sounds"
|
||||
void ForceEnableXamlSounds(HMODULE hWindowsUIXaml)
|
||||
{
|
||||
MODULEINFO mi;
|
||||
if (!hWindowsUIXaml || !GetModuleInformation(GetCurrentProcess(), hWindowsUIXaml, &mi, sizeof(MODULEINFO)))
|
||||
return;
|
||||
|
||||
// Patch DirectUI::ElementSoundPlayerService::ShouldPlaySound() to disregard XboxUtility::IsOnXbox() check
|
||||
// 74 ?? 39 59 ?? 75 ?? E8 ?? ?? ?? ?? 84 C0 75
|
||||
// ^^ change jnz to jmp
|
||||
PBYTE match = FindPattern(
|
||||
mi.lpBaseOfDll,
|
||||
mi.SizeOfImage,
|
||||
"\x74\x00\x39\x59\x00\x75\x00\xE8\x00\x00\x00\x00\x84\xC0\x75",
|
||||
"x?xx?x?x????xxx"
|
||||
);
|
||||
if (match)
|
||||
{
|
||||
PBYTE jnz = match + 14;
|
||||
DWORD flOldProtect = 0;
|
||||
if (VirtualProtect(jnz, 1, PAGE_EXECUTE_READWRITE, &flOldProtect))
|
||||
{
|
||||
*jnz = 0xEB;
|
||||
VirtualProtect(jnz, 1, flOldProtect, &flOldProtect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL IsXamlSoundsEnabled()
|
||||
{
|
||||
DWORD dwRes = 0, dwSize = sizeof(DWORD);
|
||||
RegGetValueW(HKEY_CURRENT_USER, TEXT(REGPATH_OLD), L"XamlSounds", RRF_RT_DWORD, NULL, &dwRes, &dwSize);
|
||||
return dwRes != 0;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region "EnsureXAML on OS builds 22621+"
|
||||
#ifdef _WIN64
|
||||
DEFINE_GUID(uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics,
|
||||
@ -2032,8 +2069,12 @@ HRESULT WINAPI ICoreWindow5_get_DispatcherQueueHook(void* _this, void** ppValue)
|
||||
HMODULE __fastcall Windows11v22H2_combase_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
HMODULE hModule = LoadLibraryExW(lpLibFileName, hFile, dwFlags);
|
||||
if (hModule && hModule == GetModuleHandleW(L"Windows.Ui.Xaml.dll"))
|
||||
if (hModule && hModule == GetModuleHandleW(L"Windows.UI.Xaml.dll"))
|
||||
{
|
||||
if (IsXamlSoundsEnabled())
|
||||
{
|
||||
ForceEnableXamlSounds(hModule);
|
||||
}
|
||||
DWORD flOldProtect = 0;
|
||||
IActivationFactory* pWindowsXamlManagerFactory = NULL;
|
||||
HSTRING_HEADER hstringHeaderWindowsXamlManager;
|
||||
@ -2071,6 +2112,16 @@ HMODULE __fastcall Windows11v22H2_combase_LoadLibraryExW(LPCWSTR lpLibFileName,
|
||||
}
|
||||
return hModule;
|
||||
}
|
||||
|
||||
HMODULE __fastcall combase_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
HMODULE hModule = LoadLibraryExW(lpLibFileName, hFile, dwFlags);
|
||||
if (hModule && hModule == GetModuleHandleW(L"Windows.UI.Xaml.dll"))
|
||||
{
|
||||
ForceEnableXamlSounds(hModule);
|
||||
}
|
||||
return hModule;
|
||||
}
|
||||
#endif
|
||||
#pragma endregion
|
||||
|
||||
@ -9898,6 +9949,12 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
|
||||
{
|
||||
printf("Failed to hook RtlQueryFeatureConfiguration(). rv = %d\n", rv);
|
||||
}
|
||||
|
||||
if (!bIsExplorer && IsXamlSoundsEnabled())
|
||||
{
|
||||
HANDLE hCombase = LoadLibraryW(L"combase.dll");
|
||||
VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", combase_LoadLibraryExW);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12005,9 +12062,9 @@ DWORD Inject(BOOL bIsExplorer)
|
||||
printf("Setup twinui.pcshell functions done\n");
|
||||
|
||||
|
||||
HANDLE hCombase = LoadLibraryW(L"combase.dll");
|
||||
if (IsWindows11())
|
||||
{
|
||||
HANDLE hCombase = LoadLibraryW(L"combase.dll");
|
||||
/*if (bOldTaskbar) // TODO Pulled back for now, crashes on 22621.2428
|
||||
{
|
||||
// Hook RoGetActivationFactory() for old taskbar
|
||||
@ -12030,8 +12087,12 @@ DWORD Inject(BOOL bIsExplorer)
|
||||
// Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+
|
||||
VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", Windows11v22H2_combase_LoadLibraryExW);
|
||||
}
|
||||
printf("Setup combase functions done\n");
|
||||
}
|
||||
if (!IsWindows11Version22H2OrHigher() && IsXamlSoundsEnabled())
|
||||
{
|
||||
VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", combase_LoadLibraryExW);
|
||||
}
|
||||
printf("Setup combase functions done\n");
|
||||
|
||||
|
||||
HANDLE hTwinui = LoadLibraryW(L"twinui.dll");
|
||||
@ -14030,6 +14091,13 @@ HRESULT EntryPoint(DWORD dwMethod)
|
||||
else if (bIsThisStartMEH)
|
||||
{
|
||||
InjectStartMenu();
|
||||
#ifdef _WIN64
|
||||
if (IsXamlSoundsEnabled())
|
||||
{
|
||||
HMODULE hWindowsUIXaml = LoadLibraryW(L"Windows.UI.Xaml.dll");
|
||||
ForceEnableXamlSounds(hWindowsUIXaml);
|
||||
}
|
||||
#endif
|
||||
IncrementDLLReferenceCount(hModule);
|
||||
bInstanced = TRUE;
|
||||
}
|
||||
@ -14043,6 +14111,13 @@ HRESULT EntryPoint(DWORD dwMethod)
|
||||
{
|
||||
InjectShellExperienceHost();
|
||||
}
|
||||
#ifdef _WIN64
|
||||
if (IsXamlSoundsEnabled())
|
||||
{
|
||||
HMODULE hWindowsUIXaml = LoadLibraryW(L"Windows.UI.Xaml.dll");
|
||||
ForceEnableXamlSounds(hWindowsUIXaml);
|
||||
}
|
||||
#endif
|
||||
IncrementDLLReferenceCount(hModule);
|
||||
bInstanced = TRUE;
|
||||
}
|
||||
|
@ -369,6 +369,7 @@
|
||||
#define IDS_ADV_DELAY_6000 1924
|
||||
#define IDS_ADV_DELAY_8000 1925
|
||||
#define IDS_ADV_DELAY_10000 1926
|
||||
#define IDS_ADV_XAMLSOUNDS 1927
|
||||
|
||||
#define IDS_ABOUT 2001
|
||||
#define IDS_ABOUT_VERSION 2002
|
||||
|
@ -412,6 +412,7 @@ BEGIN
|
||||
IDS_ADV_DELAY_6000 "6 seconds"
|
||||
IDS_ADV_DELAY_8000 "8 seconds"
|
||||
IDS_ADV_DELAY_10000 "10 seconds"
|
||||
IDS_ADV_XAMLSOUNDS "Enable UI sounds in Explorer's XAML views"
|
||||
|
||||
IDS_ABOUT "About"
|
||||
|
||||
|
@ -744,6 +744,9 @@
|
||||
;x 8000 %R:1925%
|
||||
;x 10000 %R:1926%
|
||||
"ExplorerReadyDelay"=dword:00000000
|
||||
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher]
|
||||
;b %R:1927% *
|
||||
"XamlSounds"=dword:00000000
|
||||
|
||||
|
||||
|
||||
|
@ -568,6 +568,9 @@
|
||||
"PinnedItemsActAsQuickLaunch"=dword:00000000
|
||||
;b %R:1913% *
|
||||
"RemoveExtraGapAroundPinnedItems"=dword:00000000
|
||||
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher]
|
||||
;b %R:1927% *
|
||||
"XamlSounds"=dword:00000000
|
||||
|
||||
|
||||
;T %R:2001%
|
||||
|
Loading…
Reference in New Issue
Block a user