OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
grt (UTC plus 2)
2012/07/12 18:37:10
2012
erikwright (departed)
2012/07/16 20:13:11
Done.
| |
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 |
12 // defines the following compiler/linker flags: | 12 // defines the following compiler/linker flags: |
13 // EnableIntrinsicFunctions="true" compiler: /Oi | 13 // EnableIntrinsicFunctions="true" compiler: /Oi |
14 // BasicRuntimeChecks="0" | 14 // BasicRuntimeChecks="0" |
15 // BufferSecurityCheck="false" compiler: /GS- | 15 // BufferSecurityCheck="false" compiler: /GS- |
16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY | 16 // EntryPointSymbol="MainEntryPoint" linker: /ENTRY |
17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB | 17 // IgnoreAllDefaultLibraries="true" linker: /NODEFAULTLIB |
18 // OptimizeForWindows98="1" liker: /OPT:NOWIN98 | 18 // OptimizeForWindows98="1" liker: /OPT:NOWIN98 |
19 // linker: /SAFESEH:NO | 19 // linker: /SAFESEH:NO |
20 | 20 |
21 // have the linker merge the sections, saving us ~500 bytes. | 21 // have the linker merge the sections, saving us ~500 bytes. |
22 #pragma comment(linker, "/MERGE:.rdata=.text") | 22 #pragma comment(linker, "/MERGE:.rdata=.text") |
23 | 23 |
24 #include <windows.h> | 24 #include <windows.h> |
25 #include <shellapi.h> | 25 #include <shellapi.h> |
26 #include <wchar.h> | |
tommi (sloooow) - chröme
2012/07/12 08:11:31
out of curiosity, why is this needed?
erikwright (departed)
2012/07/16 20:13:11
Extreme IWYU. Obviously too extreme.
Done.
grt (UTC plus 2)
2012/07/23 11:31:12
If you added it because the type wchar_t is used i
| |
26 | 27 |
27 #include "chrome/installer/mini_installer/appid.h" | 28 #include "chrome/installer/mini_installer/appid.h" |
28 #include "chrome/installer/mini_installer/configuration.h" | 29 #include "chrome/installer/mini_installer/configuration.h" |
29 #include "chrome/installer/mini_installer/decompress.h" | 30 #include "chrome/installer/mini_installer/decompress.h" |
30 #include "chrome/installer/mini_installer/mini_installer.h" | 31 #include "chrome/installer/mini_installer/mini_installer.h" |
31 #include "chrome/installer/mini_installer/mini_string.h" | 32 #include "chrome/installer/mini_installer/mini_string.h" |
32 #include "chrome/installer/mini_installer/pe_resource.h" | 33 #include "chrome/installer/mini_installer/pe_resource.h" |
33 | 34 |
34 namespace mini_installer { | 35 namespace mini_installer { |
35 | 36 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 // should try full installer next time. If the current installer works, this | 153 // 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 | 154 // 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, | 155 // be written to HKCU, but if --system-level is included in the command line, |
155 // it will be written to HKLM instead. | 156 // it will be written to HKLM instead. |
156 // TODO(grt): Write a unit test for this that uses registry virtualization. | 157 // TODO(grt): Write a unit test for this that uses registry virtualization. |
157 void SetInstallerFlags(const Configuration& configuration) { | 158 void SetInstallerFlags(const Configuration& configuration) { |
158 RegKey key; | 159 RegKey key; |
159 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; | 160 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; |
160 const HKEY root_key = | 161 const HKEY root_key = |
161 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 162 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
163 // This is ignored if multi-install is true. | |
162 const wchar_t* app_guid = | 164 const wchar_t* app_guid = |
163 configuration.has_chrome_frame() ? | 165 configuration.has_chrome_frame() ? |
164 google_update::kChromeFrameAppGuid : | 166 google_update::kChromeFrameAppGuid : |
165 configuration.chrome_app_guid(); | 167 configuration.chrome_app_guid(); |
166 StackString<128> value; | 168 StackString<128> value; |
167 LONG ret; | 169 LONG ret; |
168 | 170 |
169 // When multi_install is true, we are potentially: | 171 // When multi_install is true, we are potentially: |
170 // 1. Performing a multi-install of some product(s) on a clean machine. | 172 // 1. Performing a multi-install of some product(s) on a clean machine. |
171 // Neither the product(s) nor the multi-installer will have a ClientState | 173 // Neither the product(s) nor the multi-installer will have a ClientState |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 } | 223 } |
222 | 224 |
223 // Gets the setup.exe path from Registry by looking the value of Uninstall | 225 // Gets the setup.exe path from Registry by looking the value of Uninstall |
224 // string. |size| is measured in wchar_t units. | 226 // string. |size| is measured in wchar_t units. |
225 bool GetSetupExePathFromRegistry(const Configuration& configuration, | 227 bool GetSetupExePathFromRegistry(const Configuration& configuration, |
226 wchar_t* path, | 228 wchar_t* path, |
227 size_t size) { | 229 size_t size) { |
228 const HKEY root_key = | 230 const HKEY root_key = |
229 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 231 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
230 RegKey key; | 232 RegKey key; |
231 bool succeeded = false; | |
232 | 233 |
233 // If this is a multi install, first try looking in the binaries for the path. | 234 const int kMaxGuids = 10; |
grt (UTC plus 2)
2012/07/12 18:37:10
why not 4?
erikwright (departed)
2012/07/16 20:13:11
Done.
| |
234 if (configuration.is_multi_install() && | 235 const wchar_t* app_guids[kMaxGuids] = {0}; |
grt (UTC plus 2)
2012/07/12 18:37:10
{0} -> {}
erikwright (departed)
2012/07/16 20:13:11
Done.
| |
235 OpenClientStateKey(root_key, google_update::kMultiInstallAppGuid, | 236 size_t guid_count = 0; |
236 KEY_QUERY_VALUE, &key)) { | 237 |
237 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, | 238 // If this is a multi install, first try looking in the binaries for the path |
grt (UTC plus 2)
2012/07/12 18:37:10
"path" -> "path."
erikwright (departed)
2012/07/16 20:13:11
Done.
| |
238 size) == ERROR_SUCCESS); | 239 if (configuration.is_multi_install()) |
240 app_guids[guid_count++] = google_update::kMultiInstallAppGuid; | |
241 // Failing that, look in Chrome Frame's client state key --chrome-frame was | |
grt (UTC plus 2)
2012/07/12 18:37:10
"state key" -> "state key if"
erikwright (departed)
2012/07/16 20:13:11
Done.
| |
242 // specified. | |
243 if (guid_count < kMaxGuids && configuration.has_chrome_frame()) | |
244 app_guids[guid_count++] = google_update::kChromeFrameAppGuid; | |
245 // Make a last-ditch effort to look in the Chrome and App Host client state | |
246 // keys. | |
247 if (guid_count < kMaxGuids) | |
248 app_guids[guid_count++] = configuration.chrome_app_guid(); | |
249 if (guid_count < kMaxGuids && configuration.has_app_host()) | |
250 app_guids[guid_count++] = google_update::kChromeAppHostAppGuid; | |
251 | |
252 for (size_t i = 0; i < guid_count; ++i) { | |
253 if (!OpenClientStateKey(root_key, app_guids[i], KEY_QUERY_VALUE, &key)) | |
254 continue; | |
255 | |
256 if (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS) | |
257 return true; | |
239 } | 258 } |
240 | 259 |
241 // Failing that, look in Chrome Frame's client state key --chrome-frame was | 260 return false; |
242 // specified. | |
243 if (!succeeded && configuration.has_chrome_frame() && | |
244 OpenClientStateKey(root_key, google_update::kChromeFrameAppGuid, | |
245 KEY_QUERY_VALUE, &key)) { | |
246 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, | |
247 size) == ERROR_SUCCESS); | |
248 } | |
249 | |
250 // Make a last-ditch effort to look in Chrome's client state key. | |
251 if (!succeeded && | |
252 OpenClientStateKey(root_key, configuration.chrome_app_guid(), | |
253 KEY_QUERY_VALUE, &key)) { | |
254 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, | |
255 size) == ERROR_SUCCESS); | |
256 } | |
257 | |
258 return succeeded; | |
259 } | 261 } |
260 | 262 |
261 // Calls CreateProcess with good default parameters and waits for the process | 263 // Calls CreateProcess with good default parameters and waits for the process |
262 // to terminate returning the process exit code. | 264 // to terminate returning the process exit code. |
263 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, | 265 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, |
264 int* exit_code) { | 266 int* exit_code) { |
265 STARTUPINFOW si = {sizeof(si)}; | 267 STARTUPINFOW si = {sizeof(si)}; |
266 PROCESS_INFORMATION pi = {0}; | 268 PROCESS_INFORMATION pi = {0}; |
267 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, | 269 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, |
268 NULL, NULL, &si, &pi)) { | 270 NULL, NULL, &si, &pi)) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 case 1: | 837 case 1: |
836 dest8[count - 1] = c; | 838 dest8[count - 1] = c; |
837 } | 839 } |
838 | 840 |
839 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time | 841 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time |
840 *(dest32++) = fill; | 842 *(dest32++) = fill; |
841 | 843 |
842 return dest; | 844 return dest; |
843 } | 845 } |
844 } // extern "C" | 846 } // extern "C" |
OLD | NEW |