- support DirectInput 8 interfaces.
[wine/multimedia.git] / dlls / ntdll / sec.c
blob25eb86e2186a02a9212384f994f90116a713115f
1 /*
2 * Security functions
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
21 #include <stdlib.h>
22 #include <string.h>
23 #include <time.h>
24 #include <ctype.h>
25 #include <math.h>
26 #include <pwd.h>
27 #include <unistd.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wine/exception.h"
32 #include "file.h"
33 #include "winnls.h"
34 #include "wine/debug.h"
35 #include "winerror.h"
36 #include "stackframe.h"
38 #include "ntddk.h"
39 #include "winreg.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;
56 * SID FUNCTIONS
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,
70 PSID *pSid )
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))))
78 return FALSE;
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))
112 return FALSE;
114 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
115 return FALSE;
117 if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
118 return FALSE;
120 return TRUE;
123 /******************************************************************************
124 * RtlEqualPrefixSid [NTDLL.@]
126 BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2)
128 if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
129 return FALSE;
131 if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
132 return FALSE;
134 if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
135 return FALSE;
137 return TRUE;
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.@]
154 * PARAMS
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);
168 if (!pSid) return 0;
169 return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid));
172 /**************************************************************************
173 * RtlInitializeSid [NTDLL.@]
175 BOOL WINAPI RtlInitializeSid(
176 PSID pSid,
177 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
178 BYTE nSubAuthorityCount)
180 int i;
181 if (nSubAuthorityCount >= SID_MAX_SUB_AUTHORITIES)
182 return FALSE;
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;
192 return TRUE;
195 /**************************************************************************
196 * RtlSubAuthoritySid [NTDLL.@]
198 * PARAMS
199 * pSid []
200 * nSubAuthority []
202 LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
204 return &(pSid->SubAuthority[nSubAuthority]);
207 /**************************************************************************
208 * RtlIdentifierAuthoritySid [NTDLL.@]
210 * PARAMS
211 * pSid []
213 PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
215 return &(pSid->IdentifierAuthority);
218 /**************************************************************************
219 * RtlSubAuthorityCountSid [NTDLL.@]
221 * PARAMS
222 * pSid []
223 * nSubAuthority []
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)))
237 return FALSE;
239 if (nDestinationSidLength < (pSourceSid->SubAuthorityCount*4+8))
240 return FALSE;
242 memmove(pDestinationSid, pSourceSid, pSourceSid->SubAuthorityCount*4+8);
243 return TRUE;
245 /******************************************************************************
246 * RtlValidSid [NTDLL.@]
248 * PARAMS
249 * pSid []
251 BOOL WINAPI
252 RtlValidSid( PSID pSid )
254 BOOL ret;
255 __TRY
257 ret = TRUE;
258 if (!pSid || pSid->Revision != SID_REVISION ||
259 pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
261 ret = FALSE;
264 __EXCEPT(page_fault)
266 WARN("(%p): invalid pointer!\n", pSid);
267 return FALSE;
269 __ENDTRY
270 return ret;
275 * security descriptor functions
278 /**************************************************************************
279 * RtlCreateSecurityDescriptor [NTDLL.@]
281 * RETURNS:
282 * 0 success,
283 * STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
284 * STATUS_NO_MEMORY
286 NTSTATUS WINAPI RtlCreateSecurityDescriptor(
287 PSECURITY_DESCRIPTOR lpsd,
288 DWORD rev)
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)
317 ULONG Size;
318 Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
319 if ( SecurityDescriptor == NULL )
320 return 0;
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;
333 return Size;
336 /******************************************************************************
337 * RtlGetDaclSecurityDescriptor [NTDLL.@]
340 NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
341 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
342 OUT PBOOLEAN lpbDaclPresent,
343 OUT PACL *pDacl,
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);
357 else
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,
372 BOOLEAN daclpresent,
373 PACL dacl,
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;
381 if (!daclpresent)
382 { lpsd->Control &= ~SE_DACL_PRESENT;
383 return TRUE;
386 lpsd->Control |= SE_DACL_PRESENT;
387 lpsd->Dacl = dacl;
389 if (dacldefaulted)
390 lpsd->Control |= SE_DACL_DEFAULTED;
391 else
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,
404 OUT PACL *pSacl,
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);
418 else
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,
433 BOOLEAN saclpresent,
434 PACL sacl,
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;
441 if (!saclpresent) {
442 lpsd->Control &= ~SE_SACL_PRESENT;
443 return 0;
445 lpsd->Control |= SE_SACL_PRESENT;
446 lpsd->Sacl = sacl;
447 if (sacldefaulted)
448 lpsd->Control |= SE_SACL_DEFAULTED;
449 else
450 lpsd->Control &= ~SE_SACL_DEFAULTED;
451 return STATUS_SUCCESS;
454 /**************************************************************************
455 * RtlGetOwnerSecurityDescriptor [NTDLL.@]
457 NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
458 PSECURITY_DESCRIPTOR SecurityDescriptor,
459 PSID *Owner,
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;
469 else
470 *OwnerDefaulted = FALSE;
472 return STATUS_SUCCESS;
475 /**************************************************************************
476 * RtlSetOwnerSecurityDescriptor [NTDLL.@]
478 NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
479 PSECURITY_DESCRIPTOR lpsd,
480 PSID owner,
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;
488 lpsd->Owner = owner;
489 if (ownerdefaulted)
490 lpsd->Control |= SE_OWNER_DEFAULTED;
491 else
492 lpsd->Control &= ~SE_OWNER_DEFAULTED;
493 return STATUS_SUCCESS;
496 /**************************************************************************
497 * RtlSetGroupSecurityDescriptor [NTDLL.@]
499 NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
500 PSECURITY_DESCRIPTOR lpsd,
501 PSID group,
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;
509 lpsd->Group = group;
510 if (groupdefaulted)
511 lpsd->Control |= SE_GROUP_DEFAULTED;
512 else
513 lpsd->Control &= ~SE_GROUP_DEFAULTED;
514 return STATUS_SUCCESS;
516 /**************************************************************************
517 * RtlGetGroupSecurityDescriptor [NTDLL.@]
519 NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
520 PSECURITY_DESCRIPTOR SecurityDescriptor,
521 PSID *Group,
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;
531 else
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.@]
557 * NOTES
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;
568 if (size>0xFFFF)
569 return STATUS_INVALID_PARAMETER;
571 memset(acl,'\0',sizeof(ACL));
572 acl->AclRevision = rev;
573 acl->AclSize = size;
574 acl->AceCount = 0;
575 return 0;
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(
584 PACL acl,
585 PACE_HEADER *x)
587 PACE_HEADER ace;
588 int i;
590 *x = 0;
591 ace = (PACE_HEADER)(acl+1);
592 for (i=0;i<acl->AceCount;i++) {
593 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
594 return 0;
595 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
597 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
598 return 0;
599 *x = ace;
600 return 1;
603 /**************************************************************************
604 * RtlAddAce [NTDLL.@]
606 NTSTATUS WINAPI RtlAddAce(
607 PACL acl,
608 DWORD rev,
609 DWORD xnrofaces,
610 PACE_HEADER acestart,
611 DWORD acelen)
613 PACE_HEADER ace,targetace;
614 int nrofaces;
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) {
622 nrofaces++;
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(
636 IN OUT PACL pAcl,
637 IN DWORD dwAceRevision,
638 IN DWORD AccessMask,
639 IN PSID pSid)
641 FIXME("(%p,0x%08lx,0x%08lx,%p),stub!\n",
642 pAcl, dwAceRevision, AccessMask, pSid);
643 return TRUE;
646 /******************************************************************************
647 * RtlGetAce [NTDLL.@]
649 DWORD WINAPI RtlGetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
651 FIXME("(%p,%ld,%p),stub!\n",pAcl,dwAceIndex,pAce);
652 return 0;
656 * misc
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);
665 return 0;
668 /******************************************************************************
669 * RtlImpersonateSelf [NTDLL.@]
671 BOOL WINAPI
672 RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
674 FIXME("(%08x), stub\n", ImpersonationLevel);
675 return TRUE;
678 /******************************************************************************
679 * NtAccessCheck [NTDLL.@]
681 NTSTATUS WINAPI
682 NtAccessCheck(
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.@]
702 NTSTATUS WINAPI
703 NtSetSecurityObject(
704 IN HANDLE Handle,
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,
735 PSID Sid,
736 BOOLEAN AllocateString)
738 const char *p;
739 NTSTATUS status;
740 ANSI_STRING AnsiStr;
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);
751 return status;