Commit a81d074f authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Fix handle verifier assert in process_info_win.cc.

The current process' pseudo handle isn't meant to be closed.

Bug: 748431
Change-Id: Id0366fd55aced8022745d9576411971a2a9ca685
Reviewed-on: https://chromium-review.googlesource.com/811892Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522483}
parent e87d6dc3
......@@ -15,16 +15,11 @@ namespace base {
namespace {
base::win::ScopedHandle GetCurrentProcessToken() {
HANDLE GetCurrentProcessToken() {
HANDLE process_token;
BOOL result =
OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &process_token);
// These checks are turned on in release builds to debug
// https://bugs.chromium.org/p/chromium/issues/detail?id=748431.
PCHECK(result);
CHECK(process_token != NULL);
CHECK(process_token != INVALID_HANDLE_VALUE);
return base::win::ScopedHandle(process_token);
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token);
DCHECK(process_token != NULL && process_token != INVALID_HANDLE_VALUE);
return process_token;
}
} // namespace
......@@ -43,11 +38,11 @@ const Time CurrentProcessInfo::CreationTime() {
}
IntegrityLevel GetCurrentProcessIntegrityLevel() {
base::win::ScopedHandle scoped_process_token(GetCurrentProcessToken());
HANDLE process_token(GetCurrentProcessToken());
DWORD token_info_length = 0;
if (::GetTokenInformation(scoped_process_token.Get(), TokenIntegrityLevel,
nullptr, 0, &token_info_length) ||
if (::GetTokenInformation(process_token, TokenIntegrityLevel, nullptr, 0,
&token_info_length) ||
::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return INTEGRITY_UNKNOWN;
}
......@@ -55,9 +50,8 @@ IntegrityLevel GetCurrentProcessIntegrityLevel() {
auto token_label_bytes = std::make_unique<char[]>(token_info_length);
TOKEN_MANDATORY_LABEL* token_label =
reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get());
if (!::GetTokenInformation(scoped_process_token.Get(), TokenIntegrityLevel,
token_label, token_info_length,
&token_info_length)) {
if (!::GetTokenInformation(process_token, TokenIntegrityLevel, token_label,
token_info_length, &token_info_length)) {
return INTEGRITY_UNKNOWN;
}
......@@ -82,14 +76,14 @@ IntegrityLevel GetCurrentProcessIntegrityLevel() {
}
bool IsCurrentProcessElevated() {
base::win::ScopedHandle scoped_process_token(GetCurrentProcessToken());
HANDLE process_token(GetCurrentProcessToken());
// Unlike TOKEN_ELEVATION_TYPE which returns TokenElevationTypeDefault when
// UAC is turned off, TOKEN_ELEVATION returns whether the process is elevated.
DWORD size;
TOKEN_ELEVATION elevation;
if (!GetTokenInformation(scoped_process_token.Get(), TokenElevation,
&elevation, sizeof(elevation), &size)) {
if (!GetTokenInformation(process_token, TokenElevation, &elevation,
sizeof(elevation), &size)) {
PLOG(ERROR) << "GetTokenInformation() failed";
return false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment