mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
Start10: Updated method for using the old start menu
This commit is contained in:
parent
e60c5ff596
commit
755f101285
@ -12295,8 +12295,9 @@ DWORD InjectStartMenu()
|
||||
|
||||
if (dwStartShowClassicMode || !IsWindows11())
|
||||
{
|
||||
LoadLibraryW(L"StartUI.dll");
|
||||
hStartUI = GetModuleHandleW(L"StartUI.dll");
|
||||
hStartUI = LoadLibraryW(L"StartUI.dll");
|
||||
if (!hStartUI)
|
||||
hStartUI = LoadLibraryW(L"StartUI_.dll");
|
||||
|
||||
// Fixes hang when Start menu closes
|
||||
VnPatchDelayIAT(hStartUI, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", Start_SetWindowRgn);
|
||||
|
@ -1330,8 +1330,7 @@ BOOL DownloadFile(LPCWSTR wszURL, DWORD dwSize, LPCWSTR wszPath)
|
||||
exe_buffer = calloc(dwSize, sizeof(char));
|
||||
if (exe_buffer)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
if (bRet = InternetReadFile(
|
||||
if (InternetReadFile(
|
||||
hConnect,
|
||||
exe_buffer,
|
||||
dwSize - 1,
|
||||
@ -1342,7 +1341,7 @@ BOOL DownloadFile(LPCWSTR wszURL, DWORD dwSize, LPCWSTR wszPath)
|
||||
_wfopen_s(&f, wszPath, L"wb");
|
||||
if (f)
|
||||
{
|
||||
fwrite(exe_buffer, 1, dwRead, f);
|
||||
bOK = fwrite(exe_buffer, 1, dwRead, f) == dwRead;
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
@ -921,7 +921,15 @@ inline BOOL DoesWindows10StartMenuExist()
|
||||
wchar_t szPath[MAX_PATH];
|
||||
GetWindowsDirectoryW(szPath, MAX_PATH);
|
||||
wcscat_s(szPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\\StartUI.dll");
|
||||
return FileExistsW(szPath);
|
||||
if (FileExistsW(szPath))
|
||||
return TRUE;
|
||||
|
||||
GetWindowsDirectoryW(szPath, MAX_PATH);
|
||||
wcscat_s(szPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\\StartUI_.dll");
|
||||
if (FileExistsW(szPath))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline BOOL IsStockWindows10TaskbarAvailable()
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <Windows.h>
|
||||
#include <initguid.h>
|
||||
#include <valinet/hooking/iatpatch.h>
|
||||
// #include <valinet/hooking/iatpatch.h>
|
||||
#include <valinet/utility/memmem.h>
|
||||
#include "../ExplorerPatcher/utility.h"
|
||||
#include "ep_sm_forwards.h"
|
||||
@ -22,6 +22,33 @@ DEFINE_GUID(IID_StartUI_XamlMetaDataProvider, 0xF2777C41, 0xD2CC, 0x34B6, 0xA7,
|
||||
return TRUE;
|
||||
}*/
|
||||
|
||||
BOOL GetStartUIName(WCHAR* out, int cch)
|
||||
{
|
||||
if (out && cch)
|
||||
out[0] = 0;
|
||||
|
||||
WCHAR szPath[MAX_PATH];
|
||||
wcscpy_s(szPath, MAX_PATH, L"StartUI.dll");
|
||||
if (FileExistsW(szPath))
|
||||
{
|
||||
if (out && cch)
|
||||
wcscpy_s(out, cch, szPath);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wcscpy_s(szPath, MAX_PATH, L"StartUI_.dll");
|
||||
if (FileExistsW(szPath))
|
||||
{
|
||||
if (out && cch)
|
||||
wcscpy_s(out, cch, szPath);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WCHAR g_szStartUIName[MAX_PATH];
|
||||
|
||||
BOOL GetStartShowClassicMode()
|
||||
{
|
||||
DWORD dwStartShowClassicMode = 0;
|
||||
@ -30,7 +57,7 @@ BOOL GetStartShowClassicMode()
|
||||
if (dwStartShowClassicMode == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!FileExistsW(L"StartUI.dll"))
|
||||
if (!GetStartUIName(g_szStartUIName, ARRAYSIZE(g_szStartUIName)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -55,9 +82,10 @@ void PatchXamlMetaDataProviderGuid()
|
||||
PIMAGE_NT_HEADERS64 ntHeader = (PIMAGE_NT_HEADERS64)((u_char*)dosHeader + dosHeader->e_lfanew);
|
||||
if (ntHeader->Signature == IMAGE_NT_SIGNATURE)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER firstSection = IMAGE_FIRST_SECTION(ntHeader);
|
||||
for (unsigned int i = 0; i < ntHeader->FileHeader.NumberOfSections; ++i)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeader) + i;
|
||||
PIMAGE_SECTION_HEADER section = firstSection + i;
|
||||
if (!strncmp(section->Name, ".rdata", 6))
|
||||
{
|
||||
beginRData = (PBYTE)dosHeader + section->VirtualAddress;
|
||||
@ -72,7 +100,7 @@ void PatchXamlMetaDataProviderGuid()
|
||||
return;
|
||||
}
|
||||
|
||||
GUID* pguidTarget = memmem(beginRData, sizeRData, &IID_StartDocked_XamlMetaDataProvider, sizeof(GUID));
|
||||
GUID* pguidTarget = memmem(beginRData, sizeRData, (void*)&IID_StartDocked_XamlMetaDataProvider, sizeof(GUID));
|
||||
if (!pguidTarget)
|
||||
{
|
||||
return;
|
||||
@ -122,14 +150,17 @@ wchar_t* GetCmdArguments(int* a1)
|
||||
return pGetCmdArguments(a1);
|
||||
}
|
||||
|
||||
extern HRESULT LoadOurShellCommonPri();
|
||||
extern HRESULT GetActivationFactoryByPCWSTR_InStartUI(PCWSTR activatableClassId, REFIID riid, void** ppv);
|
||||
|
||||
#pragma comment(linker, "/export:?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z=GetActivationFactoryByPCWSTR,@129")
|
||||
HRESULT GetActivationFactoryByPCWSTR(PCWSTR activatableClassId, const GUID* iid, void** ppv)
|
||||
HRESULT GetActivationFactoryByPCWSTR(PCWSTR activatableClassId, REFIID riid, void** ppv)
|
||||
{
|
||||
if (!hOrig)
|
||||
{
|
||||
hOrig = LoadLibraryW(L"wincorlib_orig.dll");
|
||||
}
|
||||
static HRESULT (*pGetActivationFactoryByPCWSTR)(PCWSTR, const GUID*, void**) = NULL;
|
||||
static HRESULT (*pGetActivationFactoryByPCWSTR)(PCWSTR, REFIID, void**) = NULL;
|
||||
if (!pGetActivationFactoryByPCWSTR && hOrig)
|
||||
{
|
||||
pGetActivationFactoryByPCWSTR = GetProcAddress(hOrig, "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z");
|
||||
@ -139,22 +170,28 @@ HRESULT GetActivationFactoryByPCWSTR(PCWSTR activatableClassId, const GUID* iid,
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (!wcscmp(activatableClassId, L"StartDocked.App") && IsEqualGUID(iid, &IID_StartDocked_App))
|
||||
if (!wcscmp(activatableClassId, L"StartDocked.App") && IsEqualGUID(riid, &IID_StartDocked_App))
|
||||
{
|
||||
if (GetStartShowClassicMode())
|
||||
{
|
||||
return pGetActivationFactoryByPCWSTR(L"StartUI.App", &IID_StartUI_App, ppv);
|
||||
LoadOurShellCommonPri();
|
||||
return GetActivationFactoryByPCWSTR_InStartUI(L"StartUI.App", &IID_StartUI_App, ppv);
|
||||
}
|
||||
}
|
||||
else if (!wcscmp(activatableClassId, L"StartDocked.startdocked_XamlTypeInfo.XamlMetaDataProvider"))
|
||||
{
|
||||
if (GetStartShowClassicMode())
|
||||
{
|
||||
return pGetActivationFactoryByPCWSTR(L"StartUI.startui_XamlTypeInfo.XamlMetaDataProvider", iid, ppv);
|
||||
return GetActivationFactoryByPCWSTR_InStartUI(L"StartUI.startui_XamlTypeInfo.XamlMetaDataProvider", riid, ppv);
|
||||
}
|
||||
}
|
||||
|
||||
return pGetActivationFactoryByPCWSTR(activatableClassId, iid, ppv);
|
||||
if (wcsncmp(activatableClassId, L"StartUI.", 8) == 0)
|
||||
{
|
||||
return GetActivationFactoryByPCWSTR_InStartUI(activatableClassId, riid, ppv);
|
||||
}
|
||||
|
||||
return pGetActivationFactoryByPCWSTR(activatableClassId, riid, ppv);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
|
89
ep_startmenu/ep_sm_main_cpp.cpp
Normal file
89
ep_startmenu/ep_sm_main_cpp.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include <Windows.h>
|
||||
#include <windows.foundation.h>
|
||||
#include <windows.applicationmodel.resources.core.h>
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <wrl/wrappers/corewrappers.h>
|
||||
|
||||
namespace ABI::Windows::ApplicationModel::Resources::Core::Internal
|
||||
{
|
||||
MIDL_INTERFACE("4a8eac58-b652-459d-8de1-239471e8b22b")
|
||||
IResourceManagerStaticInternal : IInspectable
|
||||
{
|
||||
virtual HRESULT STDMETHODCALLTYPE GetResourceManagerForSystemProfile(IResourceManager** result) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentResourceManagerForSystemProfile(IResourceManager** result) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetCurrentResourceManagerState(DWORD* result) = 0;
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("c408a1f1-3ede-41e9-9a38-c203678c2df7")
|
||||
ISystemResourceManagerExtensions : IInspectable
|
||||
{
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDefaultResourceContextForCurrentThread(IResourceContext**) = 0;
|
||||
virtual HRESULT STDMETHODCALLTYPE GetMrtResourceManagerForResourceManager(IInspectable**) = 0;
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("8c25e859-1042-4da0-9232-bf2aa8ff3726")
|
||||
ISystemResourceManagerExtensions2 : IInspectable
|
||||
{
|
||||
virtual HRESULT STDMETHODCALLTYPE LoadPriFileForSystemUse(const WCHAR* path) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
extern "C" HRESULT LoadOurShellCommonPri()
|
||||
{
|
||||
using namespace ABI::Windows::Foundation;
|
||||
|
||||
ComPtr<IInspectable> pInspectable;
|
||||
HRESULT hr = Windows::Foundation::GetActivationFactory(
|
||||
Wrappers::HStringReference(L"Windows.ApplicationModel.Resources.Core.ResourceManager").Get(),
|
||||
pInspectable.GetAddressOf()
|
||||
);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ComPtr<ABI::Windows::ApplicationModel::Resources::Core::Internal::IResourceManagerStaticInternal> pResourceManagerStaticInternal;
|
||||
hr = pInspectable.As(&pResourceManagerStaticInternal);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ComPtr<ABI::Windows::ApplicationModel::Resources::Core::IResourceManager> pResourceManager;
|
||||
hr = pResourceManagerStaticInternal->GetCurrentResourceManagerForSystemProfile(&pResourceManager);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ComPtr<ABI::Windows::ApplicationModel::Resources::Core::Internal::ISystemResourceManagerExtensions2> pSystemResourceManagerExtensions2;
|
||||
pResourceManager.As(&pSystemResourceManagerExtensions2);
|
||||
WCHAR wszPath[MAX_PATH] = {};
|
||||
wcscat_s(wszPath, MAX_PATH, L"C:\\Program Files\\ExplorerPatcher\\Windows.UI.ShellCommon.pri");
|
||||
hr = pSystemResourceManagerExtensions2->LoadPriFileForSystemUse(wszPath);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
extern "C" WCHAR g_szStartUIName[MAX_PATH];
|
||||
|
||||
extern "C" HRESULT GetActivationFactoryByPCWSTR_InStartUI(PCWSTR activatableClassId, REFIID riid, void** ppv)
|
||||
{
|
||||
typedef HRESULT (WINAPI* DllGetActivationFactory_t)(HSTRING, IActivationFactory**);
|
||||
static DllGetActivationFactory_t pfnGetActivationFactory;
|
||||
if (!pfnGetActivationFactory)
|
||||
{
|
||||
HMODULE hModule = GetModuleHandleW(g_szStartUIName);
|
||||
if (hModule)
|
||||
{
|
||||
pfnGetActivationFactory = (DllGetActivationFactory_t)GetProcAddress(hModule, "DllGetActivationFactory");
|
||||
}
|
||||
}
|
||||
|
||||
if (!pfnGetActivationFactory)
|
||||
return E_FAIL;
|
||||
|
||||
ComPtr<IActivationFactory> activationFactory;
|
||||
HRESULT hr = pfnGetActivationFactory(Wrappers::HStringReference(activatableClassId).Get(), &activationFactory);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
return activationFactory.CopyTo(riid, ppv);
|
||||
}
|
@ -133,6 +133,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -149,6 +150,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -165,6 +167,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -181,6 +184,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -197,6 +201,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -213,6 +218,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)libs\libvalinet;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@ -228,6 +234,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ep_sm_main.c" />
|
||||
<ClCompile Include="ep_sm_main_cpp.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\ExplorerPatcher\ExplorerPatcher.rc" />
|
||||
|
Loading…
Reference in New Issue
Block a user