本文整理汇总了C++中RtlLengthSid函数的典型用法代码示例。如果您正苦于以下问题:C++ RtlLengthSid函数的具体用法?C++ RtlLengthSid怎么用?C++ RtlLengthSid使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RtlLengthSid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RtlLengthSecurityDescriptor
/*
* @implemented
*/
ULONG
NTAPI
RtlLengthSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
{
PISECURITY_DESCRIPTOR Sd;
PSID Owner, Group;
PACL Sacl, Dacl;
ULONG Length;
PAGED_CODE_RTL();
/* Start with the initial length of the SD itself */
Sd = (PISECURITY_DESCRIPTOR)SecurityDescriptor;
if (Sd->Control & SE_SELF_RELATIVE)
{
Length = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
}
else
{
Length = sizeof(SECURITY_DESCRIPTOR);
}
/* Add the length of the individual subcomponents */
Owner = SepGetOwnerFromDescriptor(Sd);
if (Owner) Length += ROUND_UP(RtlLengthSid(Owner), sizeof(ULONG));
Group = SepGetGroupFromDescriptor(Sd);
if (Group) Length += ROUND_UP(RtlLengthSid(Group), sizeof(ULONG));
Dacl = SepGetDaclFromDescriptor(Sd);
if (Dacl) Length += ROUND_UP(Dacl->AclSize, sizeof(ULONG));
Sacl = SepGetSaclFromDescriptor(Sd);
if (Sacl) Length += ROUND_UP(Sacl->AclSize, sizeof(ULONG));
/* Return the final length */
return Length;
}
示例2: RtlAccessTokenRelativeSize
static
ULONG
RtlAccessTokenRelativeSize(
PACCESS_TOKEN pToken
)
{
BOOLEAN isLocked = FALSE;
ULONG ulRelativeSize = 0;
ULONG i = 0;
ulRelativeSize += sizeof(ACCESS_TOKEN_SELF_RELATIVE);
Align32(&ulRelativeSize);
SHARED_LOCK_RWLOCK(&pToken->RwLock, isLocked);
ulRelativeSize += RtlLengthSid(pToken->User.Sid);
Align32(&ulRelativeSize);
if (pToken->Groups)
{
ulRelativeSize += sizeof(SID_AND_ATTRIBUTES_SELF_RELATIVE) * pToken->GroupCount;
Align32(&ulRelativeSize);
for (i = 0; i < pToken->GroupCount; i++)
{
ulRelativeSize += RtlLengthSid(pToken->Groups[i].Sid);
Align32(&ulRelativeSize);
}
}
if (pToken->Privileges)
{
ulRelativeSize += sizeof(pToken->Privileges[0]) * pToken->PrivilegeCount;
Align32(&ulRelativeSize);
}
if (pToken->Owner)
{
ulRelativeSize += RtlLengthSid(pToken->Owner);
Align32(&ulRelativeSize);
}
if (pToken->PrimaryGroup)
{
ulRelativeSize += RtlLengthSid(pToken->PrimaryGroup);
Align32(&ulRelativeSize);
}
if (pToken->DefaultDacl)
{
ulRelativeSize += RtlGetAclSize(pToken->DefaultDacl);
Align32(&ulRelativeSize);
}
UNLOCK_RWLOCK(&pToken->RwLock, isLocked);
return ulRelativeSize;
}
示例3: LsaSrvDuplicateSid
NTSTATUS
LsaSrvDuplicateSid(
PSID *ppSidOut,
PSID pSidIn
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PSID pSid = NULL;
ULONG ulSidSize = 0;
ulSidSize = RtlLengthSid(pSidIn);
ntStatus = LsaSrvAllocateMemory((void**)&pSid,
ulSidSize);
BAIL_ON_NTSTATUS_ERROR(ntStatus);
ntStatus = RtlCopySid(ulSidSize, pSid, pSidIn);
BAIL_ON_NTSTATUS_ERROR(ntStatus);
*ppSidOut = pSid;
cleanup:
return ntStatus;
error:
if (pSid) {
LsaSrvFreeMemory(pSid);
}
*ppSidOut = NULL;
goto cleanup;
}
示例4: PhSvcCallAddAccountRight
NTSTATUS PhSvcCallAddAccountRight(
_In_ PSID AccountSid,
_In_ PUNICODE_STRING UserRight
)
{
NTSTATUS status;
PHSVC_API_MSG m;
PVOID accountSid = NULL;
PVOID userRight = NULL;
if (!PhSvcClPortHandle)
return STATUS_PORT_DISCONNECTED;
m.ApiNumber = PhSvcAddAccountRightApiNumber;
status = STATUS_NO_MEMORY;
if (!(accountSid = PhSvcpCreateString(AccountSid, RtlLengthSid(AccountSid), &m.u.AddAccountRight.i.AccountSid)))
goto CleanupExit;
if (!(userRight = PhSvcpCreateString(UserRight->Buffer, UserRight->Length, &m.u.AddAccountRight.i.UserRight)))
goto CleanupExit;
status = PhSvcpCallServer(&m);
CleanupExit:
if (userRight) PhSvcpFreeHeap(userRight);
if (accountSid) PhSvcpFreeHeap(accountSid);
return status;
}
示例5: RtlDuplicateSid
NTSTATUS
RtlDuplicateSid(
OUT PSID* NewSid,
IN PSID OriginalSid
)
{
NTSTATUS status = STATUS_SUCCESS;
ULONG length = RtlLengthSid(OriginalSid);
PSID resultSid = NULL;
status = RTL_ALLOCATE(&resultSid, SID, length);
GOTO_CLEANUP_ON_STATUS(status);
RtlCopyMemory(resultSid, OriginalSid, length);
cleanup:
if (!NT_SUCCESS(status))
{
RTL_FREE(&resultSid);
}
*NewSid = resultSid;
return status;
}
示例6: NetAllocateLocalGroupMembersInfo0
static
DWORD
NetAllocateLocalGroupMembersInfo0(
PVOID *ppCursor,
PDWORD pdwSpaceLeft,
PVOID pSource,
PDWORD pdwSize,
NET_VALIDATION_LEVEL eValidation
)
{
DWORD err = ERROR_SUCCESS;
PVOID pCursor = NULL;
DWORD dwSpaceLeft = 0;
DWORD dwSize = 0;
PSID pSid = (PSID)pSource;
DWORD dwSidLen = 0;
if (pdwSpaceLeft)
{
dwSpaceLeft = *pdwSpaceLeft;
}
if (pdwSize)
{
dwSize = *pdwSize;
}
if (ppCursor)
{
pCursor = *ppCursor;
}
dwSidLen = RtlLengthSid(pSid);
/* lgrmi0_sid */
err = NetAllocBufferSid(&pCursor,
&dwSpaceLeft,
pSid,
dwSidLen,
&dwSize,
eValidation);
BAIL_ON_WIN_ERROR(err);
if (pdwSpaceLeft)
{
*pdwSpaceLeft = dwSpaceLeft;
}
if (pdwSize)
{
*pdwSize = dwSize;
}
cleanup:
return err;
error:
goto cleanup;
}
示例7: RtlEqualSid
BOOLEAN
RtlEqualSid(
IN PSID Sid1,
IN PSID Sid2
)
{
return ((Sid1->SubAuthorityCount == Sid2->SubAuthorityCount) &&
RtlEqualMemory(Sid1, Sid2, RtlLengthSid(Sid1)));
}
示例8: RtlCopySid
/*
* @implemented
*/
NTSTATUS NTAPI
RtlCopySid(ULONG BufferLength,
PSID Dest,
PSID Src)
{
PAGED_CODE_RTL();
if (BufferLength < RtlLengthSid(Src))
{
return STATUS_UNSUCCESSFUL;
}
memmove(Dest,
Src,
RtlLengthSid(Src));
return STATUS_SUCCESS;
}
示例9: SepCreateImpersonationTokenDacl
NTSTATUS NTAPI
SepCreateImpersonationTokenDacl(PTOKEN Token,
PTOKEN PrimaryToken,
PACL *Dacl)
{
ULONG AclLength;
PVOID TokenDacl;
PAGED_CODE();
AclLength = sizeof(ACL) +
(sizeof(ACE) + RtlLengthSid(SeAliasAdminsSid)) +
(sizeof(ACE) + RtlLengthSid(SeRestrictedCodeSid)) +
(sizeof(ACE) + RtlLengthSid(SeLocalSystemSid)) +
(sizeof(ACE) + RtlLengthSid(Token->UserAndGroups->Sid)) +
(sizeof(ACE) + RtlLengthSid(PrimaryToken->UserAndGroups->Sid));
TokenDacl = ExAllocatePoolWithTag(PagedPool, AclLength, TAG_ACL);
if (TokenDacl == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlCreateAcl(TokenDacl, AclLength, ACL_REVISION);
RtlAddAccessAllowedAce(TokenDacl, ACL_REVISION, GENERIC_ALL,
Token->UserAndGroups->Sid);
RtlAddAccessAllowedAce(TokenDacl, ACL_REVISION, GENERIC_ALL,
PrimaryToken->UserAndGroups->Sid);
RtlAddAccessAllowedAce(TokenDacl, ACL_REVISION, GENERIC_ALL,
SeAliasAdminsSid);
RtlAddAccessAllowedAce(TokenDacl, ACL_REVISION, GENERIC_ALL,
SeLocalSystemSid);
/* FIXME */
#if 0
if (Token->RestrictedSids != NULL || PrimaryToken->RestrictedSids != NULL)
{
RtlAddAccessAllowedAce(TokenDacl, ACL_REVISION, GENERIC_ALL,
SeRestrictedCodeSid);
}
#endif
return STATUS_SUCCESS;
}
示例10: CsrCreateLocalSystemSD
/*++
* @name CsrCreateLocalSystemSD
*
* The CsrCreateLocalSystemSD routine creates a Security Descriptor for
* the local account with PORT_ALL_ACCESS.
*
* @param LocalSystemSd
* Pointer to a pointer to the security descriptor to create.
*
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL otherwise.
*
* @remarks None.
*
*--*/
NTSTATUS
NTAPI
CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd)
{
SID_IDENTIFIER_AUTHORITY NtSidAuthority = {SECURITY_NT_AUTHORITY};
PSID SystemSid;
ULONG Length;
PSECURITY_DESCRIPTOR SystemSd;
PACL Dacl;
NTSTATUS Status;
/* Initialize the System SID */
RtlAllocateAndInitializeSid(&NtSidAuthority, 1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0,
&SystemSid);
/* Get the length of the SID */
Length = RtlLengthSid(SystemSid) + sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE);
/* Allocate a buffer for the Security Descriptor, with SID and DACL */
SystemSd = RtlAllocateHeap(CsrHeap, 0, SECURITY_DESCRIPTOR_MIN_LENGTH + Length);
/* Set the pointer to the DACL */
Dacl = (PACL)((ULONG_PTR)SystemSd + SECURITY_DESCRIPTOR_MIN_LENGTH);
/* Now create the SD itself */
Status = RtlCreateSecurityDescriptor(SystemSd, SECURITY_DESCRIPTOR_REVISION);
if (!NT_SUCCESS(Status)) goto Quit;
/* Create the DACL for it */
RtlCreateAcl(Dacl, Length, ACL_REVISION2);
/* Create the ACE */
Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, PORT_ALL_ACCESS, SystemSid);
if (!NT_SUCCESS(Status)) goto Quit;
/* Clear the DACL in the SD */
Status = RtlSetDaclSecurityDescriptor(SystemSd, TRUE, Dacl, FALSE);
if (!NT_SUCCESS(Status)) goto Quit;
Quit:
if (!NT_SUCCESS(Status))
{
RtlFreeHeap(CsrHeap, 0, SystemSd);
SystemSd = NULL;
}
/* Free the SID and return*/
RtlFreeSid(SystemSid);
*LocalSystemSd = SystemSd;
return Status;
}
示例11: RtlCopySid
/**************************************************************************
* RtlCopySid [[email protected]]
*/
DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
{
if (!pSourceSid || !RtlValidSid(pSourceSid) ||
(nDestinationSidLength < RtlLengthSid(pSourceSid)))
return FALSE;
if (nDestinationSidLength < (pSourceSid->SubAuthorityCount*4+8))
return FALSE;
memmove(pDestinationSid, pSourceSid, pSourceSid->SubAuthorityCount*4+8);
return TRUE;
}
示例12: LsapRpcCopySid
NTSTATUS
LsapRpcCopySid(
IN OPTIONAL PLSAP_MM_FREE_LIST FreeList,
OUT PSID *DestinationSid,
IN PSID SourceSid
)
/*++
Routine Description:
This function makes a copy of a Sid in which memory is allocated
via MIDL user allocate. It is called to return Sids via RPC to
the client.
Arguments:
FreeList - Optional pointer to Free List.
DestinationSid - Receives a pointer to the Sid copy.
SourceSid - Pointer to the Sid to be copied.
Return Value:
NTSTATUS - Standard Nt Result Code
STATUS_SUCCESS - The call completed successfully.
STATUS_INSUFFICIENT_RESOURCES - Insufficient system resources,
such as memory, to complete the call.
--*/
{
NTSTATUS Status;
ULONG SidLength = RtlLengthSid( SourceSid );
Status = LsapMmAllocateMidl(
FreeList,
DestinationSid,
SidLength
);
if (NT_SUCCESS(Status)) {
RtlCopyMemory( *DestinationSid, SourceSid, SidLength );
}
return( Status );
}
示例13: RtlEqualSid
/******************************************************************************
* RtlEqualSid [[email protected]]
*
*/
BOOL WINAPI RtlEqualSid( PSID pSid1, PSID pSid2 )
{
if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
return FALSE;
if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
return FALSE;
if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
return FALSE;
return TRUE;
}
示例14: RtlCopySidAndAttributesArray
/*
* @implemented
*/
NTSTATUS NTAPI
RtlCopySidAndAttributesArray(ULONG Count,
PSID_AND_ATTRIBUTES Src,
ULONG SidAreaSize,
PSID_AND_ATTRIBUTES Dest,
PVOID SidArea,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize)
{
ULONG SidLength;
ULONG Length;
ULONG i;
PAGED_CODE_RTL();
Length = SidAreaSize;
for (i=0; i<Count; i++)
{
if (RtlLengthSid(Src[i].Sid) > Length)
{
return(STATUS_BUFFER_TOO_SMALL);
}
SidLength = RtlLengthSid(Src[i].Sid);
Length = Length - SidLength;
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(SidLength,
SidArea,
Src[i].Sid);
SidArea = (PVOID)((ULONG_PTR)SidArea + SidLength);
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return(STATUS_SUCCESS);
}
示例15: GetAccountDomainSid
static
NTSTATUS
GetAccountDomainSid(PRPC_SID *Sid)
{
LSAPR_HANDLE PolicyHandle = NULL;
PLSAPR_POLICY_INFORMATION PolicyInfo = NULL;
ULONG Length = 0;
NTSTATUS Status;
Status = LsaIOpenPolicyTrusted(&PolicyHandle);
if (!NT_SUCCESS(Status))
{
TRACE("LsaIOpenPolicyTrusted() failed (Status 0x%08lx)\n", Status);
return Status;
}
Status = LsarQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation,
&PolicyInfo);
if (!NT_SUCCESS(Status))
{
TRACE("LsarQueryInformationPolicy() failed (Status 0x%08lx)\n", Status);
goto done;
}
Length = RtlLengthSid(PolicyInfo->PolicyAccountDomainInfo.Sid);
*Sid = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
if (*Sid == NULL)
{
ERR("Failed to allocate SID\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
goto done;
}
memcpy(*Sid, PolicyInfo->PolicyAccountDomainInfo.Sid, Length);
done:
if (PolicyInfo != NULL)
LsaIFree_LSAPR_POLICY_INFORMATION(PolicyAccountDomainInformation,
PolicyInfo);
if (PolicyHandle != NULL)
LsarClose(&PolicyHandle);
return Status;
}