michael@0: // Copyright (c) 2008, Google Inc. michael@0: // All rights reserved. michael@0: // michael@0: // Redistribution and use in source and binary forms, with or without michael@0: // modification, are permitted provided that the following conditions are michael@0: // met: michael@0: // michael@0: // * Redistributions of source code must retain the above copyright michael@0: // notice, this list of conditions and the following disclaimer. michael@0: // * Redistributions in binary form must reproduce the above michael@0: // copyright notice, this list of conditions and the following disclaimer michael@0: // in the documentation and/or other materials provided with the michael@0: // distribution. michael@0: // * Neither the name of Google Inc. nor the names of its michael@0: // contributors may be used to endorse or promote products derived from michael@0: // this software without specific prior written permission. michael@0: // michael@0: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: michael@0: #ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ michael@0: #define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include "common/windows/string_utils-inl.h" michael@0: #include "google_breakpad/common/minidump_format.h" michael@0: michael@0: namespace google_breakpad { michael@0: michael@0: // Name/value pair for custom client information. michael@0: struct CustomInfoEntry { michael@0: // Maximum length for name and value for client custom info. michael@0: static const int kNameMaxLength = 64; michael@0: static const int kValueMaxLength = 64; michael@0: michael@0: CustomInfoEntry() { michael@0: // Putting name and value in initializer list makes VC++ show warning 4351. michael@0: set_name(NULL); michael@0: set_value(NULL); michael@0: } michael@0: michael@0: CustomInfoEntry(const wchar_t* name_arg, const wchar_t* value_arg) { michael@0: set_name(name_arg); michael@0: set_value(value_arg); michael@0: } michael@0: michael@0: void set_name(const wchar_t* name_arg) { michael@0: if (!name_arg) { michael@0: name[0] = L'\0'; michael@0: return; michael@0: } michael@0: WindowsStringUtils::safe_wcscpy(name, kNameMaxLength, name_arg); michael@0: } michael@0: michael@0: void set_value(const wchar_t* value_arg) { michael@0: if (!value_arg) { michael@0: value[0] = L'\0'; michael@0: return; michael@0: } michael@0: michael@0: WindowsStringUtils::safe_wcscpy(value, kValueMaxLength, value_arg); michael@0: } michael@0: michael@0: void set(const wchar_t* name_arg, const wchar_t* value_arg) { michael@0: set_name(name_arg); michael@0: set_value(value_arg); michael@0: } michael@0: michael@0: wchar_t name[kNameMaxLength]; michael@0: wchar_t value[kValueMaxLength]; michael@0: }; michael@0: michael@0: // Constants for the protocol between client and the server. michael@0: michael@0: // Tags sent with each message indicating the purpose of michael@0: // the message. michael@0: enum MessageTag { michael@0: MESSAGE_TAG_NONE = 0, michael@0: MESSAGE_TAG_REGISTRATION_REQUEST = 1, michael@0: MESSAGE_TAG_REGISTRATION_RESPONSE = 2, michael@0: MESSAGE_TAG_REGISTRATION_ACK = 3, michael@0: MESSAGE_TAG_UPLOAD_REQUEST = 4 michael@0: }; michael@0: michael@0: struct CustomClientInfo { michael@0: const CustomInfoEntry* entries; michael@0: size_t count; michael@0: }; michael@0: michael@0: // Message structure for IPC between crash client and crash server. michael@0: struct ProtocolMessage { michael@0: ProtocolMessage() michael@0: : tag(MESSAGE_TAG_NONE), michael@0: id(0), michael@0: dump_type(MiniDumpNormal), michael@0: thread_id(0), michael@0: exception_pointers(NULL), michael@0: assert_info(NULL), michael@0: custom_client_info(), michael@0: dump_request_handle(NULL), michael@0: dump_generated_handle(NULL), michael@0: server_alive_handle(NULL) { michael@0: } michael@0: michael@0: // Creates an instance with the given parameters. michael@0: ProtocolMessage(MessageTag arg_tag, michael@0: DWORD arg_id, michael@0: MINIDUMP_TYPE arg_dump_type, michael@0: DWORD* arg_thread_id, michael@0: EXCEPTION_POINTERS** arg_exception_pointers, michael@0: MDRawAssertionInfo* arg_assert_info, michael@0: const CustomClientInfo& custom_info, michael@0: HANDLE arg_dump_request_handle, michael@0: HANDLE arg_dump_generated_handle, michael@0: HANDLE arg_server_alive) michael@0: : tag(arg_tag), michael@0: id(arg_id), michael@0: dump_type(arg_dump_type), michael@0: thread_id(arg_thread_id), michael@0: exception_pointers(arg_exception_pointers), michael@0: assert_info(arg_assert_info), michael@0: custom_client_info(custom_info), michael@0: dump_request_handle(arg_dump_request_handle), michael@0: dump_generated_handle(arg_dump_generated_handle), michael@0: server_alive_handle(arg_server_alive) { michael@0: } michael@0: michael@0: // Tag in the message. michael@0: MessageTag tag; michael@0: michael@0: // The id for this message. This may be either a process id or a crash id michael@0: // depending on the type of message. michael@0: DWORD id; michael@0: michael@0: // Dump type requested. michael@0: MINIDUMP_TYPE dump_type; michael@0: michael@0: // Client thread id pointer. michael@0: DWORD* thread_id; michael@0: michael@0: // Exception information. michael@0: EXCEPTION_POINTERS** exception_pointers; michael@0: michael@0: // Assert information in case of an invalid parameter or michael@0: // pure call failure. michael@0: MDRawAssertionInfo* assert_info; michael@0: michael@0: // Custom client information. michael@0: CustomClientInfo custom_client_info; michael@0: michael@0: // Handle to signal the crash event. michael@0: HANDLE dump_request_handle; michael@0: michael@0: // Handle to check if server is done generating crash. michael@0: HANDLE dump_generated_handle; michael@0: michael@0: // Handle to a mutex that becomes signaled (WAIT_ABANDONED) michael@0: // if server process goes down. michael@0: HANDLE server_alive_handle; michael@0: michael@0: private: michael@0: // Disable copy ctor and operator=. michael@0: ProtocolMessage(const ProtocolMessage& msg); michael@0: ProtocolMessage& operator=(const ProtocolMessage& msg); michael@0: }; michael@0: michael@0: } // namespace google_breakpad michael@0: michael@0: #endif // CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__