Added some security functions

svn path=/trunk/; revision=1049
This commit is contained in:
Eric Kohl 2000-03-12 01:18:18 +00:00
parent 9488b3031c
commit afa23cb264
7 changed files with 494 additions and 31 deletions

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_SEFUNCS_H
#define _INCLUDE_DDK_SEFUNCS_H
/* $Id: sefuncs.h,v 1.5 2000/01/26 10:07:22 dwelch Exp $ */
/* $Id: sefuncs.h,v 1.6 2000/03/12 01:18:18 ekohl Exp $ */
NTSTATUS STDCALL RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor, ULONG Revision);
BOOLEAN STDCALL RtlValidSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
ULONG STDCALL RtlLengthSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
@ -13,7 +13,10 @@ NTSTATUS STDCALL RtlGetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDes
ULONG STDCALL RtlLengthRequiredSid (UCHAR SubAuthorityCount);
NTSTATUS STDCALL RtlInitializeSid (PSID Sid, PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, UCHAR SubAuthorityCount);
PULONG STDCALL RtlSubAuthoritySid (PSID Sid, ULONG SubAuthority);
NTSTATUS STDCALL RtlCopySid (ULONG BufferLength, PSID Dest, PSID Src);
BOOLEAN STDCALL RtlEqualSid(PSID Sid1, PSID Sid2);
ULONG STDCALL RtlLengthSid (PSID Sid);
BOOLEAN STDCALL RtlValidSid (PSID Sid);
NTSTATUS STDCALL RtlAbsoluteToSelfRelativeSD (PSECURITY_DESCRIPTOR AbsSD, PSECURITY_DESCRIPTOR RelSD, PULONG BufferLength);
BOOLEAN STDCALL SeAccessCheck (IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.45 2000/03/09 16:01:24 ekohl Exp $
; $Id: ntdll.def,v 1.46 2000/03/12 01:17:23 ekohl Exp $
;
; ReactOS Operating System
;
@ -232,16 +232,16 @@ RtlAbsoluteToSelfRelativeSD@12
RtlAcquirePebLock@0
;RtlAcqureResourceExclusive
;RtlAcqureResourceShared
;RtlAddAccessAllowedAce
RtlAddAccessAllowedAce@16
;RtlAddAccessDeniedAce
;RtlAddAce
RtlAddAce@20
;RtlAddActionToRXact
;RtlAtomToAtomTable
;RtlAddAttributeActionToRXact
;RtlAddAuditAccessToAce
;RtlAddCompoundAce
;RtlAdjustPrivilege
;RtlAllocateAndInitializeSid
RtlAllocateAndInitializeSid@44
;RtlAllocateHandle
RtlAllocateHeap@12
RtlAnsiCharToUnicodeChar@4
@ -280,11 +280,11 @@ RtlConvertUlongToLargeInteger@4
;RtlCopyLuid
;RtlCopyLuidAndAttributesArray
;RtlCopySecurityDescriptor
;RtlCopySid
RtlCopySid@12
;RtlCopySidAndAttributesArray
RtlCopyString@8
RtlCopyUnicodeString@8
;RtlCreateAcl
RtlCreateAcl@12
;RtlCreateAndSetSD
;RtlCreateAtomTable
RtlCreateEnvironment@8
@ -298,7 +298,7 @@ RtlCreateSecurityDescriptor@8
RtlCreateUnicodeString@8
RtlCreateUnicodeStringFromAsciiz@8
RtlCreateUserProcess@40
;RtlCreateuserSecurityObject
;RtlCreateUserSecurityObject
RtlCreateUserThread@40
;RtlCustomCPToUnicodeN
;RtlCutoverTimeToSystemTime
@ -338,8 +338,8 @@ RtlEnterCriticalSection@4
;RtlEqualComputerName
;RtlEqualDomainName
;RtlEqualLuid
;RtlEqualPrefixSid
;RtlEqualSid
RtlEqualPrefixSid@8
RtlEqualSid@8
RtlEqualString@12
RtlEqualUnicodeString@12
RtlEraseUnicodeString@4
@ -357,7 +357,7 @@ RtlFindLongestRunSet@8
;RtlFindMessage
RtlFindSetBits@12
RtlFindSetBitsAndClear@12
;RtlFirstFreeAce
RtlFirstFreeAce@8
;RtlFlushPropertySet
;RtlFormatCurrentUserKeyPath
;RtlFormatMessage
@ -365,14 +365,14 @@ RtlFreeAnsiString@4
;RtlFreeHandle
RtlFreeHeap@12
RtlFreeOemString@4
;RtlFreeSid
RtlFreeSid@4
RtlFreeUnicodeString@4
;RtlFreeUserThreadStack
;RtlGenerate8dot3Name
;RtlGetAce
;RtlGetCallersAddress
;RtlGetCompressionWorkSpaceSize
;RtlGetControlSecurityDescriptor
RtlGetControlSecurityDescriptor@12
RtlGetCurrentDirectory_U@8
RtlGetDaclSecurityDescriptor@16
;RtlGetElementGenericTable
@ -387,7 +387,7 @@ RtlGetProcessHeap@0
;RtlGetSaclSecurityDescriptor
;RtlGetUserInfoHeap
;RtlGuidToPropertySetName
;RtlIdentifierAuthoritySid
RtlIdentifierAuthoritySid@4
;RtlImageDirectoryEntryToData
;RtlImageNtHeader
;RtlImageRvaToSection
@ -406,7 +406,7 @@ RtlInitializeCriticalSection@4
;RtlInitializeHandleTable
;RtlInitializeRXact
;RtlInitializeResource
;RtlInitializeSid
RtlInitializeSid@12
;RtlInsertElementGenericTable
RtlIntegerToChar@16
RtlIntegerToUnicodeString@12
@ -425,9 +425,9 @@ RtlLargeIntegerShiftRight@12
RtlLargeIntegerSubtract@16
;RtlLargeIntegerToChar
RtlLeaveCriticalSection@4
;RtlLengthRequiredSid
RtlLengthRequiredSid@4
RtlLengthSecurityDescriptor@4
;RtlLengthSid
RtlLengthSid@4
;RtlLocalTimeToSystemTime
RtlLockHeap@4
;RtlLookupAtomInAtomTable
@ -507,8 +507,8 @@ RtlSetOwnerSecurityDescriptor@12
RtlSizeHeap@12
;RtlSplay
;RtlStartRXact
;RtlSubAuthorityCountSid
;RtlSubAuthoritySid
RtlSubAuthorityCountSid@4
RtlSubAuthoritySid@8
;RtlSubtreePredecessor
;RtlSubtreeSuccessor
;RtlSystemTimeToLocalTime
@ -544,7 +544,7 @@ RtlUpperString@8
;RtlUsageHeap
;RtlValidAcl
RtlValidSecurityDescriptor@4
;RtlValidSid
RtlValidSid@4
RtlValidateHeap@12
;RtlValidateProcessHeaps
;RtlWalkHeap

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.34 2000/03/09 16:01:25 ekohl Exp $
; $Id: ntdll.edf,v 1.35 2000/03/12 01:17:23 ekohl Exp $
;
; ReactOS Operating System
;
@ -225,6 +225,9 @@ NtW32Call=NtW32Call@20
NtYieldExecution=NtYieldExecution@0
RtlAbsoluteToSelfRelativeSD=RtlAbsoluteToSelfRelativeSD@12
RtlAcquirePebLock=RtlAcquirePebLock@0
RtlAddAccessAllowedAce=RtlAddAccessAllowedAce@16
RtlAddAce=RtlAddAce@20
RtlAllocateAndInitializeSid=RtlAllocateAndInitializeSid@44
RtlAllocateHeap=RtlAllocateHeap@12
RtlAnsiCharToUnicodeChar=RtlAnsiCharToUnicodeChar@4
RtlAnsiStringToUnicodeSize=RtlAnsiStringToUnicodeSize@4
@ -243,8 +246,10 @@ RtlCompareString=RtlCompareString@12
RtlCompareUnicodeString=RtlCompareUnicodeString@12
RtlConvertLongToLargeInteger=RtlConvertLongToLargeInteger@4
RtlConvertUlongToLargeInteger=RtlConvertUlongToLargeInteger@4
RtlCopySid=RtlCopySid@12
RtlCopyString=RtlCopyString@8
RtlCopyUnicodeString=RtlCopyUnicodeString@8
RtlCreateAcl=RtlCreateAcl@12
RtlCreateEnvironment=RtlCreateEnvironment@8
RtlCreateHeap=RtlCreateHeap@24
RtlCreateProcessParameters=RtlCreateProcessParameters@40
@ -267,6 +272,8 @@ RtlEnlargedIntegerMultiply=RtlEnlargedIntegerMultiply@8
RtlEnlargedUnsignedDivide=RtlEnlargedUnsignedDivide@16
RtlEnlargedUnsignedMultiply=RtlEnlargedUnsignedMultiply@8
RtlEnterCriticalSection=RtlEnterCriticalSection@4
RtlEqualPrefixSid=RtlEqualPrefixSid@8
RtlEqualSid=RtlEqualSid@8
RtlEqualString=RtlEqualString@12
RtlEqualUnicodeString=RtlEqualUnicodeString@12
RtlEraseUnicodeString=RtlEraseUnicodeString@4
@ -278,13 +285,16 @@ RtlFillMemory=RtlFillMemory@12
RtlFillMemoryUlong=RtlFillMemoryUlong@12
RtlFindClearBits=RtlFindClearBits@12
RtlFindClearBitsAndSet=RtlFindClearBitsAndSet@12
RtlFirstFreeAce=RtlFirstFreeAce@8
RtlFindLongestRunClear=RtlFindLongestRunClear@8
RtlFindLongestRunSet=RtlFindLongestRunSet@8
RtlFindSetBits=RtlFindSetBits@12
RtlFindSetBitsAndClear=RtlFindSetBitsAndClear@12
RtlFreeAnsiString=RtlFreeAnsiString@4
RtlFreeHeap=RtlFreeHeap@12
RtlFreeSid=RtlFreeSid@4
RtlFreeUnicodeString=RtlFreeUnicodeString@4
RtlGetControlSecurityDescriptor=RtlGetControlSecurityDescriptor@12
RtlGetCurrentDirectory_U=RtlGetCurrentDirectory_U@8
RtlGetDaclSecurityDescriptor=RtlGetDaclSecurityDescriptor@16
RtlGetFullPathName_U=RtlGetFullPathName_U@16
@ -292,12 +302,14 @@ RtlGetGroupSecurityDescriptor=RtlGetGroupSecurityDescriptor@12
RtlGetLongestNtPathLength=RtlGetLongestNtPathLength@0
RtlGetOwnerSecurityDescriptor=RtlGetOwnerSecurityDescriptor@12
RtlGetProcessHeap=RtlGetProcessHeap@0
RtlIdentifierAuthoritySid=RtlIdentifierAuthoritySid@4
RtlInitAnsiString=RtlInitAnsiString@8
RtlInitString=RtlInitString@8
RtlInitUnicodeString=RtlInitUnicodeString@8
RtlInitializeBitMap=RtlInitializeBitMap@12
RtlInitializeContext=RtlInitializeContext@20
RtlInitializeCriticalSection=RtlInitializeCriticalSection@4
RtlInitializeSid=RtlInitializeSid@12
RtlIntegerToChar=RtlIntegerToChar@16
RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12
RtlIsDosDeviceName_U=RtlIsDosDeviceName_U@4
@ -310,7 +322,9 @@ RtlLargeIntegerShiftLeft=RtlLargeIntegerShiftLeft@12
RtlLargeIntegerShiftRight=RtlLargeIntegerShiftRight@12
RtlLargeIntegerSubtract=RtlLargeIntegerSubtract@16
RtlLeaveCriticalSection=RtlLeaveCriticalSection@4
RtlLengthRequiredSid=RtlLengthRequiredSid@4
RtlLengthSecurityDescriptor=RtlLengthSecurityDescriptor@4
RtlLengthSid=RtlLengthSid@4
RtlLockHeap=RtlLockHeap@4
RtlMoveMemory=RtlMoveMemory@12
RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
@ -337,6 +351,8 @@ RtlSetEnvironmentVariable=RtlSetEnvironmentVariable@12
RtlSetGroupSecurityDescriptor=RtlSetGroupSecurityDescriptor@12
RtlSetOwnerSecurityDescriptor=RtlSetOwnerSecurityDescriptor@12
RtlSizeHeap=RtlSizeHeap@12
RtlSubAuthorityCountSid=RtlSubAuthorityCountSid@4
RtlSubAuthoritySid=RtlSubAuthoritySid@8
RtlTimeFieldsToTime=RtlTimeFieldsToTime@8
RtlTimeToSecondsSince1970=RtlTimeToSecondsSince1970@8
RtlTimeToSecondsSince1980=RtlTimeToSecondsSince1980@8
@ -363,6 +379,7 @@ RtlUpcaseUnicodeToOemN=RtlUpcaseUnicodeToOemN@20
RtlUpperChar=RtlUpperChar@4
RtlUpperString=RtlUpperString@8
RtlValidSecurityDescriptor=RtlValidSecurityDescriptor@4
RtlValidSid=RtlValidSid@4
RtlValidateHeap=RtlValidateHeap@12
RtlZeroMemory=RtlZeroMemory@8
RtlxAnsiStringToUnicodeSize=RtlxAnsiStringToUnicodeSize@4

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.40 2000/03/09 16:00:29 ekohl Exp $
# $Id: makefile,v 1.41 2000/03/12 01:16:41 ekohl Exp $
#
# ReactOS Operating System
#
@ -30,7 +30,7 @@ DBG_OBJECTS = dbg/brkpoint.o dbg/print.o
RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/math.o rtl/mem.o rtl/nls.o rtl/process.o rtl/sd.o \
rtl/thread.o rtl/unicode.o rtl/env.o rtl/path.o rtl/ppb.o \
rtl/bitmap.o rtl/time.o
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o

215
reactos/lib/ntdll/rtl/acl.c Normal file
View file

@ -0,0 +1,215 @@
/* $Id: acl.c,v 1.1 2000/03/12 01:17:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Security manager
* FILE: kernel/se/acl.c
* PROGRAMER: David Welch <welch@cwcom.net>
* REVISION HISTORY:
* 26/07/98: Added stubs for security functions
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/
BOOLEAN
STDCALL
RtlFirstFreeAce(PACL Acl, PACE* Ace)
{
PACE Current;
PVOID AclEnd;
ULONG i;
Current = (PACE)(Acl + 1);
*Ace = NULL;
i = 0;
if (Acl->AceCount == 0)
{
*Ace = Current;
return(TRUE);
}
AclEnd = Acl->AclSize + Acl;
do
{
if ((PVOID)Current >= AclEnd)
{
return(FALSE);
}
if (Current->Header.AceType == 4)
{
if (Acl->AclRevision < 3)
{
return(FALSE);
}
}
Current = (PACE)((PVOID)Current + (ULONG)Current->Header.AceSize);
i++;
} while (i < Acl->AceCount);
if ((PVOID)Current >= AclEnd)
{
return(FALSE);
}
*Ace = Current;
return(TRUE);
}
NTSTATUS
RtlpAddKnownAce(PACL Acl,
ULONG Revision,
ACCESS_MASK AccessMask,
PSID Sid,
ULONG Type)
{
PACE Ace;
if (!RtlValidSid(Sid))
{
return(STATUS_UNSUCCESSFUL);
}
if (Acl->AclRevision > 3 ||
Revision > 3)
{
return(STATUS_UNSUCCESSFUL);
}
if (Revision < Acl->AclRevision)
{
Revision = Acl->AclRevision;
}
if (!RtlFirstFreeAce(Acl, &Ace))
{
return(STATUS_UNSUCCESSFUL);
}
if (Ace == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
if (((PVOID)Ace + RtlLengthSid(Sid) + sizeof(ACE)) >=
((PVOID)Acl + Acl->AclSize))
{
return(STATUS_UNSUCCESSFUL);
}
Ace->Header.AceFlags = 0;
Ace->Header.AceType = Type;
Ace->Header.AceSize = RtlLengthSid(Sid) + sizeof(ACE);
Ace->Header.AccessMask = AccessMask;
RtlCopySid(RtlLengthSid(Sid), (PSID)Ace + 1, Sid);
Acl->AceCount++;
Acl->AclRevision = Revision;
return(STATUS_SUCCESS);
}
NTSTATUS
STDCALL
RtlAddAccessAllowedAce (
PACL Acl,
ULONG Revision,
ACCESS_MASK AccessMask,
PSID Sid
)
{
return(RtlpAddKnownAce(Acl, Revision, AccessMask, Sid, 0));
}
NTSTATUS
STDCALL
RtlAddAce (
PACL Acl,
ULONG AclRevision,
ULONG StartingIndex,
PACE AceList,
ULONG AceListLength
)
{
PACE Ace;
ULONG i;
PACE Current;
ULONG j;
if (Acl->AclRevision != 2 &&
Acl->AclRevision != 3)
{
return(STATUS_UNSUCCESSFUL);
}
if (!RtlFirstFreeAce(Acl,&Ace))
{
return(STATUS_UNSUCCESSFUL);
}
if (Acl->AclRevision <= AclRevision)
{
AclRevision = Acl->AclRevision;
}
if (((PVOID)AceList + AceListLength) <= (PVOID)AceList)
{
return(STATUS_UNSUCCESSFUL);
}
i = 0;
Current = (PACE)(Acl + 1);
while ((PVOID)Current < ((PVOID)AceList + AceListLength))
{
if (AceList->Header.AceType == 4 &&
AclRevision < 3)
{
return(STATUS_UNSUCCESSFUL);
}
Current = (PACE)((PVOID)Current + Current->Header.AceSize);
}
if (Ace == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
if (((PVOID)Ace + AceListLength) >= ((PVOID)Acl + Acl->AclSize))
{
return(STATUS_UNSUCCESSFUL);
}
if (StartingIndex != 0)
{
if (Acl->AceCount > 0)
{
Current = (PACE)(Acl + 1);
for (j = 0; j < StartingIndex; j++)
{
Current = (PACE)((PVOID)Current + Current->Header.AceSize);
}
}
}
/* RtlpAddData(AceList, AceListLength, Current, (PVOID)Ace - Current)); */
memcpy(Current, AceList, AceListLength);
Acl->AceCount = Acl->AceCount + i;
Acl->AclRevision = AclRevision;
return(TRUE);
}
NTSTATUS
STDCALL
RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
{
if (AclSize < 8)
{
return(STATUS_UNSUCCESSFUL);
}
if (AclRevision != 2 ||
AclRevision != 3)
{
return(STATUS_UNSUCCESSFUL);
}
if (AclSize > 0xffff)
{
return(STATUS_UNSUCCESSFUL);
}
AclSize = AclSize & ~(0x3);
Acl->AclSize = AclSize;
Acl->AclRevision = AclRevision;
Acl->AceCount = 0;
Acl->Sbz1 = 0;
Acl->Sbz2 = 0;
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: sd.c,v 1.1 2000/02/05 16:08:49 ekohl Exp $
/* $Id: sd.c,v 1.2 2000/03/12 01:17:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -275,16 +275,54 @@ NTSTATUS STDCALL RtlGetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDes
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL RtlAbsoluteToSelfRelativeSD (PSECURITY_DESCRIPTOR AbsSD,
PSECURITY_DESCRIPTOR RelSD,
PULONG BufferLength)
NTSTATUS
STDCALL
RtlMakeSelfRelativeSD (
PSECURITY_DESCRIPTOR AbsSD,
PSECURITY_DESCRIPTOR RelSD,
PULONG BufferLength
)
{
if (AbsSD->Control & 0x8000)
{
return(STATUS_UNSUCCESSFUL);
}
UNIMPLEMENTED;
}
NTSTATUS
STDCALL
RtlAbsoluteToSelfRelativeSD (
PSECURITY_DESCRIPTOR AbsSD,
PSECURITY_DESCRIPTOR RelSD,
PULONG BufferLength
)
{
if (AbsSD->Control & SE_SELF_RELATIVE)
{
return STATUS_BAD_DESCRIPTOR_FORMAT;
}
return (RtlMakeSelfRelativeSD (AbsSD, RelSD, BufferLength));
}
NTSTATUS
STDCALL
RtlGetControlSecurityDescriptor (
PSECURITY_DESCRIPTOR SecurityDescriptor,
PSECURITY_DESCRIPTOR_CONTROL Control,
PULONG Revision
)
{
*Revision = SecurityDescriptor->Revision;
if (SecurityDescriptor->Revision != 1)
return STATUS_UNKNOWN_REVISION;
*Control = SecurityDescriptor->Control;
return STATUS_SUCCESS;
}
/* EOF */

190
reactos/lib/ntdll/rtl/sid.c Normal file
View file

@ -0,0 +1,190 @@
/* $Id: sid.c,v 1.1 2000/03/12 01:17:59 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Security manager
* FILE: kernel/se/sid.c
* PROGRAMER: David Welch <welch@cwcom.net>
* REVISION HISTORY:
* 26/07/98: Added stubs for security functions
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <string.h>
//#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/
BOOLEAN STDCALL RtlValidSid (PSID Sid)
{
if ((Sid->Revision & 0xf) != 1)
{
return(FALSE);
}
if (Sid->SubAuthorityCount > 15)
{
return(FALSE);
}
return(TRUE);
}
ULONG STDCALL RtlLengthRequiredSid (UCHAR SubAuthorityCount)
{
return(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
}
NTSTATUS STDCALL RtlInitializeSid (PSID Sid,
PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount)
{
Sid->Revision = 1;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority, IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
return(STATUS_SUCCESS);
}
PULONG STDCALL RtlSubAuthoritySid (PSID Sid, ULONG SubAuthority)
{
return(&Sid->SubAuthority[SubAuthority]);
}
PUCHAR STDCALL RtlSubAuthorityCountSid (PSID Sid)
{
return(&Sid->SubAuthorityCount);
}
BOOLEAN STDCALL RtlEqualSid (PSID Sid1, PSID Sid2)
{
if (Sid1->Revision != Sid2->Revision)
{
return(FALSE);
}
if ((*RtlSubAuthorityCountSid(Sid1)) !=
(*RtlSubAuthorityCountSid(Sid2)))
{
return(FALSE);
}
if (memcmp(Sid1, Sid2, RtlLengthSid(Sid1) != 0))
{
return(FALSE);
}
return(TRUE);
}
ULONG STDCALL RtlLengthSid (PSID Sid)
{
return(sizeof(SID) + (Sid->SubAuthorityCount-1)*4);
}
NTSTATUS STDCALL RtlCopySid (ULONG BufferLength, PSID Dest, PSID Src)
{
if (BufferLength < RtlLengthSid(Src))
{
return(STATUS_UNSUCCESSFUL);
}
memmove(Dest, Src, RtlLengthSid(Src));
return(STATUS_SUCCESS);
}
PSID_IDENTIFIER_AUTHORITY
STDCALL
RtlIdentifierAuthoritySid (
PSID Sid
)
{
return (&Sid->IdentifierAuthority);
}
NTSTATUS
STDCALL
RtlAllocateAndInitializeSid (
PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
ULONG SubAuthority2,
ULONG SubAuthority3,
ULONG SubAuthority4,
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid
)
{
PSID pSid;
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
pSid = (PSID)RtlAllocateHeap (RtlGetProcessHeap (),
0,
SubAuthorityCount * sizeof(DWORD) + 8);
if (pSid == NULL)
return STATUS_NO_MEMORY;
pSid->Revision = 1;
pSid->SubAuthorityCount = SubAuthorityCount;
memcpy (&pSid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
switch (SubAuthorityCount)
{
case 8:
pSid->SubAuthority[7] = SubAuthority7;
case 7:
pSid->SubAuthority[6] = SubAuthority6;
case 6:
pSid->SubAuthority[5] = SubAuthority5;
case 5:
pSid->SubAuthority[4] = SubAuthority4;
case 4:
pSid->SubAuthority[3] = SubAuthority3;
case 3:
pSid->SubAuthority[2] = SubAuthority2;
case 2:
pSid->SubAuthority[1] = SubAuthority1;
case 1:
pSid->SubAuthority[0] = SubAuthority0;
break;
}
*Sid = pSid;
return STATUS_SUCCESS;
}
PSID
STDCALL
RtlFreeSid (
PSID Sid
)
{
RtlFreeHeap (RtlGetProcessHeap (), 0, Sid);
return Sid;
}
BOOLEAN
STDCALL
RtlEqualPrefixSid (
PSID Sid1,
PSID Sid2
)
{
return (Sid1->SubAuthorityCount == Sid2->SubAuthorityCount &&
!memcmp (Sid1, Sid2,
(Sid1->SubAuthorityCount - 1) * sizeof(DWORD) + 8));
}
/* EOF */