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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Helper function to read a value from registry. Returns true if value | 127 // Helper function to read a value from registry. Returns true if value |
| 128 // is read successfully and stored in parameter value. Returns false otherwise. | 128 // is read successfully and stored in parameter value. Returns false otherwise. |
| 129 // |size| is measured in wchar_t units. | 129 // |size| is measured in wchar_t units. |
| 130 bool ReadValueFromRegistry(HKEY root_key, const wchar_t *sub_key, | 130 bool ReadValueFromRegistry(HKEY root_key, const wchar_t *sub_key, |
| 131 const wchar_t *value_name, wchar_t *value, | 131 const wchar_t *value_name, wchar_t *value, |
| 132 size_t size) { | 132 size_t size) { |
| 133 RegKey key; | 133 RegKey key; |
| 134 | 134 |
| 135 if (key.Open(root_key, sub_key, KEY_QUERY_VALUE) == ERROR_SUCCESS && | 135 if (key.Open(root_key, sub_key, |
| 136 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS && | |
|
grt (UTC plus 2)
2014/05/27 16:42:08
this function is only used for a key in HKCU that
Will Harris
2014/05/27 19:25:10
Done.
| |
| 136 key.ReadValue(value_name, value, size) == ERROR_SUCCESS) { | 137 key.ReadValue(value_name, value, size) == ERROR_SUCCESS) { |
| 137 return true; | 138 return true; |
| 138 } | 139 } |
| 139 return false; | 140 return false; |
| 140 } | 141 } |
| 141 | 142 |
| 142 // Opens the Google Update ClientState key for a product. | 143 // Opens the Google Update ClientState key for a product. |
| 143 bool OpenClientStateKey(HKEY root_key, const wchar_t* app_guid, REGSAM access, | 144 bool OpenClientStateKey(HKEY root_key, const wchar_t* app_guid, REGSAM access, |
|
grt (UTC plus 2)
2014/05/27 16:42:08
since this helper accesses a key that always needs
Will Harris
2014/05/27 19:25:10
Done. Good idea.
| |
| 144 RegKey* key) { | 145 RegKey* key) { |
| 145 PathString client_state_key; | 146 PathString client_state_key; |
| 146 return client_state_key.assign(kApRegistryKeyBase) && | 147 return client_state_key.assign(kApRegistryKeyBase) && |
| 147 client_state_key.append(app_guid) && | 148 client_state_key.append(app_guid) && |
| 148 (key->Open(root_key, client_state_key.get(), access) == ERROR_SUCCESS); | 149 (key->Open(root_key, client_state_key.get(), access) == ERROR_SUCCESS); |
| 149 } | 150 } |
| 150 | 151 |
| 151 // This function sets the flag in registry to indicate that Google Update | 152 // This function sets the flag in registry to indicate that Google Update |
| 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 | KEY_WOW64_32KEY; |
| 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; |
| 162 // This is ignored if multi-install is true. | 163 // This is ignored if multi-install is true. |
| 163 const wchar_t* app_guid = | 164 const wchar_t* app_guid = |
| 164 configuration.has_chrome_frame() ? | 165 configuration.has_chrome_frame() ? |
| 165 google_update::kChromeFrameAppGuid : | 166 google_update::kChromeFrameAppGuid : |
| 166 configuration.chrome_app_guid(); | 167 configuration.chrome_app_guid(); |
| 167 StackString<128> value; | 168 StackString<128> value; |
| 168 LONG ret; | 169 LONG ret; |
| 169 | 170 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 } | 223 } |
| 223 | 224 |
| 224 // 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 |
| 225 // string. |size| is measured in wchar_t units. | 226 // string. |size| is measured in wchar_t units. |
| 226 bool GetSetupExePathForGuidFromRegistry(bool system_level, | 227 bool GetSetupExePathForGuidFromRegistry(bool system_level, |
| 227 const wchar_t* app_guid, | 228 const wchar_t* app_guid, |
| 228 wchar_t* path, | 229 wchar_t* path, |
| 229 size_t size) { | 230 size_t size) { |
| 230 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 231 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 231 RegKey key; | 232 RegKey key; |
| 232 return OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) && | 233 return OpenClientStateKey(root_key, app_guid, |
| 234 KEY_QUERY_VALUE | KEY_WOW64_32KEY, &key) && | |
| 233 (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS); | 235 (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS); |
| 234 } | 236 } |
| 235 | 237 |
| 236 // Gets the setup.exe path from Registry by looking the value of Uninstall | 238 // Gets the setup.exe path from Registry by looking the value of Uninstall |
| 237 // string. |size| is measured in wchar_t units. | 239 // string. |size| is measured in wchar_t units. |
| 238 bool GetSetupExePathFromRegistry(const Configuration& configuration, | 240 bool GetSetupExePathFromRegistry(const Configuration& configuration, |
| 239 wchar_t* path, | 241 wchar_t* path, |
| 240 size_t size) { | 242 size_t size) { |
| 241 bool system_level = configuration.is_system_level(); | 243 bool system_level = configuration.is_system_level(); |
| 242 | 244 |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 #pragma function(memset) | 837 #pragma function(memset) |
| 836 void* memset(void* dest, int c, size_t count) { | 838 void* memset(void* dest, int c, size_t count) { |
| 837 void* start = dest; | 839 void* start = dest; |
| 838 while (count--) { | 840 while (count--) { |
| 839 *reinterpret_cast<char*>(dest) = static_cast<char>(c); | 841 *reinterpret_cast<char*>(dest) = static_cast<char>(c); |
| 840 dest = reinterpret_cast<char*>(dest) + 1; | 842 dest = reinterpret_cast<char*>(dest) + 1; |
| 841 } | 843 } |
| 842 return start; | 844 return start; |
| 843 } | 845 } |
| 844 } // extern "C" | 846 } // extern "C" |
| OLD | NEW |