| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2008, Google Inc. | |
| 2 // All rights reserved. | |
| 3 // | |
| 4 // Redistribution and use in source and binary forms, with or without | |
| 5 // modification, are permitted provided that the following conditions are | |
| 6 // met: | |
| 7 // | |
| 8 // * Redistributions of source code must retain the above copyright | |
| 9 // notice, this list of conditions and the following disclaimer. | |
| 10 // * Redistributions in binary form must reproduce the above | |
| 11 // copyright notice, this list of conditions and the following disclaimer | |
| 12 // in the documentation and/or other materials provided with the | |
| 13 // distribution. | |
| 14 // * Neither the name of Google Inc. nor the names of its | |
| 15 // contributors may be used to endorse or promote products derived from | |
| 16 // this software without specific prior written permission. | |
| 17 // | |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | |
| 30 #ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ | |
| 31 #define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ | |
| 32 | |
| 33 #include <Windows.h> | |
| 34 #include <DbgHelp.h> | |
| 35 #include <string> | |
| 36 #include <utility> | |
| 37 #include "common/windows/string_utils-inl.h" | |
| 38 #include "google_breakpad/common/minidump_format.h" | |
| 39 | |
| 40 namespace google_breakpad { | |
| 41 | |
| 42 // Name/value pair for custom client information. | |
| 43 struct CustomInfoEntry { | |
| 44 // Maximum length for name and value for client custom info. | |
| 45 static const int kNameMaxLength = 64; | |
| 46 static const int kValueMaxLength = 64; | |
| 47 | |
| 48 CustomInfoEntry() { | |
| 49 // Putting name and value in initializer list makes VC++ show warning 4351. | |
| 50 set_name(NULL); | |
| 51 set_value(NULL); | |
| 52 } | |
| 53 | |
| 54 CustomInfoEntry(const wchar_t* name_arg, const wchar_t* value_arg) { | |
| 55 set_name(name_arg); | |
| 56 set_value(value_arg); | |
| 57 } | |
| 58 | |
| 59 void set_name(const wchar_t* name_arg) { | |
| 60 if (!name_arg) { | |
| 61 name[0] = L'\0'; | |
| 62 return; | |
| 63 } | |
| 64 WindowsStringUtils::safe_wcscpy(name, kNameMaxLength, name_arg); | |
| 65 } | |
| 66 | |
| 67 void set_value(const wchar_t* value_arg) { | |
| 68 if (!value_arg) { | |
| 69 value[0] = L'\0'; | |
| 70 return; | |
| 71 } | |
| 72 | |
| 73 WindowsStringUtils::safe_wcscpy(value, kValueMaxLength, value_arg); | |
| 74 } | |
| 75 | |
| 76 void set(const wchar_t* name_arg, const wchar_t* value_arg) { | |
| 77 set_name(name_arg); | |
| 78 set_value(value_arg); | |
| 79 } | |
| 80 | |
| 81 wchar_t name[kNameMaxLength]; | |
| 82 wchar_t value[kValueMaxLength]; | |
| 83 }; | |
| 84 | |
| 85 // Constants for the protocol between client and the server. | |
| 86 | |
| 87 // Tags sent with each message indicating the purpose of | |
| 88 // the message. | |
| 89 enum MessageTag { | |
| 90 MESSAGE_TAG_NONE = 0, | |
| 91 MESSAGE_TAG_REGISTRATION_REQUEST = 1, | |
| 92 MESSAGE_TAG_REGISTRATION_RESPONSE = 2, | |
| 93 MESSAGE_TAG_REGISTRATION_ACK = 3 | |
| 94 }; | |
| 95 | |
| 96 struct CustomClientInfo { | |
| 97 const CustomInfoEntry* entries; | |
| 98 size_t count; | |
| 99 }; | |
| 100 | |
| 101 // Message structure for IPC between crash client and crash server. | |
| 102 struct ProtocolMessage { | |
| 103 ProtocolMessage() | |
| 104 : tag(MESSAGE_TAG_NONE), | |
| 105 pid(0), | |
| 106 dump_type(MiniDumpNormal), | |
| 107 thread_id(0), | |
| 108 exception_pointers(NULL), | |
| 109 assert_info(NULL), | |
| 110 custom_client_info(), | |
| 111 dump_request_handle(NULL), | |
| 112 dump_generated_handle(NULL), | |
| 113 server_alive_handle(NULL) { | |
| 114 } | |
| 115 | |
| 116 // Creates an instance with the given parameters. | |
| 117 ProtocolMessage(MessageTag arg_tag, | |
| 118 DWORD arg_pid, | |
| 119 MINIDUMP_TYPE arg_dump_type, | |
| 120 DWORD* arg_thread_id, | |
| 121 EXCEPTION_POINTERS** arg_exception_pointers, | |
| 122 MDRawAssertionInfo* arg_assert_info, | |
| 123 const CustomClientInfo& custom_info, | |
| 124 HANDLE arg_dump_request_handle, | |
| 125 HANDLE arg_dump_generated_handle, | |
| 126 HANDLE arg_server_alive) | |
| 127 : tag(arg_tag), | |
| 128 pid(arg_pid), | |
| 129 dump_type(arg_dump_type), | |
| 130 thread_id(arg_thread_id), | |
| 131 exception_pointers(arg_exception_pointers), | |
| 132 assert_info(arg_assert_info), | |
| 133 custom_client_info(custom_info), | |
| 134 dump_request_handle(arg_dump_request_handle), | |
| 135 dump_generated_handle(arg_dump_generated_handle), | |
| 136 server_alive_handle(arg_server_alive) { | |
| 137 } | |
| 138 | |
| 139 // Tag in the message. | |
| 140 MessageTag tag; | |
| 141 | |
| 142 // Process id. | |
| 143 DWORD pid; | |
| 144 | |
| 145 // Dump type requested. | |
| 146 MINIDUMP_TYPE dump_type; | |
| 147 | |
| 148 // Client thread id pointer. | |
| 149 DWORD* thread_id; | |
| 150 | |
| 151 // Exception information. | |
| 152 EXCEPTION_POINTERS** exception_pointers; | |
| 153 | |
| 154 // Assert information in case of an invalid parameter or | |
| 155 // pure call failure. | |
| 156 MDRawAssertionInfo* assert_info; | |
| 157 | |
| 158 // Custom client information. | |
| 159 CustomClientInfo custom_client_info; | |
| 160 | |
| 161 // Handle to signal the crash event. | |
| 162 HANDLE dump_request_handle; | |
| 163 | |
| 164 // Handle to check if server is done generating crash. | |
| 165 HANDLE dump_generated_handle; | |
| 166 | |
| 167 // Handle to a mutex that becomes signaled (WAIT_ABANDONED) | |
| 168 // if server process goes down. | |
| 169 HANDLE server_alive_handle; | |
| 170 | |
| 171 private: | |
| 172 // Disable copy ctor and operator=. | |
| 173 ProtocolMessage(const ProtocolMessage& msg); | |
| 174 ProtocolMessage& operator=(const ProtocolMessage& msg); | |
| 175 }; | |
| 176 | |
| 177 } // namespace google_breakpad | |
| 178 | |
| 179 #endif // CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ | |
| OLD | NEW |