Added RtlCopyLuidAndAttributesArray() and RtlCopySidAndAttributesArray().

svn path=/trunk/; revision=3308
This commit is contained in:
Eric Kohl 2002-07-29 15:37:06 +00:00
parent 5295bac977
commit 4201812a7e
7 changed files with 219 additions and 159 deletions

View file

@ -1,4 +1,4 @@
/* $Id: rtl.h,v 1.62 2002/07/25 13:15:08 ekohl Exp $ /* $Id: rtl.h,v 1.63 2002/07/29 15:33:31 ekohl Exp $
* *
*/ */
@ -660,26 +660,36 @@ VOID STDCALL
RtlCopyLuid(IN PLUID LuidDest, RtlCopyLuid(IN PLUID LuidDest,
IN PLUID LuidSrc); IN PLUID LuidSrc);
VOID VOID STDCALL
STDCALL RtlCopyLuidAndAttributesArray(ULONG Count,
RtlCopyString ( PLUID_AND_ATTRIBUTES Src,
PSTRING DestinationString, PLUID_AND_ATTRIBUTES Dest);
PSTRING SourceString
);
VOID NTSTATUS STDCALL
STDCALL RtlCopySid(ULONG BufferLength,
RtlCopyUnicodeString ( PSID Dest,
PUNICODE_STRING DestinationString, PSID Src);
PUNICODE_STRING SourceString
);
NTSTATUS NTSTATUS STDCALL
STDCALL RtlCopySidAndAttributesArray(ULONG Count,
RtlCreateAtomTable ( PSID_AND_ATTRIBUTES Src,
IN ULONG TableSize, ULONG SidAreaSize,
IN OUT PRTL_ATOM_TABLE *AtomTable PSID_AND_ATTRIBUTES Dest,
); PVOID SidArea,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize);
VOID STDCALL
RtlCopyString(PSTRING DestinationString,
PSTRING SourceString);
VOID STDCALL
RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
PUNICODE_STRING SourceString);
NTSTATUS STDCALL
RtlCreateAtomTable(IN ULONG TableSize,
IN OUT PRTL_ATOM_TABLE *AtomTable);
HANDLE HANDLE
STDCALL STDCALL
@ -2021,7 +2031,6 @@ ULONG STDCALL RtlLengthRequiredSid (UCHAR SubAuthorityCount);
PSID_IDENTIFIER_AUTHORITY STDCALL RtlIdentifierAuthoritySid (PSID Sid); PSID_IDENTIFIER_AUTHORITY STDCALL RtlIdentifierAuthoritySid (PSID Sid);
NTSTATUS STDCALL RtlInitializeSid (PSID Sid, PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, UCHAR SubAuthorityCount); NTSTATUS STDCALL RtlInitializeSid (PSID Sid, PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, UCHAR SubAuthorityCount);
PULONG STDCALL RtlSubAuthoritySid (PSID Sid, ULONG SubAuthority); PULONG STDCALL RtlSubAuthoritySid (PSID Sid, ULONG SubAuthority);
NTSTATUS STDCALL RtlCopySid (ULONG BufferLength, PSID Dest, PSID Src);
BOOLEAN STDCALL RtlEqualPrefixSid (PSID Sid1, PSID Sid2); BOOLEAN STDCALL RtlEqualPrefixSid (PSID Sid1, PSID Sid2);
BOOLEAN STDCALL RtlEqualSid(PSID Sid1, PSID Sid2); BOOLEAN STDCALL RtlEqualSid(PSID Sid1, PSID Sid2);
PSID STDCALL RtlFreeSid (PSID Sid); PSID STDCALL RtlFreeSid (PSID Sid);

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.84 2002/07/25 16:58:58 ekohl Exp $ ; $Id: ntdll.def,v 1.85 2002/07/29 15:37:05 ekohl Exp $
; ;
; ReactOS Operating System ; ReactOS Operating System
; ;
@ -322,10 +322,10 @@ RtlConvertSidToUnicodeString@12
;RtlConvertUiListToApiList ;RtlConvertUiListToApiList
RtlConvertUlongToLargeInteger@4 RtlConvertUlongToLargeInteger@4
RtlCopyLuid@8 RtlCopyLuid@8
;RtlCopyLuidAndAttributesArray RtlCopyLuidAndAttributesArray@12
;RtlCopySecurityDescriptor ;RtlCopySecurityDescriptor
RtlCopySid@12 RtlCopySid@12
;RtlCopySidAndAttributesArray RtlCopySidAndAttributesArray@28
RtlCopyString@8 RtlCopyString@8
RtlCopyUnicodeString@8 RtlCopyUnicodeString@8
RtlCreateAcl@12 RtlCreateAcl@12

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.73 2002/07/25 16:58:58 ekohl Exp $ ; $Id: ntdll.edf,v 1.74 2002/07/29 15:37:06 ekohl Exp $
; ;
; ReactOS Operating System ; ReactOS Operating System
; ;
@ -322,10 +322,10 @@ RtlConvertSidToUnicodeString=RtlConvertSidToUnicodeString@12
;RtlConvertUiListToApiList ;RtlConvertUiListToApiList
RtlConvertUlongToLargeInteger=RtlConvertUlongToLargeInteger@4 RtlConvertUlongToLargeInteger=RtlConvertUlongToLargeInteger@4
RtlCopyLuid=RtlCopyLuid@8 RtlCopyLuid=RtlCopyLuid@8
;RtlCopyLuidAndAttributesArray RtlCopyLuidAndAttributesArray=RtlCopyLuidAndAttributesArray@12
;RtlCopySecurityDescriptor ;RtlCopySecurityDescriptor
RtlCopySid=RtlCopySid@12 RtlCopySid=RtlCopySid@12
;RtlCopySidAndAttributesArray RtlCopySidAndAttributesArray=RtlCopySidAndAttributesArray@28
RtlCopyString=RtlCopyString@8 RtlCopyString=RtlCopyString@8
RtlCopyUnicodeString=RtlCopyUnicodeString@8 RtlCopyUnicodeString=RtlCopyUnicodeString@8
RtlCreateAcl=RtlCreateAcl@12 RtlCreateAcl=RtlCreateAcl@12

