1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-14 11:07:36 +01:00

FIle Explorer: Fix Pin to Start/Unpin from Start from Explorer and fix command bar option not being applied to non-primary Explorer instances

This commit is contained in:
Amrsatrio 2023-10-06 02:50:22 +07:00
parent fbaad56b22
commit 001e8d8d1d
4 changed files with 374 additions and 40 deletions

View File

@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -343,10 +343,18 @@
<ResourceCompile Include="ExplorerPatcher.rc" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="settings.reg" />
<None Include="settings10.reg" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.230824.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

View File

@ -225,5 +225,6 @@
<None Include="settings10.reg">
<Filter>Settings</Filter>
</None>
<None Include="packages.config" />
</ItemGroup>
</Project>
</Project>

View File

@ -2,7 +2,24 @@
#include <windows.system.h>
#include <winrt/windows.foundation.collections.h>
#include <winrt/windows.system.h>
#include <roapi.h>
#include <wil/winrt.h>
extern "C" extern DWORD dwStartShowClassicMode;
static void EPWilLogCallback(wil::FailureInfo const &failure) noexcept
{
wchar_t message[2048];
HRESULT hr = GetFailureLogString(message, ARRAYSIZE(message), failure);
if (SUCCEEDED(hr))
{
wprintf(L"%s", message); // message includes newline
}
}
extern "C" void InitializeWilLogCallback()
{
SetResultLoggingCallback(EPWilLogCallback);
}
static std::vector<winrt::guid> GlobalStartData_GetPlacesFromRegistry()
{
@ -137,3 +154,204 @@ extern "C" BOOL NeedsRo_SyncSettingsFromRegToCDS()
return TRUE;
}
namespace ABI::WindowsInternal::Shell::UnifiedTile
{
MIDL_INTERFACE("d3653510-4fff-4bfa-905b-ea038b142fa5")
IUnifiedTileIdentifier : public IInspectable
{
};
MIDL_INTERFACE("0e7735be-a965-44a6-a75f-54b8bcd67bec")
IWin32UnifiedTileIdentifierFactory : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE Create(HSTRING, IUnifiedTileIdentifier**) = 0;
};
}
namespace ABI::WindowsInternal::Shell::UnifiedTile::Private
{
MIDL_INTERFACE("0083831c-82d6-4e8f-bcc2-a8ac2691be49")
IUnifiedTileUserPinHelperStatics : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE CreateUserPinnedShortcutTile(IUnifiedTileIdentifier*) = 0;
};
}
namespace ABI::WindowsInternal::Shell::UnifiedTile::CuratedTileCollections
{
enum class CollectionAttributes {};
enum class PackageStatusChangeType {};
enum class StartCollectionCustomizationRestrictionType {};
enum class TilePinSize {};
namespace DataStoreCache::CuratedTileCollectionTransformer
{
class CuratedTile;
}
MIDL_INTERFACE("ffffffff-ffff-ffff-ffff-ffffffffffff")
ICuratedTileGroup : public IInspectable
{
};
MIDL_INTERFACE("ffffffff-ffff-ffff-ffff-ffffffffffff")
ICuratedTile : public IInspectable
{
};
MIDL_INTERFACE("51a07090-3a1f-49ef-9932-a971b8154790")
ICuratedTileCollection : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE get_CollectionName(HSTRING*) = 0;
virtual HRESULT STDMETHODCALLTYPE get_Attributes(CollectionAttributes*) = 0;
virtual HRESULT STDMETHODCALLTYPE put_Attributes(CollectionAttributes) = 0;
virtual HRESULT STDMETHODCALLTYPE get_Version(unsigned int*) = 0;
virtual HRESULT STDMETHODCALLTYPE put_Version(unsigned int) = 0;
virtual HRESULT STDMETHODCALLTYPE GetGroups(Windows::Foundation::Collections::IMapView<GUID, ICuratedTileGroup*>**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTiles(Windows::Foundation::Collections::IMapView<GUID, ICuratedTile*>**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetAllTilesInCollection(Windows::Foundation::Collections::IMapView<GUID, ICuratedTile*>**) = 0;
virtual HRESULT STDMETHODCALLTYPE DoesCollectionContainTile(IUnifiedTileIdentifier*, ICuratedTile**, unsigned char*) = 0;
virtual HRESULT STDMETHODCALLTYPE FindTileAndParentGroup(IUnifiedTileIdentifier*, ICuratedTile**, ICuratedTileGroup**, unsigned char*) = 0;
virtual HRESULT STDMETHODCALLTYPE MoveExistingGroupToNewParent(ICuratedTileGroup*, ICuratedTileGroup*) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateNewGroup(ICuratedTileGroup**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetGroup(GUID, ICuratedTileGroup**) = 0;
virtual HRESULT STDMETHODCALLTYPE DeleteGroup(GUID) = 0;
virtual HRESULT STDMETHODCALLTYPE RemoveGroup(GUID) = 0;
virtual HRESULT STDMETHODCALLTYPE MoveExistingTileToNewParent(ICuratedTile*, ICuratedTileGroup*) = 0;
virtual HRESULT STDMETHODCALLTYPE AddTile(IUnifiedTileIdentifier*, ICuratedTile**) = 0;
virtual HRESULT STDMETHODCALLTYPE AddTileWithId(IUnifiedTileIdentifier*, GUID, ICuratedTile**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTile(GUID, ICuratedTile**) = 0;
virtual HRESULT STDMETHODCALLTYPE DeleteTile(GUID) = 0;
virtual HRESULT STDMETHODCALLTYPE RemoveTile(GUID) = 0;
virtual HRESULT STDMETHODCALLTYPE Commit() = 0;
virtual HRESULT STDMETHODCALLTYPE CommitAsync(Windows::Foundation::IAsyncAction**) = 0;
virtual HRESULT STDMETHODCALLTYPE CommitAsyncWithTimerBypass(Windows::Foundation::IAsyncAction**) = 0;
virtual HRESULT STDMETHODCALLTYPE ResetToDefault() = 0;
virtual HRESULT STDMETHODCALLTYPE ResetToDefaultAsync(Windows::Foundation::IAsyncAction**) = 0;
virtual HRESULT STDMETHODCALLTYPE CheckForUpdate() = 0;
virtual HRESULT STDMETHODCALLTYPE GetCustomProperty(const HSTRING, HSTRING*) = 0;
virtual HRESULT STDMETHODCALLTYPE HasCustomProperty(const HSTRING, unsigned char*) = 0;
virtual HRESULT STDMETHODCALLTYPE RemoveCustomProperty(const HSTRING) = 0;
virtual HRESULT STDMETHODCALLTYPE SetCustomProperty(const HSTRING, HSTRING) = 0;
virtual HRESULT STDMETHODCALLTYPE EnsureTileRegistration() = 0;
virtual HRESULT STDMETHODCALLTYPE ResurrectTile(std::shared_ptr<DataStoreCache::CuratedTileCollectionTransformer::CuratedTile>, const GUID&) = 0;
virtual HRESULT STDMETHODCALLTYPE OnTileAddedWithinCollection(IUnifiedTileIdentifier*) = 0;
virtual HRESULT STDMETHODCALLTYPE OnTileRemovedWithinCollection(IUnifiedTileIdentifier*) = 0;
};
MIDL_INTERFACE("adbf8965-6056-4126-ab26-6660af4661ce")
IStartTileCollection : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE PinToStart(IUnifiedTileIdentifier*, TilePinSize);
virtual HRESULT STDMETHODCALLTYPE PinToStartAtLocation(IUnifiedTileIdentifier*, ICuratedTileGroup*, Windows::Foundation::Point, Windows::Foundation::Size);
virtual HRESULT STDMETHODCALLTYPE UnpinFromStart(IUnifiedTileIdentifier*);
virtual HRESULT STDMETHODCALLTYPE ReplaceTinyOrMediumTile(IUnifiedTileIdentifier*, IUnifiedTileIdentifier*);
virtual HRESULT STDMETHODCALLTYPE get_LastGroupId(GUID*);
virtual HRESULT STDMETHODCALLTYPE put_LastGroupId(GUID);
virtual HRESULT STDMETHODCALLTYPE get_CustomizationRestriction(StartCollectionCustomizationRestrictionType*);
virtual HRESULT STDMETHODCALLTYPE put_CustomizationRestriction(StartCollectionCustomizationRestrictionType);
virtual HRESULT STDMETHODCALLTYPE get_GroupCellWidth(unsigned int*);
virtual HRESULT STDMETHODCALLTYPE put_GroupCellWidth(unsigned int);
virtual HRESULT STDMETHODCALLTYPE get_PreferredColumnCount(unsigned int*);
virtual HRESULT STDMETHODCALLTYPE put_PreferredColumnCount(unsigned int);
virtual HRESULT STDMETHODCALLTYPE get_CurrentColumnCount(unsigned int*);
virtual HRESULT STDMETHODCALLTYPE put_CurrentColumnCount(unsigned int);
};
MIDL_INTERFACE("ffffffff-ffff-ffff-ffff-ffffffffffff")
ICuratedTileCollectionOptions : public IInspectable
{
};
MIDL_INTERFACE("ffffffff-ffff-ffff-ffff-ffffffffffff")
ICuratedTileCollectionManager : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE NotifyPackageStatusChanged(HSTRING, PackageStatusChangeType) = 0;
virtual HRESULT STDMETHODCALLTYPE GetCollection(HSTRING, ICuratedTileCollection**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetCollectionWithOptions(HSTRING, ICuratedTileCollectionOptions*, ICuratedTileCollection**) = 0;
virtual HRESULT STDMETHODCALLTYPE DeleteCollection(HSTRING) = 0;
virtual HRESULT STDMETHODCALLTYPE CollectionExists(HSTRING, unsigned char*) = 0;
virtual HRESULT STDMETHODCALLTYPE InitializeCollection(HSTRING) = 0;
};
MIDL_INTERFACE("15f254ac-49b3-4e6e-9c62-806ffaf554f9")
ICuratedTileCollectionManagerStatics : public IInspectable
{
virtual HRESULT STDMETHODCALLTYPE CreateWithUser(Windows::System::IUser*, ICuratedTileCollectionManager**) = 0;
};
}
struct CCacheShortcut
{
public:
const wchar_t* GetAppID(const void* a2) const
{
DWORD dwOffset = *((DWORD*)this + 11); // Same offset in Windows 10 and 11
return dwOffset != -1 ? (wchar_t*)((char*)a2 + dwOffset) : nullptr;
}
};
extern "C"
{
HRESULT(*AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStartFunc)(const CCacheShortcut* a2, const void* a3);
HRESULT AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStart(const CCacheShortcut* a2, const void* a3)
{
using namespace ABI::WindowsInternal::Shell::UnifiedTile;
using namespace ABI::WindowsInternal::Shell::UnifiedTile::Private;
using namespace ABI::WindowsInternal::Shell::UnifiedTile::CuratedTileCollections;
if (dwStartShowClassicMode)
{
return AppResolver_CAppResolverCacheBuilder__AddUserPinnedShortcutToStartFunc(a2, a3);
}
Microsoft::WRL::ComPtr<IWin32UnifiedTileIdentifierFactory> pTileIdentifierFactory;
RETURN_IF_FAILED(Windows::Foundation::GetActivationFactory(
Microsoft::WRL::Wrappers::HStringReference(L"WindowsInternal.Shell.UnifiedTile.UnifiedTileIdentifier").Get(),
pTileIdentifierFactory.GetAddressOf()
));
Microsoft::WRL::ComPtr<IUnifiedTileIdentifier> pTileIdentifier;
const wchar_t* pwszAppId = a2->GetAppID(a3);
RETURN_IF_FAILED(pTileIdentifierFactory->Create(
Microsoft::WRL::Wrappers::HStringReference(pwszAppId).Get(),
pTileIdentifier.GetAddressOf()
));
Microsoft::WRL::ComPtr<IUnifiedTileUserPinHelperStatics> pTileUserPinHelper;
RETURN_IF_FAILED(Windows::Foundation::GetActivationFactory(
Microsoft::WRL::Wrappers::HStringReference(L"WindowsInternal.Shell.UnifiedTile.Private.UnifiedTileUserPinHelper").Get(),
pTileUserPinHelper.GetAddressOf()
));
RETURN_IF_FAILED(pTileUserPinHelper->CreateUserPinnedShortcutTile(
pTileIdentifier.Get()
));
// At this point, on Windows 11 the Windows 10 code doesn't exist anymore, so we'll add them here
Microsoft::WRL::ComPtr<ICuratedTileCollectionManager> pTileCollectionManager;
RETURN_IF_FAILED(RoActivateInstance(
Microsoft::WRL::Wrappers::HStringReference(L"WindowsInternal.Shell.UnifiedTile.CuratedTileCollections.CuratedTileCollectionManager").Get(),
(IInspectable**)pTileCollectionManager.GetAddressOf()
));
Microsoft::WRL::ComPtr<ICuratedTileCollection> pTileCollection;
RETURN_IF_FAILED(pTileCollectionManager->GetCollection(
Microsoft::WRL::Wrappers::HStringReference(L"Start.TileGrid").Get(),
pTileCollection.GetAddressOf()
));
Microsoft::WRL::ComPtr<IStartTileCollection> pStartTileCollection;
RETURN_IF_FAILED(pTileCollection.As(&pStartTileCollection));
RETURN_IF_FAILED(pStartTileCollection->PinToStart(
pTileIdentifier.Get(),
static_cast<TilePinSize>(0)
));
RETURN_IF_FAILED(pTileCollection->Commit());
return S_OK;
}
}

View File

@ -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)
}
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)
}
}
}
#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
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
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)
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)
}
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:
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)
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)
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)
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)
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)
#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)
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)
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");
}