| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "util/win/process_info.h" | 15 #include "util/win/process_info.h" |
| 16 | 16 |
| 17 #include <dbghelp.h> | 17 #include <dbghelp.h> |
| 18 #include <intrin.h> | 18 #include <intrin.h> |
| 19 #include <wchar.h> | 19 #include <wchar.h> |
| 20 | 20 |
| 21 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "gtest/gtest.h" | 27 #include "gtest/gtest.h" |
| 28 #include "test/errors.h" |
| 28 #include "test/scoped_temp_dir.h" | 29 #include "test/scoped_temp_dir.h" |
| 29 #include "test/paths.h" | 30 #include "test/paths.h" |
| 30 #include "test/win/child_launcher.h" | 31 #include "test/win/child_launcher.h" |
| 31 #include "util/file/file_io.h" | 32 #include "util/file/file_io.h" |
| 32 #include "util/misc/uuid.h" | 33 #include "util/misc/uuid.h" |
| 33 #include "util/win/scoped_handle.h" | 34 #include "util/win/scoped_handle.h" |
| 34 | 35 |
| 35 namespace crashpad { | 36 namespace crashpad { |
| 36 namespace test { | 37 namespace test { |
| 37 namespace { | 38 namespace { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 ASSERT_TRUE(inherited_file.is_valid()); | 547 ASSERT_TRUE(inherited_file.is_valid()); |
| 547 | 548 |
| 548 HKEY key; | 549 HKEY key; |
| 549 ASSERT_EQ(ERROR_SUCCESS, | 550 ASSERT_EQ(ERROR_SUCCESS, |
| 550 RegOpenKeyEx( | 551 RegOpenKeyEx( |
| 551 HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft", 0, KEY_READ, &key)); | 552 HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft", 0, KEY_READ, &key)); |
| 552 ScopedRegistryKey scoped_key(key); | 553 ScopedRegistryKey scoped_key(key); |
| 553 ASSERT_TRUE(scoped_key.is_valid()); | 554 ASSERT_TRUE(scoped_key.is_valid()); |
| 554 | 555 |
| 555 std::wstring mapping_name = | 556 std::wstring mapping_name = |
| 556 base::UTF8ToUTF16(base::StringPrintf("Global\\test_mapping_%d_%I64x", | 557 base::UTF8ToUTF16(base::StringPrintf("Local\\test_mapping_%d_%I64x", |
| 557 GetCurrentProcessId(), | 558 GetCurrentProcessId(), |
| 558 base::RandUint64())); | 559 base::RandUint64())); |
| 559 ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE, | 560 ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE, |
| 560 nullptr, | 561 nullptr, |
| 561 PAGE_READWRITE, | 562 PAGE_READWRITE, |
| 562 0, | 563 0, |
| 563 1024, | 564 1024, |
| 564 mapping_name.c_str())); | 565 mapping_name.c_str())); |
| 565 ASSERT_TRUE(mapping.is_valid()); | 566 ASSERT_TRUE(mapping.is_valid()) << ErrorMessage("CreateFileMapping"); |
| 566 | 567 |
| 567 ProcessInfo info; | 568 ProcessInfo info; |
| 568 info.Initialize(GetCurrentProcess()); | 569 info.Initialize(GetCurrentProcess()); |
| 569 bool found_file_handle = false; | 570 bool found_file_handle = false; |
| 570 bool found_inherited_file_handle = false; | 571 bool found_inherited_file_handle = false; |
| 571 bool found_key_handle = false; | 572 bool found_key_handle = false; |
| 572 bool found_mapping_handle = false; | 573 bool found_mapping_handle = false; |
| 573 for (auto handle : info.Handles()) { | 574 for (auto handle : info.Handles()) { |
| 574 if (reinterpret_cast<uint32_t>(file.get()) == handle.handle) { | 575 if (reinterpret_cast<uint32_t>(file.get()) == handle.handle) { |
| 575 EXPECT_FALSE(found_file_handle); | 576 EXPECT_FALSE(found_file_handle); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 } | 619 } |
| 619 } | 620 } |
| 620 EXPECT_TRUE(found_file_handle); | 621 EXPECT_TRUE(found_file_handle); |
| 621 EXPECT_TRUE(found_key_handle); | 622 EXPECT_TRUE(found_key_handle); |
| 622 EXPECT_TRUE(found_mapping_handle); | 623 EXPECT_TRUE(found_mapping_handle); |
| 623 } | 624 } |
| 624 | 625 |
| 625 } // namespace | 626 } // namespace |
| 626 } // namespace test | 627 } // namespace test |
| 627 } // namespace crashpad | 628 } // namespace crashpad |
| OLD | NEW |