1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-23 23:21:08 +01:00

Setup: Bundle pnidui.dll and StartUI.dll due to uncertainties in MS' symbol servers

This commit is contained in:
Amrsatrio 2024-07-31 20:38:58 +07:00
parent d9595fccc6
commit b4731146a2
2 changed files with 61 additions and 50 deletions

View File

@ -657,7 +657,7 @@ typedef enum LanguageCodeTreatment
__declspec(noinline) BOOL ExtractDirectory(unzFile zipFile, const char* dirNameInZip, LPCWSTR pwszDirectory, const WCHAR* languages, LanguageCodeTreatment langCodeTreatment) __declspec(noinline) BOOL ExtractDirectory(unzFile zipFile, const char* dirNameInZip, LPCWSTR pwszDirectory, const WCHAR* languages, LanguageCodeTreatment langCodeTreatment)
{ {
if (!zipFile || !dirNameInZip) if (!zipFile)
{ {
return FALSE; return FALSE;
} }
@ -668,7 +668,7 @@ __declspec(noinline) BOOL ExtractDirectory(unzFile zipFile, const char* dirNameI
} }
BOOL bRet = TRUE; BOOL bRet = TRUE;
size_t dirNameLen = strlen(dirNameInZip); size_t dirNameLen = dirNameInZip ? strlen(dirNameInZip) : 0;
do do
{ {
@ -685,7 +685,7 @@ __declspec(noinline) BOOL ExtractDirectory(unzFile zipFile, const char* dirNameI
continue; continue;
} }
if (strncmp(szFileNameInZip, dirNameInZip, dirNameLen) != 0) if (dirNameInZip && strncmp(szFileNameInZip, dirNameInZip, dirNameLen) != 0)
{ {
continue; continue;
} }
@ -752,7 +752,14 @@ __declspec(noinline) BOOL ExtractDirectory(unzFile zipFile, const char* dirNameI
wcscpy_s(wszPath, MAX_PATH, pwszDirectory); wcscpy_s(wszPath, MAX_PATH, pwszDirectory);
wcscat_s(wszPath, MAX_PATH, L"\\"); wcscat_s(wszPath, MAX_PATH, L"\\");
WCHAR* pwszPathInDir = wszPath + wcslen(wszPath); WCHAR* pwszPathInDir = wszPath + wcslen(wszPath);
wcscat_s(wszPath, MAX_PATH, wcschr(wszFileNameInZip, '\\') + 1); // Skip the directory name in the zip file if (dirNameInZip)
{
wcscat_s(wszPath, MAX_PATH, wcschr(wszFileNameInZip, '\\') + 1); // Skip the directory name in the zip file
}
else
{
wcscat_s(wszPath, MAX_PATH, wszFileNameInZip);
}
for (WCHAR* p = pwszPathInDir; *p; p++) for (WCHAR* p = pwszPathInDir; *p; p++)
{ {
@ -781,7 +788,7 @@ BOOL DeleteResource(LPCWSTR pwszDirectory, LPCWSTR pwszFileName)
return InstallResourceHelper(FALSE, NULL, NULL, wszPath); return InstallResourceHelper(FALSE, NULL, NULL, wszPath);
} }
BOOL ShouldDownloadOrDelete(BOOL bInstall, WCHAR* wszPath, LPCSTR chash) /*BOOL ShouldDownloadOrDelete(BOOL bInstall, WCHAR* wszPath, LPCSTR chash)
{ {
if (FileExistsW(wszPath)) if (FileExistsW(wszPath))
{ {
@ -813,7 +820,7 @@ BOOL DownloadResource(BOOL bInstall, LPCWSTR pwszURL, DWORD dwSize, LPCSTR chash
bOk = DownloadFile(pwszURL, dwSize, wszPath); bOk = DownloadFile(pwszURL, dwSize, wszPath);
} }
return bOk; return bOk;
} }*/
void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, unzFile zipFile, WCHAR wszPath[260]) void ProcessTaskbarDlls(BOOL* bInOutOk, BOOL bInstall, BOOL bExtractMode, HINSTANCE hInstance, unzFile zipFile, WCHAR wszPath[260])
{ {
@ -915,19 +922,10 @@ int WINAPI wWinMain(
MemoryBuffer* pMem; MemoryBuffer* pMem;
unzFile zipFile = LoadZipFileFromResources(&pMem); unzFile zipFile = LoadZipFileFromResources(&pMem);
bOk = zipFile != NULL; bOk = zipFile != NULL;
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".IA-32.dll", wszPath, _T(PRODUCT_NAME) L".IA-32.dll"); if (bOk)
#if defined(_M_X64) {
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".amd64.dll", wszPath, _T(PRODUCT_NAME) L".amd64.dll"); bOk = ExtractDirectory(zipFile, NULL, wszPath, NULL, LCT_None);
#elif defined(_M_ARM64) }
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, PRODUCT_NAME ".arm64.dll", wszPath, _T(PRODUCT_NAME) L".arm64.dll");
#endif
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_dwm.exe", wszPath, L"ep_dwm.exe");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host.dll", wszPath, L"ep_weather_host.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_weather_host_stub.dll", wszPath, L"ep_weather_host_stub.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "WebView2Loader.dll", wszPath, L"WebView2Loader.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "wincorlib.dll", wszPath, L"wincorlib.dll");
if (bOk) bOk = InstallResource(bInstall, hInstance, zipFile, "ep_gui.dll", wszPath, L"ep_gui.dll");
ProcessTaskbarDlls(&bOk, bInstall, TRUE, hInstance, zipFile, wszPath);
if (zipFile) if (zipFile)
unzClose(zipFile); unzClose(zipFile);
if (pMem) if (pMem)
@ -1139,22 +1137,6 @@ int WINAPI wWinMain(
CloseHandle(sei.hProcess); CloseHandle(sei.hProcess);
} }
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW));
sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.hwnd = NULL;
sei.hInstApp = NULL;
sei.lpVerb = NULL;
sei.lpFile = wszPath;
sei.lpParameters = L"/f /im StartMenuExperienceHost.exe";
sei.hwnd = NULL;
sei.nShow = SW_SHOWMINIMIZED;
if (ShellExecuteExW(&sei) && sei.hProcess)
{
WaitForSingleObject(sei.hProcess, INFINITE);
CloseHandle(sei.hProcess);
}
Sleep(500); Sleep(500);
BOOL bAreRoundedCornersDisabled = FALSE; BOOL bAreRoundedCornersDisabled = FALSE;
@ -1361,10 +1343,11 @@ int WINAPI wWinMain(
} }
} }
DeleteResource(wszPath, L"Windows.UI.ShellCommon.pri"); DeleteResource(wszPath, L"Windows.UI.ShellCommon.pri");
BOOL bNoPniduiInThisBuild = global_rovi.dwBuildNumber >= 25236;
if (bInstall) if (bInstall)
{ {
const WCHAR* languages = GetSystemLanguages(); const WCHAR* languages = GetSystemLanguages();
if (global_rovi.dwBuildNumber >= 25236) if (bNoPniduiInThisBuild)
{ {
if (bOk) bOk = ExtractDirectory(zipFile, "pnidui/", wszPath, languages, LCT_MUI); if (bOk) bOk = ExtractDirectory(zipFile, "pnidui/", wszPath, languages, LCT_MUI);
} }
@ -1374,13 +1357,43 @@ int WINAPI wWinMain(
} }
} }
#if defined(_M_X64) if (bOk) bOk = InstallResource(bInstall && bNoPniduiInThisBuild, hInstance, zipFile, "pnidui/pnidui.dll", wszPath, L"pnidui.dll");
// Version 22621.3810
if (bOk) bOk = DownloadResource(bInstall && global_rovi.dwBuildNumber >= 25236, L"https://msdl.microsoft.com/download/symbols/pnidui.dll/F717CABC20B000/pnidui.dll", 2138112 + 1, "2f913bfdcf1fa8dc441aa48b508b3a09", wszPath, L"pnidui.dll"); if (bOk && bNoPniduiInThisBuild)
#elif defined(_M_ARM64) {
// Version 22621.3958 // Windows Registry Editor Version 5.00
if (bOk) bOk = DownloadResource(bInstall && global_rovi.dwBuildNumber >= 25236, L"https://msdl.microsoft.com/download/symbols/pnidui.dll/63AF842D210000/pnidui.dll", 2139648 + 1, "43bb6bb72d2529045f913fb5b055b521", wszPath, L"pnidui.dll"); //
#endif // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellServiceObjects\{C2796011-81BA-4148-8FCA-C6643245113F}]
// "AutoStart"=""
if (bInstall)
{
HKEY hKey;
RegCreateKeyExW(
HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellServiceObjects\\{C2796011-81BA-4148-8FCA-C6643245113F}",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WRITE,
NULL,
&hKey,
NULL
);
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
if (hKey)
{
RegSetValueExW(hKey, L"AutoStart", 0, REG_SZ, (const BYTE*)L"", 1 * sizeof(WCHAR));
RegCloseKey(hKey);
}
}
else
{
RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellServiceObjects\\{C2796011-81BA-4148-8FCA-C6643245113F}");
}
}
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
@ -1428,13 +1441,7 @@ int WINAPI wWinMain(
} }
BOOL bNoStartUIInThisBuild = ((global_rovi.dwBuildNumber >= 22621 && global_rovi.dwBuildNumber <= 22635) && global_ubr >= 3930) || global_rovi.dwBuildNumber >= 25169; BOOL bNoStartUIInThisBuild = ((global_rovi.dwBuildNumber >= 22621 && global_rovi.dwBuildNumber <= 22635) && global_ubr >= 3930) || global_rovi.dwBuildNumber >= 25169;
#if defined(_M_X64) if (bOk) bOk = InstallResource(bInstall && bNoStartUIInThisBuild, hInstance, zipFile, "StartUI/StartUI.dll", wszPath, L"StartUI_.dll");
// Version 22621.3733
if (bOk) bOk = DownloadResource(bInstall && bNoStartUIInThisBuild, L"https://msdl.microsoft.com/download/symbols/startui.dll/C1AEED44852000/startui.dll", 8694272 + 1, "20b55d5c6dce22f8011906281e4e6999", wszPath, L"StartUI_.dll");
#elif defined(_M_ARM64)
// Version 22621.3733
if (bOk) bOk = DownloadResource(bInstall && bNoStartUIInThisBuild, L"https://msdl.microsoft.com/download/symbols/startui.dll/122A50F3AB9000/startui.dll", 11214336 + 1, "44ab29fba796bb6977dc050eb2fa7397", wszPath, L"StartUI_.dll");
#endif
// Delete remnants from earlier versions // Delete remnants from earlier versions
if (bOk) bOk = DeleteResource(wszPath, L"AppResolverLegacy.dll"); if (bOk) bOk = DeleteResource(wszPath, L"AppResolverLegacy.dll");

