Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // mini_installer.exe is the first exe that is run when chrome is being | 5 // mini_installer.exe is the first exe that is run when chrome is being |
| 6 // installed or upgraded. It is designed to be extremely small (~5KB with no | 6 // installed or upgraded. It is designed to be extremely small (~5KB with no |
| 7 // extra resources linked) and it has two main jobs: | 7 // extra resources linked) and it has two main jobs: |
| 8 // 1) unpack the resources (possibly decompressing some) | 8 // 1) unpack the resources (possibly decompressing some) |
| 9 // 2) run the real installer (setup.exe) with appropriate flags. | 9 // 2) run the real installer (setup.exe) with appropriate flags. |
| 10 // | 10 // |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 216 |
| 217 if (!StrEndsWith(value.get(), kFullInstallerSuffix) && | 217 if (!StrEndsWith(value.get(), kFullInstallerSuffix) && |
| 218 value.append(kFullInstallerSuffix)) { | 218 value.append(kFullInstallerSuffix)) { |
| 219 key.WriteValue(kApRegistryValueName, value.get()); | 219 key.WriteValue(kApRegistryValueName, value.get()); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Gets the setup.exe path from Registry by looking the value of Uninstall | 224 // Gets the setup.exe path from Registry by looking the value of Uninstall |
| 225 // string. |size| is measured in wchar_t units. | 225 // string. |size| is measured in wchar_t units. |
| 226 bool GetSetupExePathForGuidFromRegistry(bool system_level, | 226 bool GetSetupExePathForGuidFromRegistry(bool system_level, |
|
grt (UTC plus 2)
2014/02/05 03:13:50
please rename this to GetQuotedSetupExePathForGuid
Cris Neckar
2014/02/06 20:56:23
Done.
| |
| 227 const wchar_t* app_guid, | 227 const wchar_t* app_guid, |
| 228 wchar_t* path, | 228 wchar_t* path, |
| 229 size_t size) { | 229 size_t size) { |
| 230 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 230 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 231 RegKey key; | 231 RegKey key; |
| 232 return OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) && | 232 wchar_t unquoted_path[MAX_PATH] = {0}; |
|
grt (UTC plus 2)
2014/02/05 03:13:50
{0} -> {}
Cris Neckar
2014/02/06 20:56:23
Done.
| |
| 233 (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS); | 233 if (!OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) || |
| 234 (key.ReadValue(kUninstallRegistryValueName, | |
| 235 unquoted_path, | |
| 236 MAX_PATH) != ERROR_SUCCESS)) { | |
|
grt (UTC plus 2)
2014/02/05 03:13:50
MAX_PATH -> arraysize(unquoted_path)
Cris Neckar
2014/02/06 20:56:23
Done.
| |
| 237 return false; | |
| 238 } | |
| 239 if (unquoted_path[0] == '\"') | |
| 240 return SafeStrCopy(path, size, unquoted_path); | |
| 241 | |
| 242 return SafeStrCopy(path, size, L"\"") && | |
| 243 SafeStrCat(path, size, unquoted_path) && | |
|
grt (UTC plus 2)
2014/02/05 03:13:50
nit: either four-space indent, or add parens for:
Cris Neckar
2014/02/06 20:56:23
Done.
| |
| 244 SafeStrCat(path, size, L"\""); | |
| 234 } | 245 } |
| 235 | 246 |
| 236 // Gets the setup.exe path from Registry by looking the value of Uninstall | 247 // Gets the setup.exe path from Registry by looking the value of Uninstall |
| 237 // string. |size| is measured in wchar_t units. | 248 // string. |size| is measured in wchar_t units. |
|
grt (UTC plus 2)
2014/02/05 03:13:50
please rename this to GetQuotedSetupExePathFromReg
Cris Neckar
2014/02/06 20:56:23
Done.
| |
| 238 bool GetSetupExePathFromRegistry(const Configuration& configuration, | 249 bool GetSetupExePathFromRegistry(const Configuration& configuration, |
| 239 wchar_t* path, | 250 wchar_t* path, |
| 240 size_t size) { | 251 size_t size) { |
| 241 bool system_level = configuration.is_system_level(); | 252 bool system_level = configuration.is_system_level(); |
| 242 | 253 |
| 243 // If this is a multi install, first try looking in the binaries for the path. | 254 // If this is a multi install, first try looking in the binaries for the path. |
| 244 if (configuration.is_multi_install() && GetSetupExePathForGuidFromRegistry( | 255 if (configuration.is_multi_install() && GetSetupExePathForGuidFromRegistry( |
| 245 system_level, google_update::kMultiInstallAppGuid, path, size)) { | 256 system_level, google_update::kMultiInstallAppGuid, path, size)) { |
| 246 return true; | 257 return true; |
| 247 } | 258 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 266 | 277 |
| 267 return false; | 278 return false; |
| 268 } | 279 } |
| 269 | 280 |
| 270 // Calls CreateProcess with good default parameters and waits for the process | 281 // Calls CreateProcess with good default parameters and waits for the process |
| 271 // to terminate returning the process exit code. | 282 // to terminate returning the process exit code. |
| 272 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, | 283 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, |
| 273 int* exit_code) { | 284 int* exit_code) { |
| 274 STARTUPINFOW si = {sizeof(si)}; | 285 STARTUPINFOW si = {sizeof(si)}; |
| 275 PROCESS_INFORMATION pi = {0}; | 286 PROCESS_INFORMATION pi = {0}; |
| 276 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, | 287 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, |
|
grt (UTC plus 2)
2014/02/05 03:13:50
if the intent of this CL is to mitigate against bu
Cris Neckar
2014/02/06 20:56:23
I like this way better. Done.
| |
| 277 NULL, NULL, &si, &pi)) { | 288 NULL, NULL, &si, &pi)) { |
| 278 return false; | 289 return false; |
| 279 } | 290 } |
| 280 | 291 |
| 281 ::CloseHandle(pi.hThread); | 292 ::CloseHandle(pi.hThread); |
| 282 | 293 |
| 283 bool ret = true; | 294 bool ret = true; |
| 284 DWORD wr = ::WaitForSingleObject(pi.hProcess, INFINITE); | 295 DWORD wr = ::WaitForSingleObject(pi.hProcess, INFINITE); |
| 285 if (WAIT_OBJECT_0 != wr) { | 296 if (WAIT_OBJECT_0 != wr) { |
| 286 ret = false; | 297 ret = false; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 case 1: | 864 case 1: |
| 854 dest8[count - 1] = c; | 865 dest8[count - 1] = c; |
| 855 } | 866 } |
| 856 | 867 |
| 857 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time | 868 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time |
| 858 *(dest32++) = fill; | 869 *(dest32++) = fill; |
| 859 | 870 |
| 860 return dest; | 871 return dest; |
| 861 } | 872 } |
| 862 } // extern "C" | 873 } // extern "C" |
| OLD | NEW |