Add AllocateAndInitializeSid()
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
322ada3dd5
commit
ad2d67e680
@ -80,5 +80,19 @@ namespace UnitTests
|
|||||||
else
|
else
|
||||||
Assert::IsTrue(!system_impersonator && GetLastError() == ERROR_ACCESS_DENIED);
|
Assert::IsTrue(!system_impersonator && GetLastError() == ERROR_ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(AllocateAndInitializeSid)
|
||||||
|
{
|
||||||
|
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
|
||||||
|
winstd::security_id pSIDEveryone;
|
||||||
|
Assert::IsTrue(::AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, pSIDEveryone));
|
||||||
|
|
||||||
|
SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
|
||||||
|
winstd::security_id pSIDSystem;
|
||||||
|
Assert::IsTrue(::AllocateAndInitializeSid(&SIDAuthNT, 1, SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, pSIDSystem));
|
||||||
|
|
||||||
|
winstd::security_id pSIDAdmin;
|
||||||
|
Assert::IsTrue(::AllocateAndInitializeSid(&SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, pSIDAdmin));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2429,6 +2429,21 @@ static BOOL DuplicateTokenEx(_In_ HANDLE hExistingToken, _In_ DWORD dwDesiredAcc
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Allocates and initializes a security identifier (SID) with up to eight subauthorities.
|
||||||
|
///
|
||||||
|
/// \sa [AllocateAndInitializeSid function](https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-allocateandinitializesid)
|
||||||
|
///
|
||||||
|
static BOOL AllocateAndInitializeSid(_In_ PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, _In_ BYTE nSubAuthorityCount, _In_ DWORD nSubAuthority0, _In_ DWORD nSubAuthority1, _In_ DWORD nSubAuthority2, _In_ DWORD nSubAuthority3, _In_ DWORD nSubAuthority4, _In_ DWORD nSubAuthority5, _In_ DWORD nSubAuthority6, _In_ DWORD nSubAuthority7, _Inout_ winstd::security_id& Sid)
|
||||||
|
{
|
||||||
|
PSID h;
|
||||||
|
if (AllocateAndInitializeSid(pIdentifierAuthority, nSubAuthorityCount, nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, &h)) {
|
||||||
|
Sid.attach(h);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user