Chromium Code Reviews| Index: handler/win/crashy_test_program.cc |
| diff --git a/handler/win/crashy_test_program.cc b/handler/win/crashy_test_program.cc |
| index 07c9cf101278213f36b55e3025b8b1c88ece15a4..f98fd8dd86428e62e4f49410e8bf7721deada678 100644 |
| --- a/handler/win/crashy_test_program.cc |
| +++ b/handler/win/crashy_test_program.cc |
| @@ -12,15 +12,35 @@ |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| -#include "client/crashpad_client.h" |
| +#include <windows.h> |
| +#include <winternl.h> |
| + |
| +// ntstatus.h conflicts with windows.h so define this locally. |
| +#ifndef STATUS_NO_SUCH_FILE |
| +#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.
|
| +#endif |
| #include "base/logging.h" |
| +#include "client/crashpad_client.h" |
| #include "tools/tool_support.h" |
| namespace crashpad { |
| namespace { |
| +ULONG RtlNtStatusToDosError(NTSTATUS status) { |
| + static decltype(::RtlNtStatusToDosError)* rtl_nt_status_to_dos_error = |
| + reinterpret_cast<decltype(::RtlNtStatusToDosError)*>( |
| + GetProcAddress(LoadLibrary(L"ntdll.dll"), "RtlNtStatusToDosError")); |
| + DCHECK(rtl_nt_status_to_dos_error); |
| + return rtl_nt_status_to_dos_error(status); |
| +} |
| + |
| void SomeCrashyFunction() { |
| + // SetLastError and NTSTATUS so that we have something to view in !gle in |
| + // windbg. RtlNtStatusToDosError() stores STATUS_NO_SUCH_FILE into the |
| + // LastStatusError of the TEB as a side-effect, and we'll be setting |
| + // ERROR_FILE_NOT_FOUND for GetLastError(). |
| + SetLastError(RtlNtStatusToDosError(STATUS_NO_SUCH_FILE)); |
| volatile int* foo = reinterpret_cast<volatile int*>(7); |
| *foo = 42; |
| } |