Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/installer/util/registry_key_backup.cc

Issue 282363003: Add WOW64 support to the installer registry work items (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: add wow64 logic to installer_util. mini_installer tests. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/installer/util/registry_key_backup.h" 5 #include "chrome/installer/util/registry_key_backup.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 return true; 265 return true;
266 } 266 }
267 267
268 RegistryKeyBackup::RegistryKeyBackup() { 268 RegistryKeyBackup::RegistryKeyBackup() {
269 } 269 }
270 270
271 RegistryKeyBackup::~RegistryKeyBackup() { 271 RegistryKeyBackup::~RegistryKeyBackup() {
272 } 272 }
273 273
274 bool RegistryKeyBackup::Initialize(HKEY root, const wchar_t* key_path) { 274 bool RegistryKeyBackup::Initialize(HKEY root,
275 const wchar_t* key_path,
276 REGSAM wow64_access) {
275 DCHECK(key_path); 277 DCHECK(key_path);
278 DCHECK(wow64_access == 0 ||
279 wow64_access == KEY_WOW64_32KEY ||
280 wow64_access == KEY_WOW64_64KEY);
276 281
277 RegKey key; 282 RegKey key;
278 scoped_ptr<KeyData> key_data; 283 scoped_ptr<KeyData> key_data;
279 284
280 // Does the key exist? 285 // Does the key exist?
281 LONG result = key.Open(root, key_path, kKeyReadNoNotify); 286 LONG result = key.Open(root, key_path, kKeyReadNoNotify | wow64_access);
282 if (result == ERROR_SUCCESS) { 287 if (result == ERROR_SUCCESS) {
283 key_data.reset(new KeyData()); 288 key_data.reset(new KeyData());
284 if (!key_data->Initialize(key)) { 289 if (!key_data->Initialize(key)) {
285 LOG(ERROR) << "Failed to backup key at " << key_path; 290 LOG(ERROR) << "Failed to backup key at " << key_path;
286 return false; 291 return false;
287 } 292 }
288 } else if (result != ERROR_FILE_NOT_FOUND) { 293 } else if (result != ERROR_FILE_NOT_FOUND) {
289 LOG(ERROR) << "Failed to open key at " << key_path 294 LOG(ERROR) << "Failed to open key at " << key_path
290 << " to create backup, result: " << result; 295 << " to create backup, result: " << result;
291 return false; 296 return false;
292 } 297 }
293 298
294 key_data_.swap(key_data); 299 key_data_.swap(key_data);
295 return true; 300 return true;
296 } 301 }
297 302
298 bool RegistryKeyBackup::WriteTo(HKEY root, const wchar_t* key_path) const { 303 bool RegistryKeyBackup::WriteTo(HKEY root,
304 const wchar_t* key_path,
305 REGSAM wow64_access) const {
299 DCHECK(key_path); 306 DCHECK(key_path);
307 DCHECK(wow64_access == 0 ||
308 wow64_access == KEY_WOW64_32KEY ||
309 wow64_access == KEY_WOW64_64KEY);
300 310
301 bool success = false; 311 bool success = false;
302 312
303 if (key_data_.get() != NULL) { 313 if (key_data_.get() != NULL) {
304 RegKey dest_key; 314 RegKey dest_key;
305 LONG result = dest_key.Create(root, key_path, KEY_WRITE); 315 LONG result = dest_key.Create(root, key_path, KEY_WRITE | wow64_access);
306 if (result != ERROR_SUCCESS) { 316 if (result != ERROR_SUCCESS) {
307 LOG(ERROR) << "Failed to create destination key at " << key_path 317 LOG(ERROR) << "Failed to create destination key at " << key_path
308 << " to write backup, result: " << result; 318 << " to write backup, result: " << result;
309 } else { 319 } else {
310 success = key_data_->WriteTo(&dest_key); 320 success = key_data_->WriteTo(&dest_key);
311 LOG_IF(ERROR, !success) << "Failed to write key data."; 321 LOG_IF(ERROR, !success) << "Failed to write key data.";
312 } 322 }
313 } else { 323 } else {
314 success = true; 324 success = true;
315 } 325 }
316 326
317 return success; 327 return success;
318 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698