1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/client/windows/common/ipc_protocol.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,181 @@ 1.4 +// Copyright (c) 2008, Google Inc. 1.5 +// All rights reserved. 1.6 +// 1.7 +// Redistribution and use in source and binary forms, with or without 1.8 +// modification, are permitted provided that the following conditions are 1.9 +// met: 1.10 +// 1.11 +// * Redistributions of source code must retain the above copyright 1.12 +// notice, this list of conditions and the following disclaimer. 1.13 +// * Redistributions in binary form must reproduce the above 1.14 +// copyright notice, this list of conditions and the following disclaimer 1.15 +// in the documentation and/or other materials provided with the 1.16 +// distribution. 1.17 +// * Neither the name of Google Inc. nor the names of its 1.18 +// contributors may be used to endorse or promote products derived from 1.19 +// this software without specific prior written permission. 1.20 +// 1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.32 + 1.33 +#ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ 1.34 +#define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ 1.35 + 1.36 +#include <Windows.h> 1.37 +#include <DbgHelp.h> 1.38 +#include <string> 1.39 +#include <utility> 1.40 +#include "common/windows/string_utils-inl.h" 1.41 +#include "google_breakpad/common/minidump_format.h" 1.42 + 1.43 +namespace google_breakpad { 1.44 + 1.45 +// Name/value pair for custom client information. 1.46 +struct CustomInfoEntry { 1.47 + // Maximum length for name and value for client custom info. 1.48 + static const int kNameMaxLength = 64; 1.49 + static const int kValueMaxLength = 64; 1.50 + 1.51 + CustomInfoEntry() { 1.52 + // Putting name and value in initializer list makes VC++ show warning 4351. 1.53 + set_name(NULL); 1.54 + set_value(NULL); 1.55 + } 1.56 + 1.57 + CustomInfoEntry(const wchar_t* name_arg, const wchar_t* value_arg) { 1.58 + set_name(name_arg); 1.59 + set_value(value_arg); 1.60 + } 1.61 + 1.62 + void set_name(const wchar_t* name_arg) { 1.63 + if (!name_arg) { 1.64 + name[0] = L'\0'; 1.65 + return; 1.66 + } 1.67 + WindowsStringUtils::safe_wcscpy(name, kNameMaxLength, name_arg); 1.68 + } 1.69 + 1.70 + void set_value(const wchar_t* value_arg) { 1.71 + if (!value_arg) { 1.72 + value[0] = L'\0'; 1.73 + return; 1.74 + } 1.75 + 1.76 + WindowsStringUtils::safe_wcscpy(value, kValueMaxLength, value_arg); 1.77 + } 1.78 + 1.79 + void set(const wchar_t* name_arg, const wchar_t* value_arg) { 1.80 + set_name(name_arg); 1.81 + set_value(value_arg); 1.82 + } 1.83 + 1.84 + wchar_t name[kNameMaxLength]; 1.85 + wchar_t value[kValueMaxLength]; 1.86 +}; 1.87 + 1.88 +// Constants for the protocol between client and the server. 1.89 + 1.90 +// Tags sent with each message indicating the purpose of 1.91 +// the message. 1.92 +enum MessageTag { 1.93 + MESSAGE_TAG_NONE = 0, 1.94 + MESSAGE_TAG_REGISTRATION_REQUEST = 1, 1.95 + MESSAGE_TAG_REGISTRATION_RESPONSE = 2, 1.96 + MESSAGE_TAG_REGISTRATION_ACK = 3, 1.97 + MESSAGE_TAG_UPLOAD_REQUEST = 4 1.98 +}; 1.99 + 1.100 +struct CustomClientInfo { 1.101 + const CustomInfoEntry* entries; 1.102 + size_t count; 1.103 +}; 1.104 + 1.105 +// Message structure for IPC between crash client and crash server. 1.106 +struct ProtocolMessage { 1.107 + ProtocolMessage() 1.108 + : tag(MESSAGE_TAG_NONE), 1.109 + id(0), 1.110 + dump_type(MiniDumpNormal), 1.111 + thread_id(0), 1.112 + exception_pointers(NULL), 1.113 + assert_info(NULL), 1.114 + custom_client_info(), 1.115 + dump_request_handle(NULL), 1.116 + dump_generated_handle(NULL), 1.117 + server_alive_handle(NULL) { 1.118 + } 1.119 + 1.120 + // Creates an instance with the given parameters. 1.121 + ProtocolMessage(MessageTag arg_tag, 1.122 + DWORD arg_id, 1.123 + MINIDUMP_TYPE arg_dump_type, 1.124 + DWORD* arg_thread_id, 1.125 + EXCEPTION_POINTERS** arg_exception_pointers, 1.126 + MDRawAssertionInfo* arg_assert_info, 1.127 + const CustomClientInfo& custom_info, 1.128 + HANDLE arg_dump_request_handle, 1.129 + HANDLE arg_dump_generated_handle, 1.130 + HANDLE arg_server_alive) 1.131 + : tag(arg_tag), 1.132 + id(arg_id), 1.133 + dump_type(arg_dump_type), 1.134 + thread_id(arg_thread_id), 1.135 + exception_pointers(arg_exception_pointers), 1.136 + assert_info(arg_assert_info), 1.137 + custom_client_info(custom_info), 1.138 + dump_request_handle(arg_dump_request_handle), 1.139 + dump_generated_handle(arg_dump_generated_handle), 1.140 + server_alive_handle(arg_server_alive) { 1.141 + } 1.142 + 1.143 + // Tag in the message. 1.144 + MessageTag tag; 1.145 + 1.146 + // The id for this message. This may be either a process id or a crash id 1.147 + // depending on the type of message. 1.148 + DWORD id; 1.149 + 1.150 + // Dump type requested. 1.151 + MINIDUMP_TYPE dump_type; 1.152 + 1.153 + // Client thread id pointer. 1.154 + DWORD* thread_id; 1.155 + 1.156 + // Exception information. 1.157 + EXCEPTION_POINTERS** exception_pointers; 1.158 + 1.159 + // Assert information in case of an invalid parameter or 1.160 + // pure call failure. 1.161 + MDRawAssertionInfo* assert_info; 1.162 + 1.163 + // Custom client information. 1.164 + CustomClientInfo custom_client_info; 1.165 + 1.166 + // Handle to signal the crash event. 1.167 + HANDLE dump_request_handle; 1.168 + 1.169 + // Handle to check if server is done generating crash. 1.170 + HANDLE dump_generated_handle; 1.171 + 1.172 + // Handle to a mutex that becomes signaled (WAIT_ABANDONED) 1.173 + // if server process goes down. 1.174 + HANDLE server_alive_handle; 1.175 + 1.176 + private: 1.177 + // Disable copy ctor and operator=. 1.178 + ProtocolMessage(const ProtocolMessage& msg); 1.179 + ProtocolMessage& operator=(const ProtocolMessage& msg); 1.180 +}; 1.181 + 1.182 +} // namespace google_breakpad 1.183 + 1.184 +#endif // CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__