4 * Copyright 1996-1998 Marcus Meissner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/exception.h"
34 #include "wine/debug.h"
36 #include "stackframe.h"
40 #include "ntdll_misc.h"
41 #include "msvcrt/excpt.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
45 #define NT_SUCCESS(status) (status == STATUS_SUCCESS)
47 /* filter for page-fault exceptions */
48 static WINE_EXCEPTION_FILTER(page_fault
)
50 if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION
)
51 return EXCEPTION_EXECUTE_HANDLER
;
52 return EXCEPTION_CONTINUE_SEARCH
;
59 /******************************************************************************
60 * RtlAllocateAndInitializeSid [NTDLL.@]
63 BOOLEAN WINAPI
RtlAllocateAndInitializeSid (
64 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
65 BYTE nSubAuthorityCount
,
66 DWORD nSubAuthority0
, DWORD nSubAuthority1
,
67 DWORD nSubAuthority2
, DWORD nSubAuthority3
,
68 DWORD nSubAuthority4
, DWORD nSubAuthority5
,
69 DWORD nSubAuthority6
, DWORD nSubAuthority7
,
72 TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
73 pIdentifierAuthority
,nSubAuthorityCount
,
74 nSubAuthority0
, nSubAuthority1
, nSubAuthority2
, nSubAuthority3
,
75 nSubAuthority4
, nSubAuthority5
, nSubAuthority6
, nSubAuthority7
, pSid
);
77 if (!(*pSid
= RtlAllocateHeap( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount
))))
80 (*pSid
)->Revision
= SID_REVISION
;
82 if (pIdentifierAuthority
)
83 memcpy(&(*pSid
)->IdentifierAuthority
, pIdentifierAuthority
, sizeof (SID_IDENTIFIER_AUTHORITY
));
84 *RtlSubAuthorityCountSid(*pSid
) = nSubAuthorityCount
;
86 if (nSubAuthorityCount
> 0)
87 *RtlSubAuthoritySid(*pSid
, 0) = nSubAuthority0
;
88 if (nSubAuthorityCount
> 1)
89 *RtlSubAuthoritySid(*pSid
, 1) = nSubAuthority1
;
90 if (nSubAuthorityCount
> 2)
91 *RtlSubAuthoritySid(*pSid
, 2) = nSubAuthority2
;
92 if (nSubAuthorityCount
> 3)
93 *RtlSubAuthoritySid(*pSid
, 3) = nSubAuthority3
;
94 if (nSubAuthorityCount
> 4)
95 *RtlSubAuthoritySid(*pSid
, 4) = nSubAuthority4
;
96 if (nSubAuthorityCount
> 5)
97 *RtlSubAuthoritySid(*pSid
, 5) = nSubAuthority5
;
98 if (nSubAuthorityCount
> 6)
99 *RtlSubAuthoritySid(*pSid
, 6) = nSubAuthority6
;
100 if (nSubAuthorityCount
> 7)
101 *RtlSubAuthoritySid(*pSid
, 7) = nSubAuthority7
;
103 return STATUS_SUCCESS
;
105 /******************************************************************************
106 * RtlEqualSid [NTDLL.@]
109 BOOL WINAPI
RtlEqualSid( PSID pSid1
, PSID pSid2
)
111 if (!RtlValidSid(pSid1
) || !RtlValidSid(pSid2
))
114 if (*RtlSubAuthorityCountSid(pSid1
) != *RtlSubAuthorityCountSid(pSid2
))
117 if (memcmp(pSid1
, pSid2
, RtlLengthSid(pSid1
)) != 0)
123 /******************************************************************************
124 * RtlEqualPrefixSid [NTDLL.@]
126 BOOL WINAPI
RtlEqualPrefixSid (PSID pSid1
, PSID pSid2
)
128 if (!RtlValidSid(pSid1
) || !RtlValidSid(pSid2
))
131 if (*RtlSubAuthorityCountSid(pSid1
) != *RtlSubAuthorityCountSid(pSid2
))
134 if (memcmp(pSid1
, pSid2
, RtlLengthRequiredSid(pSid1
->SubAuthorityCount
- 1)) != 0)
141 /******************************************************************************
142 * RtlFreeSid [NTDLL.@]
144 DWORD WINAPI
RtlFreeSid(PSID pSid
)
146 TRACE("(%p)\n", pSid
);
147 RtlFreeHeap( GetProcessHeap(), 0, pSid
);
148 return STATUS_SUCCESS
;
151 /**************************************************************************
152 * RtlLengthRequiredSid [NTDLL.@]
155 * nSubAuthorityCount []
157 DWORD WINAPI
RtlLengthRequiredSid(DWORD nrofsubauths
)
159 return (nrofsubauths
-1)*sizeof(DWORD
) + sizeof(SID
);
162 /**************************************************************************
163 * RtlLengthSid [NTDLL.@]
165 DWORD WINAPI
RtlLengthSid(PSID pSid
)
167 TRACE("sid=%p\n",pSid
);
169 return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid
));
172 /**************************************************************************
173 * RtlInitializeSid [NTDLL.@]
175 BOOL WINAPI
RtlInitializeSid(
177 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
178 BYTE nSubAuthorityCount
)
181 if (nSubAuthorityCount
>= SID_MAX_SUB_AUTHORITIES
)
184 pSid
->Revision
= SID_REVISION
;
185 pSid
->SubAuthorityCount
= nSubAuthorityCount
;
186 if (pIdentifierAuthority
)
187 memcpy(&pSid
->IdentifierAuthority
, pIdentifierAuthority
, sizeof (SID_IDENTIFIER_AUTHORITY
));
189 for (i
= 0; i
< nSubAuthorityCount
; i
++)
190 *RtlSubAuthoritySid(pSid
, i
) = 0;
195 /**************************************************************************
196 * RtlSubAuthoritySid [NTDLL.@]
202 LPDWORD WINAPI
RtlSubAuthoritySid( PSID pSid
, DWORD nSubAuthority
)
204 return &(pSid
->SubAuthority
[nSubAuthority
]);
207 /**************************************************************************
208 * RtlIdentifierAuthoritySid [NTDLL.@]
213 PSID_IDENTIFIER_AUTHORITY WINAPI
RtlIdentifierAuthoritySid( PSID pSid
)
215 return &(pSid
->IdentifierAuthority
);
218 /**************************************************************************
219 * RtlSubAuthorityCountSid [NTDLL.@]
225 LPBYTE WINAPI
RtlSubAuthorityCountSid(PSID pSid
)
227 return &(pSid
->SubAuthorityCount
);
230 /**************************************************************************
231 * RtlCopySid [NTDLL.@]
233 DWORD WINAPI
RtlCopySid( DWORD nDestinationSidLength
, PSID pDestinationSid
, PSID pSourceSid
)
235 if (!pSourceSid
|| !RtlValidSid(pSourceSid
) ||
236 (nDestinationSidLength
< RtlLengthSid(pSourceSid
)))
239 if (nDestinationSidLength
< (pSourceSid
->SubAuthorityCount
*4+8))
242 memmove(pDestinationSid
, pSourceSid
, pSourceSid
->SubAuthorityCount
*4+8);
245 /******************************************************************************
246 * RtlValidSid [NTDLL.@]
252 RtlValidSid( PSID pSid
)
258 if (!pSid
|| pSid
->Revision
!= SID_REVISION
||
259 pSid
->SubAuthorityCount
> SID_MAX_SUB_AUTHORITIES
)
266 WARN("(%p): invalid pointer!\n", pSid
);
275 * security descriptor functions
278 /**************************************************************************
279 * RtlCreateSecurityDescriptor [NTDLL.@]
283 * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
286 NTSTATUS WINAPI
RtlCreateSecurityDescriptor(
287 PSECURITY_DESCRIPTOR lpsd
,
290 if (rev
!=SECURITY_DESCRIPTOR_REVISION
)
291 return STATUS_UNKNOWN_REVISION
;
292 memset(lpsd
,'\0',sizeof(*lpsd
));
293 lpsd
->Revision
= SECURITY_DESCRIPTOR_REVISION
;
294 return STATUS_SUCCESS
;
296 /**************************************************************************
297 * RtlValidSecurityDescriptor [NTDLL.@]
300 NTSTATUS WINAPI
RtlValidSecurityDescriptor(
301 PSECURITY_DESCRIPTOR SecurityDescriptor
)
303 if ( ! SecurityDescriptor
)
304 return STATUS_INVALID_SECURITY_DESCR
;
305 if ( SecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
306 return STATUS_UNKNOWN_REVISION
;
308 return STATUS_SUCCESS
;
311 /**************************************************************************
312 * RtlLengthSecurityDescriptor [NTDLL.@]
314 ULONG WINAPI
RtlLengthSecurityDescriptor(
315 PSECURITY_DESCRIPTOR SecurityDescriptor
)
318 Size
= SECURITY_DESCRIPTOR_MIN_LENGTH
;
319 if ( SecurityDescriptor
== NULL
)
322 if ( SecurityDescriptor
->Owner
!= NULL
)
323 Size
+= SecurityDescriptor
->Owner
->SubAuthorityCount
;
324 if ( SecurityDescriptor
->Group
!= NULL
)
325 Size
+= SecurityDescriptor
->Group
->SubAuthorityCount
;
328 if ( SecurityDescriptor
->Sacl
!= NULL
)
329 Size
+= SecurityDescriptor
->Sacl
->AclSize
;
330 if ( SecurityDescriptor
->Dacl
!= NULL
)
331 Size
+= SecurityDescriptor
->Dacl
->AclSize
;
336 /******************************************************************************
337 * RtlGetDaclSecurityDescriptor [NTDLL.@]
340 NTSTATUS WINAPI
RtlGetDaclSecurityDescriptor(
341 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
342 OUT PBOOLEAN lpbDaclPresent
,
344 OUT PBOOLEAN lpbDaclDefaulted
)
346 TRACE("(%p,%p,%p,%p)\n",
347 pSecurityDescriptor
, lpbDaclPresent
, *pDacl
, lpbDaclDefaulted
);
349 if (pSecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
350 return STATUS_UNKNOWN_REVISION
;
352 if ( (*lpbDaclPresent
= (SE_DACL_PRESENT
& pSecurityDescriptor
->Control
) ? 1 : 0) )
354 if ( SE_SELF_RELATIVE
& pSecurityDescriptor
->Control
)
355 { *pDacl
= (PACL
) ((LPBYTE
)pSecurityDescriptor
+ (DWORD
)pSecurityDescriptor
->Dacl
);
358 { *pDacl
= pSecurityDescriptor
->Dacl
;
362 *lpbDaclDefaulted
= (( SE_DACL_DEFAULTED
& pSecurityDescriptor
->Control
) ? 1 : 0);
364 return STATUS_SUCCESS
;
367 /**************************************************************************
368 * RtlSetDaclSecurityDescriptor [NTDLL.@]
370 NTSTATUS WINAPI
RtlSetDaclSecurityDescriptor (
371 PSECURITY_DESCRIPTOR lpsd
,
374 BOOLEAN dacldefaulted
)
376 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
377 return STATUS_UNKNOWN_REVISION
;
378 if (lpsd
->Control
& SE_SELF_RELATIVE
)
379 return STATUS_INVALID_SECURITY_DESCR
;
382 { lpsd
->Control
&= ~SE_DACL_PRESENT
;
386 lpsd
->Control
|= SE_DACL_PRESENT
;
390 lpsd
->Control
|= SE_DACL_DEFAULTED
;
392 lpsd
->Control
&= ~SE_DACL_DEFAULTED
;
394 return STATUS_SUCCESS
;
397 /******************************************************************************
398 * RtlGetSaclSecurityDescriptor [NTDLL.@]
401 NTSTATUS WINAPI
RtlGetSaclSecurityDescriptor(
402 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
403 OUT PBOOLEAN lpbSaclPresent
,
405 OUT PBOOLEAN lpbSaclDefaulted
)
407 TRACE("(%p,%p,%p,%p)\n",
408 pSecurityDescriptor
, lpbSaclPresent
, *pSacl
, lpbSaclDefaulted
);
410 if (pSecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
411 return STATUS_UNKNOWN_REVISION
;
413 if ( (*lpbSaclPresent
= (SE_SACL_PRESENT
& pSecurityDescriptor
->Control
) ? 1 : 0) )
415 if ( SE_SELF_RELATIVE
& pSecurityDescriptor
->Control
)
416 { *pSacl
= (PACL
) ((LPBYTE
)pSecurityDescriptor
+ (DWORD
)pSecurityDescriptor
->Sacl
);
419 { *pSacl
= pSecurityDescriptor
->Sacl
;
423 *lpbSaclDefaulted
= (( SE_SACL_DEFAULTED
& pSecurityDescriptor
->Control
) ? 1 : 0);
425 return STATUS_SUCCESS
;
428 /**************************************************************************
429 * RtlSetSaclSecurityDescriptor [NTDLL.@]
431 NTSTATUS WINAPI
RtlSetSaclSecurityDescriptor (
432 PSECURITY_DESCRIPTOR lpsd
,
435 BOOLEAN sacldefaulted
)
437 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
438 return STATUS_UNKNOWN_REVISION
;
439 if (lpsd
->Control
& SE_SELF_RELATIVE
)
440 return STATUS_INVALID_SECURITY_DESCR
;
442 lpsd
->Control
&= ~SE_SACL_PRESENT
;
445 lpsd
->Control
|= SE_SACL_PRESENT
;
448 lpsd
->Control
|= SE_SACL_DEFAULTED
;
450 lpsd
->Control
&= ~SE_SACL_DEFAULTED
;
451 return STATUS_SUCCESS
;
454 /**************************************************************************
455 * RtlGetOwnerSecurityDescriptor [NTDLL.@]
457 NTSTATUS WINAPI
RtlGetOwnerSecurityDescriptor(
458 PSECURITY_DESCRIPTOR SecurityDescriptor
,
460 PBOOLEAN OwnerDefaulted
)
462 if ( !SecurityDescriptor
|| !Owner
|| !OwnerDefaulted
)
463 return STATUS_INVALID_PARAMETER
;
465 *Owner
= SecurityDescriptor
->Owner
;
466 if ( *Owner
!= NULL
) {
467 if ( SecurityDescriptor
->Control
& SE_OWNER_DEFAULTED
)
468 *OwnerDefaulted
= TRUE
;
470 *OwnerDefaulted
= FALSE
;
472 return STATUS_SUCCESS
;
475 /**************************************************************************
476 * RtlSetOwnerSecurityDescriptor [NTDLL.@]
478 NTSTATUS WINAPI
RtlSetOwnerSecurityDescriptor(
479 PSECURITY_DESCRIPTOR lpsd
,
481 BOOLEAN ownerdefaulted
)
483 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
484 return STATUS_UNKNOWN_REVISION
;
485 if (lpsd
->Control
& SE_SELF_RELATIVE
)
486 return STATUS_INVALID_SECURITY_DESCR
;
490 lpsd
->Control
|= SE_OWNER_DEFAULTED
;
492 lpsd
->Control
&= ~SE_OWNER_DEFAULTED
;
493 return STATUS_SUCCESS
;
496 /**************************************************************************
497 * RtlSetGroupSecurityDescriptor [NTDLL.@]
499 NTSTATUS WINAPI
RtlSetGroupSecurityDescriptor (
500 PSECURITY_DESCRIPTOR lpsd
,
502 BOOLEAN groupdefaulted
)
504 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
505 return STATUS_UNKNOWN_REVISION
;
506 if (lpsd
->Control
& SE_SELF_RELATIVE
)
507 return STATUS_INVALID_SECURITY_DESCR
;
511 lpsd
->Control
|= SE_GROUP_DEFAULTED
;
513 lpsd
->Control
&= ~SE_GROUP_DEFAULTED
;
514 return STATUS_SUCCESS
;
516 /**************************************************************************
517 * RtlGetGroupSecurityDescriptor [NTDLL.@]
519 NTSTATUS WINAPI
RtlGetGroupSecurityDescriptor(
520 PSECURITY_DESCRIPTOR SecurityDescriptor
,
522 PBOOLEAN GroupDefaulted
)
524 if ( !SecurityDescriptor
|| !Group
|| !GroupDefaulted
)
525 return STATUS_INVALID_PARAMETER
;
527 *Group
= SecurityDescriptor
->Group
;
528 if ( *Group
!= NULL
) {
529 if ( SecurityDescriptor
->Control
& SE_GROUP_DEFAULTED
)
530 *GroupDefaulted
= TRUE
;
532 *GroupDefaulted
= FALSE
;
534 return STATUS_SUCCESS
;
537 /**************************************************************************
538 * RtlMakeSelfRelativeSD [NTDLL.@]
540 NTSTATUS WINAPI
RtlMakeSelfRelativeSD(
541 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
542 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
543 IN OUT LPDWORD lpdwBufferLength
)
545 FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor
,
546 pSelfRelativeSecurityDescriptor
, lpdwBufferLength
,*lpdwBufferLength
);
547 return STATUS_SUCCESS
;
551 * access control list's
554 /**************************************************************************
555 * RtlCreateAcl [NTDLL.@]
558 * This should return NTSTATUS
560 NTSTATUS WINAPI
RtlCreateAcl(PACL acl
,DWORD size
,DWORD rev
)
562 TRACE("%p 0x%08lx 0x%08lx\n", acl
, size
, rev
);
564 if (rev
!=ACL_REVISION
)
565 return STATUS_INVALID_PARAMETER
;
566 if (size
<sizeof(ACL
))
567 return STATUS_BUFFER_TOO_SMALL
;
569 return STATUS_INVALID_PARAMETER
;
571 memset(acl
,'\0',sizeof(ACL
));
572 acl
->AclRevision
= rev
;
578 /**************************************************************************
579 * RtlFirstFreeAce [NTDLL.@]
580 * looks for the AceCount+1 ACE, and if it is still within the alloced
581 * ACL, return a pointer to it
583 BOOLEAN WINAPI
RtlFirstFreeAce(
591 ace
= (PACE_HEADER
)(acl
+1);
592 for (i
=0;i
<acl
->AceCount
;i
++) {
593 if ((DWORD
)ace
>=(((DWORD
)acl
)+acl
->AclSize
))
595 ace
= (PACE_HEADER
)(((BYTE
*)ace
)+ace
->AceSize
);
597 if ((DWORD
)ace
>=(((DWORD
)acl
)+acl
->AclSize
))
603 /**************************************************************************
604 * RtlAddAce [NTDLL.@]
606 NTSTATUS WINAPI
RtlAddAce(
610 PACE_HEADER acestart
,
613 PACE_HEADER ace
,targetace
;
616 if (acl
->AclRevision
!= ACL_REVISION
)
617 return STATUS_INVALID_PARAMETER
;
618 if (!RtlFirstFreeAce(acl
,&targetace
))
619 return STATUS_INVALID_PARAMETER
;
620 nrofaces
=0;ace
=acestart
;
621 while (((DWORD
)ace
-(DWORD
)acestart
)<acelen
) {
623 ace
= (PACE_HEADER
)(((BYTE
*)ace
)+ace
->AceSize
);
625 if ((DWORD
)targetace
+acelen
>(DWORD
)acl
+acl
->AclSize
) /* too much aces */
626 return STATUS_INVALID_PARAMETER
;
627 memcpy((LPBYTE
)targetace
,acestart
,acelen
);
628 acl
->AceCount
+=nrofaces
;
629 return STATUS_SUCCESS
;
632 /******************************************************************************
633 * RtlAddAccessAllowedAce [NTDLL.@]
635 BOOL WINAPI
RtlAddAccessAllowedAce(
637 IN DWORD dwAceRevision
,
641 FIXME("(%p,0x%08lx,0x%08lx,%p),stub!\n",
642 pAcl
, dwAceRevision
, AccessMask
, pSid
);
646 /******************************************************************************
647 * RtlGetAce [NTDLL.@]
649 DWORD WINAPI
RtlGetAce(PACL pAcl
,DWORD dwAceIndex
,LPVOID
*pAce
)
651 FIXME("(%p,%ld,%p),stub!\n",pAcl
,dwAceIndex
,pAce
);
659 /******************************************************************************
660 * RtlAdjustPrivilege [NTDLL.@]
662 DWORD WINAPI
RtlAdjustPrivilege(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
)
664 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
,x4
);
668 /******************************************************************************
669 * RtlImpersonateSelf [NTDLL.@]
672 RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
674 FIXME("(%08x), stub\n", ImpersonationLevel
);
678 /******************************************************************************
679 * NtAccessCheck [NTDLL.@]
683 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
684 IN HANDLE ClientToken
,
685 IN ACCESS_MASK DesiredAccess
,
686 IN PGENERIC_MAPPING GenericMapping
,
687 OUT PPRIVILEGE_SET PrivilegeSet
,
688 OUT PULONG ReturnLength
,
689 OUT PULONG GrantedAccess
,
690 OUT PBOOLEAN AccessStatus
)
692 FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
693 SecurityDescriptor
, ClientToken
, DesiredAccess
, GenericMapping
,
694 PrivilegeSet
, ReturnLength
, GrantedAccess
, AccessStatus
);
695 *AccessStatus
= TRUE
;
696 return STATUS_SUCCESS
;
699 /******************************************************************************
700 * NtSetSecurityObject [NTDLL.@]
705 IN SECURITY_INFORMATION SecurityInformation
,
706 IN PSECURITY_DESCRIPTOR SecurityDescriptor
)
708 FIXME("0x%08x 0x%08lx %p\n", Handle
, SecurityInformation
, SecurityDescriptor
);
709 return STATUS_SUCCESS
;
712 /******************************************************************************
713 * RtlGetControlSecurityDescriptor (NTDLL.@)
716 NTSTATUS WINAPI
RtlGetControlSecurityDescriptor(
717 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
718 PSECURITY_DESCRIPTOR_CONTROL pControl
,
719 LPDWORD lpdwRevision
)
721 FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor
,pControl
,lpdwRevision
);
722 return STATUS_SUCCESS
;
725 /******************************************************************************
726 * RtlConvertSidToUnicodeString (NTDLL.@)
728 * The returned SID is used to access the USER registry hive usually
730 * the native function returns something like
731 * "S-1-5-21-0000000000-000000000-0000000000-500";
733 NTSTATUS WINAPI
RtlConvertSidToUnicodeString(
734 PUNICODE_STRING String
,
736 BOOLEAN AllocateString
)
742 struct passwd
*pwd
= getpwuid( getuid() );
743 p
= (pwd
) ? pwd
->pw_name
: ".Default";
745 FIXME("(%p %p %u)\n", String
, Sid
, AllocateString
);
747 RtlInitAnsiString(&AnsiStr
, p
);
748 status
= RtlAnsiStringToUnicodeString(String
, &AnsiStr
, AllocateString
);
750 TRACE("%s (%u %u)\n",debugstr_w(String
->Buffer
),String
->Length
,String
->MaximumLength
);