View File

@ -377,6 +377,10 @@
</UsingTask> </UsingTask>
<Target Name="CreateZip" BeforeTargets="ResourceCompile"> <Target Name="CreateZip" BeforeTargets="ResourceCompile">
<MakeDir Directories="..\build\$(Configuration)\$(Platform)\ep_setup_files" /> <MakeDir Directories="..\build\$(Configuration)\$(Platform)\ep_setup_files" />
<DownloadFile DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\pnidui" DestinationFileName="pnidui.dll" SourceUrl="https://msdl.microsoft.com/download/symbols/pnidui.dll/F717CABC20B000/pnidui.dll" SkipUnchangedFiles="true" Retries="3" Condition="'$(Platform)' == 'x64'" />
<DownloadFile DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\pnidui" DestinationFileName="pnidui.dll" SourceUrl="https://msdl.microsoft.com/download/symbols/pnidui.dll/63AF842D210000/pnidui.dll" SkipUnchangedFiles="true" Retries="3" Condition="'$(Platform)' == 'ARM64'" />
<DownloadFile DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\StartUI" DestinationFileName="StartUI.dll" SourceUrl="https://msdl.microsoft.com/download/symbols/startui.dll/C1AEED44852000/startui.dll" SkipUnchangedFiles="true" Retries="3" Condition="'$(Platform)' == 'x64'" />
<DownloadFile DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\StartUI" DestinationFileName="StartUI.dll" SourceUrl="https://msdl.microsoft.com/download/symbols/startui.dll/122A50F3AB9000/startui.dll" SkipUnchangedFiles="true" Retries="3" Condition="'$(Platform)' == 'ARM64'" />
<Copy SourceFiles="@(PackFile)" DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\%(RecursiveDir)" /> <Copy SourceFiles="@(PackFile)" DestinationFolder="..\build\$(Configuration)\$(Platform)\ep_setup_files\%(RecursiveDir)" />
<ZipDirectory SourceDirectory="..\build\$(Configuration)\$(Platform)\ep_setup_files" DestinationFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" Overwrite="true" /> <ZipDirectory SourceDirectory="..\build\$(Configuration)\$(Platform)\ep_setup_files" DestinationFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" Overwrite="true" />
<EncryptFile OutputFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" EncryptionKey="$(ZipEncryptionKey)" Condition="'$(WithEncryption)' == 'true'" /> <EncryptFile OutputFile="..\build\$(Configuration)\$(Platform)\ep_setup_files.zip" EncryptionKey="$(ZipEncryptionKey)" Condition="'$(WithEncryption)' == 'true'" />