mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-17 16:43:53 +00:00
win: Fix use of THREAD_ALL_ACCESS on XP
OpenThread(THREAD_ALL_ACCESS, ...) fails on XP with the uplevel value of THREAD_ALL_ACCESS, so use the XP value. Similar to the PROCESS_ALL_ACCESS in https://codereview.chromium.org/1337133002/ but I mistakenly only grepped for PROCESS_ALL_ACCESS at that point. R=mark@chromium.org BUG=crashpad:50 Review URL: https://codereview.chromium.org/1337653005 .
This commit is contained in:
parent
d62866f734
commit
c3cc1d19c1
@ -20,7 +20,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "test/errors.h"
|
||||||
#include "test/win/win_child_process.h"
|
#include "test/win/win_child_process.h"
|
||||||
|
#include "util/win/xp_compat.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -33,23 +35,33 @@ bool SuspendCountMatches(HANDLE process, DWORD desired_suspend_count) {
|
|||||||
DWORD process_id = GetProcessId(process);
|
DWORD process_id = GetProcessId(process);
|
||||||
|
|
||||||
ScopedKernelHANDLE snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0));
|
ScopedKernelHANDLE snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0));
|
||||||
if (!snapshot.is_valid())
|
if (!snapshot.is_valid()) {
|
||||||
|
ADD_FAILURE() << ErrorMessage("CreateToolhelp32Snapshot");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
THREADENTRY32 te;
|
THREADENTRY32 te;
|
||||||
te.dwSize = sizeof(te);
|
te.dwSize = sizeof(te);
|
||||||
if (!Thread32First(snapshot.get(), &te))
|
|
||||||
|
BOOL ret = Thread32First(snapshot.get(), &te);
|
||||||
|
if (!ret) {
|
||||||
|
ADD_FAILURE() << ErrorMessage("Thread32First");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
if (te.dwSize >= offsetof(THREADENTRY32, th32OwnerProcessID) +
|
if (te.dwSize >= offsetof(THREADENTRY32, th32OwnerProcessID) +
|
||||||
sizeof(te.th32OwnerProcessID) &&
|
sizeof(te.th32OwnerProcessID) &&
|
||||||
te.th32OwnerProcessID == process_id) {
|
te.th32OwnerProcessID == process_id) {
|
||||||
ScopedKernelHANDLE thread(
|
ScopedKernelHANDLE thread(
|
||||||
OpenThread(THREAD_ALL_ACCESS, false, te.th32ThreadID));
|
OpenThread(kXPThreadAllAccess, false, te.th32ThreadID));
|
||||||
|
EXPECT_TRUE(thread.is_valid()) << ErrorMessage("OpenThread");
|
||||||
DWORD result = SuspendThread(thread.get());
|
DWORD result = SuspendThread(thread.get());
|
||||||
EXPECT_NE(result, static_cast<DWORD>(-1));
|
EXPECT_NE(result, static_cast<DWORD>(-1))
|
||||||
if (result != static_cast<DWORD>(-1))
|
<< ErrorMessage("SuspendThread");
|
||||||
ResumeThread(thread.get());
|
if (result != static_cast<DWORD>(-1)) {
|
||||||
|
EXPECT_NE(ResumeThread(thread.get()), static_cast<DWORD>(-1))
|
||||||
|
<< ErrorMessage("ResumeThread");
|
||||||
|
}
|
||||||
if (result != desired_suspend_count)
|
if (result != desired_suspend_count)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,14 @@ enum {
|
|||||||
//! Requesting `PROCESS_ALL_ACCESS` with the value defined when building
|
//! Requesting `PROCESS_ALL_ACCESS` with the value defined when building
|
||||||
//! against a Vista+ SDK results in `ERROR_ACCESS_DENIED` when running on XP.
|
//! 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
|
//! See https://msdn.microsoft.com/en-ca/library/windows/desktop/ms684880.aspx
|
||||||
kXPProcessAllAccess = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF
|
kXPProcessAllAccess = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF,
|
||||||
|
|
||||||
|
//! \brief This is the XP-suitable value of `THREAD_ALL_ACCESS`.
|
||||||
|
//!
|
||||||
|
//! Requesting `THREAD_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-us/library/windows/desktop/ms686769.aspx
|
||||||
|
kXPThreadAllAccess = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace crashpad
|
} // namespace crashpad
|
||||||
|
Loading…
x
Reference in New Issue
Block a user