Chromium Code Reviews| 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 #include <stdlib.h> | |
| 8 | 9 |
| 9 #include "chrome/installer/mini_installer/decompress.h" | 10 #include "chrome/installer/mini_installer/decompress.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 FNALLOC(Alloc) { | 14 FNALLOC(Alloc) { |
| 14 return ::HeapAlloc(::GetProcessHeap(), 0, cb); | 15 return ::HeapAlloc(::GetProcessHeap(), 0, cb); |
| 15 } | 16 } |
| 16 | 17 |
| 17 FNFREE(Free) { | 18 FNFREE(Free) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 // environment variables set, so we try a couple that *should* always be | 184 // 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 | 185 // present and fallback to the default Windows install path if all else |
| 185 // fails. | 186 // fails. |
| 186 // The cabinet.dll should be available on all supported versions of Windows. | 187 // The cabinet.dll should be available on all supported versions of Windows. |
| 187 static const wchar_t* const candidate_paths[] = { | 188 static const wchar_t* const candidate_paths[] = { |
| 188 L"%WINDIR%\\system32\\cabinet.dll", | 189 L"%WINDIR%\\system32\\cabinet.dll", |
| 189 L"%SYSTEMROOT%\\system32\\cabinet.dll", | 190 L"%SYSTEMROOT%\\system32\\cabinet.dll", |
| 190 L"C:\\Windows\\system32\\cabinet.dll", | 191 L"C:\\Windows\\system32\\cabinet.dll", |
| 191 }; | 192 }; |
| 192 | 193 |
| 193 wchar_t path[MAX_PATH] = {0}; | 194 wchar_t path[MAX_PATH] = {0}; |
|
grt (UTC plus 2)
2015/05/06 16:46:34
change this to:
static const DWORD kBufferSize
tfarina
2015/05/06 17:21:55
Done.
| |
| 194 for (int i = 0; i < arraysize(candidate_paths); ++i) { | 195 for (int i = 0; i < _countof(candidate_paths); ++i) { |
|
grt (UTC plus 2)
2015/05/06 16:46:34
this also looks like a job for:
for (const wch
tfarina
2015/05/06 17:21:55
Done.
| |
| 195 path[0] = L'\0'; | 196 path[0] = L'\0'; |
| 196 DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i], | 197 DWORD result = ::ExpandEnvironmentStringsW(candidate_paths[i], |
| 197 path, arraysize(path)); | 198 path, _countof(path)); |
| 198 | 199 |
| 199 if (result > 0 && result <= arraysize(path)) | 200 if (result > 0 && result <= _countof(path)) |
| 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 |