Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ExplorerPatcher/ExplorerPatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
<ClCompile Include="ShellExperienceHostPatches.cpp">
<ExcludedFromBuild Condition="'$(WithMainPatcher)'!='true'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="StartExperience.cpp" />
<ClCompile Include="StartMenu.c">
<ExcludedFromBuild Condition="'$(WithMainPatcher)'!='true'">true</ExcludedFromBuild>
</ClCompile>
Expand Down Expand Up @@ -299,6 +300,7 @@
<ClInclude Include="queryversion.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="SettingsMonitor.h" />
<ClInclude Include="StartExperience.h" />
<ClInclude Include="StartMenu.h" />
<ClInclude Include="StartupSound.h" />
<ClInclude Include="symbols.h" />
Expand Down
139 changes: 139 additions & 0 deletions ExplorerPatcher/StartExperience.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#include "StartExperience.h"

#include <wrl/implements.h>
#include <wil/wrl.h>

using namespace Microsoft::WRL;

namespace wis = ABI::Windows::Internal::Shell;
namespace wf = ABI::Windows::Foundation;

using namespace ABI;

class CStartExperienceWrapper
: public RuntimeClass<RuntimeClassFlags<WinRtClassicComMix>
, wis::StartUI::IStartExperience
>
{
InspectableClass(L"", BaseTrust);

public:
CStartExperienceWrapper() = default;
HRESULT RuntimeClassInitialize(IStartExperience* pInner);

//~ Begin wis::StartUI::IStartExperience Interface
STDMETHODIMP ProcessBackgroundImage(IInspectable* a1, int a2, INT64* a3) override;
STDMETHODIMP get_WaitableExplorerProcessHandle(UINT64* a1) override;
STDMETHODIMP PromoteAppsToTopOfFrequentList(wf::Collections::IVector<HSTRING>* a1) override;
STDMETHODIMP add_GlobalAnimationRequested(
wf::ITypedEventHandler<
wis::StartUI::StartExperience*, wis::StartUI::StartExperienceAnimationRequestedEventArgs*>* a1,
EventRegistrationToken* token) override;
STDMETHODIMP remove_GlobalAnimationRequested(EventRegistrationToken token) override;
STDMETHODIMP add_ShellModeChanged(
wf::ITypedEventHandler<wis::StartUI::StartExperience*, wis::StartUI::ShellModeChangedEventArgs*>* a1,
EventRegistrationToken* token) override;
STDMETHODIMP remove_ShellModeChanged(EventRegistrationToken token) override;
//~ End wis::StartUI::IStartExperience Interface

private:
ComPtr<IStartExperience> _spInner;
};

HRESULT CStartExperienceWrapper::RuntimeClassInitialize(IStartExperience* pInner)
{
_spInner = pInner;
return S_OK;
}

HRESULT CStartExperienceWrapper::ProcessBackgroundImage(IInspectable* a1, int a2, INT64* a3)
{
return _spInner->ProcessBackgroundImage(a1, a2, a3);
}

HRESULT CStartExperienceWrapper::get_WaitableExplorerProcessHandle(UINT64* a1)
{
return _spInner->get_WaitableExplorerProcessHandle(a1);
}

HRESULT CStartExperienceWrapper::PromoteAppsToTopOfFrequentList(wf::Collections::IVector<HSTRING>* a1)
{
return _spInner->PromoteAppsToTopOfFrequentList(a1);
}

HRESULT CStartExperienceWrapper::add_GlobalAnimationRequested(
wf::ITypedEventHandler<
wis::StartUI::StartExperience*, wis::StartUI::StartExperienceAnimationRequestedEventArgs*>* a1,
EventRegistrationToken* token)
{
return _spInner->add_GlobalAnimationRequested(a1, token);
}

HRESULT CStartExperienceWrapper::remove_GlobalAnimationRequested(EventRegistrationToken token)
{
return _spInner->remove_GlobalAnimationRequested(token);
}

