| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <windows.h> // NOLINT | 5 #include <windows.h> // NOLINT |
| 6 #include <fcntl.h> // for _O_* constants | 6 #include <fcntl.h> // for _O_* constants |
| 7 #include <fdi.h> | 7 #include <fdi.h> |
| 8 | 8 |
| 9 #include "chrome/installer/mini_installer/decompress.h" | 9 #include "chrome/installer/mini_installer/decompress.h" |
| 10 | 10 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // environment variables set, so we try a couple that *should* always be | 183 // environment variables set, so we try a couple that *should* always be |
| 184 // present and fallback to the default Windows install path if all else | 184 // present and fallback to the default Windows install path if all else |
| 185 // fails. | 185 // fails. |
| 186 // The cabinet.dll should be available on all supported versions of Windows. | 186 // The cabinet.dll should be available on all supported versions of Windows. |
| 187 static const wchar_t* const candidate_paths[] = { | 187 static const wchar_t* const candidate_paths[] = { |
| 188 L"%WINDIR%\\system32\\cabinet.dll", | 188 L"%WINDIR%\\system32\\cabinet.dll", |
| 189 L"%SYSTEMROOT%\\system32\\cabinet.dll", | 189 L"%SYSTEMROOT%\\system32\\cabinet.dll", |
| 190 L"C:\\Windows\\system32\\cabinet.dll", | 190 L"C:\\Windows\\system32\\cabinet.dll", |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 wchar_t path[MAX_PATH] = {0}; | 193 static const DWORD kBufferSize = MAX_PATH; |
| 194 for (int i = 0; i < arraysize(candidate_paths); ++i) { | 194 wchar_t path[kBufferSize]; |
| 195 for (const wchar_t* candidate_path : candidate_paths) { |
| 195 path[0] = L'\0'; | 196 path[0] = L'\0'; |
| 196 DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i], | 197 DWORD result = ::ExpandEnvironmentStringsW(candidate_path, |
| 197 path, arraysize(path)); | 198 path, kBufferSize); |
| 198 | 199 |
| 199 if (result > 0 && result <= arraysize(path)) | 200 if (result > 0 && result <= kBufferSize) |
| 200 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); | 201 g_fdi = ::LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
| 201 | 202 |
| 202 if (g_fdi) | 203 if (g_fdi) |
| 203 break; | 204 break; |
| 204 } | 205 } |
| 205 } | 206 } |
| 206 | 207 |
| 207 if (g_fdi) { | 208 if (g_fdi) { |
| 208 g_FDICreate = | 209 g_FDICreate = |
| 209 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate")); | 210 reinterpret_cast<FDICreateFn>(::GetProcAddress(g_fdi, "FDICreate")); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 &Notify, NULL, const_cast<wchar_t*>(destination))) { | 253 &Notify, NULL, const_cast<wchar_t*>(destination))) { |
| 253 success = true; | 254 success = true; |
| 254 } | 255 } |
| 255 g_FDIDestroy(fdi); | 256 g_FDIDestroy(fdi); |
| 256 } | 257 } |
| 257 | 258 |
| 258 return success; | 259 return success; |
| 259 } | 260 } |
| 260 | 261 |
| 261 } // namespace mini_installer | 262 } // namespace mini_installer |
| OLD | NEW |