diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 02:33:50 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 02:33:50 +0000 |
commit | 497f98356f9f46879f478873f11b6528ef56c368 (patch) | |
tree | 3537cb2111ca6ba6515a4d998eecc904aaedd6c6 /chrome/installer | |
parent | 15b5ab5c9d4dae0eaf5b73e71a417cee0a4e6035 (diff) | |
download | chromium_src-497f98356f9f46879f478873f11b6528ef56c368.zip chromium_src-497f98356f9f46879f478873f11b6528ef56c368.tar.gz chromium_src-497f98356f9f46879f478873f11b6528ef56c368.tar.bz2 |
Add alternate search paths for the decompression DLL used by mini_installer.exe.
BUG=102474
TEST=chrome installs, even when %WINDIR% and %SYSTEMROOT% are not set.
Review URL: http://codereview.chromium.org/8507021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/mini_installer/decompress.cc | 29 | ||||
-rw-r--r-- | chrome/installer/mini_installer/decompress.h | 5 | ||||
-rw-r--r-- | chrome/installer/mini_installer/mini_installer.cc | 5 |
3 files changed, 30 insertions, 9 deletions
diff --git a/chrome/installer/mini_installer/decompress.cc b/chrome/installer/mini_installer/decompress.cc index ced226d..ed9098a 100644 --- a/chrome/installer/mini_installer/decompress.cc +++ b/chrome/installer/mini_installer/decompress.cc @@ -179,11 +179,32 @@ FDICopyFn g_FDICopy = NULL; bool InitializeFdi() { if (!g_fdi) { + // It has been observed that some users do not have the expected + // environment variables set, so we try a couple that *should* always be + // present and fallback to the default Windows install path if all else + // fails. + // The cabinet.dll should be available on all supported versions of Windows. + static const wchar_t* const candidate_paths[] = { + L"%WINDIR%\\system32\\cabinet.dll", + L"%SYSTEMROOT%\\system32\\cabinet.dll", + L"C:\\Windows\\system32\\cabinet.dll", + }; + wchar_t path[MAX_PATH] = {0}; - ::ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\cabinet.dll", path, - MAX_PATH); - // This DLL should be available on all supported versions of Windows. - g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + for (int i = 0; i < arraysize(candidate_paths); ++i) { + path[0] = L'\0'; + DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i], + path, arraysize(path)); + + if (result > 0 && result <= arraysize(path)) + g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + + if (g_fdi) + break; + } + } + + if (g_fdi) { g_FDICreate = reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate")); g_FDIDestroy = diff --git a/chrome/installer/mini_installer/decompress.h b/chrome/installer/mini_installer/decompress.h index 8e093aa..579ee3c 100644 --- a/chrome/installer/mini_installer/decompress.h +++ b/chrome/installer/mini_installer/decompress.h @@ -6,6 +6,11 @@ #define CHROME_INSTALLER_MINI_INSTALLER_DECOMPRESS_H_ #pragma once +// arraysize borrowed from basictypes.h +template <typename T, size_t N> +char (&ArraySizeHelper(T (&array)[N]))[N]; +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + namespace mini_installer { // Same as the tool, expand.exe. Decompresses a file that was compressed diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc index 44a17e2..ea3add3 100644 --- a/chrome/installer/mini_installer/mini_installer.cc +++ b/chrome/installer/mini_installer/mini_installer.cc @@ -31,11 +31,6 @@ #include "chrome/installer/mini_installer/mini_string.h" #include "chrome/installer/mini_installer/pe_resource.h" -// arraysize borrowed from basictypes.h -template <typename T, size_t N> -char (&ArraySizeHelper(T (&array)[N]))[N]; -#define arraysize(array) (sizeof(ArraySizeHelper(array))) - namespace mini_installer { typedef StackString<MAX_PATH> PathString; |