HRESULT CStartExperienceWrapper::add_ShellModeChanged(
wf::ITypedEventHandler<
wis::StartUI::StartExperience*, wis::StartUI::ShellModeChangedEventArgs*>* a1, EventRegistrationToken* token)
{
*token = {};
return S_OK;
}

HRESULT CStartExperienceWrapper::remove_ShellModeChanged(EventRegistrationToken token)
{
return S_OK;
}

class CStartExperienceStaticsWrapper
: public RuntimeClass<RuntimeClassFlags<WinRtClassicComMix>
, wis::StartUI::IStartExperienceStatics
>
{
InspectableClass(L"", BaseTrust);

public:
CStartExperienceStaticsWrapper() = default;
HRESULT RuntimeClassInitialize(IStartExperienceStatics* pInner);

//~ Begin wis::StartUI::IStartExperienceStatics Interface
STDMETHODIMP GetForCurrentView(wis::StartUI::IStartExperience** ppStartExperience) override;
STDMETHODIMP GetIfNoCurrentView(wis::StartUI::IStartExperience** ppStartExperience) override;
//~ End wis::StartUI::IStartExperienceStatics Interface

private:
ComPtr<IStartExperienceStatics> _spInner;
};

HRESULT CStartExperienceStaticsWrapper::RuntimeClassInitialize(IStartExperienceStatics* pInner)
{
_spInner = pInner;
return S_OK;
}

HRESULT CStartExperienceStaticsWrapper::GetForCurrentView(wis::StartUI::IStartExperience** ppStartExperience)
{
ComPtr<wis::StartUI::IStartExperience> spStartExperience;
RETURN_IF_FAILED(_spInner->GetForCurrentView(&spStartExperience));
RETURN_HR(MakeAndInitialize<CStartExperienceWrapper>(ppStartExperience, spStartExperience.Get()));
}

HRESULT CStartExperienceStaticsWrapper::GetIfNoCurrentView(wis::StartUI::IStartExperience** ppStartExperience)
{
ComPtr<wis::StartUI::IStartExperience> spStartExperience;
RETURN_IF_FAILED(_spInner->GetIfNoCurrentView(&spStartExperience));
RETURN_HR(MakeAndInitialize<CStartExperienceWrapper>(ppStartExperience, spStartExperience.Get()));
}

EXTERN_C HRESULT StartExperienceWrapper_Wrap(REFIID riid, void** ppv)
{
ComPtr<wis::StartUI::IStartExperienceStatics> spInner;
spInner.Attach(*reinterpret_cast<wis::StartUI::IStartExperienceStatics**>(ppv));
*ppv = nullptr;

ComPtr<CStartExperienceStaticsWrapper> spInstance;
RETURN_IF_FAILED(MakeAndInitialize<CStartExperienceStaticsWrapper>(&spInstance, spInner.Get()));
RETURN_HR(spInstance.CopyTo(riid, ppv));
}
45 changes: 45 additions & 0 deletions ExplorerPatcher/StartExperience.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

#include <Windows.h>
#include <Windows.Foundation.h>
#include <Windows.Foundation.Collections.h>

#include <initguid.h>
DEFINE_GUID(IID_IStartExperience, 0x4C4D0C66, 0x5BD5, 0xFD8C, 0x61, 0x7F, 0x3C, 0x77, 0x78, 0xF4, 0x6B, 0xB6);
DEFINE_GUID(IID_IStartExperienceStatics, 0xFB2E3E59, 0xB442, 0x4B5B, 0x91, 0x28, 0x23, 0x19, 0xBF, 0x8D, 0xE3, 0xB0);

