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 <windows.h> | 15 #include <windows.h> |
16 #include <winternl.h> | 16 #include <winternl.h> |
17 | 17 |
18 // ntstatus.h conflicts with windows.h so define this locally. | 18 // ntstatus.h conflicts with windows.h so define this locally. |
19 #ifndef STATUS_NO_SUCH_FILE | 19 #ifndef STATUS_NO_SUCH_FILE |
20 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F) | 20 #define STATUS_NO_SUCH_FILE static_cast<NTSTATUS>(0xC000000F) |
21 #endif | 21 #endif |
22 | 22 |
23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
24 #include "base/logging.h" | 24 #include "base/logging.h" |
25 #include "client/crashpad_client.h" | 25 #include "client/crashpad_client.h" |
26 #include "tools/tool_support.h" | 26 #include "tools/tool_support.h" |
27 #include "util/win/critical_section_with_debug_info.h" | 27 #include "util/win/critical_section_with_debug_info.h" |
| 28 #include "util/win/get_function.h" |
28 | 29 |
29 namespace crashpad { | 30 namespace crashpad { |
30 namespace { | 31 namespace { |
31 | 32 |
32 CRITICAL_SECTION g_test_critical_section; | 33 CRITICAL_SECTION g_test_critical_section; |
33 | 34 |
34 ULONG RtlNtStatusToDosError(NTSTATUS status) { | 35 ULONG RtlNtStatusToDosError(NTSTATUS status) { |
35 static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error = | 36 static const auto rtl_nt_status_to_dos_error = |
36 reinterpret_cast<decltype(::RtlNtStatusToDosError)*>( | 37 GET_FUNCTION_REQUIRED(L"ntdll.dll", ::RtlNtStatusToDosError); |
37 GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError")); | |
38 DCHECK(rtl_nt_status_to_dos_error); | |
39 return rtl_nt_status_to_dos_error(status); | 38 return rtl_nt_status_to_dos_error(status); |
40 } | 39 } |
41 | 40 |
42 void AllocateMemoryOfVariousProtections() { | 41 void AllocateMemoryOfVariousProtections() { |
43 SYSTEM_INFO system_info; | 42 SYSTEM_INFO system_info; |
44 GetSystemInfo(&system_info); | 43 GetSystemInfo(&system_info); |
45 | 44 |
46 const size_t kPageSize = system_info.dwPageSize; | 45 const size_t kPageSize = system_info.dwPageSize; |
47 | 46 |
48 const uint32_t kPageTypes[] = { | 47 const uint32_t kPageTypes[] = { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 114 |
116 return 0; | 115 return 0; |
117 } | 116 } |
118 | 117 |
119 } // namespace | 118 } // namespace |
120 } // namespace crashpad | 119 } // namespace crashpad |
121 | 120 |
122 int wmain(int argc, wchar_t* argv[]) { | 121 int wmain(int argc, wchar_t* argv[]) { |
123 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); | 122 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); |
124 } | 123 } |
OLD | NEW |