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 <winternl.h> | 17 #include <winternl.h> |
18 | 18 |
19 #include <algorithm> | 19 #include <algorithm> |
20 #include <limits> | 20 #include <limits> |
21 | 21 |
22 #include "base/logging.h" | 22 #include "base/logging.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/template_util.h" | 25 #include "base/template_util.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #include "util/numeric/safe_assignment.h" | 27 #include "util/numeric/safe_assignment.h" |
| 28 #include "util/win/get_function.h" |
28 #include "util/win/nt_internals.h" | 29 #include "util/win/nt_internals.h" |
29 #include "util/win/ntstatus_logging.h" | 30 #include "util/win/ntstatus_logging.h" |
30 #include "util/win/process_structs.h" | 31 #include "util/win/process_structs.h" |
31 #include "util/win/scoped_handle.h" | 32 #include "util/win/scoped_handle.h" |
32 | 33 |
33 namespace crashpad { | 34 namespace crashpad { |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
37 NTSTATUS NtQueryInformationProcess(HANDLE process_handle, | 38 NTSTATUS NtQueryInformationProcess(HANDLE process_handle, |
38 PROCESSINFOCLASS process_information_class, | 39 PROCESSINFOCLASS process_information_class, |
39 PVOID process_information, | 40 PVOID process_information, |
40 ULONG process_information_length, | 41 ULONG process_information_length, |
41 PULONG return_length) { | 42 PULONG return_length) { |
42 static decltype(::NtQueryInformationProcess)* nt_query_information_process = | 43 static const auto nt_query_information_process = |
43 reinterpret_cast<decltype(::NtQueryInformationProcess)*>(GetProcAddress( | 44 GET_FUNCTION_REQUIRED(L"ntdll.dll", ::NtQueryInformationProcess); |
44 LoadLibrary(L"ntdll.dll"), "NtQueryInformationProcess")); | |
45 DCHECK(nt_query_information_process); | |
46 return nt_query_information_process(process_handle, | 45 return nt_query_information_process(process_handle, |
47 process_information_class, | 46 process_information_class, |
48 process_information, | 47 process_information, |
49 process_information_length, | 48 process_information_length, |
50 return_length); | 49 return_length); |
51 } | 50 } |
52 | 51 |
53 bool IsProcessWow64(HANDLE process_handle) { | 52 bool IsProcessWow64(HANDLE process_handle) { |
54 static decltype(IsWow64Process)* is_wow64_process = | 53 static const auto is_wow64_process = |
55 reinterpret_cast<decltype(IsWow64Process)*>( | 54 GET_FUNCTION(L"kernel32.dll", ::IsWow64Process); |
56 GetProcAddress(LoadLibrary(L"kernel32.dll"), "IsWow64Process")); | |
57 if (!is_wow64_process) | 55 if (!is_wow64_process) |
58 return false; | 56 return false; |
59 BOOL is_wow64; | 57 BOOL is_wow64; |
60 if (!is_wow64_process(process_handle, &is_wow64)) { | 58 if (!is_wow64_process(process_handle, &is_wow64)) { |
61 PLOG(ERROR) << "IsWow64Process"; | 59 PLOG(ERROR) << "IsWow64Process"; |
62 return false; | 60 return false; |
63 } | 61 } |
64 return is_wow64; | 62 return is_wow64; |
65 } | 63 } |
66 | 64 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 } else { | 663 } else { |
666 result.push_back(as_ranges[i]); | 664 result.push_back(as_ranges[i]); |
667 } | 665 } |
668 DCHECK(result.back().IsValid()); | 666 DCHECK(result.back().IsValid()); |
669 } | 667 } |
670 | 668 |
671 return result; | 669 return result; |
672 } | 670 } |
673 | 671 |
674 } // namespace crashpad | 672 } // namespace crashpad |
OLD | NEW |