Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: rlz/win/lib/process_info.cc

Issue 921913002: Move GetProcessIntegrityLevel to file_info.h and remove the handle argument. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Information about the current process. 5 // Information about the current process.
6 6
7 #include "rlz/win/lib/process_info.h" 7 #include "rlz/win/lib/process_info.h"
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process_info.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/win/scoped_handle.h" 14 #include "base/win/scoped_handle.h"
15 #include "base/win/win_util.h" 15 #include "base/win/win_util.h"
16 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
17 #include "rlz/lib/assert.h" 17 #include "rlz/lib/assert.h"
18 18
19 namespace { 19 namespace {
20 20
21 HRESULT GetElevationType(PTOKEN_ELEVATION_TYPE elevation) { 21 HRESULT GetElevationType(PTOKEN_ELEVATION_TYPE elevation) {
22 if (!elevation) 22 if (!elevation)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 bool ProcessInfo::HasAdminRights() { 94 bool ProcessInfo::HasAdminRights() {
95 static bool evaluated = false; 95 static bool evaluated = false;
96 static bool has_rights = false; 96 static bool has_rights = false;
97 97
98 if (!evaluated) { 98 if (!evaluated) {
99 if (IsRunningAsSystem()) { 99 if (IsRunningAsSystem()) {
100 has_rights = true; 100 has_rights = true;
101 } else if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 101 } else if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
102 TOKEN_ELEVATION_TYPE elevation; 102 TOKEN_ELEVATION_TYPE elevation;
103 base::IntegrityLevel level; 103 if (SUCCEEDED(GetElevationType(&elevation))) {
104 104 base::IntegrityLevel level = base::GetCurrentProcessIntegrityLevel();
105 if (SUCCEEDED(GetElevationType(&elevation)) && 105 if (level != base::INTEGRITY_UNKNOWN) {
106 base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), &level)) 106 has_rights = (elevation == TokenElevationTypeFull) ||
107 has_rights = (elevation == TokenElevationTypeFull) || 107 (level == base::HIGH_INTEGRITY);
108 (level == base::HIGH_INTEGRITY); 108 }
109 }
109 } else { 110 } else {
110 long group = 0; 111 long group = 0;
111 if (GetUserGroup(&group)) 112 if (GetUserGroup(&group))
112 has_rights = (group == DOMAIN_ALIAS_RID_ADMINS); 113 has_rights = (group == DOMAIN_ALIAS_RID_ADMINS);
113 } 114 }
114 } 115 }
115 116
116 evaluated = true; 117 evaluated = true;
117 if (!has_rights) 118 if (!has_rights)
118 ASSERT_STRING("ProcessInfo::HasAdminRights: Does not have admin rights."); 119 ASSERT_STRING("ProcessInfo::HasAdminRights: Does not have admin rights.");
119 120
120 return has_rights; 121 return has_rights;
121 } 122 }
122 123
123 }; // namespace 124 }; // namespace
OLDNEW
« no previous file with comments | « cloud_print/virtual_driver/win/port_monitor/port_monitor_dll.cc ('k') | rlz/win/lib/registry_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698