From f652ccddcc2b2e6960cb7d19b8d4cb7698317d0d Mon Sep 17 00:00:00 2001 From: dmex Date: Sun, 11 Dec 2022 03:19:00 +1100 Subject: [PATCH] SetupTool: Fix regression querying %ProgramFiles% (SHGetKnownFolderPath doesn't handle 32bit) --- tools/CustomSetupTool/util.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/CustomSetupTool/util.c b/tools/CustomSetupTool/util.c index facb3d9ae..e0f57d818 100644 --- a/tools/CustomSetupTool/util.c +++ b/tools/CustomSetupTool/util.c @@ -117,7 +117,16 @@ PPH_STRING SetupFindInstallDirectory( if (PhIsNullOrEmptyString(setupInstallPath)) { - setupInstallPath = PhGetKnownFolderPath(&FOLDERID_ProgramFiles, L"\\SystemInformer\\"); + static PH_STRINGREF programW6432 = PH_STRINGREF_INIT(L"%ProgramW6432%\\SystemInformer\\"); + static PH_STRINGREF programFiles = PH_STRINGREF_INIT(L"%ProgramFiles%\\SystemInformer\\"); + SYSTEM_INFO info; + + GetNativeSystemInfo(&info); + + if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) + setupInstallPath = PhExpandEnvironmentStrings(&programW6432); + else + setupInstallPath = PhExpandEnvironmentStrings(&programFiles); } if (PhIsNullOrEmptyString(setupInstallPath))