win: Add version to client registration request

Follow up after suggestion in https://codereview.chromium.org/1301853002/.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/1314683008 .
This commit is contained in:
Scott Graham 2015-09-04 11:52:07 -07:00
parent 1c7843bd44
commit 28c5da9080
3 changed files with 18 additions and 3 deletions

View File

@ -105,6 +105,7 @@ bool CrashpadClient::SetHandler(const std::string& ipc_port) {
ClientToServerMessage message;
memset(&message, 0, sizeof(message));
message.type = ClientToServerMessage::kRegister;
message.registration.version = RegistrationRequest::kMessageVersion;
message.registration.client_process_id = GetCurrentProcessId();
message.registration.exception_information =
reinterpret_cast<WinVMAddress>(&g_exception_information);

View File

@ -317,6 +317,12 @@ bool ExceptionHandlerServer::ServiceClientConnection(
return false;
}
if (message.registration.version != RegistrationRequest::kMessageVersion) {
LOG(ERROR) << "unexpected version. got: " << message.registration.version
<< " expecting: " << RegistrationRequest::kMessageVersion;
return false;
}
decltype(GetNamedPipeClientProcessId)* get_named_pipe_client_process_id =
GetNamedPipeClientProcessIdFunction();
if (get_named_pipe_client_process_id) {

View File

@ -38,12 +38,20 @@ struct ExceptionInformation {
//! \brief A client registration request.
struct RegistrationRequest {
//! \brief The address, in the client process address space, of an
//! ExceptionInformation structure.
WinVMAddress exception_information;
//! \brief The expected value of `version`. This should be changed whenever
//! the messages or ExceptionInformation are modified incompatibly.
enum { kMessageVersion = 1 };
//! \brief Version field to detect skew between client and server. Should be
//! set to kMessageVersion.
int version;
//! \brief The PID of the client process.
DWORD client_process_id;
//! \brief The address, in the client process address space, of an
//! ExceptionInformation structure.
WinVMAddress exception_information;
};
//! \brief A message only sent to the server by itself to trigger shutdown.