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 "client/crashpad_client.h" | 15 #include <windows.h> |
16 #include <winternl.h> | |
17 | |
18 // ntstatus.h conflicts with windows.h so define this locally. | |
19 #ifndef STATUS_NO_SUCH_FILE | |
20 #define STATUS_NO_SUCH_FILE 0xC000000F | |
Mark Mentovai
2015/10/01 20:28:05
<ntstatus.h> uses ((NTSTATUS)0xC000000FL). We shou
scottmg
2015/10/01 21:01:07
Done.
| |
21 #endif | |
16 | 22 |
17 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "client/crashpad_client.h" | |
18 #include "tools/tool_support.h" | 25 #include "tools/tool_support.h" |
19 | 26 |
20 namespace crashpad { | 27 namespace crashpad { |
21 namespace { | 28 namespace { |
22 | 29 |
30 ULONG RtlNtStatusToDosError(NTSTATUS status) { | |
31 static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error = | |
32 reinterpret_cast<decltype(::RtlNtStatusToDosError)*>( | |
33 GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError")); | |
34 DCHECK(rtl_nt_status_to_dos_error); | |
35 return rtl_nt_status_to_dos_error(status); | |
36 } | |
37 | |
23 void SomeCrashyFunction() { | 38 void SomeCrashyFunction() { |
39 // SetLastError and NTSTATUS so that we have something to view in !gle in | |
40 // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the | |
41 // LastStatusError of the TEB as a side-effect, and we'll be setting | |
42 // ERROR_FILE_NOT_FOUND for GetLastError(). | |
43 SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE)); | |
24 volatile int* foo = reinterpret_cast<volatile int*>(7); | 44 volatile int* foo = reinterpret_cast<volatile int*>(7); |
25 *foo = 42; | 45 *foo = 42; |
26 } | 46 } |
27 | 47 |
28 int CrashyMain(int argc, char* argv[]) { | 48 int CrashyMain(int argc, char* argv[]) { |
29 if (argc != 2) { | 49 if (argc != 2) { |
30 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); | 50 fprintf(stderr, "Usage: %s <server_pipe_name>\n", argv[0]); |
31 return 1; | 51 return 1; |
32 } | 52 } |
33 | 53 |
(...skipping 11 matching lines...) Expand all Loading... | |
45 | 65 |
46 return 0; | 66 return 0; |
47 } | 67 } |
48 | 68 |
49 } // namespace | 69 } // namespace |
50 } // namespace crashpad | 70 } // namespace crashpad |
51 | 71 |
52 int wmain(int argc, wchar_t* argv[]) { | 72 int wmain(int argc, wchar_t* argv[]) { |
53 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); | 73 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::CrashyMain); |
54 } | 74 } |
OLD | NEW |