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
37 #include "wine/exception.h"
40 #include "wine/debug.h"
42 #include "stackframe.h"
46 #include "ntdll_misc.h"
47 #include "msvcrt/excpt.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
51 #define NT_SUCCESS(status) (status == STATUS_SUCCESS)
53 /* filter for page-fault exceptions */
54 static WINE_EXCEPTION_FILTER(page_fault
)
56 if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION
)
57 return EXCEPTION_EXECUTE_HANDLER
;
58 return EXCEPTION_CONTINUE_SEARCH
;
65 /******************************************************************************
66 * RtlAllocateAndInitializeSid [NTDLL.@]
69 BOOLEAN WINAPI
RtlAllocateAndInitializeSid (
70 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
71 BYTE nSubAuthorityCount
,
72 DWORD nSubAuthority0
, DWORD nSubAuthority1
,
73 DWORD nSubAuthority2
, DWORD nSubAuthority3
,
74 DWORD nSubAuthority4
, DWORD nSubAuthority5
,
75 DWORD nSubAuthority6
, DWORD nSubAuthority7
,
78 TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
79 pIdentifierAuthority
,nSubAuthorityCount
,
80 nSubAuthority0
, nSubAuthority1
, nSubAuthority2
, nSubAuthority3
,
81 nSubAuthority4
, nSubAuthority5
, nSubAuthority6
, nSubAuthority7
, pSid
);
83 if (!(*pSid
= RtlAllocateHeap( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount
))))
86 (*pSid
)->Revision
= SID_REVISION
;
88 if (pIdentifierAuthority
)
89 memcpy(&(*pSid
)->IdentifierAuthority
, pIdentifierAuthority
, sizeof (SID_IDENTIFIER_AUTHORITY
));
90 *RtlSubAuthorityCountSid(*pSid
) = nSubAuthorityCount
;
92 if (nSubAuthorityCount
> 0)
93 *RtlSubAuthoritySid(*pSid
, 0) = nSubAuthority0
;
94 if (nSubAuthorityCount
> 1)
95 *RtlSubAuthoritySid(*pSid
, 1) = nSubAuthority1
;
96 if (nSubAuthorityCount
> 2)
97 *RtlSubAuthoritySid(*pSid
, 2) = nSubAuthority2
;
98 if (nSubAuthorityCount
> 3)
99 *RtlSubAuthoritySid(*pSid
, 3) = nSubAuthority3
;
100 if (nSubAuthorityCount
> 4)
101 *RtlSubAuthoritySid(*pSid
, 4) = nSubAuthority4
;
102 if (nSubAuthorityCount
> 5)
103 *RtlSubAuthoritySid(*pSid
, 5) = nSubAuthority5
;
104 if (nSubAuthorityCount
> 6)
105 *RtlSubAuthoritySid(*pSid
, 6) = nSubAuthority6
;
106 if (nSubAuthorityCount
> 7)
107 *RtlSubAuthoritySid(*pSid
, 7) = nSubAuthority7
;
109 return STATUS_SUCCESS
;
111 /******************************************************************************
112 * RtlEqualSid [NTDLL.@]
115 BOOL WINAPI
RtlEqualSid( PSID pSid1
, PSID pSid2
)
117 if (!RtlValidSid(pSid1
) || !RtlValidSid(pSid2
))
120 if (*RtlSubAuthorityCountSid(pSid1
) != *RtlSubAuthorityCountSid(pSid2
))
123 if (memcmp(pSid1
, pSid2
, RtlLengthSid(pSid1
)) != 0)
129 /******************************************************************************
130 * RtlEqualPrefixSid [NTDLL.@]
132 BOOL WINAPI
RtlEqualPrefixSid (PSID pSid1
, PSID pSid2
)
134 if (!RtlValidSid(pSid1
) || !RtlValidSid(pSid2
))
137 if (*RtlSubAuthorityCountSid(pSid1
) != *RtlSubAuthorityCountSid(pSid2
))
140 if (memcmp(pSid1
, pSid2
, RtlLengthRequiredSid(pSid1
->SubAuthorityCount
- 1)) != 0)
147 /******************************************************************************
148 * RtlFreeSid [NTDLL.@]
150 DWORD WINAPI
RtlFreeSid(PSID pSid
)
152 TRACE("(%p)\n", pSid
);
153 RtlFreeHeap( GetProcessHeap(), 0, pSid
);
154 return STATUS_SUCCESS
;
157 /**************************************************************************
158 * RtlLengthRequiredSid [NTDLL.@]
161 * nSubAuthorityCount []
163 DWORD WINAPI
RtlLengthRequiredSid(DWORD nrofsubauths
)
165 return (nrofsubauths
-1)*sizeof(DWORD
) + sizeof(SID
);
168 /**************************************************************************
169 * RtlLengthSid [NTDLL.@]
171 DWORD WINAPI
RtlLengthSid(PSID pSid
)
173 TRACE("sid=%p\n",pSid
);
175 return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid
));
178 /**************************************************************************
179 * RtlInitializeSid [NTDLL.@]
181 BOOL WINAPI
RtlInitializeSid(
183 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
184 BYTE nSubAuthorityCount
)
187 if (nSubAuthorityCount
>= SID_MAX_SUB_AUTHORITIES
)
190 pSid
->Revision
= SID_REVISION
;
191 pSid
->SubAuthorityCount
= nSubAuthorityCount
;
192 if (pIdentifierAuthority
)
193 memcpy(&pSid
->IdentifierAuthority
, pIdentifierAuthority
, sizeof (SID_IDENTIFIER_AUTHORITY
));
195 for (i
= 0; i
< nSubAuthorityCount
; i
++)
196 *RtlSubAuthoritySid(pSid
, i
) = 0;
201 /**************************************************************************
202 * RtlSubAuthoritySid [NTDLL.@]
208 LPDWORD WINAPI
RtlSubAuthoritySid( PSID pSid
, DWORD nSubAuthority
)
210 return &(pSid
->SubAuthority
[nSubAuthority
]);
213 /**************************************************************************
214 * RtlIdentifierAuthoritySid [NTDLL.@]
219 PSID_IDENTIFIER_AUTHORITY WINAPI
RtlIdentifierAuthoritySid( PSID pSid
)
221 return &(pSid
->IdentifierAuthority
);
224 /**************************************************************************
225 * RtlSubAuthorityCountSid [NTDLL.@]
231 LPBYTE WINAPI
RtlSubAuthorityCountSid(PSID pSid
)
233 return &(pSid
->SubAuthorityCount
);
236 /**************************************************************************
237 * RtlCopySid [NTDLL.@]
239 DWORD WINAPI
RtlCopySid( DWORD nDestinationSidLength
, PSID pDestinationSid
, PSID pSourceSid
)
241 if (!pSourceSid
|| !RtlValidSid(pSourceSid
) ||
242 (nDestinationSidLength
< RtlLengthSid(pSourceSid
)))
245 if (nDestinationSidLength
< (pSourceSid
->SubAuthorityCount
*4+8))
248 memmove(pDestinationSid
, pSourceSid
, pSourceSid
->SubAuthorityCount
*4+8);
251 /******************************************************************************
252 * RtlValidSid [NTDLL.@]
258 RtlValidSid( PSID pSid
)
264 if (!pSid
|| pSid
->Revision
!= SID_REVISION
||
265 pSid
->SubAuthorityCount
> SID_MAX_SUB_AUTHORITIES
)
272 WARN("(%p): invalid pointer!\n", pSid
);
281 * security descriptor functions
284 /**************************************************************************
285 * RtlCreateSecurityDescriptor [NTDLL.@]
289 * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
292 NTSTATUS WINAPI
RtlCreateSecurityDescriptor(
293 PSECURITY_DESCRIPTOR lpsd
,
296 if (rev
!=SECURITY_DESCRIPTOR_REVISION
)
297 return STATUS_UNKNOWN_REVISION
;
298 memset(lpsd
,'\0',sizeof(*lpsd
));
299 lpsd
->Revision
= SECURITY_DESCRIPTOR_REVISION
;
300 return STATUS_SUCCESS
;
302 /**************************************************************************
303 * RtlValidSecurityDescriptor [NTDLL.@]
306 NTSTATUS WINAPI
RtlValidSecurityDescriptor(
307 PSECURITY_DESCRIPTOR SecurityDescriptor
)
309 if ( ! SecurityDescriptor
)
310 return STATUS_INVALID_SECURITY_DESCR
;
311 if ( SecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
312 return STATUS_UNKNOWN_REVISION
;
314 return STATUS_SUCCESS
;
317 /**************************************************************************
318 * RtlLengthSecurityDescriptor [NTDLL.@]
320 ULONG WINAPI
RtlLengthSecurityDescriptor(
321 PSECURITY_DESCRIPTOR SecurityDescriptor
)
324 Size
= SECURITY_DESCRIPTOR_MIN_LENGTH
;
325 if ( SecurityDescriptor
== NULL
)
328 if ( SecurityDescriptor
->Owner
!= NULL
)
329 Size
+= SecurityDescriptor
->Owner
->SubAuthorityCount
;
330 if ( SecurityDescriptor
->Group
!= NULL
)
331 Size
+= SecurityDescriptor
->Group
->SubAuthorityCount
;
334 if ( SecurityDescriptor
->Sacl
!= NULL
)
335 Size
+= SecurityDescriptor
->Sacl
->AclSize
;
336 if ( SecurityDescriptor
->Dacl
!= NULL
)
337 Size
+= SecurityDescriptor
->Dacl
->AclSize
;
342 /******************************************************************************
343 * RtlGetDaclSecurityDescriptor [NTDLL.@]
346 NTSTATUS WINAPI
RtlGetDaclSecurityDescriptor(
347 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
348 OUT PBOOLEAN lpbDaclPresent
,
350 OUT PBOOLEAN lpbDaclDefaulted
)
352 TRACE("(%p,%p,%p,%p)\n",
353 pSecurityDescriptor
, lpbDaclPresent
, *pDacl
, lpbDaclDefaulted
);
355 if (pSecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
356 return STATUS_UNKNOWN_REVISION
;
358 if ( (*lpbDaclPresent
= (SE_DACL_PRESENT
& pSecurityDescriptor
->Control
) ? 1 : 0) )
360 if ( SE_SELF_RELATIVE
& pSecurityDescriptor
->Control
)
361 { *pDacl
= (PACL
) ((LPBYTE
)pSecurityDescriptor
+ (DWORD
)pSecurityDescriptor
->Dacl
);
364 { *pDacl
= pSecurityDescriptor
->Dacl
;
368 *lpbDaclDefaulted
= (( SE_DACL_DEFAULTED
& pSecurityDescriptor
->Control
) ? 1 : 0);
370 return STATUS_SUCCESS
;
373 /**************************************************************************
374 * RtlSetDaclSecurityDescriptor [NTDLL.@]
376 NTSTATUS WINAPI
RtlSetDaclSecurityDescriptor (
377 PSECURITY_DESCRIPTOR lpsd
,
380 BOOLEAN dacldefaulted
)
382 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
383 return STATUS_UNKNOWN_REVISION
;
384 if (lpsd
->Control
& SE_SELF_RELATIVE
)
385 return STATUS_INVALID_SECURITY_DESCR
;
388 { lpsd
->Control
&= ~SE_DACL_PRESENT
;
392 lpsd
->Control
|= SE_DACL_PRESENT
;
396 lpsd
->Control
|= SE_DACL_DEFAULTED
;
398 lpsd
->Control
&= ~SE_DACL_DEFAULTED
;
400 return STATUS_SUCCESS
;
403 /******************************************************************************
404 * RtlGetSaclSecurityDescriptor [NTDLL.@]
407 NTSTATUS WINAPI
RtlGetSaclSecurityDescriptor(
408 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
409 OUT PBOOLEAN lpbSaclPresent
,
411 OUT PBOOLEAN lpbSaclDefaulted
)
413 TRACE("(%p,%p,%p,%p)\n",
414 pSecurityDescriptor
, lpbSaclPresent
, *pSacl
, lpbSaclDefaulted
);
416 if (pSecurityDescriptor
->Revision
!= SECURITY_DESCRIPTOR_REVISION
)
417 return STATUS_UNKNOWN_REVISION
;
419 if ( (*lpbSaclPresent
= (SE_SACL_PRESENT
& pSecurityDescriptor
->Control
) ? 1 : 0) )
421 if ( SE_SELF_RELATIVE
& pSecurityDescriptor
->Control
)
422 { *pSacl
= (PACL
) ((LPBYTE
)pSecurityDescriptor
+ (DWORD
)pSecurityDescriptor
->Sacl
);
425 { *pSacl
= pSecurityDescriptor
->Sacl
;
429 *lpbSaclDefaulted
= (( SE_SACL_DEFAULTED
& pSecurityDescriptor
->Control
) ? 1 : 0);
431 return STATUS_SUCCESS
;
434 /**************************************************************************
435 * RtlSetSaclSecurityDescriptor [NTDLL.@]
437 NTSTATUS WINAPI
RtlSetSaclSecurityDescriptor (
438 PSECURITY_DESCRIPTOR lpsd
,
441 BOOLEAN sacldefaulted
)
443 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
444 return STATUS_UNKNOWN_REVISION
;
445 if (lpsd
->Control
& SE_SELF_RELATIVE
)
446 return STATUS_INVALID_SECURITY_DESCR
;
448 lpsd
->Control
&= ~SE_SACL_PRESENT
;
451 lpsd
->Control
|= SE_SACL_PRESENT
;
454 lpsd
->Control
|= SE_SACL_DEFAULTED
;
456 lpsd
->Control
&= ~SE_SACL_DEFAULTED
;
457 return STATUS_SUCCESS
;
460 /**************************************************************************
461 * RtlGetOwnerSecurityDescriptor [NTDLL.@]
463 NTSTATUS WINAPI
RtlGetOwnerSecurityDescriptor(
464 PSECURITY_DESCRIPTOR SecurityDescriptor
,
466 PBOOLEAN OwnerDefaulted
)
468 if ( !SecurityDescriptor
|| !Owner
|| !OwnerDefaulted
)
469 return STATUS_INVALID_PARAMETER
;
471 *Owner
= SecurityDescriptor
->Owner
;
472 if ( *Owner
!= NULL
) {
473 if ( SecurityDescriptor
->Control
& SE_OWNER_DEFAULTED
)
474 *OwnerDefaulted
= TRUE
;
476 *OwnerDefaulted
= FALSE
;
478 return STATUS_SUCCESS
;
481 /**************************************************************************
482 * RtlSetOwnerSecurityDescriptor [NTDLL.@]
484 NTSTATUS WINAPI
RtlSetOwnerSecurityDescriptor(
485 PSECURITY_DESCRIPTOR lpsd
,
487 BOOLEAN ownerdefaulted
)
489 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
490 return STATUS_UNKNOWN_REVISION
;
491 if (lpsd
->Control
& SE_SELF_RELATIVE
)
492 return STATUS_INVALID_SECURITY_DESCR
;
496 lpsd
->Control
|= SE_OWNER_DEFAULTED
;
498 lpsd
->Control
&= ~SE_OWNER_DEFAULTED
;
499 return STATUS_SUCCESS
;
502 /**************************************************************************
503 * RtlSetGroupSecurityDescriptor [NTDLL.@]
505 NTSTATUS WINAPI
RtlSetGroupSecurityDescriptor (
506 PSECURITY_DESCRIPTOR lpsd
,
508 BOOLEAN groupdefaulted
)
510 if (lpsd
->Revision
!=SECURITY_DESCRIPTOR_REVISION
)
511 return STATUS_UNKNOWN_REVISION
;
512 if (lpsd
->Control
& SE_SELF_RELATIVE
)
513 return STATUS_INVALID_SECURITY_DESCR
;
517 lpsd
->Control
|= SE_GROUP_DEFAULTED
;
519 lpsd
->Control
&= ~SE_GROUP_DEFAULTED
;
520 return STATUS_SUCCESS
;
522 /**************************************************************************
523 * RtlGetGroupSecurityDescriptor [NTDLL.@]
525 NTSTATUS WINAPI
RtlGetGroupSecurityDescriptor(
526 PSECURITY_DESCRIPTOR SecurityDescriptor
,
528 PBOOLEAN GroupDefaulted
)
530 if ( !SecurityDescriptor
|| !Group
|| !GroupDefaulted
)
531 return STATUS_INVALID_PARAMETER
;
533 *Group
= SecurityDescriptor
->Group
;
534 if ( *Group
!= NULL
) {
535 if ( SecurityDescriptor
->Control
& SE_GROUP_DEFAULTED
)
536 *GroupDefaulted
= TRUE
;
538 *GroupDefaulted
= FALSE
;
540 return STATUS_SUCCESS
;
543 /**************************************************************************
544 * RtlMakeSelfRelativeSD [NTDLL.@]
546 NTSTATUS WINAPI
RtlMakeSelfRelativeSD(
547 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
548 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
549 IN OUT LPDWORD lpdwBufferLength
)
551 FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor
,
552 pSelfRelativeSecurityDescriptor
, lpdwBufferLength
,*lpdwBufferLength
);
553 return STATUS_SUCCESS
;
557 * access control list's
560 /**************************************************************************
561 * RtlCreateAcl [NTDLL.@]
564 * This should return NTSTATUS
566 NTSTATUS WINAPI
RtlCreateAcl(PACL acl
,DWORD size
,DWORD rev
)
568 TRACE("%p 0x%08lx 0x%08lx\n", acl
, size
, rev
);
570 if (rev
!=ACL_REVISION
)
571 return STATUS_INVALID_PARAMETER
;
572 if (size
<sizeof(ACL
))
573 return STATUS_BUFFER_TOO_SMALL
;
575 return STATUS_INVALID_PARAMETER
;
577 memset(acl
,'\0',sizeof(ACL
));
578 acl
->AclRevision
= rev
;
584 /**************************************************************************
585 * RtlFirstFreeAce [NTDLL.@]
586 * looks for the AceCount+1 ACE, and if it is still within the alloced
587 * ACL, return a pointer to it
589 BOOLEAN WINAPI
RtlFirstFreeAce(
597 ace
= (PACE_HEADER
)(acl
+1);
598 for (i
=0;i
<acl
->AceCount
;i
++) {
599 if ((DWORD
)ace
>=(((DWORD
)acl
)+acl
->AclSize
))
601 ace
= (PACE_HEADER
)(((BYTE
*)ace
)+ace
->AceSize
);
603 if ((DWORD
)ace
>=(((DWORD
)acl
)+acl
->AclSize
))
609 /**************************************************************************
610 * RtlAddAce [NTDLL.@]
612 NTSTATUS WINAPI
RtlAddAce(
616 PACE_HEADER acestart
,
619 PACE_HEADER ace
,targetace
;
622 if (acl
->AclRevision
!= ACL_REVISION
)
623 return STATUS_INVALID_PARAMETER
;
624 if (!RtlFirstFreeAce(acl
,&targetace
))
625 return STATUS_INVALID_PARAMETER
;
626 nrofaces
=0;ace
=acestart
;
627 while (((DWORD
)ace
-(DWORD
)acestart
)<acelen
) {
629 ace
= (PACE_HEADER
)(((BYTE
*)ace
)+ace
->AceSize
);
631 if ((DWORD
)targetace
+acelen
>(DWORD
)acl
+acl
->AclSize
) /* too much aces */
632 return STATUS_INVALID_PARAMETER
;
633 memcpy((LPBYTE
)targetace
,acestart
,acelen
);
634 acl
->AceCount
+=nrofaces
;
635 return STATUS_SUCCESS
;
638 /******************************************************************************
639 * RtlAddAccessAllowedAce [NTDLL.@]
641 BOOL WINAPI
RtlAddAccessAllowedAce(
643 IN DWORD dwAceRevision
,
647 FIXME("(%p,0x%08lx,0x%08lx,%p),stub!\n",
648 pAcl
, dwAceRevision
, AccessMask
, pSid
);
652 /******************************************************************************
653 * RtlGetAce [NTDLL.@]
655 DWORD WINAPI
RtlGetAce(PACL pAcl
,DWORD dwAceIndex
,LPVOID
*pAce
)
657 FIXME("(%p,%ld,%p),stub!\n",pAcl
,dwAceIndex
,pAce
);
665 /******************************************************************************
666 * RtlAdjustPrivilege [NTDLL.@]
668 DWORD WINAPI
RtlAdjustPrivilege(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
)
670 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
,x4
);
674 /******************************************************************************
675 * RtlImpersonateSelf [NTDLL.@]
678 RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
680 FIXME("(%08x), stub\n", ImpersonationLevel
);
684 /******************************************************************************
685 * NtAccessCheck [NTDLL.@]
689 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
690 IN HANDLE ClientToken
,
691 IN ACCESS_MASK DesiredAccess
,
692 IN PGENERIC_MAPPING GenericMapping
,
693 OUT PPRIVILEGE_SET PrivilegeSet
,
694 OUT PULONG ReturnLength
,
695 OUT PULONG GrantedAccess
,
696 OUT PBOOLEAN AccessStatus
)
698 FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
699 SecurityDescriptor
, ClientToken
, DesiredAccess
, GenericMapping
,
700 PrivilegeSet
, ReturnLength
, GrantedAccess
, AccessStatus
);
701 *AccessStatus
= TRUE
;
702 return STATUS_SUCCESS
;
705 /******************************************************************************
706 * NtSetSecurityObject [NTDLL.@]
711 IN SECURITY_INFORMATION SecurityInformation
,
712 IN PSECURITY_DESCRIPTOR SecurityDescriptor
)
714 FIXME("0x%08x 0x%08lx %p\n", Handle
, SecurityInformation
, SecurityDescriptor
);
715 return STATUS_SUCCESS
;
718 /******************************************************************************
719 * RtlGetControlSecurityDescriptor (NTDLL.@)
722 NTSTATUS WINAPI
RtlGetControlSecurityDescriptor(
723 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
724 PSECURITY_DESCRIPTOR_CONTROL pControl
,
725 LPDWORD lpdwRevision
)
727 FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor
,pControl
,lpdwRevision
);
728 return STATUS_SUCCESS
;
731 /******************************************************************************
732 * RtlConvertSidToUnicodeString (NTDLL.@)
734 * The returned SID is used to access the USER registry hive usually
736 * the native function returns something like
737 * "S-1-5-21-0000000000-000000000-0000000000-500";
739 NTSTATUS WINAPI
RtlConvertSidToUnicodeString(
740 PUNICODE_STRING String
,
742 BOOLEAN AllocateString
)
749 struct passwd
*pwd
= getpwuid( getuid() );
750 p
= pwd
? pwd
->pw_name
: NULL
;
754 p
= p
? p
: ".Default";
756 FIXME("(%p %p %u)\n", String
, Sid
, AllocateString
);
758 RtlInitAnsiString(&AnsiStr
, p
);
759 status
= RtlAnsiStringToUnicodeString(String
, &AnsiStr
, AllocateString
);
761 TRACE("%s (%u %u)\n",debugstr_w(String
->Buffer
),String
->Length
,String
->MaximumLength
);