Created stub functions for advapi32.GetExplicitEntriesFromAclA/W().
[wine] / dlls / advapi32 / security.c
1 /*
2  * Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  FIXME: for all functions thunking down to Rtl* functions:  implement SetLastError()
19  */
20
21 #include <stdarg.h>
22 #include <string.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winerror.h"
27 #include "rpcnterr.h"
28 #include "winreg.h"
29 #include "winternl.h"
30 #include "ntstatus.h"
31 #include "ntsecapi.h"
32 #include "accctrl.h"
33
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
38
39 #define CallWin32ToNt(func) \
40         { NTSTATUS ret; \
41           ret = (func); \
42           if (ret !=STATUS_SUCCESS) \
43           { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
44           return TRUE; \
45         }
46
47 static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
48 {
49         if (oa)
50         {
51           TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
52                 oa->Length, oa->RootDirectory,
53                 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
54                 oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
55         }
56 }
57
58 /************************************************************
59  *                ADVAPI_IsLocalComputer
60  *
61  * Checks whether the server name indicates local machine.
62  */
63 BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
64 {
65     if (!ServerName)
66     {
67         return TRUE;
68     }
69     else
70     {
71         DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
72         BOOL Result;
73         LPWSTR buf;
74
75         buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
76         Result = GetComputerNameW(buf,  &dwSize);
77         if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
78             ServerName += 2;
79         Result = Result && !lstrcmpW(ServerName, buf);
80         HeapFree(GetProcessHeap(), 0, buf);
81
82         return Result;
83     }
84 }
85
86 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
87     if (!ADVAPI_IsLocalComputer(ServerName)) \
88     { \
89         FIXME("Action Implemented for local computer only. " \
90               "Requested for server %s\n", debugstr_w(ServerName)); \
91         return FailureCode; \
92     }
93
94 /*      ##############################
95         ######  TOKEN FUNCTIONS ######
96         ##############################
97 */
98
99 /******************************************************************************
100  * OpenProcessToken                     [ADVAPI32.@]
101  * Opens the access token associated with a process handle.
102  *
103  * PARAMS
104  *   ProcessHandle [I] Handle to process
105  *   DesiredAccess [I] Desired access to process
106  *   TokenHandle   [O] Pointer to handle of open access token
107  *
108  * RETURNS
109  *  Success: TRUE. TokenHandle contains the access token.
110  *  Failure: FALSE.
111  *
112  * NOTES
113  *  See NtOpenProcessToken.
114  */
115 BOOL WINAPI
116 OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
117                   HANDLE *TokenHandle )
118 {
119         CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
120 }
121
122 /******************************************************************************
123  * OpenThreadToken [ADVAPI32.@]
124  *
125  * Opens the access token associated with a thread handle.
126  *
127  * PARAMS
128  *   ThreadHandle  [I] Handle to process
129  *   DesiredAccess [I] Desired access to the thread
130  *   OpenAsSelf    [I] ???
131  *   TokenHandle   [O] Destination for the token handle
132  *
133  * RETURNS
134  *  Success: TRUE. TokenHandle contains the access token.
135  *  Failure: FALSE.
136  *
137  * NOTES
138  *  See NtOpenThreadToken.
139  */
140 BOOL WINAPI
141 OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
142                  BOOL OpenAsSelf, HANDLE *TokenHandle)
143 {
144         CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
145 }
146
147 /******************************************************************************
148  * AdjustTokenPrivileges [ADVAPI32.@]
149  *
150  * Adjust the privileges of an open token handle.
151  * 
152  * PARAMS
153  *  TokenHandle          [I]   Handle from OpenProcessToken() or OpenThreadToken() 
154  *  DisableAllPrivileges [I]   TRUE=Remove all privileges, FALSE=Use NewState
155  *  NewState             [I]   Desired new privileges of the token
156  *  BufferLength         [I]   Length of NewState
157  *  PreviousState        [O]   Destination for the previous state
158  *  ReturnLength         [I/O] Size of PreviousState
159  *
160  *
161  * RETURNS
162  *  Success: TRUE. Privileges are set to NewState and PreviousState is updated.
163  *  Failure: FALSE.
164  *
165  * NOTES
166  *  See NtAdjustPrivilegesToken.
167  */
168 BOOL WINAPI
169 AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
170                        LPVOID NewState, DWORD BufferLength,
171                        LPVOID PreviousState, LPDWORD ReturnLength )
172 {
173         CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
174 }
175
176 /******************************************************************************
177  * CheckTokenMembership [ADVAPI32.@]
178  *
179  * Determine if an access token is a member of a SID.
180  * 
181  * PARAMS
182  *   TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
183  *   SidToCheck  [I] SID that possibly contains the token
184  *   IsMember    [O] Destination for result.
185  *
186  * RETURNS
187  *  Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
188  *  Failure: FALSE.
189  */
190 BOOL WINAPI
191 CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
192                       PBOOL IsMember )
193 {
194   FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
195
196   *IsMember = TRUE;
197   return(TRUE);
198 }
199
200 /******************************************************************************
201  * GetTokenInformation [ADVAPI32.@]
202  *
203  * PARAMS
204  *   token           [I] Handle from OpenProcessToken() or OpenThreadToken()
205  *   tokeninfoclass  [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
206  *   tokeninfo       [O] Destination for token information
207  *   tokeninfolength [I] Length of tokeninfo
208  *   retlen          [O] Destination for returned token information length
209  *
210  * RETURNS
211  *  Success: TRUE. tokeninfo contains retlen bytes of token information
212  *  Failure: FALSE.
213  *
214  * NOTES
215  *  See NtQueryInformationToken.
216  */
217 BOOL WINAPI
218 GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
219                      LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
220 {
221     TRACE("(%p, %s, %p, %ld, %p): \n",
222           token,
223           (tokeninfoclass == TokenUser) ? "TokenUser" :
224           (tokeninfoclass == TokenGroups) ? "TokenGroups" :
225           (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
226           (tokeninfoclass == TokenOwner) ? "TokenOwner" :
227           (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
228           (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
229           (tokeninfoclass == TokenSource) ? "TokenSource" :
230           (tokeninfoclass == TokenType) ? "TokenType" :
231           (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
232           (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
233           (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
234           (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
235           (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
236           (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
237           (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
238           "Unknown",
239           tokeninfo, tokeninfolength, retlen);
240     CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
241 }
242
243 /******************************************************************************
244  * SetTokenInformation [ADVAPI32.@]
245  *
246  * Set information for an access token.
247  *
248  * PARAMS
249  *   token           [I] Handle from OpenProcessToken() or OpenThreadToken()
250  *   tokeninfoclass  [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
251  *   tokeninfo       [I] Token information to set
252  *   tokeninfolength [I] Length of tokeninfo
253  *
254  * RETURNS
255  *  Success: TRUE. The information for the token is set to tokeninfo.
256  *  Failure: FALSE.
257  */
258 BOOL WINAPI
259 SetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
260                      LPVOID tokeninfo, DWORD tokeninfolength )
261 {
262     FIXME("(%p, %s, %p, %ld): stub\n",
263           token,
264           (tokeninfoclass == TokenUser) ? "TokenUser" :
265           (tokeninfoclass == TokenGroups) ? "TokenGroups" :
266           (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
267           (tokeninfoclass == TokenOwner) ? "TokenOwner" :
268           (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
269           (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
270           (tokeninfoclass == TokenSource) ? "TokenSource" :
271           (tokeninfoclass == TokenType) ? "TokenType" :
272           (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
273           (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
274           (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
275           (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
276           (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
277           (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
278           (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
279           "Unknown",
280           tokeninfo, tokeninfolength);
281
282     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
283
284     return FALSE;
285 }
286
287 /*************************************************************************
288  * SetThreadToken [ADVAPI32.@]
289  *
290  * Assigns an 'impersonation token' to a thread so it can assume the
291  * security privledges of another thread or process.  Can also remove
292  * a previously assigned token. 
293  *
294  * PARAMS
295  *   thread          [O] Handle to thread to set the token for
296  *   token           [I] Token to set
297  *
298  * RETURNS
299  *  Success: TRUE. The threads access token is set to token
300  *  Failure: FALSE.
301  *
302  * NOTES
303  *  Only supported on NT or higher. On Win9X this function does nothing.
304  *  See SetTokenInformation.
305  */
306 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
307 {
308     FIXME("(%p, %p): stub (NT impl. only)\n", thread, token);
309
310     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
311
312     return FALSE;
313 }
314
315 /*      ##############################
316         ######  SID FUNCTIONS   ######
317         ##############################
318 */
319
320 /******************************************************************************
321  * AllocateAndInitializeSid [ADVAPI32.@]
322  *
323  * PARAMS
324  *   pIdentifierAuthority []
325  *   nSubAuthorityCount   []
326  *   nSubAuthority0       []
327  *   nSubAuthority1       []
328  *   nSubAuthority2       []
329  *   nSubAuthority3       []
330  *   nSubAuthority4       []
331  *   nSubAuthority5       []
332  *   nSubAuthority6       []
333  *   nSubAuthority7       []
334  *   pSid                 []
335  */
336 BOOL WINAPI
337 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
338                           BYTE nSubAuthorityCount,
339                           DWORD nSubAuthority0, DWORD nSubAuthority1,
340                           DWORD nSubAuthority2, DWORD nSubAuthority3,
341                           DWORD nSubAuthority4, DWORD nSubAuthority5,
342                           DWORD nSubAuthority6, DWORD nSubAuthority7,
343                           PSID *pSid )
344 {
345         CallWin32ToNt (RtlAllocateAndInitializeSid(
346                 pIdentifierAuthority, nSubAuthorityCount,
347                 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
348                 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
349                 pSid ));
350 }
351
352 /******************************************************************************
353  * FreeSid [ADVAPI32.@]
354  *
355  * PARAMS
356  *   pSid []
357  */
358 PVOID WINAPI
359 FreeSid( PSID pSid )
360 {
361         RtlFreeSid(pSid);
362         return NULL; /* is documented like this */
363 }
364
365 /******************************************************************************
366  * CopySid [ADVAPI32.@]
367  *
368  * PARAMS
369  *   nDestinationSidLength []
370  *   pDestinationSid       []
371  *   pSourceSid            []
372  */
373 BOOL WINAPI
374 CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
375 {
376         return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
377 }
378
379 /******************************************************************************
380  * IsValidSid [ADVAPI32.@]
381  *
382  * PARAMS
383  *   pSid []
384  */
385 BOOL WINAPI
386 IsValidSid( PSID pSid )
387 {
388         return RtlValidSid( pSid );
389 }
390
391 /******************************************************************************
392  * EqualSid [ADVAPI32.@]
393  *
394  * PARAMS
395  *   pSid1 []
396  *   pSid2 []
397  */
398 BOOL WINAPI
399 EqualSid( PSID pSid1, PSID pSid2 )
400 {
401         return RtlEqualSid( pSid1, pSid2 );
402 }
403
404 /******************************************************************************
405  * EqualPrefixSid [ADVAPI32.@]
406  */
407 BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
408 {
409         return RtlEqualPrefixSid(pSid1, pSid2);
410 }
411
412 /******************************************************************************
413  * GetSidLengthRequired [ADVAPI32.@]
414  *
415  * PARAMS
416  *   nSubAuthorityCount []
417  */
418 DWORD WINAPI
419 GetSidLengthRequired( BYTE nSubAuthorityCount )
420 {
421         return RtlLengthRequiredSid(nSubAuthorityCount);
422 }
423
424 /******************************************************************************
425  * InitializeSid [ADVAPI32.@]
426  *
427  * PARAMS
428  *   pIdentifierAuthority []
429  */
430 BOOL WINAPI
431 InitializeSid (
432         PSID pSid,
433         PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
434         BYTE nSubAuthorityCount)
435 {
436         return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
437 }
438
439 /******************************************************************************
440  * GetSidIdentifierAuthority [ADVAPI32.@]
441  *
442  * PARAMS
443  *   pSid []
444  */
445 PSID_IDENTIFIER_AUTHORITY WINAPI
446 GetSidIdentifierAuthority( PSID pSid )
447 {
448         return RtlIdentifierAuthoritySid(pSid);
449 }
450
451 /******************************************************************************
452  * GetSidSubAuthority [ADVAPI32.@]
453  *
454  * PARAMS
455  *   pSid          []
456  *   nSubAuthority []
457  */
458 PDWORD WINAPI
459 GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
460 {
461         return RtlSubAuthoritySid(pSid, nSubAuthority);
462 }
463
464 /******************************************************************************
465  * GetSidSubAuthorityCount [ADVAPI32.@]
466  *
467  * PARAMS
468  *   pSid []
469  */
470 PUCHAR WINAPI
471 GetSidSubAuthorityCount (PSID pSid)
472 {
473         return RtlSubAuthorityCountSid(pSid);
474 }
475
476 /******************************************************************************
477  * GetLengthSid [ADVAPI32.@]
478  *
479  * PARAMS
480  *   pSid []
481  */
482 DWORD WINAPI
483 GetLengthSid (PSID pSid)
484 {
485         return RtlLengthSid(pSid);
486 }
487
488 /*      ##############################################
489         ######  SECURITY DESCRIPTOR FUNCTIONS   ######
490         ##############################################
491 */
492
493 /******************************************************************************
494  * InitializeSecurityDescriptor [ADVAPI32.@]
495  *
496  * PARAMS
497  *   pDescr   []
498  *   revision []
499  */
500 BOOL WINAPI
501 InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
502 {
503         CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
504 }
505
506 /******************************************************************************
507  * GetSecurityDescriptorLength [ADVAPI32.@]
508  */
509 DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
510 {
511         return (RtlLengthSecurityDescriptor(pDescr));
512 }
513
514 /******************************************************************************
515  * GetSecurityDescriptorOwner [ADVAPI32.@]
516  *
517  * PARAMS
518  *   pOwner            []
519  *   lpbOwnerDefaulted []
520  */
521 BOOL WINAPI
522 GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
523                             LPBOOL lpbOwnerDefaulted )
524 {
525         CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
526 }
527
528 /******************************************************************************
529  * SetSecurityDescriptorOwner [ADVAPI32.@]
530  *
531  * PARAMS
532  */
533 BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
534                                    PSID pOwner, BOOL bOwnerDefaulted)
535 {
536         CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
537 }
538 /******************************************************************************
539  * GetSecurityDescriptorGroup                   [ADVAPI32.@]
540  */
541 BOOL WINAPI GetSecurityDescriptorGroup(
542         PSECURITY_DESCRIPTOR SecurityDescriptor,
543         PSID *Group,
544         LPBOOL GroupDefaulted)
545 {
546         CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
547 }
548 /******************************************************************************
549  * SetSecurityDescriptorGroup [ADVAPI32.@]
550  */
551 BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
552                                            PSID Group, BOOL GroupDefaulted)
553 {
554         CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
555 }
556
557 /******************************************************************************
558  * IsValidSecurityDescriptor [ADVAPI32.@]
559  *
560  * PARAMS
561  *   lpsecdesc []
562  */
563 BOOL WINAPI
564 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
565 {
566         CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
567 }
568
569 /******************************************************************************
570  *  GetSecurityDescriptorDacl                   [ADVAPI32.@]
571  */
572 BOOL WINAPI GetSecurityDescriptorDacl(
573         IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
574         OUT LPBOOL lpbDaclPresent,
575         OUT PACL *pDacl,
576         OUT LPBOOL lpbDaclDefaulted)
577 {
578         CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
579                                                pDacl, (PBOOLEAN)lpbDaclDefaulted));
580 }
581
582 /******************************************************************************
583  *  SetSecurityDescriptorDacl                   [ADVAPI32.@]
584  */
585 BOOL WINAPI
586 SetSecurityDescriptorDacl (
587         PSECURITY_DESCRIPTOR lpsd,
588         BOOL daclpresent,
589         PACL dacl,
590         BOOL dacldefaulted )
591 {
592         CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
593 }
594 /******************************************************************************
595  *  GetSecurityDescriptorSacl                   [ADVAPI32.@]
596  */
597 BOOL WINAPI GetSecurityDescriptorSacl(
598         IN PSECURITY_DESCRIPTOR lpsd,
599         OUT LPBOOL lpbSaclPresent,
600         OUT PACL *pSacl,
601         OUT LPBOOL lpbSaclDefaulted)
602 {
603         CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd,
604            (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted));
605 }
606
607 /**************************************************************************
608  * SetSecurityDescriptorSacl                    [ADVAPI32.@]
609  */
610 BOOL WINAPI SetSecurityDescriptorSacl (
611         PSECURITY_DESCRIPTOR lpsd,
612         BOOL saclpresent,
613         PACL lpsacl,
614         BOOL sacldefaulted)
615 {
616         CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
617 }
618 /******************************************************************************
619  * MakeSelfRelativeSD [ADVAPI32.@]
620  *
621  * PARAMS
622  *   lpabssecdesc  []
623  *   lpselfsecdesc []
624  *   lpbuflen      []
625  */
626 BOOL WINAPI
627 MakeSelfRelativeSD(
628         IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
629         IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
630         IN OUT LPDWORD lpdwBufferLength)
631 {
632         CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
633 }
634
635 /******************************************************************************
636  * GetSecurityDescriptorControl                 [ADVAPI32.@]
637  */
638
639 BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR  pSecurityDescriptor,
640                  PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
641 {
642         CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
643 }
644
645 /*      ##############################
646         ######  ACL FUNCTIONS   ######
647         ##############################
648 */
649
650 /*************************************************************************
651  * InitializeAcl [ADVAPI32.@]
652  */
653 DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
654 {
655         CallWin32ToNt (RtlCreateAcl(acl, size, rev));
656 }
657
658 /******************************************************************************
659  *  AddAccessAllowedAce [ADVAPI32.@]
660  */
661 BOOL WINAPI AddAccessAllowedAce(
662         IN OUT PACL pAcl,
663         IN DWORD dwAceRevision,
664         IN DWORD AccessMask,
665         IN PSID pSid)
666 {
667         CallWin32ToNt(RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
668 }
669
670 /******************************************************************************
671  *  AddAccessAllowedAceEx [ADVAPI32.@]
672  */
673 BOOL WINAPI AddAccessAllowedAceEx(
674         IN OUT PACL pAcl,
675         IN DWORD dwAceRevision,
676         IN DWORD AceFlags,
677         IN DWORD AccessMask,
678         IN PSID pSid)
679 {
680         CallWin32ToNt(RtlAddAccessAllowedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
681 }
682
683 /******************************************************************************
684  *  AddAccessDeniedAce [ADVAPI32.@]
685  */
686 BOOL WINAPI AddAccessDeniedAce(
687         IN OUT PACL pAcl,
688         IN DWORD dwAceRevision,
689         IN DWORD AccessMask,
690         IN PSID pSid)
691 {
692         CallWin32ToNt(RtlAddAccessDeniedAce(pAcl, dwAceRevision, AccessMask, pSid));
693 }
694
695 /******************************************************************************
696  *  AddAccessDeniedAceEx [ADVAPI32.@]
697  */
698 BOOL WINAPI AddAccessDeniedAceEx(
699         IN OUT PACL pAcl,
700         IN DWORD dwAceRevision,
701         IN DWORD AceFlags,
702         IN DWORD AccessMask,
703         IN PSID pSid)
704 {
705         CallWin32ToNt(RtlAddAccessDeniedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
706 }
707
708 /******************************************************************************
709  *  AddAce [ADVAPI32.@]
710  */
711 BOOL WINAPI AddAce(
712         IN OUT PACL pAcl,
713         IN DWORD dwAceRevision,
714         IN DWORD dwStartingAceIndex,
715         LPVOID pAceList,
716         DWORD nAceListLength)
717 {
718         CallWin32ToNt(RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, pAceList, nAceListLength));
719 }
720
721 /******************************************************************************
722  *  FindFirstFreeAce [ADVAPI32.@]
723  */
724 BOOL WINAPI FindFirstFreeAce(IN PACL pAcl, LPVOID * pAce)
725 {
726         return RtlFirstFreeAce(pAcl, (PACE_HEADER *)pAce);
727 }
728
729 /******************************************************************************
730  * GetAce [ADVAPI32.@]
731  */
732 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
733 {
734     CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce));
735 }
736
737 /******************************************************************************
738  * GetAclInformation [ADVAPI32.@]
739  */
740 BOOL WINAPI GetAclInformation(
741   PACL pAcl,
742   LPVOID pAclInformation,
743   DWORD nAclInformationLength,
744   ACL_INFORMATION_CLASS dwAclInformationClass)
745 {
746         FIXME("(%p,%p,%ld,%d): stub\n",pAcl, pAclInformation,
747                 nAclInformationLength, dwAclInformationClass);
748   return FALSE;
749 }
750
751 /******************************************************************************
752  *  IsValidAcl [ADVAPI32.@]
753  */
754 BOOL WINAPI IsValidAcl(IN PACL pAcl)
755 {
756         return RtlValidAcl(pAcl);
757 }
758
759 /*      ##############################
760         ######  MISC FUNCTIONS  ######
761         ##############################
762 */
763
764 static const char * const DefaultPrivNames[] =
765 {
766     NULL, NULL,
767     "SeCreateTokenPrivilege", "SeAssignPrimaryTokenPrivilege",
768     "SeLockMemoryPrivilege", "SeIncreaseQuotaPrivilege",
769     "SeMachineAccountPrivilege", "SeTcbPrivilege",
770     "SeSecurityPrivilege", "SeTakeOwnershipPrivilege",
771     "SeLoadDriverPrivilege", "SeSystemProfilePrivilege",
772     "SeSystemtimePrivilege", "SeProfileSingleProcessPrivilege",
773     "SeIncreaseBasePriorityPrivilege", "SeCreatePagefilePrivilege",
774     "SeCreatePermanentPrivilege", "SeBackupPrivilege",
775     "SeRestorePrivilege", "SeShutdownPrivilege",
776     "SeDebugPrivilege", "SeAuditPrivilege",
777     "SeSystemEnvironmentPrivilege", "SeChangeNotifyPrivilege",
778     "SeRemoteShutdownPrivilege",
779 };
780 #define NUMPRIVS (sizeof DefaultPrivNames/sizeof DefaultPrivNames[0])
781
782 /******************************************************************************
783  * LookupPrivilegeValueW                        [ADVAPI32.@]
784  *
785  * See LookupPrivilegeValueA.
786  */
787 BOOL WINAPI
788 LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid )
789 {
790     UINT i;
791     WCHAR priv[0x28];
792
793     TRACE("%s,%s,%p\n",debugstr_w(lpSystemName), debugstr_w(lpName), lpLuid);
794
795     for( i=0; i<NUMPRIVS; i++ )
796     {
797         if( !DefaultPrivNames[i] )
798             continue;
799         MultiByteToWideChar( CP_ACP, 0, DefaultPrivNames[i], -1,
800                              priv, sizeof priv );
801         if( strcmpW( priv, lpName) )
802             continue;
803         lpLuid->LowPart = i;
804         lpLuid->HighPart = 0;
805         TRACE( "%s -> %08lx-%08lx\n",debugstr_w( lpSystemName ),
806                lpLuid->HighPart, lpLuid->LowPart );
807         return TRUE;
808     }
809     return FALSE;
810 }
811
812 /******************************************************************************
813  * LookupPrivilegeValueA                        [ADVAPI32.@]
814  *
815  * Retrieves LUID used on a system to represent the privilege name.
816  *
817  * PARAMS
818  *  lpSystemName [I] Name of the system
819  *  lpName       [I] Name of the privilege
820  *  pLuid        [O] Destination for the resulting LUD
821  *
822  * RETURNS
823  *  Success: TRUE. pLuid contains the requested LUID.
824  *  Failure: FALSE.
825  */
826 BOOL WINAPI
827 LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid )
828 {
829     UNICODE_STRING lpSystemNameW;
830     UNICODE_STRING lpNameW;
831     BOOL ret;
832
833     RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
834     RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName);
835     ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid);
836     RtlFreeUnicodeString(&lpNameW);
837     RtlFreeUnicodeString(&lpSystemNameW);
838     return ret;
839 }
840
841
842 /******************************************************************************
843  * LookupPrivilegeNameA                 [ADVAPI32.@]
844  */
845 BOOL WINAPI
846 LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName, LPDWORD cchName)
847 {
848     FIXME("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
849     return FALSE;
850 }
851
852 /******************************************************************************
853  * LookupPrivilegeNameW                 [ADVAPI32.@]
854  */
855 BOOL WINAPI
856 LookupPrivilegeNameW( LPCWSTR lpSystemName, PLUID lpLuid, LPSTR lpName, LPDWORD cchName)
857 {
858     FIXME("%s %p %p %p\n", debugstr_w(lpSystemName), lpLuid, lpName, cchName);
859     return FALSE;
860 }
861
862 /******************************************************************************
863  * GetFileSecurityA [ADVAPI32.@]
864  *
865  * Obtains Specified information about the security of a file or directory.
866  *
867  * PARAMS
868  *  lpFileName           [I] Name of the file to get info for
869  *  RequestedInformation [I] SE_ flags from "winnt.h"
870  *  pSecurityDescriptor  [O] Destination for security information
871  *  nLength              [I] Length of pSecurityDescriptor
872  *  lpnLengthNeeded      [O] Destination for length of returned security information
873  *
874  * RETURNS
875  *  Success: TRUE. pSecurityDescriptor contains the requested information.
876  *  Failure: FALSE. lpnLengthNeeded contains the required space to return the info. 
877  *
878  * NOTES
879  *  The information returned is constrained by the callers access rights and
880  *  privileges.
881  */
882 BOOL WINAPI
883 GetFileSecurityA( LPCSTR lpFileName,
884                     SECURITY_INFORMATION RequestedInformation,
885                     PSECURITY_DESCRIPTOR pSecurityDescriptor,
886                     DWORD nLength, LPDWORD lpnLengthNeeded )
887 {
888   FIXME("(%s) : stub\n", debugstr_a(lpFileName));
889   return TRUE;
890 }
891
892 /******************************************************************************
893  * GetFileSecurityW [ADVAPI32.@]
894  *
895  * See GetFileSecurityA.
896  */
897 BOOL WINAPI
898 GetFileSecurityW( LPCWSTR lpFileName,
899                     SECURITY_INFORMATION RequestedInformation,
900                     PSECURITY_DESCRIPTOR pSecurityDescriptor,
901                     DWORD nLength, LPDWORD lpnLengthNeeded )
902 {
903   FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
904   return TRUE;
905 }
906
907
908 /******************************************************************************
909  * LookupAccountSidA [ADVAPI32.@]
910  */
911 BOOL WINAPI
912 LookupAccountSidA(
913         IN LPCSTR system,
914         IN PSID sid,
915         OUT LPSTR account,
916         IN OUT LPDWORD accountSize,
917         OUT LPSTR domain,
918         IN OUT LPDWORD domainSize,
919         OUT PSID_NAME_USE name_use )
920 {
921         static const char ac[] = "Administrator";
922         static const char dm[] = "DOMAIN";
923         FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
924               debugstr_a(system),sid,
925               account,accountSize,accountSize?*accountSize:0,
926               domain,domainSize,domainSize?*domainSize:0,
927               name_use);
928
929         if (accountSize) *accountSize = strlen(ac)+1;
930         if (account && (*accountSize > strlen(ac)))
931           strcpy(account, ac);
932
933         if (domainSize) *domainSize = strlen(dm)+1;
934         if (domain && (*domainSize > strlen(dm)))
935           strcpy(domain,dm);
936
937         if (name_use) *name_use = SidTypeUser;
938         return TRUE;
939 }
940
941 /******************************************************************************
942  * LookupAccountSidW [ADVAPI32.@]
943  *
944  * PARAMS
945  *   system      []
946  *   sid         []
947  *   account     []
948  *   accountSize []
949  *   domain      []
950  *   domainSize  []
951  *   name_use    []
952  */
953 BOOL WINAPI
954 LookupAccountSidW(
955         IN LPCWSTR system,
956         IN PSID sid,
957         OUT LPWSTR account,
958         IN OUT LPDWORD accountSize,
959         OUT LPWSTR domain,
960         IN OUT LPDWORD domainSize,
961         OUT PSID_NAME_USE name_use )
962 {
963     static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
964     static const WCHAR dm[] = {'D','O','M','A','I','N',0};
965         FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
966               debugstr_w(system),sid,
967               account,accountSize,accountSize?*accountSize:0,
968               domain,domainSize,domainSize?*domainSize:0,
969               name_use);
970
971         if (accountSize) *accountSize = strlenW(ac)+1;
972         if (account && (*accountSize > strlenW(ac)))
973             strcpyW(account, ac);
974
975         if (domainSize) *domainSize = strlenW(dm)+1;
976         if (domain && (*domainSize > strlenW(dm)))
977             strcpyW(domain,dm);
978
979         if (name_use) *name_use = SidTypeUser;
980         return TRUE;
981 }
982
983 /******************************************************************************
984  * SetFileSecurityA [ADVAPI32.@]
985  * Sets the security of a file or directory
986  */
987 BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
988                                 SECURITY_INFORMATION RequestedInformation,
989                                 PSECURITY_DESCRIPTOR pSecurityDescriptor)
990 {
991   FIXME("(%s) : stub\n", debugstr_a(lpFileName));
992   return TRUE;
993 }
994
995 /******************************************************************************
996  * SetFileSecurityW [ADVAPI32.@]
997  * Sets the security of a file or directory
998  *
999  * PARAMS
1000  *   lpFileName           []
1001  *   RequestedInformation []
1002  *   pSecurityDescriptor  []
1003  */
1004 BOOL WINAPI
1005 SetFileSecurityW( LPCWSTR lpFileName,
1006                     SECURITY_INFORMATION RequestedInformation,
1007                     PSECURITY_DESCRIPTOR pSecurityDescriptor )
1008 {
1009   FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
1010   return TRUE;
1011 }
1012
1013 /******************************************************************************
1014  * QueryWindows31FilesMigration [ADVAPI32.@]
1015  *
1016  * PARAMS
1017  *   x1 []
1018  */
1019 BOOL WINAPI
1020 QueryWindows31FilesMigration( DWORD x1 )
1021 {
1022         FIXME("(%ld):stub\n",x1);
1023         return TRUE;
1024 }
1025
1026 /******************************************************************************
1027  * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
1028  *
1029  * PARAMS
1030  *   x1 []
1031  *   x2 []
1032  *   x3 []
1033  *   x4 []
1034  */
1035 BOOL WINAPI
1036 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
1037                                                DWORD x4 )
1038 {
1039         FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
1040         return TRUE;
1041 }
1042
1043 /******************************************************************************
1044  * LsaOpenPolicy [ADVAPI32.@]
1045  *
1046  * PARAMS
1047  *   x1 []
1048  *   x2 []
1049  *   x3 []
1050  *   x4 []
1051  */
1052 NTSTATUS WINAPI
1053 LsaOpenPolicy(
1054         IN PLSA_UNICODE_STRING SystemName,
1055         IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1056         IN ACCESS_MASK DesiredAccess,
1057         IN OUT PLSA_HANDLE PolicyHandle)
1058 {
1059         FIXME("(%s,%p,0x%08lx,%p):stub\n",
1060               SystemName?debugstr_w(SystemName->Buffer):"null",
1061               ObjectAttributes, DesiredAccess, PolicyHandle);
1062         ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
1063                                   STATUS_ACCESS_VIOLATION);
1064         dumpLsaAttributes(ObjectAttributes);
1065         if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
1066         return STATUS_SUCCESS;
1067 }
1068
1069 /******************************************************************************
1070  * LsaQueryInformationPolicy [ADVAPI32.@]
1071  */
1072 NTSTATUS WINAPI
1073 LsaQueryInformationPolicy(
1074         IN LSA_HANDLE PolicyHandle,
1075         IN POLICY_INFORMATION_CLASS InformationClass,
1076         OUT PVOID *Buffer)
1077 {
1078         FIXME("(%p,0x%08x,%p):stub\n",
1079               PolicyHandle, InformationClass, Buffer);
1080
1081         if(!Buffer) return FALSE;
1082         switch (InformationClass)
1083         {
1084           case PolicyAuditEventsInformation: /* 2 */
1085             {
1086               PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
1087               p->AuditingMode = FALSE; /* no auditing */
1088               *Buffer = p;
1089             }
1090             break;
1091           case PolicyPrimaryDomainInformation: /* 3 */
1092           case PolicyAccountDomainInformation: /* 5 */
1093             {
1094               struct di
1095               { POLICY_PRIMARY_DOMAIN_INFO ppdi;
1096                 SID sid;
1097               };
1098               SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
1099
1100               struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
1101               RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
1102
1103               xdi->ppdi.Sid = &(xdi->sid);
1104               xdi->sid.Revision = SID_REVISION;
1105               xdi->sid.SubAuthorityCount = 1;
1106               xdi->sid.IdentifierAuthority = localSidAuthority;
1107               xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
1108               *Buffer = xdi;
1109             }
1110             break;
1111           case  PolicyAuditLogInformation:
1112           case  PolicyPdAccountInformation:
1113           case  PolicyLsaServerRoleInformation:
1114           case  PolicyReplicaSourceInformation:
1115           case  PolicyDefaultQuotaInformation:
1116           case  PolicyModificationInformation:
1117           case  PolicyAuditFullSetInformation:
1118           case  PolicyAuditFullQueryInformation:
1119           case  PolicyDnsDomainInformation:
1120             {
1121               FIXME("category not implemented\n");
1122               return FALSE;
1123             }
1124         }
1125         return TRUE;
1126 }
1127
1128 /******************************************************************************
1129  * LsaLookupSids [ADVAPI32.@]
1130  */
1131 typedef struct
1132 {
1133         SID_NAME_USE Use;
1134         LSA_UNICODE_STRING Name;
1135         LONG DomainIndex;
1136 } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
1137
1138 typedef struct
1139 {
1140         LSA_UNICODE_STRING Name;
1141         PSID Sid;
1142 } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
1143
1144 typedef struct
1145 {
1146         ULONG Entries;
1147         PLSA_TRUST_INFORMATION Domains;
1148 } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
1149
1150 NTSTATUS WINAPI
1151 LsaLookupSids(
1152         IN LSA_HANDLE PolicyHandle,
1153         IN ULONG Count,
1154         IN PSID *Sids,
1155         OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
1156         OUT PLSA_TRANSLATED_NAME *Names )
1157 {
1158         FIXME("%p %lu %p %p %p\n",
1159           PolicyHandle, Count, Sids, ReferencedDomains, Names);
1160         return FALSE;
1161 }
1162
1163 /******************************************************************************
1164  * LsaFreeMemory [ADVAPI32.@]
1165  */
1166 NTSTATUS WINAPI
1167 LsaFreeMemory(IN PVOID Buffer)
1168 {
1169         TRACE("(%p)\n",Buffer);
1170         return HeapFree(GetProcessHeap(), 0, Buffer);
1171 }
1172 /******************************************************************************
1173  * LsaClose [ADVAPI32.@]
1174  */
1175 NTSTATUS WINAPI
1176 LsaClose(IN LSA_HANDLE ObjectHandle)
1177 {
1178         FIXME("(%p):stub\n",ObjectHandle);
1179         return 0xc0000000;
1180 }
1181
1182 /******************************************************************************
1183  * LsaNtStatusToWinError [ADVAPI32.@]
1184  *
1185  * PARAMS
1186  *   Status [I]
1187  */
1188 ULONG WINAPI
1189 LsaNtStatusToWinError(NTSTATUS Status)
1190 {
1191     return RtlNtStatusToDosError(Status);
1192 }
1193
1194 /******************************************************************************
1195  * NotifyBootConfigStatus [ADVAPI32.@]
1196  *
1197  * PARAMS
1198  *   x1 []
1199  */
1200 BOOL WINAPI
1201 NotifyBootConfigStatus( DWORD x1 )
1202 {
1203         FIXME("(0x%08lx):stub\n",x1);
1204         return 1;
1205 }
1206
1207 /******************************************************************************
1208  * RevertToSelf [ADVAPI32.@]
1209  *
1210  * PARAMS
1211  *   void []
1212  */
1213 BOOL WINAPI
1214 RevertToSelf( void )
1215 {
1216         FIXME("(), stub\n");
1217         return TRUE;
1218 }
1219
1220 /******************************************************************************
1221  * ImpersonateSelf [ADVAPI32.@]
1222  */
1223 BOOL WINAPI
1224 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
1225 {
1226         return RtlImpersonateSelf(ImpersonationLevel);
1227 }
1228
1229 /******************************************************************************
1230  * ImpersonateLoggedOnUser [ADVAPI32.@]
1231  */
1232 BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
1233 {
1234     FIXME("(%p):stub returning FALSE\n", hToken);
1235     return FALSE;
1236 }
1237
1238 /******************************************************************************
1239  * AccessCheck [ADVAPI32.@]
1240  *
1241  * FIXME check cast LPBOOL to PBOOLEAN
1242  */
1243 BOOL WINAPI
1244 AccessCheck(
1245         PSECURITY_DESCRIPTOR SecurityDescriptor,
1246         HANDLE ClientToken,
1247         DWORD DesiredAccess,
1248         PGENERIC_MAPPING GenericMapping,
1249         PPRIVILEGE_SET PrivilegeSet,
1250         LPDWORD PrivilegeSetLength,
1251         LPDWORD GrantedAccess,
1252         LPBOOL AccessStatus)
1253 {
1254         CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
1255           GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
1256 }
1257
1258 /*************************************************************************
1259  * SetKernelObjectSecurity [ADVAPI32.@]
1260  */
1261 BOOL WINAPI SetKernelObjectSecurity (
1262         IN HANDLE Handle,
1263         IN SECURITY_INFORMATION SecurityInformation,
1264         IN PSECURITY_DESCRIPTOR SecurityDescriptor )
1265 {
1266         CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
1267 }
1268
1269 /******************************************************************************
1270  * LookupAccountNameA [ADVAPI32.@]
1271  */
1272 BOOL WINAPI
1273 LookupAccountNameA(
1274         IN LPCSTR system,
1275         IN LPCSTR account,
1276         OUT PSID sid,
1277         OUT LPDWORD cbSid,
1278         LPSTR ReferencedDomainName,
1279         IN OUT LPDWORD cbReferencedDomainName,
1280         OUT PSID_NAME_USE name_use )
1281 {
1282     FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
1283     return FALSE;
1284 }
1285
1286 /******************************************************************************
1287  * PrivilegeCheck [ADVAPI32.@]
1288  */
1289 BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
1290 {
1291         FIXME("stub %p %p %p\n", ClientToken, RequiredPrivileges, pfResult);
1292         if (pfResult)
1293                 *pfResult=TRUE;
1294         return TRUE;
1295 }
1296
1297 /******************************************************************************
1298  * AccessCheckAndAuditAlarmA [ADVAPI32.@]
1299  */
1300 BOOL WINAPI AccessCheckAndAuditAlarmA(LPCSTR Subsystem, LPVOID HandleId, LPSTR ObjectTypeName,
1301   LPSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
1302   PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
1303   LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
1304 {
1305         FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem),
1306                 HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName),
1307                 SecurityDescriptor, DesiredAccess, GenericMapping,
1308                 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
1309         return TRUE;
1310 }
1311
1312 /******************************************************************************
1313  * AccessCheckAndAuditAlarmW [ADVAPI32.@]
1314  */
1315 BOOL WINAPI AccessCheckAndAuditAlarmW(LPCWSTR Subsystem, LPVOID HandleId, LPWSTR ObjectTypeName,
1316   LPWSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
1317   PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
1318   LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
1319 {
1320         FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem),
1321                 HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName),
1322                 SecurityDescriptor, DesiredAccess, GenericMapping,
1323                 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
1324         return TRUE;
1325 }
1326
1327
1328 /******************************************************************************
1329  * GetSecurityInfoExW [ADVAPI32.@]
1330  */
1331 DWORD WINAPI GetSecurityInfoExW(
1332         HANDLE hObject, SE_OBJECT_TYPE ObjectType, 
1333         SECURITY_INFORMATION SecurityInfo, LPCWSTR lpProvider,
1334         LPCWSTR lpProperty, PACTRL_ACCESSW *ppAccessList, 
1335         PACTRL_AUDITW *ppAuditList, LPWSTR *lppOwner, LPWSTR *lppGroup
1336 )
1337 {
1338   FIXME("stub!\n");
1339   return ERROR_BAD_PROVIDER; 
1340 }
1341
1342 /******************************************************************************
1343  * BuildTrusteeWithSidA [ADVAPI32.@]
1344  */
1345 VOID WINAPI BuildTrusteeWithSidA(PTRUSTEEA pTrustee, PSID pSid)
1346 {
1347     FIXME("%p %p\n", pTrustee, pSid);
1348 }
1349
1350 /******************************************************************************
1351  * BuildTrusteeWithSidW [ADVAPI32.@]
1352  */
1353 VOID WINAPI BuildTrusteeWithSidW(PTRUSTEEW pTrustee, PSID pSid)
1354 {
1355     FIXME("%p %p\n", pTrustee, pSid);
1356 }
1357
1358 /******************************************************************************
1359  * SetEntriesInAclA [ADVAPI32.@]
1360  */
1361 DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
1362                                PACL OldAcl, PACL* NewAcl )
1363 {
1364     FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
1365     return ERROR_CALL_NOT_IMPLEMENTED;
1366 }
1367
1368 /******************************************************************************
1369  * SetEntriesInAclW [ADVAPI32.@]
1370  */
1371 DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
1372                                PACL OldAcl, PACL* NewAcl )
1373 {
1374     FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
1375     return ERROR_CALL_NOT_IMPLEMENTED;
1376 }
1377
1378 /******************************************************************************
1379  * SetNamedSecurityInfoA [ADVAPI32.@]
1380  */
1381 DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
1382         SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
1383         PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
1384 {
1385     FIXME("%s %d %ld %p %p %p %p\n", debugstr_a(pObjectName), ObjectType,
1386            SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
1387     return ERROR_CALL_NOT_IMPLEMENTED;
1388 }
1389
1390 /******************************************************************************
1391  * SetNamedSecurityInfoW [ADVAPI32.@]
1392  */
1393 DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
1394         SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
1395         PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
1396 {
1397     FIXME("%s %d %ld %p %p %p %p\n", debugstr_w(pObjectName), ObjectType,
1398            SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
1399     return ERROR_CALL_NOT_IMPLEMENTED;
1400 }
1401
1402 /******************************************************************************
1403  * GetExplicitEntriesFromAclA [ADVAPI32.@]
1404  */
1405 DWORD WINAPI GetExplicitEntriesFromAclA( PACL pacl, PULONG pcCountOfExplicitEntries,
1406         PEXPLICIT_ACCESSA* pListOfExplicitEntries)
1407 {
1408     FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
1409     return ERROR_CALL_NOT_IMPLEMENTED;
1410 }
1411
1412 /******************************************************************************
1413  * GetExplicitEntriesFromAclW [ADVAPI32.@]
1414  */
1415 DWORD WINAPI GetExplicitEntriesFromAclW( PACL pacl, PULONG pcCountOfExplicitEntries,
1416         PEXPLICIT_ACCESSW* pListOfExplicitEntries)
1417 {
1418     FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
1419     return ERROR_CALL_NOT_IMPLEMENTED;
1420 }