| 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 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 *group = 0; | 52 *group = 0; |
| 53 | 53 |
| 54 // groups are listed in DECREASING order of importance | 54 // groups are listed in DECREASING order of importance |
| 55 // (eg. If a user is a member of both the admin group and | 55 // (eg. If a user is a member of both the admin group and |
| 56 // the power user group, it is more useful to list the user | 56 // the power user group, it is more useful to list the user |
| 57 // as an admin) | 57 // as an admin) |
| 58 DWORD user_groups[] = {DOMAIN_ALIAS_RID_ADMINS, | 58 DWORD user_groups[] = {DOMAIN_ALIAS_RID_ADMINS, |
| 59 DOMAIN_ALIAS_RID_POWER_USERS}; | 59 DOMAIN_ALIAS_RID_POWER_USERS}; |
| 60 SID_IDENTIFIER_AUTHORITY nt_authority = {SECURITY_NT_AUTHORITY}; | 60 SID_IDENTIFIER_AUTHORITY nt_authority = {SECURITY_NT_AUTHORITY}; |
| 61 | 61 |
| 62 for (int i = 0; i < arraysize(user_groups) && *group == 0; ++i) { | 62 for (size_t i = 0; i < arraysize(user_groups) && *group == 0; ++i) { |
| 63 PSID current_group; | 63 PSID current_group; |
| 64 if (AllocateAndInitializeSid(&nt_authority, 2, | 64 if (AllocateAndInitializeSid(&nt_authority, 2, |
| 65 SECURITY_BUILTIN_DOMAIN_RID, | 65 SECURITY_BUILTIN_DOMAIN_RID, |
| 66 user_groups[i], 0, 0, 0, 0, | 66 user_groups[i], 0, 0, 0, 0, |
| 67 0, 0, ¤t_group)) { | 67 0, 0, ¤t_group)) { |
| 68 BOOL current_level; | 68 BOOL current_level; |
| 69 if (CheckTokenMembership(NULL, current_group, ¤t_level) && | 69 if (CheckTokenMembership(NULL, current_group, ¤t_level) && |
| 70 current_level) { | 70 current_level) { |
| 71 *group = user_groups[i]; | 71 *group = user_groups[i]; |
| 72 } | 72 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 evaluated = true; | 117 evaluated = true; |
| 118 if (!has_rights) | 118 if (!has_rights) |
| 119 ASSERT_STRING("ProcessInfo::HasAdminRights: Does not have admin rights."); | 119 ASSERT_STRING("ProcessInfo::HasAdminRights: Does not have admin rights."); |
| 120 | 120 |
| 121 return has_rights; | 121 return has_rights; |
| 122 } | 122 } |
| 123 | 123 |
| 124 }; // namespace | 124 }; // namespace |
| OLD | NEW |