OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_UTIL_WIN_INITIAL_CLIENT_DATA_H_ |
| 16 #define CRASHPAD_UTIL_WIN_INITIAL_CLIENT_DATA_H_ |
| 17 |
| 18 #include <windows.h> |
| 19 |
| 20 #include <string> |
| 21 |
| 22 #include "base/macros.h" |
| 23 #include "util/win/address_types.h" |
| 24 |
| 25 namespace crashpad { |
| 26 |
| 27 //! \brief A container for the data associated with the `--initial-client-data` |
| 28 //! method for initializing the handler process on Windows. |
| 29 class InitialClientData { |
| 30 public: |
| 31 //! \brief Constructs an unintialized instance to be used with |
| 32 //! InitializeFromString(). |
| 33 InitialClientData(); |
| 34 |
| 35 //! \brief Constructs an instance of InitialClientData. This object does not |
| 36 //! take ownership of any of the referenced HANDLEs. |
| 37 //! |
| 38 //! \param[in] request_crash_dump An event signalled from the client on crash. |
| 39 //! \param[in] request_non_crash_dump An event signalled from the client when |
| 40 //! it would like a dump to be taken, but allowed to continue afterwards. |
| 41 //! \param[in] non_crash_dump_completed An event signalled from the handler to |
| 42 //! tell the client that the non-crash dump has completed, and it can |
| 43 //! continue execution. |
| 44 //! \param[in] first_pipe_instance The server end and first instance of a pipe |
| 45 //! that will be used for communication with all other clients after this |
| 46 //! initial one. |
| 47 //! \param[in] client_process A process handle for the client being |
| 48 //! registered. |
| 49 //! \param[in] crash_exception_information The address, in the client's |
| 50 //! address space, of an ExceptionInformation structure, used when |
| 51 //! handling a crash dump request. |
| 52 //! \param[in] non_crash_exception_information The address, in the client's |
| 53 //! address space, of an ExceptionInformation structure, used when |
| 54 //! handling a non-crashing dump request. |
| 55 //! \param[in] debug_critical_section_address The address, in the client |
| 56 //! process's address space, of a `CRITICAL_SECTION` allocated with a |
| 57 //! valid .DebugInfo field. This can be accomplished by using |
| 58 //! InitializeCriticalSectionWithDebugInfoIfPossible() or equivalent. This |
| 59 //! value can be `0`, however then limited lock data will be available in |
| 60 //! minidumps. |
| 61 InitialClientData(HANDLE request_crash_dump, |
| 62 HANDLE request_non_crash_dump, |
| 63 HANDLE non_crash_dump_completed, |
| 64 HANDLE first_pipe_instance, |
| 65 HANDLE client_process, |
| 66 WinVMAddress crash_exception_information, |
| 67 WinVMAddress non_crash_exception_information, |
| 68 WinVMAddress debug_critical_section_address); |
| 69 |
| 70 //! \brief Returns whether the object has been initialized successfully. |
| 71 bool IsValid() const { return is_valid_; } |
| 72 |
| 73 //! Initializes this object from a string representation presumed to have been |
| 74 //! created by StringRepresentation(). |
| 75 //! |
| 76 //! \param[in] str The output of StringRepresentation(). |
| 77 //! |
| 78 //! \return `true` on success, or `false` with a message logged on failure. |
| 79 bool InitializeFromString(const std::string& str); |
| 80 |
| 81 //! \brief Returns a string representation of the data of this object, |
| 82 //! suitable for passing on the command line. |
| 83 std::string StringRepresentation() const; |
| 84 |
| 85 HANDLE request_crash_dump() const { return request_crash_dump_; } |
| 86 HANDLE request_non_crash_dump() const { return request_non_crash_dump_; } |
| 87 HANDLE non_crash_dump_completed() const { return non_crash_dump_completed_; } |
| 88 HANDLE first_pipe_instance() const { return first_pipe_instance_; } |
| 89 HANDLE client_process() const { return client_process_; } |
| 90 WinVMAddress crash_exception_information() const { |
| 91 return crash_exception_information_; |
| 92 } |
| 93 WinVMAddress non_crash_exception_information() const { |
| 94 return non_crash_exception_information_; |
| 95 } |
| 96 WinVMAddress debug_critical_section_address() const { |
| 97 return debug_critical_section_address_; |
| 98 } |
| 99 |
| 100 private: |
| 101 WinVMAddress crash_exception_information_; |
| 102 WinVMAddress non_crash_exception_information_; |
| 103 WinVMAddress debug_critical_section_address_; |
| 104 HANDLE request_crash_dump_; |
| 105 HANDLE request_non_crash_dump_; |
| 106 HANDLE non_crash_dump_completed_; |
| 107 HANDLE first_pipe_instance_; |
| 108 HANDLE client_process_; |
| 109 bool is_valid_; |
| 110 |
| 111 #if _MSC_VER < 1900 |
| 112 // The default copy and assignment constructors are fine, as we don't take |
| 113 // ownership of the handles. They also shouldn't be required for how we use |
| 114 // this class, however, VS2013 seems to think they are. |
| 115 #else |
| 116 DISALLOW_COPY_AND_ASSIGN(InitialClientData); |
| 117 #endif // _MSC_VER < 1900 |
| 118 }; |
| 119 |
| 120 } // namespace crashpad |
| 121 |
| 122 #endif // CRASHPAD_UTIL_WIN_INITIAL_CLIENT_DATA_H_ |
OLD | NEW |