@ -9811,6 +9811,7 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
@@ -9811,6 +9811,7 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
}
VnPatchIAT ( hExplorerFrame , " API-MS-WIN-CORE-STRING-L1-1-0.DLL " , " CompareStringOrdinal " , ExplorerFrame_CompareStringOrdinal ) ;
VnPatchIAT ( hExplorerFrame , " user32.dll " , " GetSystemMetricsForDpi " , explorerframe_GetSystemMetricsForDpi ) ;
VnPatchIAT ( hExplorerFrame , " api-ms-win-core-com-l1-1-0.dll " , " CoCreateInstance " , ExplorerFrame_CoCreateInstanceHook ) ;
}
else
{
@ -9824,6 +9825,7 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
@@ -9824,6 +9825,7 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
}
VnPatchIAT ( hExplorerFrame , " API-MS-WIN-CORE-STRING-L1-1-0.DLL " , " CompareStringOrdinal " , CompareStringOrdinal ) ;
VnPatchIAT ( hExplorerFrame , " user32.dll " , " GetSystemMetricsForDpi " , GetSystemMetricsForDpi ) ;
VnPatchIAT ( hExplorerFrame , " api-ms-win-core-com-l1-1-0.dll " , " CoCreateInstance " , CoCreateInstance ) ;
FreeLibrary ( hExplorerFrame ) ;
FreeLibrary ( hExplorerFrame ) ;
}
@ -9904,8 +9906,28 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
@@ -9904,8 +9906,28 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
}
}
}
# ifdef _WIN64
// As of writing this function is never invoked with bInstall=TRUE, so we don't handle the case if it's false for now
RtlQueryFeatureConfigurationFunc = GetProcAddress ( GetModuleHandleW ( L " ntdll.dll " ) , " RtlQueryFeatureConfiguration " ) ;
int rv = - 1 ;
if ( RtlQueryFeatureConfigurationFunc )
{
rv = funchook_prepare (
funchook ,
( void * * ) & RtlQueryFeatureConfigurationFunc ,
RtlQueryFeatureConfigurationHook
) ;
}
if ( rv ! = 0 )
{
printf ( " Failed to hook RtlQueryFeatureConfiguration(). rv = %d \n " , rv ) ;
}
# endif
}
# pragma region "Enable old Alt+Tab"
INT64 ( * twinui_pcshell_IsUndockedAssetAvailableFunc ) ( INT a1 , INT64 a2 , INT64 a3 , const char * a4 ) ;
INT64 twinui_pcshell_IsUndockedAssetAvailableHook ( INT a1 , INT64 a2 , INT64 a3 , const char * a4 )
{
@ -9936,7 +9958,11 @@ INT64 twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook(INT64 _this
@@ -9936,7 +9958,11 @@ INT64 twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook(INT64 _this
return twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc ( _this , a2 , a3 , a4 , a5 ) ;
return twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc ( _this , a2 , a3 , a4 , a5 ) ;
}
# pragma endregion
# pragma region "Fixes related to the removal of STTest feature flag (22621.2134+)"
# ifdef _WIN64
HRESULT ( * twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc ) ( IInspectable * _this , HMONITOR hMonitor , float * outHeight ) ;
HRESULT twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorHook ( IInspectable * _this , HMONITOR hMonitor , float * outHeight )
{
@ -9951,7 +9977,6 @@ HRESULT twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMo
@@ -9951,7 +9977,6 @@ HRESULT twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMo
return twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc ( _this , hMonitor , outHeight ) ;
}
# ifdef _WIN64
static struct
{
int coroInstance_rcOut ; // 22621.1992: 0x10
@ -10426,12 +10451,11 @@ BOOL Moment2PatchHardwareConfirmator(LPMODULEINFO mi)
@@ -10426,12 +10451,11 @@ BOOL Moment2PatchHardwareConfirmator(LPMODULEINFO mi)
return TRUE ;
}
# endif
# pragma endregion
BOOL IsDebuggerPresentHook ( )
{
return FALSE ;
}
# pragma region "Enable EP weather on Windows Server SKUs"
# ifdef _WIN64
BOOL PeopleBand_IsOS ( DWORD dwOS )
{
if ( dwOS = = OS_ANYSERVER ) return FALSE ;
@ -10461,7 +10485,12 @@ BOOL explorer_IsOS(DWORD dwOS)
@@ -10461,7 +10485,12 @@ BOOL explorer_IsOS(DWORD dwOS)
}
return IsOS ( dwOS ) ;
}
# endif
# pragma endregion
# pragma region "Find offsets of needed functions when symbols are not available"
# ifdef _WIN64
void TryToFindTwinuiPCShellOffsets ( DWORD * pOffsets )
{
// We read from the file instead of from memory because other tweak software might've modified the functions we're looking for
@ -10634,6 +10663,88 @@ cleanup:
@@ -10634,6 +10663,88 @@ cleanup:
free ( pFile ) ;
CloseHandle ( hFile ) ;
}
# endif
# pragma endregion
# pragma region "Fix Pin to Start from Explorer not working when using Windows 10 start menu"
# ifdef _WIN64
HRESULT ( * AppResolver_StartDocked_GetStartScreenManagerExtensionStaticsFunc ) ( void * * out ) ;
HRESULT AppResolver_StartDocked_GetStartScreenManagerExtensionStatics ( void * * out )
{
if ( dwStartShowClassicMode )
{
// Keep the value of out as NULL and return S_OK to execute the old code
return S_OK ;
}
return AppResolver_StartDocked_GetStartScreenManagerExtensionStaticsFunc ( out ) ;
}
typedef struct CCacheShortcut CCacheShortcut ;
extern HRESULT ( * AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStartFunc ) ( const CCacheShortcut * a2 , const void * a3 ) ;
extern HRESULT AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStart ( const CCacheShortcut * a2 , const void * a3 ) ;
void PatchAppResolver ( )
{
HANDLE hAppResolver = LoadLibraryW ( L " AppResolver.dll " ) ;
MODULEINFO miAppResolver ;
GetModuleInformation ( GetCurrentProcess ( ) , hAppResolver , & miAppResolver , sizeof ( MODULEINFO ) ) ;
// StartDocked::GetStartScreenManagerExtensionStatics
// 48 89 5C 24 ? 48 89 74 24 ? 55 57 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 37 ?? 8B F1 48 83 21 00
PBYTE match = FindPattern (
hAppResolver ,
miAppResolver . SizeOfImage ,
" \x48 \x89 \x5C \x24 \x00 \x48 \x89 \x74 \x24 \x00 \x55 \x57 \x41 \x56 \x48 \x8D \x6C \x24 \x00 \x48 \x81 \xEC \x00 \x00 \x00 \x00 \x48 \x8B \x05 \x00 \x00 \x00 \x00 \x48 \x33 \xC4 \x48 \x89 \x45 \x37 \x00 \x8B \xF1 \x48 \x83 \x21 \x00 " ,
" xxxx?xxxx?xxxxxxxx?xxx????xxx????xxxxxxx?xxxxxx "
) ;
int rv = - 1 ;
if ( match )
{
AppResolver_StartDocked_GetStartScreenManagerExtensionStaticsFunc = match ;
printf ( " StartDocked::GetStartScreenManagerExtensionStatics() = %llX \n " , match - ( PBYTE ) hAppResolver ) ;
rv = funchook_prepare (
funchook ,
( void * * ) & AppResolver_StartDocked_GetStartScreenManagerExtensionStaticsFunc ,
AppResolver_StartDocked_GetStartScreenManagerExtensionStatics
) ;
}
if ( rv ! = 0 )
{
printf ( " Failed to hook StartDocked::GetStartScreenManagerExtensionStatics(). rv = %d \n " , rv ) ;
}
// CAppResolverCacheBuilder::_AddUserPinnedShortcutToStart()
// 8B ? 48 8B D3 E8 ? ? ? ? 48 8B 8D
// ^^^^^^^
match = FindPattern (
hAppResolver ,
miAppResolver . SizeOfImage ,
" \x8B \x00 \x48 \x8B \xD3 \xE8 \x00 \x00 \x00 \x00 \x48 \x8B \x8D " ,
" x?xxxx????xxx "
) ;
rv = - 1 ;
if ( match )
{
match + = 5 ;
match = match + 5 + * ( int * ) ( match + 1 ) ;
AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStartFunc = match ;
printf ( " CAppResolverCacheBuilder::_AddUserPinnedShortcutToStart() = %llX \n " , match - ( PBYTE ) hAppResolver ) ;
extern HRESULT AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStart ( const void * a2 , const void * a3 ) ;
rv = funchook_prepare (
funchook ,
( void * * ) & AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStartFunc ,
AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStart
) ;
}
if ( rv ! = 0 )
{
printf ( " Failed to hook CAppResolverCacheBuilder::_AddUserPinnedShortcutToStart(). rv = %d \n " , rv ) ;
}
}
# endif
# pragma endregion
DWORD Inject ( BOOL bIsExplorer )
{
@ -10663,10 +10774,10 @@ DWORD Inject(BOOL bIsExplorer)
@@ -10663,10 +10774,10 @@ DWORD Inject(BOOL bIsExplorer)
Explorer_RefreshUI ( 99 ) ;
# ifdef _WIN64
if ( bIsExplorer )
// if (bIsExplorer)
{
funchook = funchook_create ( ) ;
printf ( " funchook create %d \n " , funchook ! = 0 ) ;
// printf("funchook create %d\n", funchook != 0);
}
# endif
@ -10847,10 +10958,19 @@ DWORD Inject(BOOL bIsExplorer)
@@ -10847,10 +10958,19 @@ DWORD Inject(BOOL bIsExplorer)
if ( ! bIsExplorer )
{
return ;
# ifdef _WIN64
rv = funchook_install ( funchook , 0 ) ;
if ( rv ! = 0 )
{
printf ( " Failed to install hooks. rv = %d \n " , rv ) ;
}
# endif
return 0 ;
}
# ifdef _WIN64
extern void InitializeWilLogCallback ( ) ;
InitializeWilLogCallback ( ) ;
wprintf ( L " Running on Windows %d, OS Build %d.%d.%d.%d. \n " , IsWindows11 ( ) ? 11 : 10 , global_rovi . dwMajorVersion , global_rovi . dwMinorVersion , global_rovi . dwBuildNumber , global_ubr ) ;
# endif
@ -10930,21 +11050,6 @@ DWORD Inject(BOOL bIsExplorer)
@@ -10930,21 +11050,6 @@ DWORD Inject(BOOL bIsExplorer)
printf ( " Loaded symbols \n " ) ;
}
RtlQueryFeatureConfigurationFunc = GetProcAddress ( GetModuleHandleW ( L " ntdll.dll " ) , " RtlQueryFeatureConfiguration " ) ;
if ( RtlQueryFeatureConfigurationFunc ) {
rv = funchook_prepare (
funchook ,
( void * * ) & RtlQueryFeatureConfigurationFunc ,
RtlQueryFeatureConfigurationHook
) ;
if ( rv ! = 0 )
{
FreeLibraryAndExitThread ( hModule , rv ) ;
return FALSE ;
}
}
printf ( " Setup ntdll functions done \n " ) ;
HANDLE hUser32 = LoadLibraryW ( L " user32.dll " ) ;
CreateWindowInBand = GetProcAddress ( hUser32 , " CreateWindowInBand " ) ;
@ -10985,10 +11090,13 @@ DWORD Inject(BOOL bIsExplorer)
@@ -10985,10 +11090,13 @@ DWORD Inject(BOOL bIsExplorer)
VnPatchIAT ( hExplorer , " uxtheme.dll " , " OpenThemeDataForDpi " , explorer_OpenThemeDataForDpi ) ;
VnPatchIAT ( hExplorer , " uxtheme.dll " , " DrawThemeBackground " , explorer_DrawThemeBackground ) ;
VnPatchIAT ( hExplorer , " uxtheme.dll " , " CloseThemeData " , explorer_CloseThemeData ) ;
// Fix Windows 10 taskbar high DPI button width bug
if ( IsWindows11 ( ) )
{
// Fix Windows 10 taskbar high DPI button width bug
VnPatchIAT ( hExplorer , " api-ms-win-ntuser-sysparams-l1-1-0.dll " , " GetSystemMetrics " , patched_GetSystemMetrics ) ;
// Fix Pin to Start/Unpin from Start
PatchAppResolver ( ) ;
}
//VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadStringW", explorer_LoadStringWHook);
if ( bClassicThemeMitigations )
@ -11270,7 +11378,6 @@ DWORD Inject(BOOL bIsExplorer)
@@ -11270,7 +11378,6 @@ DWORD Inject(BOOL bIsExplorer)
# endif
VnPatchIAT ( hTwinuiPcshell , " API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL " , " RegGetValueW " , twinuipcshell_RegGetValueW ) ;
//VnPatchIAT(hTwinuiPcshell, "api-ms-win-core-debug-l1-1-0.dll", "IsDebuggerPresent", IsDebuggerPresentHook);
printf ( " Setup twinui.pcshell functions done \n " ) ;
@ -11432,11 +11539,6 @@ DWORD Inject(BOOL bIsExplorer)
@@ -11432,11 +11539,6 @@ DWORD Inject(BOOL bIsExplorer)
printf ( " Setup shell32 functions done \n " ) ;
HANDLE hExplorerFrame = GetModuleHandleW ( L " ExplorerFrame.dll " ) ;
VnPatchIAT ( hExplorerFrame , " api-ms-win-core-com-l1-1-0.dll " , " CoCreateInstance " , ExplorerFrame_CoCreateInstanceHook ) ;
printf ( " Setup explorerframe functions done \n " ) ;
HANDLE hWindowsStorage = LoadLibraryW ( L " windows.storage.dll " ) ;
SHELL32_CanDisplayWin8CopyDialogFunc = GetProcAddress ( hShell32 , " SHELL32_CanDisplayWin8CopyDialog " ) ;
if ( SHELL32_CanDisplayWin8CopyDialogFunc ) VnPatchDelayIAT ( hWindowsStorage , " ext-ms-win-shell-exports-internal-l1-1-0.dll " , " SHELL32_CanDisplayWin8CopyDialog " , SHELL32_CanDisplayWin8CopyDialogHook ) ;
@ -11506,15 +11608,20 @@ DWORD Inject(BOOL bIsExplorer)
@@ -11506,15 +11608,20 @@ DWORD Inject(BOOL bIsExplorer)
ResetEvent ( hEvent ) ;
} */
if ( IsWindows11 ( ) ) {
if ( bOldTaskbar ) {
if ( IsWindows11 ( ) )
{
if ( bOldTaskbar )
{
CreateThread ( 0 , 0 , PlayStartupSound , 0 , 0 , 0 ) ;
printf ( " Play startup sound thread... \n " ) ;
CreateThread ( 0 , 0 , SignalShellReady , dwExplorerReadyDelay , 0 , 0 ) ;
printf ( " Signal shell ready... \n " ) ;
} else {
}
else
{
CreateThread ( 0 , 0 , FixTaskbarAutohide , 0 , 0 , 0 ) ;
if ( ! IsWindows11Version22H2Build2361OrHigher ( ) ) {
if ( IsWindows11Version23H2OrHigher ( ) )
{
RegDeleteKeyValueW ( HKEY_CURRENT_USER , L " Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Explorer \\ Advanced " , L " TaskbarGlomLevel " ) ;
RegDeleteKeyValueW ( HKEY_CURRENT_USER , L " Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Explorer \\ Advanced " , L " MMTaskbarGlomLevel " ) ;
}