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

Side by Side Diff: chrome_elf/nt_registry/nt_registry_unittest.cc

Issue 2507263002: Make nt_registry Create/OpenRegKey return a scoped object
Patch Set: fixes Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_elf/nt_registry/nt_registry.h" 5 #include "chrome_elf/nt_registry/nt_registry.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <rpc.h> 8 #include <rpc.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 13 matching lines...) Expand all
24 // https://cs.chromium.org/chromium/src/build/toolchain/win/BUILD.gn?sq%3Dpackag e:chromium&l=314 24 // https://cs.chromium.org/chromium/src/build/toolchain/win/BUILD.gn?sq%3Dpackag e:chromium&l=314
25 //------------------------------------------------------------------------------ 25 //------------------------------------------------------------------------------
26 26
27 // Utility function for the WOW64 redirection test suites. 27 // Utility function for the WOW64 redirection test suites.
28 // Note: Testing redirection through ADVAPI32 here as well, to get notice if 28 // Note: Testing redirection through ADVAPI32 here as well, to get notice if
29 // expected behaviour changes! 29 // expected behaviour changes!
30 // If |redirected_path| == nullptr, no redirection is expected in any case. 30 // If |redirected_path| == nullptr, no redirection is expected in any case.
31 void DoRedirectTest(nt::ROOT_KEY nt_root_key, 31 void DoRedirectTest(nt::ROOT_KEY nt_root_key,
32 const wchar_t* path, 32 const wchar_t* path,
33 const wchar_t* redirected_path OPTIONAL) { 33 const wchar_t* redirected_path OPTIONAL) {
34 HANDLE handle = INVALID_HANDLE_VALUE;
35 HKEY key_handle = nullptr; 34 HKEY key_handle = nullptr;
36 constexpr ACCESS_MASK kAccess = KEY_WRITE | DELETE; 35 constexpr ACCESS_MASK kAccess = KEY_WRITE | DELETE;
37 const HKEY root_key = 36 const HKEY root_key =
38 (nt_root_key == nt::HKCU) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 37 (nt_root_key == nt::HKCU) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
39 38
40 // Make sure clean before starting. 39 // Make sure clean before starting.
41 nt::DeleteRegKey(nt_root_key, nt::NONE, path); 40 nt::DeleteRegKey(nt_root_key, nt::NONE, path);
42 if (redirected_path) 41 if (redirected_path)
43 nt::DeleteRegKey(nt_root_key, nt::NONE, redirected_path); 42 nt::DeleteRegKey(nt_root_key, nt::NONE, redirected_path);
44 43
45 //---------------------------------------------------------------------------- 44 //----------------------------------------------------------------------------
46 // No redirection through ADVAPI32 on straight x86 or x64. 45 // No redirection through ADVAPI32 on straight x86 or x64.
47 ASSERT_EQ(ERROR_SUCCESS, 46 ASSERT_EQ(ERROR_SUCCESS,
48 RegCreateKeyExW(root_key, path, 0, nullptr, REG_OPTION_NON_VOLATILE, 47 RegCreateKeyExW(root_key, path, 0, nullptr, REG_OPTION_NON_VOLATILE,
49 kAccess, nullptr, &key_handle, nullptr)); 48 kAccess, nullptr, &key_handle, nullptr));
50 ASSERT_EQ(ERROR_SUCCESS, RegCloseKey(key_handle)); 49 ASSERT_EQ(ERROR_SUCCESS, RegCloseKey(key_handle));
51 ASSERT_TRUE(nt::OpenRegKey(nt_root_key, path, kAccess, &handle, nullptr)); 50 {
52 ASSERT_TRUE(nt::DeleteRegKey(handle)); 51 nt::ScopedHANDLE handle(
53 nt::CloseRegKey(handle); 52 nt::OpenRegKey(nt_root_key, path, kAccess, nullptr));
53 ASSERT_TRUE(handle.is_valid());
54 ASSERT_TRUE(nt::DeleteRegKey(handle.get()));
55 }
54 56
55 #ifdef _WIN64 57 #ifdef _WIN64
56 //---------------------------------------------------------------------------- 58 //----------------------------------------------------------------------------
57 // Try forcing WOW64 redirection on x64 through ADVAPI32. 59 // Try forcing WOW64 redirection on x64 through ADVAPI32.
58 ASSERT_EQ(ERROR_SUCCESS, 60 ASSERT_EQ(ERROR_SUCCESS,
59 RegCreateKeyExW(root_key, path, 0, nullptr, REG_OPTION_NON_VOLATILE, 61 RegCreateKeyExW(root_key, path, 0, nullptr, REG_OPTION_NON_VOLATILE,
60 kAccess | KEY_WOW64_32KEY, nullptr, &key_handle, 62 kAccess | KEY_WOW64_32KEY, nullptr, &key_handle,
61 nullptr)); 63 nullptr));
62 ASSERT_EQ(ERROR_SUCCESS, RegCloseKey(key_handle)); 64 ASSERT_EQ(ERROR_SUCCESS, RegCloseKey(key_handle));
63 // Check path: 65 // Check path:
64 if (nt::OpenRegKey(nt_root_key, path, kAccess, &handle, nullptr)) { 66 {
65 if (redirected_path) 67 nt::ScopedHANDLE handle(
68 nt::OpenRegKey(nt_root_key, path, kAccess, nullptr));
69 if (handle.is_valid()) {
70 if (redirected_path)
71 ADD_FAILURE();
72 ASSERT_TRUE(nt::DeleteRegKey(handle.get()));
73 } else if (!redirected_path) {
74 // Should have succeeded.
66 ADD_FAILURE(); 75 ADD_FAILURE();
67 ASSERT_TRUE(nt::DeleteRegKey(handle)); 76 }
68 nt::CloseRegKey(handle);
69 } else if (!redirected_path) {
70 // Should have succeeded.
71 ADD_FAILURE();
72 } 77 }
73 if (redirected_path) { 78 if (redirected_path) {
74 // Check redirected path: 79 // Check redirected path:
75 if (nt::OpenRegKey(nt_root_key, redirected_path, kAccess, &handle, 80 nt::ScopedHANDLE handle(
76 nullptr)) { 81 nt::OpenRegKey(nt_root_key, redirected_path, kAccess, nullptr));
82 if (handle.is_valid()) {
77 if (!redirected_path) 83 if (!redirected_path)
78 ADD_FAILURE(); 84 ADD_FAILURE();
79 ASSERT_TRUE(nt::DeleteRegKey(handle)); 85 ASSERT_TRUE(nt::DeleteRegKey(handle.get()));
80 nt::CloseRegKey(handle);
81 } else { 86 } else {
82 // Should have succeeded. 87 // Should have succeeded.
83 ADD_FAILURE(); 88 ADD_FAILURE();
84 } 89 }
85 } 90 }
86 91
87 //---------------------------------------------------------------------------- 92 //----------------------------------------------------------------------------
88 // Try forcing WOW64 redirection on x64 through NTDLL. 93 // Try forcing WOW64 redirection on x64 through NTDLL.
89 ASSERT_TRUE( 94 ASSERT_TRUE(nt::CreateRegKey(nt_root_key, path, kAccess | KEY_WOW64_32KEY)
90 nt::CreateRegKey(nt_root_key, path, kAccess | KEY_WOW64_32KEY, nullptr)); 95 .is_valid());
91 // Check path: 96 // Check path:
92 if (nt::OpenRegKey(nt_root_key, path, kAccess, &handle, nullptr)) { 97 {
93 if (redirected_path) 98 nt::ScopedHANDLE handle(
99 nt::OpenRegKey(nt_root_key, path, kAccess, nullptr));
100 if (handle.is_valid()) {
101 if (redirected_path)
102 ADD_FAILURE();
103 ASSERT_TRUE(nt::DeleteRegKey(handle.get()));
104 } else if (!redirected_path) {
105 // Should have succeeded.
94 ADD_FAILURE(); 106 ADD_FAILURE();
95 ASSERT_TRUE(nt::DeleteRegKey(handle)); 107 }
96 nt::CloseRegKey(handle);
97 } else if (!redirected_path) {
98 // Should have succeeded.
99 ADD_FAILURE();
100 } 108 }
101 if (redirected_path) { 109 if (redirected_path) {
102 // Check redirected path: 110 // Check redirected path:
103 if (nt::OpenRegKey(nt_root_key, redirected_path, kAccess, &handle, 111 nt::ScopedHANDLE handle(
104 nullptr)) { 112 nt::OpenRegKey(nt_root_key, redirected_path, kAccess, nullptr));
113 if (handle.is_valid()) {
105 if (!redirected_path) 114 if (!redirected_path)
106 ADD_FAILURE(); 115 ADD_FAILURE();
107 ASSERT_TRUE(nt::DeleteRegKey(handle)); 116 ASSERT_TRUE(nt::DeleteRegKey(handle.get()));
108 nt::CloseRegKey(handle);
109 } else { 117 } else {
110 // Should have succeeded. 118 // Should have succeeded.
111 ADD_FAILURE(); 119 ADD_FAILURE();
112 } 120 }
113 } 121 }
114 #endif // _WIN64 122 #endif // _WIN64
115 } 123 }
116 124
117 // These test reg paths match |kClassesSubtree| in nt_registry.cc. 125 // These test reg paths match |kClassesSubtree| in nt_registry.cc.
118 constexpr const wchar_t* kClassesRedirects[] = { 126 constexpr const wchar_t* kClassesRedirects[] = {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 316
309 private: 317 private:
310 registry_util::RegistryOverrideManager override_manager_; 318 registry_util::RegistryOverrideManager override_manager_;
311 }; 319 };
312 320
313 //------------------------------------------------------------------------------ 321 //------------------------------------------------------------------------------
314 // NT registry API tests 322 // NT registry API tests
315 //------------------------------------------------------------------------------ 323 //------------------------------------------------------------------------------
316 324
317 TEST_F(NtRegistryTest, API_DWORD) { 325 TEST_F(NtRegistryTest, API_DWORD) {
318 HANDLE key_handle;
319 const wchar_t* dword_val_name = L"DwordTestValue"; 326 const wchar_t* dword_val_name = L"DwordTestValue";
320 DWORD dword_val = 1234; 327 DWORD dword_val = 1234;
321 328
322 // Create a subkey to play under. 329 // Create a subkey to play under.
323 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, L"NTRegistry\\dword", KEY_ALL_ACCESS, 330 nt::ScopedHANDLE key_handle(
324 &key_handle)); 331 nt::CreateRegKey(nt::HKCU, L"NTRegistry\\dword", KEY_ALL_ACCESS));
325 ASSERT_NE(key_handle, INVALID_HANDLE_VALUE); 332 ASSERT_TRUE(key_handle.is_valid());
326 ASSERT_NE(key_handle, nullptr); 333 ASSERT_NE(key_handle.get(), nullptr);
327 334
328 DWORD get_dword = 0; 335 DWORD get_dword = 0;
329 EXPECT_FALSE(nt::QueryRegValueDWORD(key_handle, dword_val_name, &get_dword)); 336 EXPECT_FALSE(
337 nt::QueryRegValueDWORD(key_handle.get(), dword_val_name, &get_dword));
330 338
331 // Set 339 // Set
332 EXPECT_TRUE(nt::SetRegValueDWORD(key_handle, dword_val_name, dword_val)); 340 EXPECT_TRUE(
341 nt::SetRegValueDWORD(key_handle.get(), dword_val_name, dword_val));
333 342
334 // Get 343 // Get
335 EXPECT_TRUE(nt::QueryRegValueDWORD(key_handle, dword_val_name, &get_dword)); 344 EXPECT_TRUE(
345 nt::QueryRegValueDWORD(key_handle.get(), dword_val_name, &get_dword));
336 EXPECT_TRUE(get_dword == dword_val); 346 EXPECT_TRUE(get_dword == dword_val);
337 347
338 // Clean up 348 // Clean up
339 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 349 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
340 nt::CloseRegKey(key_handle);
341 } 350 }
342 351
343 TEST_F(NtRegistryTest, API_SZ) { 352 TEST_F(NtRegistryTest, API_SZ) {
344 HANDLE key_handle;
345 const wchar_t* sz_val_name = L"SzTestValue"; 353 const wchar_t* sz_val_name = L"SzTestValue";
346 std::wstring sz_val = L"blah de blah de blahhhhh."; 354 std::wstring sz_val = L"blah de blah de blahhhhh.";
347 const wchar_t* sz_val_name2 = L"SzTestValueEmpty"; 355 const wchar_t* sz_val_name2 = L"SzTestValueEmpty";
348 std::wstring sz_val2 = L""; 356 std::wstring sz_val2 = L"";
349 357
350 // Create a subkey to play under. 358 // Create a subkey to play under.
351 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, L"NTRegistry\\sz", KEY_ALL_ACCESS, 359 nt::ScopedHANDLE key_handle(
352 &key_handle)); 360 nt::CreateRegKey(nt::HKCU, L"NTRegistry\\sz", KEY_ALL_ACCESS));
353 ASSERT_NE(key_handle, INVALID_HANDLE_VALUE); 361 ASSERT_TRUE(key_handle.is_valid());
354 ASSERT_NE(key_handle, nullptr); 362 ASSERT_NE(key_handle.get(), nullptr);
355 363
356 std::wstring get_sz; 364 std::wstring get_sz;
357 EXPECT_FALSE(nt::QueryRegValueSZ(key_handle, sz_val_name, &get_sz)); 365 EXPECT_FALSE(nt::QueryRegValueSZ(key_handle.get(), sz_val_name, &get_sz));
358 366
359 // Set 367 // Set
360 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name, sz_val)); 368 EXPECT_TRUE(nt::SetRegValueSZ(key_handle.get(), sz_val_name, sz_val));
361 EXPECT_TRUE(nt::SetRegValueSZ(key_handle, sz_val_name2, sz_val2)); 369 EXPECT_TRUE(nt::SetRegValueSZ(key_handle.get(), sz_val_name2, sz_val2));
362 370
363 // Get 371 // Get
364 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name, &get_sz)); 372 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle.get(), sz_val_name, &get_sz));
365 EXPECT_TRUE(get_sz.compare(sz_val) == 0); 373 EXPECT_TRUE(get_sz.compare(sz_val) == 0);
366 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle, sz_val_name2, &get_sz)); 374 EXPECT_TRUE(nt::QueryRegValueSZ(key_handle.get(), sz_val_name2, &get_sz));
367 EXPECT_TRUE(get_sz.compare(sz_val2) == 0); 375 EXPECT_TRUE(get_sz.compare(sz_val2) == 0);
368 376
369 // Clean up 377 // Clean up
370 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 378 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
371 nt::CloseRegKey(key_handle);
372 } 379 }
373 380
374 TEST_F(NtRegistryTest, API_MULTISZ) { 381 TEST_F(NtRegistryTest, API_MULTISZ) {
375 HANDLE key_handle;
376 const wchar_t* multisz_val_name = L"SzmultiTestValue"; 382 const wchar_t* multisz_val_name = L"SzmultiTestValue";
377 std::vector<std::wstring> multisz_val; 383 std::vector<std::wstring> multisz_val;
378 std::wstring multi1 = L"one"; 384 std::wstring multi1 = L"one";
379 std::wstring multi2 = L"two"; 385 std::wstring multi2 = L"two";
380 std::wstring multi3 = L"three"; 386 std::wstring multi3 = L"three";
381 const wchar_t* multisz_val_name2 = L"SzmultiTestValueBad"; 387 const wchar_t* multisz_val_name2 = L"SzmultiTestValueBad";
382 std::wstring multi_empty = L""; 388 std::wstring multi_empty = L"";
383 389
384 // Create a subkey to play under. 390 // Create a subkey to play under.
385 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, L"NTRegistry\\multisz", KEY_ALL_ACCESS, 391 nt::ScopedHANDLE key_handle(
386 &key_handle)); 392 nt::CreateRegKey(nt::HKCU, L"NTRegistry\\multisz", KEY_ALL_ACCESS));
387 ASSERT_NE(key_handle, INVALID_HANDLE_VALUE); 393 ASSERT_TRUE(key_handle.is_valid());
388 ASSERT_NE(key_handle, nullptr); 394 ASSERT_NE(key_handle.get(), nullptr);
389 395
390 multisz_val.push_back(multi1); 396 multisz_val.push_back(multi1);
391 multisz_val.push_back(multi2); 397 multisz_val.push_back(multi2);
392 multisz_val.push_back(multi3); 398 multisz_val.push_back(multi3);
393 // Set 399 // Set
394 EXPECT_TRUE( 400 EXPECT_TRUE(
395 nt::SetRegValueMULTISZ(key_handle, multisz_val_name, multisz_val)); 401 nt::SetRegValueMULTISZ(key_handle.get(), multisz_val_name, multisz_val));
396 multisz_val.clear(); 402 multisz_val.clear();
397 multisz_val.push_back(multi_empty); 403 multisz_val.push_back(multi_empty);
398 // Set 404 // Set
399 EXPECT_TRUE( 405 EXPECT_TRUE(
400 nt::SetRegValueMULTISZ(key_handle, multisz_val_name2, multisz_val)); 406 nt::SetRegValueMULTISZ(key_handle.get(), multisz_val_name2, multisz_val));
401 multisz_val.clear(); 407 multisz_val.clear();
402 408
403 // Get 409 // Get
404 EXPECT_TRUE( 410 EXPECT_TRUE(nt::QueryRegValueMULTISZ(key_handle.get(), multisz_val_name,
405 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name, &multisz_val)); 411 &multisz_val));
406 if (multisz_val.size() == 3) { 412 if (multisz_val.size() == 3) {
407 EXPECT_TRUE(multi1.compare(multisz_val.at(0)) == 0); 413 EXPECT_TRUE(multi1.compare(multisz_val.at(0)) == 0);
408 EXPECT_TRUE(multi2.compare(multisz_val.at(1)) == 0); 414 EXPECT_TRUE(multi2.compare(multisz_val.at(1)) == 0);
409 EXPECT_TRUE(multi3.compare(multisz_val.at(2)) == 0); 415 EXPECT_TRUE(multi3.compare(multisz_val.at(2)) == 0);
410 } else { 416 } else {
411 EXPECT_TRUE(false); 417 EXPECT_TRUE(false);
412 } 418 }
413 multisz_val.clear(); 419 multisz_val.clear();
414 420
415 // Get 421 // Get
416 EXPECT_TRUE( 422 EXPECT_TRUE(nt::QueryRegValueMULTISZ(key_handle.get(), multisz_val_name2,
417 nt::QueryRegValueMULTISZ(key_handle, multisz_val_name2, &multisz_val)); 423 &multisz_val));
418 if (multisz_val.size() == 1) { 424 if (multisz_val.size() == 1) {
419 EXPECT_TRUE(multi_empty.compare(multisz_val.at(0)) == 0); 425 EXPECT_TRUE(multi_empty.compare(multisz_val.at(0)) == 0);
420 } else { 426 } else {
421 EXPECT_TRUE(false); 427 EXPECT_TRUE(false);
422 } 428 }
423 multisz_val.clear(); 429 multisz_val.clear();
424 430
425 // Clean up 431 // Clean up
426 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 432 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
427 nt::CloseRegKey(key_handle);
428 } 433 }
429 434
430 TEST_F(NtRegistryTest, CreateRegKeyRecursion) { 435 TEST_F(NtRegistryTest, CreateRegKeyRecursion) {
431 HANDLE key_handle;
432 const wchar_t* sz_new_key_1 = L"test1\\new\\subkey"; 436 const wchar_t* sz_new_key_1 = L"test1\\new\\subkey";
433 const wchar_t* sz_new_key_2 = L"test2\\new\\subkey\\blah\\"; 437 const wchar_t* sz_new_key_2 = L"test2\\new\\subkey\\blah\\";
434 const wchar_t* sz_new_key_3 = L"\\test3\\new\\subkey\\\\blah2"; 438 const wchar_t* sz_new_key_3 = L"\\test3\\new\\subkey\\\\blah2";
435 439
436 // Tests for CreateRegKey recursion. 440 // Tests for CreateRegKey recursion.
437 ASSERT_TRUE( 441 {
438 nt::CreateRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS, nullptr)); 442 nt::ScopedHANDLE create_handle(
439 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS, 443 nt::CreateRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS));
440 &key_handle, nullptr)); 444 ASSERT_TRUE(create_handle.is_valid());
441 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 445 }
442 nt::CloseRegKey(key_handle); 446 {
447 nt::ScopedHANDLE key_handle(
448 nt::OpenRegKey(nt::HKCU, sz_new_key_1, KEY_ALL_ACCESS, nullptr));
449 EXPECT_TRUE(key_handle.is_valid());
450 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
451 }
443 452
444 ASSERT_TRUE( 453 {
445 nt::CreateRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS, nullptr)); 454 nt::ScopedHANDLE key_handle(
446 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS, 455 nt::CreateRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS));
447 &key_handle, nullptr)); 456 ASSERT_TRUE(key_handle.is_valid());
448 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 457 }
449 nt::CloseRegKey(key_handle); 458 {
459 nt::ScopedHANDLE key_handle(
460 nt::OpenRegKey(nt::HKCU, sz_new_key_2, KEY_ALL_ACCESS, nullptr));
461 EXPECT_TRUE(key_handle.is_valid());
462 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
463 }
450 464
451 ASSERT_TRUE( 465 {
452 nt::CreateRegKey(nt::HKCU, sz_new_key_3, KEY_ALL_ACCESS, nullptr)); 466 nt::ScopedHANDLE key_handle(
453 EXPECT_TRUE(nt::OpenRegKey(nt::HKCU, L"test3\\new\\subkey\\blah2", 467 nt::CreateRegKey(nt::HKCU, sz_new_key_3, KEY_ALL_ACCESS));
454 KEY_ALL_ACCESS, &key_handle, nullptr)); 468 ASSERT_TRUE(key_handle.is_valid());
455 EXPECT_TRUE(nt::DeleteRegKey(key_handle)); 469 }
456 nt::CloseRegKey(key_handle); 470 {
471 nt::ScopedHANDLE key_handle(nt::OpenRegKey(
472 nt::HKCU, L"test3\\new\\subkey\\blah2", KEY_ALL_ACCESS, nullptr));
473 EXPECT_TRUE(key_handle.is_valid());
474 EXPECT_TRUE(nt::DeleteRegKey(key_handle.get()));
475 }
457 476
458 // Subkey path can be null. 477 // Subkey path can be null.
459 ASSERT_TRUE(nt::CreateRegKey(nt::HKCU, nullptr, KEY_ALL_ACCESS, &key_handle)); 478 {
460 ASSERT_NE(key_handle, INVALID_HANDLE_VALUE); 479 nt::ScopedHANDLE key_handle(
461 ASSERT_NE(key_handle, nullptr); 480 nt::CreateRegKey(nt::HKCU, nullptr, KEY_ALL_ACCESS));
462 nt::CloseRegKey(key_handle); 481 ASSERT_TRUE(key_handle.is_valid());
482 ASSERT_NE(key_handle.get(), nullptr);
483 }
463 } 484 }
464 485
465 } // namespace 486 } // namespace
OLDNEW
« chrome/install_static/install_util.cc ('K') | « chrome_elf/nt_registry/nt_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698