MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / IsUserAdmin

Function IsUserAdmin

shared/User.h:5–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <windows.h>
4
5static inline BOOL IsUserAdmin(void) {
6 SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
7 PSID adminsSid = NULL;
8 BOOL result = FALSE;
9
10 if (!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminsSid)) {
11 return FALSE;
12 }
13
14 if (!CheckTokenMembership(NULL, adminsSid, &result)) {
15 result = FALSE;
16 }
17
18 FreeSid(adminsSid);
19 return result;
20}
21
22static inline BOOL IsElevated(void) {
23 HANDLE hToken = NULL;

Callers 5

GetUserTypeMethod · 0.85
RegisterServerFunction · 0.85
LaunchUpdateSiteFunction · 0.85
WriteLogBannerFunction · 0.85
IsAdmin.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected