MCPcopy Create free account
hub / github.com/Meowmycks/LetMeowIn / IsSystemProcess

Function IsSystemProcess

src/main.cpp:447–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447BOOL IsSystemProcess(HANDLE hToken) {
448 BOOL isSystem = FALSE;
449 NTSTATUS status = STATUS_SUCCESS;
450 PTOKEN_USER pTokenUser = nullptr;
451 ULONG pTokenUserSize = sizeof(PTOKEN_USER);
452 pTokenUser = (PTOKEN_USER)malloc(pTokenUserSize);
453
454 const uintptr_t jmpNtQIT = GetOffset(unASCIIme<std::string>(TIQtN));
455 const int NtQIT = GetVal<int>(unASCIIme<std::string>(TIQtN));
456
457 SetJumpAddress(jmpNtQIT);
458 status = NtQueryInformationToken(hToken, TokenUser, pTokenUser, pTokenUserSize, &pTokenUserSize, NtQIT);
459
460 while (status == STATUS_BUFFER_TOO_SMALL || status == STATUS_INFO_LENGTH_MISMATCH) {
461 if (pTokenUser) free(pTokenUser);
462 pTokenUser = (PTOKEN_USER)malloc(pTokenUserSize);
463 if (!pTokenUser) {
464 return FALSE;
465 }
466 SetJumpAddress(jmpNtQIT);
467 status = NtQueryInformationToken(hToken, TokenUser, pTokenUser, pTokenUserSize, &pTokenUserSize, NtQIT);
468 }
469
470 if (!NT_SUCCESS(status)) {
471 if (pTokenUser) free(pTokenUser);
472 return FALSE;
473 }
474
475 PSID pSystemSid;
476 ConvertStringSidToSid(L"S-1-5-18", &pSystemSid);
477 isSystem = EqualSid(pTokenUser->User.Sid, pSystemSid);
478 free(pTokenUser);
479 LocalFree(pSystemSid);
480
481 return isSystem;
482}
483
484HANDLE FindersKeepers(LUID luid = { 0,0 }) {
485 PSYSTEM_PROCESS_INFORMATION sysProcInfo = GetSysProcInfo();

Callers 1

FindersKeepersFunction · 0.85

Calls 1

GetOffsetFunction · 0.85

Tested by

no test coverage detected