Remove Get/SetBeepActive from USER driver and manage it locally inside
[wine] / dlls / ntdll / sec.c
1 /*
2  *      Security functions
3  *
4  *      Copyright 1996-1998 Marcus Meissner
5  */
6
7 #include <stdlib.h>
8 #include <string.h>
9 #include <time.h>
10 #include <ctype.h>
11 #include <math.h>
12 #include "windef.h"
13 #include "winbase.h"
14 #include "wine/exception.h"
15 #include "file.h"
16 #include "heap.h"
17 #include "winnls.h"
18 #include "debugtools.h"
19 #include "winerror.h"
20 #include "stackframe.h"
21
22 #include "ntddk.h"
23 #include "winreg.h"
24 #include "ntdll_misc.h"
25
26 DEFAULT_DEBUG_CHANNEL(ntdll);
27
28 #define NT_SUCCESS(status) (status == STATUS_SUCCESS)
29
30 /* filter for page-fault exceptions */
31 static WINE_EXCEPTION_FILTER(page_fault)
32 {
33     if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
34         return EXCEPTION_EXECUTE_HANDLER;
35     return EXCEPTION_CONTINUE_SEARCH;
36 }
37
38 /*
39  *      SID FUNCTIONS
40  */
41
42 /******************************************************************************
43  *  RtlAllocateAndInitializeSid         [NTDLL.265] 
44  *
45  */
46 BOOLEAN WINAPI RtlAllocateAndInitializeSid (
47         PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
48         BYTE nSubAuthorityCount,
49         DWORD nSubAuthority0, DWORD nSubAuthority1,
50         DWORD nSubAuthority2, DWORD nSubAuthority3,
51         DWORD nSubAuthority4, DWORD nSubAuthority5,
52         DWORD nSubAuthority6, DWORD nSubAuthority7,
53         PSID *pSid )
54 {
55         TRACE("(%p, 0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,%p)\n",
56                 pIdentifierAuthority,nSubAuthorityCount,
57                 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
58                 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7, pSid);
59
60         if (!(*pSid = HeapAlloc( GetProcessHeap(), 0, RtlLengthRequiredSid(nSubAuthorityCount))))
61           return FALSE;
62
63         (*pSid)->Revision = SID_REVISION;
64
65         if (pIdentifierAuthority)
66           memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
67         *RtlSubAuthorityCountSid(*pSid) = nSubAuthorityCount;
68
69         if (nSubAuthorityCount > 0)
70           *RtlSubAuthoritySid(*pSid, 0) = nSubAuthority0;
71         if (nSubAuthorityCount > 1)
72           *RtlSubAuthoritySid(*pSid, 1) = nSubAuthority1;
73         if (nSubAuthorityCount > 2)
74           *RtlSubAuthoritySid(*pSid, 2) = nSubAuthority2;
75         if (nSubAuthorityCount > 3)
76           *RtlSubAuthoritySid(*pSid, 3) = nSubAuthority3;
77         if (nSubAuthorityCount > 4)
78           *RtlSubAuthoritySid(*pSid, 4) = nSubAuthority4;
79         if (nSubAuthorityCount > 5)
80           *RtlSubAuthoritySid(*pSid, 5) = nSubAuthority5;
81         if (nSubAuthorityCount > 6)
82           *RtlSubAuthoritySid(*pSid, 6) = nSubAuthority6;
83         if (nSubAuthorityCount > 7)
84           *RtlSubAuthoritySid(*pSid, 7) = nSubAuthority7;
85
86         return STATUS_SUCCESS;
87 }
88 /******************************************************************************
89  *  RtlEqualSid         [NTDLL.352] 
90  *
91  */
92 BOOL WINAPI RtlEqualSid( PSID pSid1, PSID pSid2 )
93 {
94     if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
95         return FALSE;
96
97     if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
98         return FALSE;
99
100     if (memcmp(pSid1, pSid2, RtlLengthSid(pSid1)) != 0)
101         return FALSE;
102
103     return TRUE;
104 }
105
106 /******************************************************************************
107  * RtlEqualPrefixSid    [ntdll.]
108  */
109 BOOL WINAPI RtlEqualPrefixSid (PSID pSid1, PSID pSid2) 
110 {
111     if (!RtlValidSid(pSid1) || !RtlValidSid(pSid2))
112         return FALSE;
113
114     if (*RtlSubAuthorityCountSid(pSid1) != *RtlSubAuthorityCountSid(pSid2))
115         return FALSE;
116
117     if (memcmp(pSid1, pSid2, RtlLengthRequiredSid(pSid1->SubAuthorityCount - 1)) != 0)
118         return FALSE;
119
120     return TRUE;
121 }
122
123
124 /******************************************************************************
125  *  RtlFreeSid          [NTDLL.376] 
126  */
127 DWORD WINAPI RtlFreeSid(PSID pSid) 
128 {
129         TRACE("(%p)\n", pSid);
130         HeapFree( GetProcessHeap(), 0, pSid );
131         return STATUS_SUCCESS;
132 }
133
134 /**************************************************************************
135  * RtlLengthRequiredSid [NTDLL.427]
136  *
137  * PARAMS
138  *   nSubAuthorityCount []
139  */
140 DWORD WINAPI RtlLengthRequiredSid(DWORD nrofsubauths)
141 {
142         return (nrofsubauths-1)*sizeof(DWORD) + sizeof(SID);
143 }
144
145 /**************************************************************************
146  *                 RtlLengthSid                         [NTDLL.429]
147  */
148 DWORD WINAPI RtlLengthSid(PSID pSid)
149 {
150         TRACE("sid=%p\n",pSid);
151         if (!pSid) return 0; 
152         return RtlLengthRequiredSid(*RtlSubAuthorityCountSid(pSid));
153 }
154
155 /**************************************************************************
156  *                 RtlInitializeSid                     [NTDLL.410]
157  */
158 BOOL WINAPI RtlInitializeSid(
159         PSID pSid,
160         PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
161         BYTE nSubAuthorityCount)
162 {
163         int i;
164         if (nSubAuthorityCount >= SID_MAX_SUB_AUTHORITIES)
165           return FALSE;
166
167         pSid->Revision = SID_REVISION;
168         pSid->SubAuthorityCount = nSubAuthorityCount;
169         if (pIdentifierAuthority)
170           memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority, sizeof (SID_IDENTIFIER_AUTHORITY));
171
172         for (i = 0; i < nSubAuthorityCount; i++)
173           *RtlSubAuthoritySid(pSid, i) = 0;
174
175         return TRUE;
176 }
177
178 /**************************************************************************
179  *                 RtlSubAuthoritySid                   [NTDLL.497]
180  *
181  * PARAMS
182  *   pSid          []
183  *   nSubAuthority []
184  */
185 LPDWORD WINAPI RtlSubAuthoritySid( PSID pSid, DWORD nSubAuthority )
186 {
187         return &(pSid->SubAuthority[nSubAuthority]);
188 }
189
190 /**************************************************************************
191  * RtlIdentifierAuthoritySid    [NTDLL.395]
192  *
193  * PARAMS
194  *   pSid []
195  */
196 PSID_IDENTIFIER_AUTHORITY WINAPI RtlIdentifierAuthoritySid( PSID pSid )
197 {
198         return &(pSid->IdentifierAuthority);
199 }
200
201 /**************************************************************************
202  *                 RtlSubAuthorityCountSid              [NTDLL.496]
203  *
204  * PARAMS
205  *   pSid          []
206  *   nSubAuthority []
207  */
208 LPBYTE WINAPI RtlSubAuthorityCountSid(PSID pSid)
209 {
210         return &(pSid->SubAuthorityCount);
211 }
212
213 /**************************************************************************
214  *                 RtlCopySid                           [NTDLL.302]
215  */
216 DWORD WINAPI RtlCopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
217 {
218         if (!pSourceSid || !RtlValidSid(pSourceSid) ||
219             (nDestinationSidLength < RtlLengthSid(pSourceSid)))
220           return FALSE;
221
222         if (nDestinationSidLength < (pSourceSid->SubAuthorityCount*4+8))
223           return FALSE;
224
225         memmove(pDestinationSid, pSourceSid, pSourceSid->SubAuthorityCount*4+8);
226         return TRUE;
227 }
228 /******************************************************************************
229  * RtlValidSid [NTDLL.532]
230  *
231  * PARAMS
232  *   pSid []
233  */
234 BOOL WINAPI
235 RtlValidSid( PSID pSid )
236 {
237     BOOL ret;
238     __TRY
239     {
240         ret = TRUE;
241         if (!pSid || pSid->Revision != SID_REVISION ||
242             pSid->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES)
243         {
244             ret = FALSE;
245         }
246     }
247     __EXCEPT(page_fault)
248     {
249         WARN("(%p): invalid pointer!\n", pSid);
250         return FALSE;
251     }
252     __ENDTRY
253     return ret;
254 }
255
256
257 /*
258  *      security descriptor functions
259  */
260
261 /**************************************************************************
262  * RtlCreateSecurityDescriptor                  [NTDLL.313]
263  *
264  * RETURNS:
265  *  0 success, 
266  *  STATUS_INVALID_OWNER, STATUS_PRIVILEGE_NOT_HELD, STATUS_NO_INHERITANCE,
267  *  STATUS_NO_MEMORY 
268  */
269 NTSTATUS WINAPI RtlCreateSecurityDescriptor(
270         PSECURITY_DESCRIPTOR lpsd,
271         DWORD rev)
272 {
273         if (rev!=SECURITY_DESCRIPTOR_REVISION)
274                 return STATUS_UNKNOWN_REVISION;
275         memset(lpsd,'\0',sizeof(*lpsd));
276         lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
277         return STATUS_SUCCESS;
278 }
279 /**************************************************************************
280  * RtlValidSecurityDescriptor                   [NTDLL.313]
281  *
282  */
283 NTSTATUS WINAPI RtlValidSecurityDescriptor(
284         PSECURITY_DESCRIPTOR SecurityDescriptor)
285 {
286         if ( ! SecurityDescriptor )
287                 return STATUS_INVALID_SECURITY_DESCR;
288         if ( SecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION )
289                 return STATUS_UNKNOWN_REVISION;
290
291         return STATUS_SUCCESS;
292 }
293
294 /**************************************************************************
295  *  RtlLengthSecurityDescriptor                 [NTDLL]
296  */
297 ULONG WINAPI RtlLengthSecurityDescriptor(
298         PSECURITY_DESCRIPTOR SecurityDescriptor)
299 {
300         ULONG Size;
301         Size = SECURITY_DESCRIPTOR_MIN_LENGTH;
302         if ( SecurityDescriptor == NULL )
303                 return 0;
304
305         if ( SecurityDescriptor->Owner != NULL )
306                 Size += SecurityDescriptor->Owner->SubAuthorityCount;
307         if ( SecurityDescriptor->Group != NULL )
308                 Size += SecurityDescriptor->Group->SubAuthorityCount;
309
310
311         if ( SecurityDescriptor->Sacl != NULL )
312                 Size += SecurityDescriptor->Sacl->AclSize;
313         if ( SecurityDescriptor->Dacl != NULL )
314                 Size += SecurityDescriptor->Dacl->AclSize;
315
316         return Size;
317 }
318
319 /******************************************************************************
320  *  RtlGetDaclSecurityDescriptor                [NTDLL] 
321  *
322  */
323 NTSTATUS WINAPI RtlGetDaclSecurityDescriptor(
324         IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
325         OUT PBOOLEAN lpbDaclPresent,
326         OUT PACL *pDacl,
327         OUT PBOOLEAN lpbDaclDefaulted)
328 {
329         TRACE("(%p,%p,%p,%p)\n",
330         pSecurityDescriptor, lpbDaclPresent, *pDacl, lpbDaclDefaulted);
331
332         if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
333           return STATUS_UNKNOWN_REVISION ;
334
335         if ( (*lpbDaclPresent = (SE_DACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
336         {
337           if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
338           { *pDacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Dacl);
339           }
340           else
341           { *pDacl = pSecurityDescriptor->Dacl;
342           }
343         }
344
345         *lpbDaclDefaulted = (( SE_DACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
346         
347         return STATUS_SUCCESS;
348 }
349
350 /**************************************************************************
351  *  RtlSetDaclSecurityDescriptor                [NTDLL.483]
352  */
353 NTSTATUS WINAPI RtlSetDaclSecurityDescriptor (
354         PSECURITY_DESCRIPTOR lpsd,
355         BOOLEAN daclpresent,
356         PACL dacl,
357         BOOLEAN dacldefaulted )
358 {
359         if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
360                 return STATUS_UNKNOWN_REVISION;
361         if (lpsd->Control & SE_SELF_RELATIVE)
362                 return STATUS_INVALID_SECURITY_DESCR;
363
364         if (!daclpresent) 
365         {       lpsd->Control &= ~SE_DACL_PRESENT;
366                 return TRUE;
367         }
368
369         lpsd->Control |= SE_DACL_PRESENT;
370         lpsd->Dacl = dacl;
371
372         if (dacldefaulted)
373                 lpsd->Control |= SE_DACL_DEFAULTED;
374         else
375                 lpsd->Control &= ~SE_DACL_DEFAULTED;
376
377         return STATUS_SUCCESS;
378 }
379
380 /******************************************************************************
381  *  RtlGetSaclSecurityDescriptor                [NTDLL] 
382  *
383  */
384 NTSTATUS WINAPI RtlGetSaclSecurityDescriptor(
385         IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
386         OUT PBOOLEAN lpbSaclPresent,
387         OUT PACL *pSacl,
388         OUT PBOOLEAN lpbSaclDefaulted)
389 {
390         TRACE("(%p,%p,%p,%p)\n",
391         pSecurityDescriptor, lpbSaclPresent, *pSacl, lpbSaclDefaulted);
392
393         if (pSecurityDescriptor->Revision != SECURITY_DESCRIPTOR_REVISION)
394           return STATUS_UNKNOWN_REVISION ;
395
396         if ( (*lpbSaclPresent = (SE_SACL_PRESENT & pSecurityDescriptor->Control) ? 1 : 0) )
397         {
398           if ( SE_SELF_RELATIVE & pSecurityDescriptor->Control)
399           { *pSacl = (PACL) ((LPBYTE)pSecurityDescriptor + (DWORD)pSecurityDescriptor->Sacl);
400           }
401           else
402           { *pSacl = pSecurityDescriptor->Sacl;
403           }
404         }
405
406         *lpbSaclDefaulted = (( SE_SACL_DEFAULTED & pSecurityDescriptor->Control ) ? 1 : 0);
407         
408         return STATUS_SUCCESS;
409 }
410
411 /**************************************************************************
412  * RtlSetSaclSecurityDescriptor                 [NTDLL.488]
413  */
414 NTSTATUS WINAPI RtlSetSaclSecurityDescriptor (
415         PSECURITY_DESCRIPTOR lpsd,
416         BOOLEAN saclpresent,
417         PACL sacl,
418         BOOLEAN sacldefaulted)
419 {
420         if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
421                 return STATUS_UNKNOWN_REVISION;
422         if (lpsd->Control & SE_SELF_RELATIVE)
423                 return STATUS_INVALID_SECURITY_DESCR;
424         if (!saclpresent) {
425                 lpsd->Control &= ~SE_SACL_PRESENT;
426                 return 0;
427         }
428         lpsd->Control |= SE_SACL_PRESENT;
429         lpsd->Sacl = sacl;
430         if (sacldefaulted)
431                 lpsd->Control |= SE_SACL_DEFAULTED;
432         else
433                 lpsd->Control &= ~SE_SACL_DEFAULTED;
434         return STATUS_SUCCESS;
435 }
436
437 /**************************************************************************
438  * RtlGetOwnerSecurityDescriptor                [NTDLL.488]
439  */
440 NTSTATUS WINAPI RtlGetOwnerSecurityDescriptor(
441         PSECURITY_DESCRIPTOR SecurityDescriptor,
442         PSID *Owner,
443         PBOOLEAN OwnerDefaulted)
444 {
445         if ( !SecurityDescriptor  || !Owner || !OwnerDefaulted )
446                 return STATUS_INVALID_PARAMETER;
447
448         *Owner = SecurityDescriptor->Owner;
449         if ( *Owner != NULL )  {
450                 if ( SecurityDescriptor->Control & SE_OWNER_DEFAULTED )
451                         *OwnerDefaulted = TRUE;
452                 else
453                         *OwnerDefaulted = FALSE;
454         }
455         return STATUS_SUCCESS;
456 }
457
458 /**************************************************************************
459  *                 RtlSetOwnerSecurityDescriptor                [NTDLL.487]
460  */
461 NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(
462         PSECURITY_DESCRIPTOR lpsd,
463         PSID owner,
464         BOOLEAN ownerdefaulted)
465 {
466         if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
467                 return STATUS_UNKNOWN_REVISION;
468         if (lpsd->Control & SE_SELF_RELATIVE)
469                 return STATUS_INVALID_SECURITY_DESCR;
470
471         lpsd->Owner = owner;
472         if (ownerdefaulted)
473                 lpsd->Control |= SE_OWNER_DEFAULTED;
474         else
475                 lpsd->Control &= ~SE_OWNER_DEFAULTED;
476         return STATUS_SUCCESS;
477 }
478
479 /**************************************************************************
480  *                 RtlSetGroupSecurityDescriptor                [NTDLL.485]
481  */
482 NTSTATUS WINAPI RtlSetGroupSecurityDescriptor (
483         PSECURITY_DESCRIPTOR lpsd,
484         PSID group,
485         BOOLEAN groupdefaulted)
486 {
487         if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
488                 return STATUS_UNKNOWN_REVISION;
489         if (lpsd->Control & SE_SELF_RELATIVE)
490                 return STATUS_INVALID_SECURITY_DESCR;
491
492         lpsd->Group = group;
493         if (groupdefaulted)
494                 lpsd->Control |= SE_GROUP_DEFAULTED;
495         else
496                 lpsd->Control &= ~SE_GROUP_DEFAULTED;
497         return STATUS_SUCCESS;
498 }
499 /**************************************************************************
500  *                 RtlGetGroupSecurityDescriptor                [NTDLL]
501  */
502 NTSTATUS WINAPI RtlGetGroupSecurityDescriptor(
503         PSECURITY_DESCRIPTOR SecurityDescriptor,
504         PSID *Group,
505         PBOOLEAN GroupDefaulted)
506 {
507         if ( !SecurityDescriptor || !Group || !GroupDefaulted )
508                 return STATUS_INVALID_PARAMETER;
509
510         *Group = SecurityDescriptor->Group;
511         if ( *Group != NULL )  {
512                 if ( SecurityDescriptor->Control & SE_GROUP_DEFAULTED )
513                         *GroupDefaulted = TRUE;
514                 else
515                         *GroupDefaulted = FALSE;
516         }
517         return STATUS_SUCCESS;
518
519
520 /**************************************************************************
521  *                 RtlMakeSelfRelativeSD                [NTDLL]
522  */
523 NTSTATUS WINAPI RtlMakeSelfRelativeSD(
524         IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
525         IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
526         IN OUT LPDWORD lpdwBufferLength)
527 {
528         FIXME("(%p,%p,%p(%lu))\n", pAbsoluteSecurityDescriptor,
529         pSelfRelativeSecurityDescriptor, lpdwBufferLength,*lpdwBufferLength);
530         return STATUS_SUCCESS;
531 }
532
533 /*
534  *      access control list's
535  */
536
537 /**************************************************************************
538  *                 RtlCreateAcl                         [NTDLL.306]
539  *
540  * NOTES
541  *    This should return NTSTATUS
542  */
543 NTSTATUS WINAPI RtlCreateAcl(PACL acl,DWORD size,DWORD rev)
544 {
545         TRACE("%p 0x%08lx 0x%08lx\n", acl, size, rev);
546
547         if (rev!=ACL_REVISION)
548                 return STATUS_INVALID_PARAMETER;
549         if (size<sizeof(ACL))
550                 return STATUS_BUFFER_TOO_SMALL;
551         if (size>0xFFFF)
552                 return STATUS_INVALID_PARAMETER;
553
554         memset(acl,'\0',sizeof(ACL));
555         acl->AclRevision        = rev;
556         acl->AclSize            = size;
557         acl->AceCount           = 0;
558         return 0;
559 }
560
561 /**************************************************************************
562  *                 RtlFirstFreeAce                      [NTDLL.370]
563  * looks for the AceCount+1 ACE, and if it is still within the alloced
564  * ACL, return a pointer to it
565  */
566 BOOLEAN WINAPI RtlFirstFreeAce(
567         PACL acl,
568         PACE_HEADER *x)
569 {
570         PACE_HEADER     ace;
571         int             i;
572
573         *x = 0;
574         ace = (PACE_HEADER)(acl+1);
575         for (i=0;i<acl->AceCount;i++) {
576                 if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
577                         return 0;
578                 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
579         }
580         if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
581                 return 0;
582         *x = ace;
583         return 1;
584 }
585
586 /**************************************************************************
587  *                 RtlAddAce                            [NTDLL.260]
588  */
589 NTSTATUS WINAPI RtlAddAce(
590         PACL acl,
591         DWORD rev,
592         DWORD xnrofaces,
593         PACE_HEADER acestart,
594         DWORD acelen)
595 {
596         PACE_HEADER     ace,targetace;
597         int             nrofaces;
598
599         if (acl->AclRevision != ACL_REVISION)
600                 return STATUS_INVALID_PARAMETER;
601         if (!RtlFirstFreeAce(acl,&targetace))
602                 return STATUS_INVALID_PARAMETER;
603         nrofaces=0;ace=acestart;
604         while (((DWORD)ace-(DWORD)acestart)<acelen) {
605                 nrofaces++;
606                 ace = (PACE_HEADER)(((BYTE*)ace)+ace->AceSize);
607         }
608         if ((DWORD)targetace+acelen>(DWORD)acl+acl->AclSize) /* too much aces */
609                 return STATUS_INVALID_PARAMETER;
610         memcpy((LPBYTE)targetace,acestart,acelen);
611         acl->AceCount+=nrofaces;
612         return STATUS_SUCCESS;
613 }
614
615 /******************************************************************************
616  *  RtlAddAccessAllowedAce              [NTDLL] 
617  */
618 BOOL WINAPI RtlAddAccessAllowedAce(
619         IN OUT PACL pAcl,
620         IN DWORD dwAceRevision,
621         IN DWORD AccessMask,
622         IN PSID pSid)
623 {
624         FIXME("(%p,0x%08lx,0x%08lx,%p),stub!\n",
625         pAcl, dwAceRevision, AccessMask, pSid);
626         return 0;
627 }
628
629 /******************************************************************************
630  *  RtlGetAce           [NTDLL] 
631  */
632 DWORD WINAPI RtlGetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce ) 
633 {
634         FIXME("(%p,%ld,%p),stub!\n",pAcl,dwAceIndex,pAce);
635         return 0;
636 }
637
638 /*
639  *      misc
640  */
641
642 /******************************************************************************
643  *  RtlAdjustPrivilege          [NTDLL] 
644  */
645 DWORD WINAPI RtlAdjustPrivilege(DWORD x1,DWORD x2,DWORD x3,DWORD x4) 
646 {
647         FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
648         return 0;
649 }
650
651 /******************************************************************************
652  *  RtlImpersonateSelf          [NTDLL] 
653  */
654 BOOL WINAPI
655 RtlImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
656 {
657         FIXME("(%08x), stub\n", ImpersonationLevel);
658         return TRUE;
659 }
660
661 /******************************************************************************
662  *  NtAccessCheck               [NTDLL]
663  */
664 NTSTATUS WINAPI 
665 NtAccessCheck(
666         IN PSECURITY_DESCRIPTOR SecurityDescriptor,
667         IN HANDLE ClientToken,
668         IN ACCESS_MASK DesiredAccess,
669         IN PGENERIC_MAPPING GenericMapping,
670         OUT PPRIVILEGE_SET PrivilegeSet,
671         OUT PULONG ReturnLength,
672         OUT PULONG GrantedAccess,
673         OUT PBOOLEAN AccessStatus)
674 {
675         FIXME("(%p, %04x, %08lx, %p, %p, %p, %p, %p), stub\n",
676           SecurityDescriptor, ClientToken, DesiredAccess, GenericMapping, 
677           PrivilegeSet, ReturnLength, GrantedAccess, AccessStatus);
678         *AccessStatus = TRUE;
679         return STATUS_SUCCESS;
680 }
681
682 /******************************************************************************
683  *  NtSetSecurityObject         [NTDLL]
684  */
685 NTSTATUS WINAPI
686 NtSetSecurityObject(
687         IN HANDLE Handle,
688         IN SECURITY_INFORMATION SecurityInformation,
689         IN PSECURITY_DESCRIPTOR SecurityDescriptor) 
690 {
691         FIXME("0x%08x 0x%08lx %p\n", Handle, SecurityInformation, SecurityDescriptor);
692         return STATUS_SUCCESS;
693 }
694
695 /******************************************************************************
696  * RtlGetControlSecurityDescriptor
697  */
698
699 NTSTATUS WINAPI RtlGetControlSecurityDescriptor(
700         PSECURITY_DESCRIPTOR  pSecurityDescriptor,
701         PSECURITY_DESCRIPTOR_CONTROL pControl,
702         LPDWORD lpdwRevision)
703 {
704         FIXME("(%p,%p,%p),stub!\n",pSecurityDescriptor,pControl,lpdwRevision);
705         return STATUS_SUCCESS;
706 }               
707
708 /******************************************************************************
709  * RtlConvertSidToUnicodeString
710  */
711 NTSTATUS WINAPI RtlConvertSidToUnicodeString(
712        PUNICODE_STRING UnicodeSID,
713        PSID *pSid)
714 {
715 /*      LPSTR GenSID = "S-1-5-21-0000000000-000000000-0000000000-500"; */
716
717         LPSTR GenSID = ".Default";      /* usually the returned SID is used to */
718                                         /* access  "\\REGISTRY\\USER\\.DEFAULT" */
719
720         ANSI_STRING AnsiStr;
721
722         FIXME("(%p %p)\n", UnicodeSID, pSid);
723         dump_UnicodeString(UnicodeSID, FALSE);
724
725         RtlInitAnsiString(&AnsiStr, GenSID);
726         return RtlAnsiStringToUnicodeString(UnicodeSID, &AnsiStr, TRUE);
727 }