OLD | NEW |
1 // Copyright (c) 2012 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 // 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 // |
11 // In order to be really small the app doesn't link against the CRT and | 11 // In order to be really small the app doesn't link against the CRT and |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // should try full installer next time. If the current installer works, this | 152 // should try full installer next time. If the current installer works, this |
153 // flag is cleared by setup.exe at the end of install. The flag will by default | 153 // flag is cleared by setup.exe at the end of install. The flag will by default |
154 // be written to HKCU, but if --system-level is included in the command line, | 154 // be written to HKCU, but if --system-level is included in the command line, |
155 // it will be written to HKLM instead. | 155 // it will be written to HKLM instead. |
156 // TODO(grt): Write a unit test for this that uses registry virtualization. | 156 // TODO(grt): Write a unit test for this that uses registry virtualization. |
157 void SetInstallerFlags(const Configuration& configuration) { | 157 void SetInstallerFlags(const Configuration& configuration) { |
158 RegKey key; | 158 RegKey key; |
159 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; | 159 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; |
160 const HKEY root_key = | 160 const HKEY root_key = |
161 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 161 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
162 // This is ignored if multi-install is true. | |
163 const wchar_t* app_guid = | 162 const wchar_t* app_guid = |
164 configuration.has_chrome_frame() ? | 163 configuration.has_chrome_frame() ? |
165 google_update::kChromeFrameAppGuid : | 164 google_update::kChromeFrameAppGuid : |
166 configuration.chrome_app_guid(); | 165 configuration.chrome_app_guid(); |
167 StackString<128> value; | 166 StackString<128> value; |
168 LONG ret; | 167 LONG ret; |
169 | 168 |
170 // When multi_install is true, we are potentially: | 169 // When multi_install is true, we are potentially: |
171 // 1. Performing a multi-install of some product(s) on a clean machine. | 170 // 1. Performing a multi-install of some product(s) on a clean machine. |
172 // Neither the product(s) nor the multi-installer will have a ClientState | 171 // Neither the product(s) nor the multi-installer will have a ClientState |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 215 |
217 if (!StrEndsWith(value.get(), kFullInstallerSuffix) && | 216 if (!StrEndsWith(value.get(), kFullInstallerSuffix) && |
218 value.append(kFullInstallerSuffix)) { | 217 value.append(kFullInstallerSuffix)) { |
219 key.WriteValue(kApRegistryValueName, value.get()); | 218 key.WriteValue(kApRegistryValueName, value.get()); |
220 } | 219 } |
221 } | 220 } |
222 } | 221 } |
223 | 222 |
224 // Gets the setup.exe path from Registry by looking the value of Uninstall | 223 // Gets the setup.exe path from Registry by looking the value of Uninstall |
225 // string. |size| is measured in wchar_t units. | 224 // string. |size| is measured in wchar_t units. |
226 bool GetSetupExePathForGuidFromRegistry(bool system_level, | |
227 const wchar_t* app_guid, | |
228 wchar_t* path, | |
229 size_t size) { | |
230 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
231 RegKey key; | |
232 return OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) && | |
233 (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS); | |
234 } | |
235 | |
236 // Gets the setup.exe path from Registry by looking the value of Uninstall | |
237 // string. |size| is measured in wchar_t units. | |
238 bool GetSetupExePathFromRegistry(const Configuration& configuration, | 225 bool GetSetupExePathFromRegistry(const Configuration& configuration, |
239 wchar_t* path, | 226 wchar_t* path, |
240 size_t size) { | 227 size_t size) { |
241 bool system_level = configuration.is_system_level(); | 228 const HKEY root_key = |
| 229 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 230 RegKey key; |
| 231 bool succeeded = false; |
242 | 232 |
243 // If this is a multi install, first try looking in the binaries for the path. | 233 // If this is a multi install, first try looking in the binaries for the path. |
244 if (configuration.is_multi_install() && GetSetupExePathForGuidFromRegistry( | 234 if (configuration.is_multi_install() && |
245 system_level, google_update::kMultiInstallAppGuid, path, size)) { | 235 OpenClientStateKey(root_key, google_update::kMultiInstallAppGuid, |
246 return true; | 236 KEY_QUERY_VALUE, &key)) { |
| 237 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, |
| 238 size) == ERROR_SUCCESS); |
247 } | 239 } |
248 | 240 |
249 // Failing that, look in Chrome Frame's client state key if --chrome-frame was | 241 // Failing that, look in Chrome Frame's client state key --chrome-frame was |
250 // specified. | 242 // specified. |
251 if (configuration.has_chrome_frame() && GetSetupExePathForGuidFromRegistry( | 243 if (!succeeded && configuration.has_chrome_frame() && |
252 system_level, google_update::kChromeFrameAppGuid, path, size)) { | 244 OpenClientStateKey(root_key, google_update::kChromeFrameAppGuid, |
253 return true; | 245 KEY_QUERY_VALUE, &key)) { |
| 246 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, |
| 247 size) == ERROR_SUCCESS); |
254 } | 248 } |
255 | 249 |
256 // Make a last-ditch effort to look in the Chrome and App Host client state | 250 // Make a last-ditch effort to look in Chrome's client state key. |
257 // keys. | 251 if (!succeeded && |
258 if (GetSetupExePathForGuidFromRegistry( | 252 OpenClientStateKey(root_key, configuration.chrome_app_guid(), |
259 system_level, configuration.chrome_app_guid(), path, size)) { | 253 KEY_QUERY_VALUE, &key)) { |
260 return true; | 254 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, |
261 } | 255 size) == ERROR_SUCCESS); |
262 if (configuration.has_app_host() && GetSetupExePathForGuidFromRegistry( | |
263 system_level, google_update::kChromeAppHostAppGuid, path, size)) { | |
264 return true; | |
265 } | 256 } |
266 | 257 |
267 return false; | 258 return succeeded; |
268 } | 259 } |
269 | 260 |
270 // Calls CreateProcess with good default parameters and waits for the process | 261 // Calls CreateProcess with good default parameters and waits for the process |
271 // to terminate returning the process exit code. | 262 // to terminate returning the process exit code. |
272 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, | 263 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, |
273 int* exit_code) { | 264 int* exit_code) { |
274 STARTUPINFOW si = {sizeof(si)}; | 265 STARTUPINFOW si = {sizeof(si)}; |
275 PROCESS_INFORMATION pi = {0}; | 266 PROCESS_INFORMATION pi = {0}; |
276 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, | 267 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, |
277 NULL, NULL, &si, &pi)) { | 268 NULL, NULL, &si, &pi)) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 case 1: | 835 case 1: |
845 dest8[count - 1] = c; | 836 dest8[count - 1] = c; |
846 } | 837 } |
847 | 838 |
848 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time | 839 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time |
849 *(dest32++) = fill; | 840 *(dest32++) = fill; |
850 | 841 |
851 return dest; | 842 return dest; |
852 } | 843 } |
853 } // extern "C" | 844 } // extern "C" |
OLD | NEW |