Last active
October 5, 2023 07:47
-
-
Save m417z/8039a6fd02e3e08c6e77c0fce94ef6e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==WindhawkMod== | |
// @id explorer-features-test | |
// @name Explorer features test | |
// @description Enjoy experimenting | |
// @version 0.1 | |
// @author m417z | |
// @github https://github.com/m417z | |
// @twitter https://twitter.com/m417z | |
// @homepage https://m417z.com/ | |
// @include explorer.exe | |
// @architecture x86-64 | |
// @compilerOptions -lversion | |
// ==/WindhawkMod== | |
// ==WindhawkModReadme== | |
/* | |
# Explorer features test | |
You can toggle the different features in settings. | |
To get to the old Explorer, try disabling `WASDKInXamlExtensionsUdk` or | |
`WASDKInFileExplorer`. | |
You might need to restart explorer to apply some of the features. | |
Tested with explorerframe.dll version 10.0.22621.2361. | |
*/ | |
// ==/WindhawkModReadme== | |
// clang-format off | |
// ==WindhawkModSettings== | |
/* | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], AccessibilityXAMLContextMenu: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FEMNB: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FERecommendations: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FETTOM: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FileExplorerCOFE: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FileExplorerGallery: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FileExplorerInsights: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], FileExplorerNavpaneFixes: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], MRTCoreSystemShimForWASDK: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], MSDTDeprecationPhase1: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], MTestUx14: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], MTestUx15: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], Servicing-ExternalExtensionTelemetry: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], Servicing-FileExplorer-GetListPerfImprovements: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], Servicing-FileExplorerItemViewFlash: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], Servicing-FileExplorerSettingChange: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], Servicing-SmartFeatureRollout: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], TIFE: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], TypeActivationRedirection: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], WASDKInFileExplorer: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], WASDKInXamlExtensionsUdk: None} | |
- {$options: [{None: Default}, {D: 🔴 Disable}, {E: 🟢 Enable}], XAMLFolderViewSupport: None} | |
*/ | |
// ==/WindhawkModSettings== | |
// clang-format on | |
#include <windhawk_utils.h> | |
#include <algorithm> | |
#include <string> | |
#include <vector> | |
enum class ModuleVersion { | |
Unsupported, | |
Win10, | |
Win11, | |
}; | |
ModuleVersion g_moduleVersion; | |
VS_FIXEDFILEINFO* GetModuleVersionInfo(HMODULE hModule, UINT* puPtrLen) { | |
void* pFixedFileInfo = nullptr; | |
UINT uPtrLen = 0; | |
HRSRC hResource = | |
FindResource(hModule, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); | |
if (hResource) { | |
HGLOBAL hGlobal = LoadResource(hModule, hResource); | |
if (hGlobal) { | |
void* pData = LockResource(hGlobal); | |
if (pData) { | |
if (!VerQueryValue(pData, L"\\", &pFixedFileInfo, &uPtrLen) || | |
uPtrLen == 0) { | |
pFixedFileInfo = nullptr; | |
uPtrLen = 0; | |
} | |
} | |
} | |
} | |
if (puPtrLen) { | |
*puPtrLen = uPtrLen; | |
} | |
return (VS_FIXEDFILEINFO*)pFixedFileInfo; | |
} | |
ModuleVersion GetModuleVersion(HMODULE hModule = nullptr) { | |
VS_FIXEDFILEINFO* fixedFileInfo = GetModuleVersionInfo(hModule, nullptr); | |
if (!fixedFileInfo) { | |
return ModuleVersion::Unsupported; | |
} | |
WORD major = HIWORD(fixedFileInfo->dwFileVersionMS); | |
WORD minor = LOWORD(fixedFileInfo->dwFileVersionMS); | |
WORD build = HIWORD(fixedFileInfo->dwFileVersionLS); | |
WORD qfe = LOWORD(fixedFileInfo->dwFileVersionLS); | |
Wh_Log(L"Version: %u.%u.%u.%u", major, minor, build, qfe); | |
switch (major) { | |
case 10: | |
if (build < 22000) { | |
return ModuleVersion::Win10; | |
} else { | |
return ModuleVersion::Win11; | |
} | |
break; | |
} | |
return ModuleVersion::Unsupported; | |
} | |
bool WINAPI FeatureEnabler(PVOID pThis) { | |
Wh_Log(L">"); | |
return true; | |
} | |
bool WINAPI FeatureDisabler(PVOID pThis) { | |
Wh_Log(L">"); | |
return false; | |
} | |
BOOL Wh_ModInit() { | |
Wh_Log(L">"); | |
HMODULE module = LoadLibrary(L"explorerframe.dll"); | |
if (!module) { | |
Wh_Log(L"Couldn't load explorerframe.dll"); | |
return FALSE; | |
} | |
g_moduleVersion = GetModuleVersion(module); | |
if (g_moduleVersion < ModuleVersion::Win11) { | |
Wh_Log(L"Unsupported module version"); | |
return FALSE; | |
} | |
PCWSTR features[] = { | |
L"AccessibilityXAMLContextMenu", | |
L"FEMNB", | |
L"FERecommendations", | |
L"FETTOM", | |
L"FileExplorerCOFE", | |
L"FileExplorerGallery", | |
L"FileExplorerInsights", | |
L"FileExplorerNavpaneFixes", | |
L"MRTCoreSystemShimForWASDK", | |
L"MSDTDeprecationPhase1", | |
L"MTestUx14", | |
L"MTestUx15", | |
L"Servicing_ExternalExtensionTelemetry", | |
L"Servicing_FileExplorer_GetListPerfImprovements", | |
L"Servicing_FileExplorerItemViewFlash", | |
L"Servicing_FileExplorerSettingChange", | |
L"Servicing_SmartFeatureRollout", | |
L"TIFE", | |
L"TypeActivationRedirection", | |
L"WASDKInFileExplorer", | |
L"WASDKInXamlExtensionsUdk", | |
L"XAMLFolderViewSupport", | |
}; | |
std::vector<std::wstring> symbolNames; | |
std::vector<WindhawkUtils::SYMBOL_HOOK> symbolHooks; | |
void* throwaway; | |
for (auto feature : features) { | |
std::wstring setting = feature; | |
std::replace(setting.begin(), setting.end(), '_', '-'); | |
void* hook = nullptr; | |
PCWSTR value = Wh_GetStringSetting(setting.c_str()); | |
if (wcscmp(value, L"D") == 0) { | |
hook = (void*)FeatureDisabler; | |
} else if (wcscmp(value, L"E") == 0) { | |
hook = (void*)FeatureEnabler; | |
} | |
Wh_FreeStringSetting(value); | |
{ | |
std::wstring sym = | |
LR"(public: bool __cdecl wil::details::FeatureImpl<struct __WilFeatureTraits_Feature_)"; | |
sym += feature; | |
sym += LR"(>::__private_IsEnabled(void))"; | |
symbolNames.push_back(std::move(sym)); | |
symbolHooks.push_back({ | |
{symbolNames.back()}, | |
&throwaway, | |
hook, | |
true, | |
}); | |
} | |
{ | |
std::wstring sym = | |
LR"(public: bool __cdecl wil::details::FeatureImpl<struct __WilFeatureTraits_Feature_)"; | |
sym += feature; | |
sym += LR"(>::__private_IsEnabled(enum wil::ReportingKind))"; | |
symbolNames.push_back(std::move(sym)); | |
symbolHooks.push_back({ | |
{symbolNames.back()}, | |
&throwaway, | |
hook, | |
true, | |
}); | |
} | |
} | |
return HookSymbols(module, symbolHooks.data(), symbolHooks.size()); | |
} | |
BOOL Wh_ModSettingsChanged(BOOL* bReload) { | |
Wh_Log(L">"); | |
*bReload = TRUE; | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment