Planeshift
ipc_protocol.h
Go to the documentation of this file.
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>
39 
40 namespace google_breakpad {
41 
42 // Name/value pair for custom client information.
44  // Maximum length for name and value for client custom info.
45  static const int kNameMaxLength = 64;
46  static const int kValueMaxLength = 64;
47 
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];
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 {
95 };
96 
99  size_t count;
100 };
101 
102 // Message structure for IPC between crash client and crash server.
105  : tag(MESSAGE_TAG_NONE),
106  id(0),
107  dump_type(MiniDumpNormal),
108  thread_id(0),
109  exception_pointers(NULL),
110  assert_info(NULL),
111  custom_client_info(),
112  dump_request_handle(NULL),
113  dump_generated_handle(NULL),
114  server_alive_handle(NULL) {
115  }
116 
117  // Creates an instance with the given parameters.
119  DWORD arg_id,
120  MINIDUMP_TYPE arg_dump_type,
121  DWORD* arg_thread_id,
122  EXCEPTION_POINTERS** arg_exception_pointers,
123  MDRawAssertionInfo* arg_assert_info,
124  const CustomClientInfo& custom_info,
125  HANDLE arg_dump_request_handle,
126  HANDLE arg_dump_generated_handle,
127  HANDLE arg_server_alive)
128  : tag(arg_tag),
129  id(arg_id),
130  dump_type(arg_dump_type),
131  thread_id(arg_thread_id),
132  exception_pointers(arg_exception_pointers),
133  assert_info(arg_assert_info),
134  custom_client_info(custom_info),
135  dump_request_handle(arg_dump_request_handle),
136  dump_generated_handle(arg_dump_generated_handle),
137  server_alive_handle(arg_server_alive) {
138  }
139 
140  // Tag in the message.
142 
143  // The id for this message. This may be either a process id or a crash id
144  // depending on the type of message.
145  DWORD id;
146 
147  // Dump type requested.
148  MINIDUMP_TYPE dump_type;
149 
150  // Client thread id pointer.
151  DWORD* thread_id;
152 
153  // Exception information.
154  EXCEPTION_POINTERS** exception_pointers;
155 
156  // Assert information in case of an invalid parameter or
157  // pure call failure.
159 
160  // Custom client information.
162 
163  // Handle to signal the crash event.
165 
166  // Handle to check if server is done generating crash.
168 
169  // Handle to a mutex that becomes signaled (WAIT_ABANDONED)
170  // if server process goes down.
172 
173  private:
174  // Disable copy ctor and operator=.
175  ProtocolMessage(const ProtocolMessage& msg);
176  ProtocolMessage& operator=(const ProtocolMessage& msg);
177 };
178 
179 } // namespace google_breakpad
180 
181 #endif // CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__
static const int kValueMaxLength
Definition: ipc_protocol.h:46
ProtocolMessage(MessageTag arg_tag, DWORD arg_id, MINIDUMP_TYPE arg_dump_type, DWORD *arg_thread_id, EXCEPTION_POINTERS **arg_exception_pointers, MDRawAssertionInfo *arg_assert_info, const CustomClientInfo &custom_info, HANDLE arg_dump_request_handle, HANDLE arg_dump_generated_handle, HANDLE arg_server_alive)
Definition: ipc_protocol.h:118
MDRawAssertionInfo * assert_info
Definition: ipc_protocol.h:158
void set_name(const wchar_t *name_arg)
Definition: ipc_protocol.h:59
wchar_t value[kValueMaxLength]
Definition: ipc_protocol.h:82
static void safe_wcscpy(wchar_t *destination, size_t destination_size, const wchar_t *source)
CustomInfoEntry(const wchar_t *name_arg, const wchar_t *value_arg)
Definition: ipc_protocol.h:54
CustomClientInfo custom_client_info
Definition: ipc_protocol.h:161
wchar_t name[kNameMaxLength]
Definition: ipc_protocol.h:81
EXCEPTION_POINTERS ** exception_pointers
Definition: ipc_protocol.h:154
const CustomInfoEntry * entries
Definition: ipc_protocol.h:98
void set_value(const wchar_t *value_arg)
Definition: ipc_protocol.h:67