diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index f61898c66..b2212a3fc 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -101,6 +101,7 @@ $(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories) MultiThreaded Cdecl + stdcpp20 Console @@ -130,6 +131,7 @@ $(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories) MultiThreaded StdCall + stdcpp20 Console @@ -158,6 +160,7 @@ MultiThreadedDebug Cdecl $(SolutionDir)debug.h + stdcpp20 Console @@ -184,6 +187,7 @@ MultiThreadedDebug StdCall $(SolutionDir)debug.h + stdcpp20 Console @@ -268,6 +272,10 @@ true true + + true + true + true true diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters index 687be01f7..d78f2d101 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters @@ -157,6 +157,9 @@ Source Files + + Source Files + Source Files @@ -223,4 +226,4 @@ Settings - \ No newline at end of file + diff --git a/ExplorerPatcher/StartMenuSettings.cpp b/ExplorerPatcher/StartMenuSettings.cpp new file mode 100644 index 000000000..9f8b56911 --- /dev/null +++ b/ExplorerPatcher/StartMenuSettings.cpp @@ -0,0 +1,139 @@ +#include +#include +#include +#include +#include + +static std::vector GlobalStartData_GetPlacesFromRegistry() +{ + std::vector places; + + DWORD dwSize; + HRESULT hr = RegGetValueW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start", + L"VisiblePlaces", + RRF_RT_REG_BINARY, + nullptr, + nullptr, + &dwSize + ); + if (FAILED(hr) || dwSize == 0) + return places; + + places.resize(dwSize / sizeof(winrt::guid)); + hr = RegGetValueW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start", + L"VisiblePlaces", + RRF_RT_REG_BINARY, + nullptr, + places.data(), + &dwSize + ); + if (FAILED(hr)) + places.clear(); + + return places; +} + +namespace ABI::WindowsInternal::Shell::CDSProperties +{ + interface IStartGlobalProperties; + + MIDL_INTERFACE("2c670963-f8a9-4bbb-9adf-683a3a89537e") + IStartGlobalPropertiesFactory : public IInspectable + { + virtual HRESULT STDMETHODCALLTYPE Create(Windows::System::IUser* user, IStartGlobalProperties** result) = 0; + }; + + MIDL_INTERFACE("ee807266-a2db-4c9a-a1b4-970d33f99c91") + IStartGlobalProperties : public IInspectable + { + virtual HRESULT STDMETHODCALLTYPE get_FullScreenMode(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_FullScreenMode(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE get_HideAppList(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_HideAppList(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE get_HideRecentList(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_HideRecentList(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE get_HideFrequentList(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_HideFrequentList(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE get_StartMenuRelativeHeightPixels(unsigned int*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_StartMenuRelativeHeightPixels(unsigned int) = 0; + virtual HRESULT STDMETHODCALLTYPE get_PlacesInitialized(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_PlacesInitialized(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE get_PlacesInitializedVersion(unsigned int*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_PlacesInitializedVersion(unsigned int) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVisiblePlaces(Windows::Foundation::Collections::IVectorView**) = 0; + virtual HRESULT STDMETHODCALLTYPE SetVisiblePlaces(Windows::Foundation::Collections::IVectorView*) = 0; + virtual HRESULT STDMETHODCALLTYPE get_StartViewRestoring(unsigned char*) = 0; + virtual HRESULT STDMETHODCALLTYPE put_StartViewRestoring(unsigned char) = 0; + virtual HRESULT STDMETHODCALLTYPE add_PropertiesChanged( + /*Windows::Foundation::ITypedEventHandler< + StartGlobalProperties*, + StartGlobalPropertiesChangedArgs* + >*, + EventRegistrationToken**/ + ) = 0; + virtual HRESULT STDMETHODCALLTYPE remove_PropertiesChanged(EventRegistrationToken) = 0; + }; +} + +extern "C" BOOL NeedsRo_SyncSettingsFromRegToCDS() +{ + winrt::com_ptr global_properties_factory; + winrt::param::hstring hstr = L"WindowsInternal.Shell.CDSProperties.StartGlobalProperties"; + HRESULT hr = RoGetActivationFactory( + *(HSTRING*)&hstr, + __uuidof(ABI::WindowsInternal::Shell::CDSProperties::IStartGlobalPropertiesFactory), + global_properties_factory.put_void() + ); + if (FAILED(hr)) + { + return FALSE; + } + + winrt::Windows::System::User user = winrt::Windows::System::User::FindAllAsync().get().GetAt(0); + winrt::com_ptr start_global_properties; + hr = global_properties_factory->Create(user.as().get(), start_global_properties.put()); + if (FAILED(hr)) + { + return FALSE; + } + + DWORD dwValue, dwSize; + + // ShowFrequentList + dwValue = 0; // Default off + dwSize = sizeof(DWORD); + RegGetValueW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start", + L"ShowFrequentList", + RRF_RT_REG_DWORD, + nullptr, + &dwValue, + &dwSize + ); + start_global_properties->put_HideFrequentList(!dwValue); + + // ShowRecentList + dwValue = 1; // Default on + dwSize = sizeof(DWORD); + RegGetValueW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Start", + L"ShowRecentList", + RRF_RT_REG_DWORD, + nullptr, + &dwValue, + &dwSize + ); + start_global_properties->put_HideRecentList(!dwValue); + + // VisiblePlaces + auto places_view = single_threaded_vector(GlobalStartData_GetPlacesFromRegistry()).GetView(); + start_global_properties->SetVisiblePlaces(places_view.as>().get()); + + return TRUE; +} diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 5d9560214..2c96e072a 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -1968,7 +1968,7 @@ void EnsureXAML() hr = IXamlApplicationStatics_get_Current(pXamlApplicationStatics, &pXamlApplication); if (FAILED(hr)) { - printf("[EnsureXAML] IXamlApplicationStatics::get_Current() failed.\n"); + printf("[EnsureXAML] IXamlApplicationStatics::get_Current() failed. 0x%lX\n", hr); goto cleanup1; } pXamlApplication->lpVtbl->Release(pXamlApplication); @@ -1996,7 +1996,7 @@ void EnsureXAML() hr = pCoreWindow5->lpVtbl->get_DispatcherQueue(pCoreWindow5, &pDispatcherQueue); if (FAILED(hr)) { - printf("[EnsureXAML] ICoreWindow5::get_DispatcherQueue() failed.\n"); + printf("[EnsureXAML] ICoreWindow5::get_DispatcherQueue() failed. 0x%lX\n", hr); goto cleanup3; } // Keep pDispatcherQueue referenced in memory @@ -11180,7 +11180,7 @@ DWORD Inject(BOOL bIsExplorer) twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook ); } - else + else if (IsWindows11()) { twinui_pcshell_IsUndockedAssetAvailableFunc = (INT64(*)(void*, POINT*)) ((uintptr_t)hTwinuiPcshell + symbols_PTRS.twinui_pcshell_PTRS[7]); @@ -11195,7 +11195,7 @@ DWORD Inject(BOOL bIsExplorer) { if (IsWindows11Version22H2OrHigher()) printf("Failed to hook twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHost(). rv = %d\n", rv); - else + else if (IsWindows11()) printf("Failed to hook twinui_pcshell_IsUndockedAssetAvailable(). rv = %d\n", rv); } @@ -12337,6 +12337,11 @@ int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) SetWindowPos(hWnd, NULL, mi.rcWork.left, mi.rcWork.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); } } + if (bIsWindowVisible && dwStartShowClassicMode && IsWindows11Version22H2Build2134OrHigher()) + { + extern void NeedsRo_SyncSettingsFromRegToCDS(); + NeedsRo_SyncSettingsFromRegToCDS(); + } } return SetWindowRgn(hWnd, hRgn, bRedraw); } @@ -13100,7 +13105,7 @@ void InjectShellExperienceHostFor22H2OrHigher() { if (RegOpenKeyW(HKEY_CURRENT_USER, _T(SEH_REGPATH), &hKey) != ERROR_SUCCESS) return; RegCloseKey(hKey); HMODULE hQA = LoadLibraryW(L"Windows.UI.QuickActions.dll"); - if (hQA) VnPatchIAT(hQA, "api-ms-win-core-sysinfo-l1-2-0.dll", "GetProductInfo", SEH_GetProductInfo); + //if (hQA) VnPatchIAT(hQA, "api-ms-win-core-sysinfo-l1-2-0.dll", "GetProductInfo", SEH_GetProductInfo); //if (hQA) VnPatchIAT(hQA, "ntdll.dll", "RtlGetDeviceFamilyInfoEnum", SEH_RtlGetDeviceFamilyInfoEnum); //if (hQA) VnPatchIAT(hQA, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", SEH_RegGetValueW); #endif