MCPcopy Create free account
hub / github.com/antonioCoco/RogueWinRM / IsTokenSystem

Function IsTokenSystem

RogueWinRM.cpp:608–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608int IsTokenSystem(HANDLE tok)
609{
610 DWORD Size, UserSize, DomainSize;
611 SID* sid;
612 SID_NAME_USE SidType;
613 TCHAR UserName[64], DomainName[64];
614 TOKEN_USER* User;
615 Size = 0;
616 GetTokenInformation(tok, TokenUser, NULL, 0, &Size);
617 if (!Size)
618 return FALSE;
619
620 User = (TOKEN_USER*)malloc(Size);
621 assert(User);
622 GetTokenInformation(tok, TokenUser, User, Size, &Size);
623 assert(Size);
624 Size = GetLengthSid(User->User.Sid);
625 assert(Size);
626 sid = (SID*)malloc(Size);
627 assert(sid);
628
629 CopySid(Size, sid, User->User.Sid);
630 UserSize = (sizeof UserName / sizeof * UserName) - 1;
631 DomainSize = (sizeof DomainName / sizeof * DomainName) - 1;
632 LookupAccountSid(NULL, sid, UserName, &UserSize, DomainName, &DomainSize, &SidType);
633 free(sid);
634
635 printf("%S\\%S\n", DomainName, UserName);
636 if (!_wcsicmp(UserName, L"SYSTEM"))
637 return 1;
638
639 return 0;
640}
641
642bool isBitsRunning() {
643 SC_HANDLE hService, hSCManager;

Callers 1

RunRogueWinRMFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected