MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / GetServiceSid

Method GetServiceSid

WinSysCore/ServiceManager.cpp:305–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305Sid ServiceManager::GetServiceSid(const wchar_t* name) {
306 bool userService = (GetServiceStatus(name).Type & ServiceType::UserService) == ServiceType::UserService;
307 BYTE sid[SECURITY_MAX_SID_SIZE];
308 WCHAR domain[32];
309 DWORD domainSize = _countof(domain), sidSize = _countof(sid);
310 SID_NAME_USE use;
311 std::wstring serviceName(L"NT SERVICE\\");
312 serviceName += name;
313 if (userService) // use base name
314 serviceName = serviceName.substr(0, serviceName.rfind(L'_'));
315
316 if (::LookupAccountName(nullptr, serviceName.c_str(), (PSID)sid,
317 &sidSize, domain, &domainSize, &use))
318 return Sid((PSID)sid);
319
320 return Sid();
321}

Callers

nothing calls this directly

Calls 1

SidClass · 0.85

Tested by

no test coverage detected