View file

@ -1,4 +1,4 @@
/* $Id: luid.c,v 1.2 2000/06/29 23:35:31 dwelch Exp $ /* $Id: luid.c,v 1.3 2002/07/29 15:36:20 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -15,32 +15,35 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID STDCALL
STDCALL RtlCopyLuid(PLUID LuidDest,
RtlCopyLuid ( PLUID LuidSrc)
PLUID LuidDest,
PLUID LuidSrc
)
{ {
LuidDest->QuadPart = LuidSrc->QuadPart; LuidDest->QuadPart = LuidSrc->QuadPart;
} }
#if 0
RtlCopyLuidAndAttributesArray (
)
{
VOID STDCALL
RtlCopyLuidAndAttributesArray(ULONG Count,
PLUID_AND_ATTRIBUTES Src,
PLUID_AND_ATTRIBUTES Dest)
{
ULONG i;
for (i = 0; i < Count; i++)
{
RtlCopyMemory(&Dest[i],
&Src[i],
sizeof(LUID_AND_ATTRIBUTES));
}
} }
#endif
BOOLEAN
STDCALL BOOLEAN STDCALL
RtlEqualLuid ( RtlEqualLuid(PLUID Luid1,
PLUID Luid1, PLUID Luid2)
PLUID Luid2
)
{ {
return ((Luid1->QuadPart == Luid2->QuadPart) ? TRUE : FALSE); return((Luid1->QuadPart == Luid2->QuadPart) ? TRUE : FALSE);
} }
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: sid.c,v 1.3 2002/06/15 10:10:19 ekohl Exp $ /* $Id: sid.c,v 1.4 2002/07/29 15:36:20 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -18,87 +18,143 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN STDCALL RtlValidSid (PSID Sid) BOOLEAN STDCALL
RtlValidSid(IN PSID Sid)
{ {
if ((Sid->Revision & 0xf) != 1) if ((Sid->Revision & 0xf) != 1)
{ {
return(FALSE); return(FALSE);
} }
if (Sid->SubAuthorityCount > 15) if (Sid->SubAuthorityCount > 15)
{ {
return(FALSE); return(FALSE);
} }
return(TRUE); return(TRUE);
} }
ULONG STDCALL RtlLengthRequiredSid (UCHAR SubAuthorityCount)
ULONG STDCALL
RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
{ {
return(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG)); return(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
} }
NTSTATUS STDCALL RtlInitializeSid (PSID Sid,
PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, NTSTATUS STDCALL
UCHAR SubAuthorityCount) RtlInitializeSid(IN PSID Sid,
IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
IN UCHAR SubAuthorityCount)
{ {
Sid->Revision = 1; Sid->Revision = 1;
Sid->SubAuthorityCount = SubAuthorityCount; Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority, IdentifierAuthority, memcpy(&Sid->IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY)); IdentifierAuthority,
return(STATUS_SUCCESS); sizeof(SID_IDENTIFIER_AUTHORITY));
return(STATUS_SUCCESS);
} }
PULONG STDCALL RtlSubAuthoritySid (PSID Sid, ULONG SubAuthority)
PULONG STDCALL
RtlSubAuthoritySid(IN PSID Sid,
IN ULONG SubAuthority)
{ {
return(&Sid->SubAuthority[SubAuthority]); return(&Sid->SubAuthority[SubAuthority]);
} }
PUCHAR STDCALL RtlSubAuthorityCountSid (PSID Sid)
PUCHAR STDCALL
RtlSubAuthorityCountSid(IN PSID Sid)
{ {
return(&Sid->SubAuthorityCount); return(&Sid->SubAuthorityCount);
} }
BOOLEAN STDCALL RtlEqualSid (PSID Sid1, PSID Sid2)
BOOLEAN STDCALL
RtlEqualSid(IN PSID Sid1,
IN PSID Sid2)
{ {
if (Sid1->Revision != Sid2->Revision) if (Sid1->Revision != Sid2->Revision)
{ {
return(FALSE); return(FALSE);
} }
if ((*RtlSubAuthorityCountSid(Sid1)) != if ((*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2)))
(*RtlSubAuthorityCountSid(Sid2))) {
{ return(FALSE);
return(FALSE); }
}
if (memcmp(Sid1, Sid2, RtlLengthSid(Sid1)) != 0) if (memcmp(Sid1, Sid2, RtlLengthSid(Sid1)) != 0)
{ {
return(FALSE); return(FALSE);
} }
return(TRUE); return(TRUE);
} }
ULONG STDCALL RtlLengthSid (PSID Sid)
ULONG STDCALL
RtlLengthSid(IN PSID Sid)
{ {
return(sizeof(SID) + (Sid->SubAuthorityCount-1)*4); return(sizeof(SID) + (Sid->SubAuthorityCount-1)*4);
} }
NTSTATUS STDCALL RtlCopySid (ULONG BufferLength, PSID Dest, PSID Src)
NTSTATUS STDCALL
RtlCopySid(ULONG BufferLength,
PSID Dest,
PSID Src)
{ {
if (BufferLength < RtlLengthSid(Src)) if (BufferLength < RtlLengthSid(Src))
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
memmove(Dest, Src, RtlLengthSid(Src)); memmove(Dest,
return(STATUS_SUCCESS); Src,
RtlLengthSid(Src));
return(STATUS_SUCCESS);
} }
PSID_IDENTIFIER_AUTHORITY
STDCALL NTSTATUS STDCALL
RtlIdentifierAuthoritySid ( RtlCopySidAndAttributesArray(ULONG Count,
PSID Sid PSID_AND_ATTRIBUTES Src,
) ULONG SidAreaSize,
PSID_AND_ATTRIBUTES Dest,
PVOID SidArea,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize)
{ {
return (&Sid->IdentifierAuthority); ULONG SidLength;
ULONG Length;
ULONG i;
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 = SidArea + SidLength;
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return(STATUS_SUCCESS);
} }
PSID_IDENTIFIER_AUTHORITY STDCALL
RtlIdentifierAuthoritySid(IN PSID Sid)
{
return(&Sid->IdentifierAuthority);
}
NTSTATUS NTSTATUS
STDCALL STDCALL
RtlAllocateAndInitializeSid ( RtlAllocateAndInitializeSid (
@ -162,37 +218,30 @@ RtlAllocateAndInitializeSid (
} }
PSID PSID STDCALL
STDCALL RtlFreeSid(IN PSID Sid)
RtlFreeSid (
PSID Sid
)
{ {
RtlFreeHeap (RtlGetProcessHeap (), 0, Sid); RtlFreeHeap(RtlGetProcessHeap(),
return Sid; 0,
Sid);
return(Sid);
} }
BOOLEAN BOOLEAN STDCALL
STDCALL RtlEqualPrefixSid(IN PSID Sid1,
RtlEqualPrefixSid ( IN PSID Sid2)
PSID Sid1,
PSID Sid2
)
{ {
return (Sid1->SubAuthorityCount == Sid2->SubAuthorityCount && return(Sid1->SubAuthorityCount == Sid2->SubAuthorityCount &&
!memcmp (Sid1, Sid2, !memcmp(Sid1, Sid2,
(Sid1->SubAuthorityCount - 1) * sizeof(DWORD) + 8)); (Sid1->SubAuthorityCount - 1) * sizeof(DWORD) + 8));
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlConvertSidToUnicodeString(PUNICODE_STRING String,
RtlConvertSidToUnicodeString ( PSID Sid,
PUNICODE_STRING String, BOOLEAN AllocateBuffer)
PSID Sid,
BOOLEAN AllocateBuffer
)
{ {
WCHAR Buffer[256]; WCHAR Buffer[256];
PWSTR wcs; PWSTR wcs;

View file

@ -1,4 +1,4 @@
/* $Id: sid.c,v 1.9 2002/06/15 10:10:43 ekohl Exp $ /* $Id: sid.c,v 1.10 2002/07/29 15:34:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -513,7 +513,7 @@ RtlSubAuthoritySid(PSID Sid,
PUCHAR STDCALL PUCHAR STDCALL
RtlSubAuthorityCountSid (PSID Sid) RtlSubAuthorityCountSid(PSID Sid)
{ {
return(&Sid->SubAuthorityCount); return(&Sid->SubAuthorityCount);
} }
@ -561,6 +561,38 @@ RtlCopySid(ULONG BufferLength,
} }
NTSTATUS STDCALL
RtlCopySidAndAttributesArray(ULONG Count,
PSID_AND_ATTRIBUTES Src,
ULONG SidAreaSize,
PSID_AND_ATTRIBUTES Dest,
PVOID SidArea,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize)
{
ULONG Length;
ULONG i;
Length = SidAreaSize;
for (i=0; i<Count; i++)
{
if (RtlLengthSid(Src[i].Sid) > Length)
{
return(STATUS_BUFFER_TOO_SMALL);
}
Length = Length - RtlLengthSid(Src[i].Sid);
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(RtlLengthSid(Src[i].Sid), SidArea, Src[i].Sid);
SidArea = SidArea + RtlLengthSid(Src[i].Sid);
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NTSTATUS STDCALL
RtlConvertSidToUnicodeString(PUNICODE_STRING String, RtlConvertSidToUnicodeString(PUNICODE_STRING String,
PSID Sid, PSID Sid,

View file

@ -1,4 +1,4 @@
/* $Id: token.c,v 1.18 2002/07/04 19:56:36 dwelch Exp $ /* $Id: token.c,v 1.19 2002/07/29 15:34:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -69,39 +69,6 @@ NTSTATUS SeExchangePrimaryToken(PEPROCESS Process,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS
RtlCopySidAndAttributesArray(ULONG Count, // ebp + 8
PSID_AND_ATTRIBUTES Src, // ebp + C
ULONG SidAreaSize, // ebp + 10
PSID_AND_ATTRIBUTES Dest, // ebp + 14
PVOID SidArea, // ebp + 18
PVOID* RemainingSidArea, // ebp + 1C
PULONG RemainingSidAreaSize) // ebp + 20
{
ULONG Length; // ebp - 4
ULONG i;
Length = SidAreaSize;
for (i=0; i<Count; i++)
{
if (RtlLengthSid(Src[i].Sid) > Length)
{
return(STATUS_BUFFER_TOO_SMALL);
}
Length = Length - RtlLengthSid(Src[i].Sid);
Dest[i].Sid = SidArea;
Dest[i].Attributes = Src[i].Attributes;
RtlCopySid(RtlLengthSid(Src[i].Sid), SidArea, Src[i].Sid);
SidArea = SidArea + RtlLengthSid(Src[i].Sid);
}
*RemainingSidArea = SidArea;
*RemainingSidAreaSize = Length;
return(STATUS_SUCCESS);
}
static ULONG static ULONG
RtlLengthSidAndAttributes(ULONG Count, RtlLengthSidAndAttributes(ULONG Count,
PSID_AND_ATTRIBUTES Src) PSID_AND_ATTRIBUTES Src)