win: Fix OpenProcess(PROCESS_ALL_ACCESS, ...) on XP

PROCESS_ALL_ACCESS was changed in later SDKs and the newer value fails
when run on XP with ERROR_ACCESS_DENIED. Use the old value to maintain
compatibility with XP.

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

Review URL: https://codereview.chromium.org/1337133002 .
This commit is contained in:
Scott Graham 2015-09-11 13:16:06 -07:00
parent 1678e1a3ac
commit 3a886267aa
4 changed files with 39 additions and 3 deletions

View File

@ -42,6 +42,7 @@
#include "base/strings/utf_string_conversions.h"
#include "snapshot/win/process_snapshot_win.h"
#include "util/win/scoped_process_suspend.h"
#include "util/win/xp_compat.h"
#endif // OS_MACOSX
namespace crashpad {
@ -151,7 +152,7 @@ int GenerateDumpMain(int argc, char* argv[]) {
}
#elif defined(OS_WIN)
ScopedKernelHANDLE process(
OpenProcess(PROCESS_ALL_ACCESS, false, options.pid));
OpenProcess(kXPProcessAllAccess, false, options.pid));
if (!process.is_valid()) {
LOG(ERROR) << "could not open process " << options.pid;
return EXIT_FAILURE;

View File

@ -166,6 +166,7 @@
'win/scoped_process_suspend.h',
'win/time.cc',
'win/time.h',
'win/xp_compat.h',
],
'conditions': [
['OS=="mac"', {

View File

@ -27,6 +27,7 @@
#include "util/misc/tri_state.h"
#include "util/misc/uuid.h"
#include "util/win/registration_protocol_win.h"
#include "util/win/xp_compat.h"
namespace crashpad {
@ -342,14 +343,14 @@ bool ExceptionHandlerServer::ServiceClientConnection(
// the process, but the client will be able to, so we make a second attempt
// having impersonated the client.
HANDLE client_process = OpenProcess(
PROCESS_ALL_ACCESS, false, message.registration.client_process_id);
kXPProcessAllAccess, false, message.registration.client_process_id);
if (!client_process) {
if (!ImpersonateNamedPipeClient(service_context.pipe())) {
PLOG(ERROR) << "ImpersonateNamedPipeClient";
return false;
}
HANDLE client_process = OpenProcess(
PROCESS_ALL_ACCESS, false, message.registration.client_process_id);
kXPProcessAllAccess, false, message.registration.client_process_id);
PCHECK(RevertToSelf());
if (!client_process) {
LOG(ERROR) << "failed to open " << message.registration.client_process_id;

33
util/win/xp_compat.h Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2015 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_UTIL_WIN_XP_COMPAT_H_
#define CRASHPAD_UTIL_WIN_XP_COMPAT_H_
#include <windows.h>
namespace crashpad {
enum {
//! \brief This is the XP-suitable value of `PROCESS_ALL_ACCESS`.
//!
//! Requesting `PROCESS_ALL_ACCESS` with the value defined when building
//! against a Vista+ SDK results in `ERROR_ACCESS_DENIED` when running on XP.
//! See https://msdn.microsoft.com/en-ca/library/windows/desktop/ms684880.aspx
kXPProcessAllAccess = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF
};
} // namespace crashpad
#endif // CRASHPAD_UTIL_WIN_XP_COMPAT_H_