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 "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
23 #include "snapshot/win/process_reader_win.h" | 23 #include "snapshot/win/process_reader_win.h" |
24 #include "test/errors.h" | 24 #include "test/errors.h" |
25 #include "util/win/get_function.h" | 25 #include "util/win/get_module_information.h" |
26 #include "util/win/module_version.h" | 26 #include "util/win/module_version.h" |
27 #include "util/win/process_info.h" | 27 #include "util/win/process_info.h" |
28 | 28 |
29 extern "C" IMAGE_DOS_HEADER __ImageBase; | 29 extern "C" IMAGE_DOS_HEADER __ImageBase; |
30 | 30 |
31 namespace crashpad { | 31 namespace crashpad { |
32 namespace test { | 32 namespace test { |
33 namespace { | 33 namespace { |
34 | 34 |
35 BOOL CrashpadGetModuleInformation(HANDLE process, | |
36 HMODULE module, | |
37 MODULEINFO* module_info, | |
38 DWORD cb) { | |
39 static const auto get_module_information = | |
40 GET_FUNCTION_REQUIRED(L"psapi.dll", ::GetModuleInformation); | |
41 return get_module_information(process, module, module_info, cb); | |
42 } | |
43 | |
44 TEST(PEImageReader, DebugDirectory) { | 35 TEST(PEImageReader, DebugDirectory) { |
45 PEImageReader pe_image_reader; | 36 PEImageReader pe_image_reader; |
46 ProcessReaderWin process_reader; | 37 ProcessReaderWin process_reader; |
47 ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), | 38 ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), |
48 ProcessSuspensionState::kRunning)); | 39 ProcessSuspensionState::kRunning)); |
49 HMODULE self = reinterpret_cast<HMODULE>(&__ImageBase); | 40 HMODULE self = reinterpret_cast<HMODULE>(&__ImageBase); |
50 MODULEINFO module_info; | 41 MODULEINFO module_info; |
51 ASSERT_TRUE(CrashpadGetModuleInformation( | 42 ASSERT_TRUE(CrashpadGetModuleInformation( |
52 GetCurrentProcess(), self, &module_info, sizeof(module_info))) | 43 GetCurrentProcess(), self, &module_info, sizeof(module_info))) |
53 << ErrorMessage("GetModuleInformation"); | 44 << ErrorMessage("GetModuleInformation"); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 155 |
165 for (const auto& module : modules) { | 156 for (const auto& module : modules) { |
166 SCOPED_TRACE(base::UTF16ToUTF8(module.name)); | 157 SCOPED_TRACE(base::UTF16ToUTF8(module.name)); |
167 TestVSFixedFileInfo(&process_reader, module, false); | 158 TestVSFixedFileInfo(&process_reader, module, false); |
168 } | 159 } |
169 } | 160 } |
170 | 161 |
171 } // namespace | 162 } // namespace |
172 } // namespace test | 163 } // namespace test |
173 } // namespace crashpad | 164 } // namespace crashpad |
OLD | NEW |