Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { |
|
rvargas (doing something else)
2015/02/12 22:47:12
This looks a little weird but I'm strictly followi
cpu_(ooo_6.6-7.5)
2015/02/13 00:25:12
Acknowledged.
| |
| 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 |
| OLD | NEW |