mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:32:10 +08:00
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:
parent
1678e1a3ac
commit
3a886267aa
@ -42,6 +42,7 @@
|
|||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "snapshot/win/process_snapshot_win.h"
|
#include "snapshot/win/process_snapshot_win.h"
|
||||||
#include "util/win/scoped_process_suspend.h"
|
#include "util/win/scoped_process_suspend.h"
|
||||||
|
#include "util/win/xp_compat.h"
|
||||||
#endif // OS_MACOSX
|
#endif // OS_MACOSX
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
@ -151,7 +152,7 @@ int GenerateDumpMain(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
ScopedKernelHANDLE process(
|
ScopedKernelHANDLE process(
|
||||||
OpenProcess(PROCESS_ALL_ACCESS, false, options.pid));
|
OpenProcess(kXPProcessAllAccess, false, options.pid));
|
||||||
if (!process.is_valid()) {
|
if (!process.is_valid()) {
|
||||||
LOG(ERROR) << "could not open process " << options.pid;
|
LOG(ERROR) << "could not open process " << options.pid;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -166,6 +166,7 @@
|
|||||||
'win/scoped_process_suspend.h',
|
'win/scoped_process_suspend.h',
|
||||||
'win/time.cc',
|
'win/time.cc',
|
||||||
'win/time.h',
|
'win/time.h',
|
||||||
|
'win/xp_compat.h',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS=="mac"', {
|
['OS=="mac"', {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "util/misc/tri_state.h"
|
#include "util/misc/tri_state.h"
|
||||||
#include "util/misc/uuid.h"
|
#include "util/misc/uuid.h"
|
||||||
#include "util/win/registration_protocol_win.h"
|
#include "util/win/registration_protocol_win.h"
|
||||||
|
#include "util/win/xp_compat.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
|
|
||||||
@ -342,14 +343,14 @@ bool ExceptionHandlerServer::ServiceClientConnection(
|
|||||||
// the process, but the client will be able to, so we make a second attempt
|
// the process, but the client will be able to, so we make a second attempt
|
||||||
// having impersonated the client.
|
// having impersonated the client.
|
||||||
HANDLE client_process = OpenProcess(
|
HANDLE client_process = OpenProcess(
|
||||||
PROCESS_ALL_ACCESS, false, message.registration.client_process_id);
|
kXPProcessAllAccess, false, message.registration.client_process_id);
|
||||||
if (!client_process) {
|
if (!client_process) {
|
||||||
if (!ImpersonateNamedPipeClient(service_context.pipe())) {
|
if (!ImpersonateNamedPipeClient(service_context.pipe())) {
|
||||||
PLOG(ERROR) << "ImpersonateNamedPipeClient";
|
PLOG(ERROR) << "ImpersonateNamedPipeClient";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HANDLE client_process = OpenProcess(
|
HANDLE client_process = OpenProcess(
|
||||||
PROCESS_ALL_ACCESS, false, message.registration.client_process_id);
|
kXPProcessAllAccess, false, message.registration.client_process_id);
|
||||||
PCHECK(RevertToSelf());
|
PCHECK(RevertToSelf());
|
||||||
if (!client_process) {
|
if (!client_process) {
|
||||||
LOG(ERROR) << "failed to open " << message.registration.client_process_id;
|
LOG(ERROR) << "failed to open " << message.registration.client_process_id;
|
||||||
|
33
util/win/xp_compat.h
Normal file
33
util/win/xp_compat.h
Normal 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_
|
Loading…
x
Reference in New Issue
Block a user