update for HEAD-2003091401
[reactos.git] / lib / ntdll / rtl / sid.c
index c5f7d90..90413a8 100644 (file)
@@ -33,6 +33,9 @@ RtlValidSid(IN PSID Sid)
 }
 
 
+/*
+ * @implemented
+ */
 ULONG STDCALL
 RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
 {
@@ -40,6 +43,9 @@ RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlInitializeSid(IN PSID Sid,
                 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
@@ -54,6 +60,9 @@ RtlInitializeSid(IN PSID Sid,
 }
 
 
+/*
+ * @implemented
+ */
 PULONG STDCALL
 RtlSubAuthoritySid(IN PSID Sid,
                   IN ULONG SubAuthority)
@@ -62,6 +71,9 @@ RtlSubAuthoritySid(IN PSID Sid,
 }
 
 
+/*
+ * @implemented
+ */
 PUCHAR STDCALL
 RtlSubAuthorityCountSid(IN PSID Sid)
 {
@@ -69,6 +81,9 @@ RtlSubAuthorityCountSid(IN PSID Sid)
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN STDCALL
 RtlEqualSid(IN PSID Sid1,
            IN PSID Sid2)
@@ -89,6 +104,9 @@ RtlEqualSid(IN PSID Sid1,
 }
 
 
+/*
+ * @implemented
+ */
 ULONG STDCALL
 RtlLengthSid(IN PSID Sid)
 {
@@ -96,6 +114,9 @@ RtlLengthSid(IN PSID Sid)
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlCopySid(ULONG BufferLength,
           PSID Dest,
@@ -112,6 +133,9 @@ RtlCopySid(ULONG BufferLength,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlCopySidAndAttributesArray(ULONG Count,
                             PSID_AND_ATTRIBUTES Src,
@@ -148,6 +172,9 @@ RtlCopySidAndAttributesArray(ULONG Count,
 }
 
 
+/*
+ * @implemented
+ */
 PSID_IDENTIFIER_AUTHORITY STDCALL
 RtlIdentifierAuthoritySid(IN PSID Sid)
 {
@@ -155,6 +182,9 @@ RtlIdentifierAuthoritySid(IN PSID Sid)
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS
 STDCALL
 RtlAllocateAndInitializeSid (
@@ -218,6 +248,9 @@ RtlAllocateAndInitializeSid (
 }
 
 
+/*
+ * @implemented
+ */
 PSID STDCALL
 RtlFreeSid(IN PSID Sid)
 {
@@ -228,6 +261,9 @@ RtlFreeSid(IN PSID Sid)
 }
 
 
+/*
+ * @implemented
+ */
 BOOLEAN STDCALL
 RtlEqualPrefixSid(IN PSID Sid1,
                  IN PSID Sid2)
@@ -238,74 +274,77 @@ RtlEqualPrefixSid(IN PSID Sid1,
 }
 
 
+/*
+ * @implemented
+ */
 NTSTATUS STDCALL
 RtlConvertSidToUnicodeString(PUNICODE_STRING String,
                             PSID Sid,
                             BOOLEAN AllocateBuffer)
 {
-       WCHAR Buffer[256];
-       PWSTR wcs;
-       ULONG Length;
-       BYTE  i;
+  WCHAR Buffer[256];
+  PWSTR wcs;
+  ULONG Length;
+  ULONG i;
 
-       if (RtlValidSid (Sid) == FALSE)
-               return STATUS_INVALID_SID;
+  if (RtlValidSid (Sid) == FALSE)
+    return STATUS_INVALID_SID;
 
-       wcs = Buffer;
-       wcs += swprintf (wcs, L"S-%u-", Sid->Revision);
-       if (!Sid->IdentifierAuthority.Value[0] &&
-           !Sid->IdentifierAuthority.Value[1])
-       {
-               wcs += swprintf (wcs,
-                                L"%u",
-                                (DWORD)Sid->IdentifierAuthority.Value[2] << 24 |
-                                (DWORD)Sid->IdentifierAuthority.Value[3] << 16 |
-                                (DWORD)Sid->IdentifierAuthority.Value[4] << 8 |
-                                (DWORD)Sid->IdentifierAuthority.Value[5]);
-       }
-       else
-       {
-               wcs += swprintf (wcs,
-                                L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
-                                Sid->IdentifierAuthority.Value[0],
-                                Sid->IdentifierAuthority.Value[1],
-                                Sid->IdentifierAuthority.Value[2],
-                                Sid->IdentifierAuthority.Value[3],
-                                Sid->IdentifierAuthority.Value[4],
-                                Sid->IdentifierAuthority.Value[5]);
-       }
+  wcs = Buffer;
+  wcs += swprintf (wcs, L"S-%u-", Sid->Revision);
+  if (Sid->IdentifierAuthority.Value[0] == 0 &&
+      Sid->IdentifierAuthority.Value[1] == 0)
+    {
+      wcs += swprintf (wcs,
+                      L"%lu",
+                      (ULONG)Sid->IdentifierAuthority.Value[2] << 24 |
+                      (ULONG)Sid->IdentifierAuthority.Value[3] << 16 |
+                      (ULONG)Sid->IdentifierAuthority.Value[4] << 8 |
+                      (ULONG)Sid->IdentifierAuthority.Value[5]);
+    }
+  else
+    {
+      wcs += swprintf (wcs,
+                      L"0x%02hx%02hx%02hx%02hx%02hx%02hx",
+                      Sid->IdentifierAuthority.Value[0],
+                      Sid->IdentifierAuthority.Value[1],
+                      Sid->IdentifierAuthority.Value[2],
+                      Sid->IdentifierAuthority.Value[3],
+                      Sid->IdentifierAuthority.Value[4],
+                      Sid->IdentifierAuthority.Value[5]);
+    }
 
-       for (i = 0; i < Sid->SubAuthorityCount; i++)
-       {
-               wcs += swprintf (wcs,
-                                L"-%u",
-                                Sid->SubAuthority[0]);
-       }
+  for (i = 0; i < Sid->SubAuthorityCount; i++)
+    {
+      wcs += swprintf (wcs,
+                      L"-%u",
+                      Sid->SubAuthority[i]);
+    }
 
-       Length = (wcs - Buffer) * sizeof(WCHAR);
-       if(AllocateBuffer)
-       {
-               String->Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
-                                                 0,
-                                                 Length + sizeof(WCHAR));
-               if (String->Buffer == NULL)
-                       return STATUS_NO_MEMORY;
-               String->MaximumLength = Length + sizeof(WCHAR);
-       }
-       else
-       {
-               if (Length > String->MaximumLength)
-                       return STATUS_BUFFER_TOO_SMALL;
-       }
+  Length = (wcs - Buffer) * sizeof(WCHAR);
+  if (AllocateBuffer)
+    {
+      String->Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
+                                       0,
+                                       Length + sizeof(WCHAR));
+      if (String->Buffer == NULL)
+       return STATUS_NO_MEMORY;
+      String->MaximumLength = Length + sizeof(WCHAR);
+    }
+  else
+    {
+      if (Length > String->MaximumLength)
+       return STATUS_BUFFER_TOO_SMALL;
+    }
 
-       String->Length = Length;
-       memmove (String->Buffer,
-                Buffer,
-                Length);
-       if (Length < String->MaximumLength)
-               String->Buffer[Length] = 0;
+  String->Length = Length;
+  RtlCopyMemory (String->Buffer,
+                Buffer,
+                Length);
+  if (Length < String->MaximumLength)
+    String->Buffer[Length / sizeof(WCHAR)] = 0;
 
-       return STATUS_SUCCESS;
+  return STATUS_SUCCESS;
 }
 
 /* EOF */