| 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 "snapshot/win/pe_image_reader.h" | 15 #include "snapshot/win/pe_image_reader.h" |
| 16 | 16 |
| 17 #define PSAPI_VERSION 1 | 17 #define PSAPI_VERSION 1 |
| 18 #include <psapi.h> | 18 #include <psapi.h> |
| 19 | 19 |
| 20 #include "gtest/gtest.h" | 20 #include "gtest/gtest.h" |
| 21 #include "snapshot/win/process_reader_win.h" | 21 #include "snapshot/win/process_reader_win.h" |
| 22 #include "util/win/get_function.h" |
| 22 | 23 |
| 23 extern "C" IMAGE_DOS_HEADER __ImageBase; | 24 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 24 | 25 |
| 25 namespace crashpad { | 26 namespace crashpad { |
| 26 namespace test { | 27 namespace test { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 BOOL CrashpadGetModuleInformation(HANDLE process, | 30 BOOL CrashpadGetModuleInformation(HANDLE process, |
| 30 HMODULE module, | 31 HMODULE module, |
| 31 MODULEINFO* module_info, | 32 MODULEINFO* module_info, |
| 32 DWORD cb) { | 33 DWORD cb) { |
| 33 static decltype(GetModuleInformation)* get_module_information = | 34 static const auto get_module_information = |
| 34 reinterpret_cast<decltype(GetModuleInformation)*>( | 35 GET_FUNCTION_REQUIRED(L"psapi.dll", ::GetModuleInformation); |
| 35 GetProcAddress(LoadLibrary(L"psapi.dll"), "GetModuleInformation")); | |
| 36 DCHECK(get_module_information); | |
| 37 return get_module_information(process, module, module_info, cb); | 36 return get_module_information(process, module, module_info, cb); |
| 38 } | 37 } |
| 39 | 38 |
| 40 TEST(PEImageReader, DebugDirectory) { | 39 TEST(PEImageReader, DebugDirectory) { |
| 41 PEImageReader pe_image_reader; | 40 PEImageReader pe_image_reader; |
| 42 ProcessReaderWin process_reader; | 41 ProcessReaderWin process_reader; |
| 43 ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), | 42 ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), |
| 44 ProcessSuspensionState::kRunning)); | 43 ProcessSuspensionState::kRunning)); |
| 45 HMODULE self = reinterpret_cast<HMODULE>(&__ImageBase); | 44 HMODULE self = reinterpret_cast<HMODULE>(&__ImageBase); |
| 46 MODULEINFO module_info; | 45 MODULEINFO module_info; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 EXPECT_NE(std::string::npos, pdbname.find("crashpad_snapshot_test")); | 57 EXPECT_NE(std::string::npos, pdbname.find("crashpad_snapshot_test")); |
| 59 const std::string suffix(".pdb"); | 58 const std::string suffix(".pdb"); |
| 60 EXPECT_EQ( | 59 EXPECT_EQ( |
| 61 0, | 60 0, |
| 62 pdbname.compare(pdbname.size() - suffix.size(), suffix.size(), suffix)); | 61 pdbname.compare(pdbname.size() - suffix.size(), suffix.size(), suffix)); |
| 63 } | 62 } |
| 64 | 63 |
| 65 } // namespace | 64 } // namespace |
| 66 } // namespace test | 65 } // namespace test |
| 67 } // namespace crashpad | 66 } // namespace crashpad |
| OLD | NEW |