namespace ABI::Windows::Internal::Shell::StartUI
{

struct StartExperience;

class StartExperienceAnimationRequestedEventArgs;
class ShellModeChangedEventArgs;

MIDL_INTERFACE("4c4d0c66-5bd5-fd8c-617f-3c7778f46bb6")
IStartExperience : IInspectable
{
virtual HRESULT STDMETHODCALLTYPE ProcessBackgroundImage(IInspectable*, int, INT64*) = 0;
virtual HRESULT STDMETHODCALLTYPE get_WaitableExplorerProcessHandle(UINT64*) = 0;
virtual HRESULT STDMETHODCALLTYPE PromoteAppsToTopOfFrequentList(
ABI::Windows::Foundation::Collections::IVector<HSTRING>*) = 0;
virtual HRESULT STDMETHODCALLTYPE add_GlobalAnimationRequested(
ABI::Windows::Foundation::ITypedEventHandler<
StartExperience*, StartExperienceAnimationRequestedEventArgs*>*, EventRegistrationToken*) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_GlobalAnimationRequested(EventRegistrationToken) = 0;
virtual HRESULT STDMETHODCALLTYPE add_ShellModeChanged(
ABI::Windows::Foundation::ITypedEventHandler<
StartExperience*, ShellModeChangedEventArgs*>*, EventRegistrationToken*) = 0;
virtual HRESULT STDMETHODCALLTYPE remove_ShellModeChanged(EventRegistrationToken) = 0;
};

MIDL_INTERFACE("fb2e3e59-b442-4b5b-9128-2319bf8de3b0")
IStartExperienceStatics : IInspectable
{
virtual HRESULT STDMETHODCALLTYPE GetForCurrentView(IStartExperience**) = 0;
virtual HRESULT STDMETHODCALLTYPE GetIfNoCurrentView(IStartExperience**) = 0;
};

} // ABI::Windows::Internal::Shell::StartUI

EXTERN_C HRESULT StartExperienceWrapper_Wrap(REFIID riid, void** ppv);
32 changes: 32 additions & 0 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -12215,6 +12215,27 @@ HRESULT StartUI_CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD
return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv);
}

HRESULT StartExperienceWrapper_Wrap(REFIID riid, void** ppv);

EXTERN_C const IID IID_IStartExperienceStatics;

HRESULT (STDAPICALLTYPE *StartUI_GetActivationFactoryByPCWSTRFunc)(PCWSTR activatableClassId, REFIID riid, void** ppv);
HRESULT STDAPICALLTYPE StartUI_GetActivationFactoryByPCWSTRHook(PCWSTR activatableClassId, REFIID riid, void** ppv)
{
if (wcscmp(activatableClassId, L"Windows.Internal.Shell.StartUI.StartExperience") == 0
&& IsEqualIID(riid, &IID_IStartExperienceStatics))
{
HRESULT hr = StartUI_GetActivationFactoryByPCWSTRFunc(activatableClassId, riid, ppv);
if (SUCCEEDED(hr))
{
hr = StartExperienceWrapper_Wrap(riid, ppv);
}
return hr;
}

return StartUI_GetActivationFactoryByPCWSTRFunc(activatableClassId, riid, ppv);
}

int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
{
WCHAR wszDebug[MAX_PATH];
Expand Down Expand Up @@ -12846,6 +12867,17 @@ DWORD InjectStartMenu()
VnPatchIAT(hWindowsCloudStore, "api-ms-win-core-registry-l1-1-0.dll", "RegOpenKeyExW", StartUI_RegOpenKeyExW);
VnPatchIAT(hWindowsCloudStore, "api-ms-win-core-registry-l1-1-0.dll", "RegQueryValueExW", StartUI_RegQueryValueExW);
VnPatchIAT(hWindowsCloudStore, "api-ms-win-core-registry-l1-1-0.dll", "RegCloseKey", StartUI_RegCloseKey);

// Adds compatibility with RLTM ("Remove Legacy Tablet Mode" / 61558864) feature flag
HANDLE hWincorlib = GetModuleHandleW(L"wincorlib.DLL");
if (hWincorlib)
{
StartUI_GetActivationFactoryByPCWSTRFunc = GetProcAddress(hWincorlib, "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z");
}
if (StartUI_GetActivationFactoryByPCWSTRFunc)
{
VnPatchIAT(hStartUI, "wincorlib.DLL", "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", StartUI_GetActivationFactoryByPCWSTRHook);
}
}
}
else
Expand Down