| 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, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
| 28 #include "minidump/minidump_file_writer.h" | 28 #include "minidump/minidump_file_writer.h" |
| 29 #include "snapshot/crashpad_info_client_options.h" | 29 #include "snapshot/crashpad_info_client_options.h" |
| 30 #include "snapshot/win/process_snapshot_win.h" | 30 #include "snapshot/win/process_snapshot_win.h" |
| 31 #include "util/file/file_writer.h" | 31 #include "util/file/file_writer.h" |
| 32 #include "util/misc/tri_state.h" | 32 #include "util/misc/tri_state.h" |
| 33 #include "util/misc/uuid.h" | 33 #include "util/misc/uuid.h" |
| 34 #include "util/win/get_function.h" | 34 #include "util/win/get_function.h" |
| 35 #include "util/win/handle.h" | 35 #include "util/win/handle.h" |
| 36 #include "util/win/registration_protocol_win.h" | 36 #include "util/win/registration_protocol_win.h" |
| 37 #include "util/win/safe_terminate_process.h" |
| 37 #include "util/win/xp_compat.h" | 38 #include "util/win/xp_compat.h" |
| 38 | 39 |
| 39 namespace crashpad { | 40 namespace crashpad { |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 decltype(GetNamedPipeClientProcessId)* GetNamedPipeClientProcessIdFunction() { | 44 decltype(GetNamedPipeClientProcessId)* GetNamedPipeClientProcessIdFunction() { |
| 44 static const auto get_named_pipe_client_process_id = | 45 static const auto get_named_pipe_client_process_id = |
| 45 GET_FUNCTION(L"kernel32.dll", ::GetNamedPipeClientProcessId); | 46 GET_FUNCTION(L"kernel32.dll", ::GetNamedPipeClientProcessId); |
| 46 return get_named_pipe_client_process_id; | 47 return get_named_pipe_client_process_id; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // This function is executed on the thread pool. | 540 // This function is executed on the thread pool. |
| 540 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 541 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 541 base::AutoLock lock(*client->lock()); | 542 base::AutoLock lock(*client->lock()); |
| 542 | 543 |
| 543 // Capture the exception. | 544 // Capture the exception. |
| 544 unsigned int exit_code = client->delegate()->ExceptionHandlerServerException( | 545 unsigned int exit_code = client->delegate()->ExceptionHandlerServerException( |
| 545 client->process(), | 546 client->process(), |
| 546 client->crash_exception_information_address(), | 547 client->crash_exception_information_address(), |
| 547 client->debug_critical_section_address()); | 548 client->debug_critical_section_address()); |
| 548 | 549 |
| 549 TerminateProcess(client->process(), exit_code); | 550 SafeTerminateProcess(client->process(), exit_code); |
| 550 } | 551 } |
| 551 | 552 |
| 552 // static | 553 // static |
| 553 void __stdcall ExceptionHandlerServer::OnNonCrashDumpEvent(void* ctx, BOOLEAN) { | 554 void __stdcall ExceptionHandlerServer::OnNonCrashDumpEvent(void* ctx, BOOLEAN) { |
| 554 // This function is executed on the thread pool. | 555 // This function is executed on the thread pool. |
| 555 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 556 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 556 base::AutoLock lock(*client->lock()); | 557 base::AutoLock lock(*client->lock()); |
| 557 | 558 |
| 558 // Capture the exception. | 559 // Capture the exception. |
| 559 client->delegate()->ExceptionHandlerServerException( | 560 client->delegate()->ExceptionHandlerServerException( |
| 560 client->process(), | 561 client->process(), |
| 561 client->non_crash_exception_information_address(), | 562 client->non_crash_exception_information_address(), |
| 562 client->debug_critical_section_address()); | 563 client->debug_critical_section_address()); |
| 563 | 564 |
| 564 bool result = !!SetEvent(client->non_crash_dump_completed_event()); | 565 bool result = !!SetEvent(client->non_crash_dump_completed_event()); |
| 565 PLOG_IF(ERROR, !result) << "SetEvent"; | 566 PLOG_IF(ERROR, !result) << "SetEvent"; |
| 566 } | 567 } |
| 567 | 568 |
| 568 // static | 569 // static |
| 569 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { | 570 void __stdcall ExceptionHandlerServer::OnProcessEnd(void* ctx, BOOLEAN) { |
| 570 // This function is executed on the thread pool. | 571 // This function is executed on the thread pool. |
| 571 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); | 572 internal::ClientData* client = reinterpret_cast<internal::ClientData*>(ctx); |
| 572 base::AutoLock lock(*client->lock()); | 573 base::AutoLock lock(*client->lock()); |
| 573 | 574 |
| 574 // Post back to the main thread to have it delete this client record. | 575 // Post back to the main thread to have it delete this client record. |
| 575 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); | 576 PostQueuedCompletionStatus(client->port(), 0, ULONG_PTR(client), nullptr); |
| 576 } | 577 } |
| 577 | 578 |
| 578 } // namespace crashpad | 579 } // namespace crashpad |
| OLD | NEW |