OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "snapshot/win/pe_image_reader.h" |
| 16 |
| 17 #include <psapi.h> |
| 18 |
| 19 #include "gtest/gtest.h" |
| 20 #include "snapshot/win/process_reader_win.h" |
| 21 |
| 22 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 23 |
| 24 namespace crashpad { |
| 25 namespace test { |
| 26 namespace { |
| 27 |
| 28 TEST(PEImageReader, DebugDirectory) { |
| 29 PEImageReader pe_image_reader; |
| 30 ProcessReaderWin process_reader; |
| 31 ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess())); |
| 32 HMODULE self = reinterpret_cast<HMODULE>(&__ImageBase); |
| 33 MODULEINFO module_info; |
| 34 ASSERT_TRUE(GetModuleInformation( |
| 35 GetCurrentProcess(), self, &module_info, sizeof(module_info))); |
| 36 EXPECT_EQ(self, module_info.lpBaseOfDll); |
| 37 EXPECT_TRUE(pe_image_reader.Initialize(&process_reader, |
| 38 reinterpret_cast<WinVMAddress>(self), |
| 39 module_info.SizeOfImage, |
| 40 "self")); |
| 41 UUID uuid; |
| 42 DWORD age; |
| 43 std::string pdbname; |
| 44 EXPECT_TRUE(pe_image_reader.DebugDirectoryInformation(&uuid, &age, &pdbname)); |
| 45 EXPECT_NE(-1, pdbname.find("crashpad_snapshot_test")); |
| 46 const std::string suffix(".pdb"); |
| 47 EXPECT_EQ( |
| 48 0, |
| 49 pdbname.compare(pdbname.size() - suffix.size(), suffix.size(), suffix)); |
| 50 } |
| 51 |
| 52 } // namespace |
| 53 } // namespace test |
| 54 } // namespace crashpad |
OLD | NEW |