2 * Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
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.
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.
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
18 * FIXME: for all functions thunking down to Rtl* functions: implement SetLastError()
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
35 #define CallWin32ToNt(func) \
38 if (ret !=STATUS_SUCCESS) \
39 { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
43 static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
47 TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
48 oa->Length, oa->RootDirectory,
49 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
50 oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
54 /************************************************************
55 * ADVAPI_IsLocalComputer
57 * Checks whether the server name indicates local machine.
59 BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
67 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
71 buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
72 Result = GetComputerNameW(buf, &dwSize);
73 if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
75 Result = Result && !lstrcmpW(ServerName, buf);
76 HeapFree(GetProcessHeap(), 0, buf);
82 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
83 if (!ADVAPI_IsLocalComputer(ServerName)) \
85 FIXME("Action Implemented for local computer only. " \
86 "Requested for server %s\n", debugstr_w(ServerName)); \
90 /* ##############################
91 ###### TOKEN FUNCTIONS ######
92 ##############################
95 /******************************************************************************
96 * OpenProcessToken [ADVAPI32.@]
97 * Opens the access token associated with a process handle.
100 * ProcessHandle [I] Handle to process
101 * DesiredAccess [I] Desired access to process
102 * TokenHandle [O] Pointer to handle of open access token
105 * Success: TRUE. TokenHandle contains the access token.
109 * See NtOpenProcessToken.
112 OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
113 HANDLE *TokenHandle )
115 CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
118 /******************************************************************************
119 * OpenThreadToken [ADVAPI32.@]
121 * Opens the access token associated with a thread handle.
124 * ThreadHandle [I] Handle to process
125 * DesiredAccess [I] Desired access to the thread
127 * TokenHandle [O] Destination for the token handle
130 * Success: TRUE. TokenHandle contains the access token.
134 * See NtOpenThreadToken.
137 OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
138 BOOL OpenAsSelf, HANDLE *TokenHandle)
140 CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
143 /******************************************************************************
144 * AdjustTokenPrivileges [ADVAPI32.@]
146 * Adjust the privileges of an open token handle.
149 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
150 * DisableAllPrivileges [I] TRUE=Remove all privileges, FALSE=Use NewState
151 * NewState [I] Desired new privileges of the token
152 * BufferLength [I] Length of NewState
153 * PreviousState [O] Destination for the previous state
154 * ReturnLength [I/O] Size of PreviousState
158 * Success: TRUE. Privileges are set to NewState and PreviousState is updated.
162 * See NtAdjustPrivilegesToken.
165 AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
166 LPVOID NewState, DWORD BufferLength,
167 LPVOID PreviousState, LPDWORD ReturnLength )
169 CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
172 /******************************************************************************
173 * CheckTokenMembership [ADVAPI32.@]
175 * Determine if an access token is a member of a SID.
178 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
179 * SidToCheck [I] SID that possibly contains the token
180 * IsMember [O] Destination for result.
183 * Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
187 CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
190 FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
196 /******************************************************************************
197 * GetTokenInformation [ADVAPI32.@]
200 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
201 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
202 * tokeninfo [O] Destination for token information
203 * tokeninfolength [I] Length of tokeninfo
204 * retlen [O] Destination for returned token information length
207 * Success: TRUE. tokeninfo contains retlen bytes of token information
211 * See NtQueryInformationToken.
214 GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
215 LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
217 TRACE("(%p, %s, %p, %ld, %p): \n",
219 (tokeninfoclass == TokenUser) ? "TokenUser" :
220 (tokeninfoclass == TokenGroups) ? "TokenGroups" :
221 (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
222 (tokeninfoclass == TokenOwner) ? "TokenOwner" :
223 (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
224 (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
225 (tokeninfoclass == TokenSource) ? "TokenSource" :
226 (tokeninfoclass == TokenType) ? "TokenType" :
227 (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
228 (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
229 (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
230 (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
231 (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
232 (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
233 (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
235 tokeninfo, tokeninfolength, retlen);
236 CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
239 /******************************************************************************
240 * SetTokenInformation [ADVAPI32.@]
242 * Set information for an access token.
245 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
246 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
247 * tokeninfo [I] Token information to set
248 * tokeninfolength [I] Length of tokeninfo
251 * Success: TRUE. The information for the token is set to tokeninfo.
255 SetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
256 LPVOID tokeninfo, DWORD tokeninfolength )
258 FIXME("(%p, %s, %p, %ld): stub\n",
260 (tokeninfoclass == TokenUser) ? "TokenUser" :
261 (tokeninfoclass == TokenGroups) ? "TokenGroups" :
262 (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
263 (tokeninfoclass == TokenOwner) ? "TokenOwner" :
264 (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
265 (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
266 (tokeninfoclass == TokenSource) ? "TokenSource" :
267 (tokeninfoclass == TokenType) ? "TokenType" :
268 (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
269 (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
270 (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
271 (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
272 (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
273 (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
274 (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
276 tokeninfo, tokeninfolength);
278 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
283 /*************************************************************************
284 * SetThreadToken [ADVAPI32.@]
286 * Assigns an 'impersonation token' to a thread so it can assume the
287 * security privledges of another thread or process. Can also remove
288 * a previously assigned token.
291 * thread [O] Handle to thread to set the token for
292 * token [I] Token to set
295 * Success: TRUE. The threads access token is set to token
299 * Only supported on NT or higher. On Win9X this function does nothing.
300 * See SetTokenInformation.
302 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
304 FIXME("(%p, %p): stub (NT impl. only)\n", thread, token);
306 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
311 /* ##############################
312 ###### SID FUNCTIONS ######
313 ##############################
316 /******************************************************************************
317 * AllocateAndInitializeSid [ADVAPI32.@]
320 * pIdentifierAuthority []
321 * nSubAuthorityCount []
333 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
334 BYTE nSubAuthorityCount,
335 DWORD nSubAuthority0, DWORD nSubAuthority1,
336 DWORD nSubAuthority2, DWORD nSubAuthority3,
337 DWORD nSubAuthority4, DWORD nSubAuthority5,
338 DWORD nSubAuthority6, DWORD nSubAuthority7,
341 CallWin32ToNt (RtlAllocateAndInitializeSid(
342 pIdentifierAuthority, nSubAuthorityCount,
343 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
344 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
348 /******************************************************************************
349 * FreeSid [ADVAPI32.@]
358 return NULL; /* is documented like this */
361 /******************************************************************************
362 * CopySid [ADVAPI32.@]
365 * nDestinationSidLength []
370 CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
372 return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
375 /******************************************************************************
376 * IsValidSid [ADVAPI32.@]
382 IsValidSid( PSID pSid )
384 return RtlValidSid( pSid );
387 /******************************************************************************
388 * EqualSid [ADVAPI32.@]
395 EqualSid( PSID pSid1, PSID pSid2 )
397 return RtlEqualSid( pSid1, pSid2 );
400 /******************************************************************************
401 * EqualPrefixSid [ADVAPI32.@]
403 BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
405 return RtlEqualPrefixSid(pSid1, pSid2);
408 /******************************************************************************
409 * GetSidLengthRequired [ADVAPI32.@]
412 * nSubAuthorityCount []
415 GetSidLengthRequired( BYTE nSubAuthorityCount )
417 return RtlLengthRequiredSid(nSubAuthorityCount);
420 /******************************************************************************
421 * InitializeSid [ADVAPI32.@]
424 * pIdentifierAuthority []
429 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
430 BYTE nSubAuthorityCount)
432 return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
435 /******************************************************************************
436 * GetSidIdentifierAuthority [ADVAPI32.@]
441 PSID_IDENTIFIER_AUTHORITY WINAPI
442 GetSidIdentifierAuthority( PSID pSid )
444 return RtlIdentifierAuthoritySid(pSid);
447 /******************************************************************************
448 * GetSidSubAuthority [ADVAPI32.@]
455 GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
457 return RtlSubAuthoritySid(pSid, nSubAuthority);
460 /******************************************************************************
461 * GetSidSubAuthorityCount [ADVAPI32.@]
467 GetSidSubAuthorityCount (PSID pSid)
469 return RtlSubAuthorityCountSid(pSid);
472 /******************************************************************************
473 * GetLengthSid [ADVAPI32.@]
479 GetLengthSid (PSID pSid)
481 return RtlLengthSid(pSid);
484 /* ##############################################
485 ###### SECURITY DESCRIPTOR FUNCTIONS ######
486 ##############################################
489 /******************************************************************************
490 * InitializeSecurityDescriptor [ADVAPI32.@]
497 InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
499 CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
502 /******************************************************************************
503 * GetSecurityDescriptorLength [ADVAPI32.@]
505 DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
507 return (RtlLengthSecurityDescriptor(pDescr));
510 /******************************************************************************
511 * GetSecurityDescriptorOwner [ADVAPI32.@]
515 * lpbOwnerDefaulted []
518 GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
519 LPBOOL lpbOwnerDefaulted )
521 CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
524 /******************************************************************************
525 * SetSecurityDescriptorOwner [ADVAPI32.@]
529 BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
530 PSID pOwner, BOOL bOwnerDefaulted)
532 CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
534 /******************************************************************************
535 * GetSecurityDescriptorGroup [ADVAPI32.@]
537 BOOL WINAPI GetSecurityDescriptorGroup(
538 PSECURITY_DESCRIPTOR SecurityDescriptor,
540 LPBOOL GroupDefaulted)
542 CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
544 /******************************************************************************
545 * SetSecurityDescriptorGroup [ADVAPI32.@]
547 BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
548 PSID Group, BOOL GroupDefaulted)
550 CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
553 /******************************************************************************
554 * IsValidSecurityDescriptor [ADVAPI32.@]
560 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
562 CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
565 /******************************************************************************
566 * GetSecurityDescriptorDacl [ADVAPI32.@]
568 BOOL WINAPI GetSecurityDescriptorDacl(
569 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
570 OUT LPBOOL lpbDaclPresent,
572 OUT LPBOOL lpbDaclDefaulted)
574 CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
575 pDacl, (PBOOLEAN)lpbDaclDefaulted));
578 /******************************************************************************
579 * SetSecurityDescriptorDacl [ADVAPI32.@]
582 SetSecurityDescriptorDacl (
583 PSECURITY_DESCRIPTOR lpsd,
588 CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
590 /******************************************************************************
591 * GetSecurityDescriptorSacl [ADVAPI32.@]
593 BOOL WINAPI GetSecurityDescriptorSacl(
594 IN PSECURITY_DESCRIPTOR lpsd,
595 OUT LPBOOL lpbSaclPresent,
597 OUT LPBOOL lpbSaclDefaulted)
599 CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd,
600 (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted));
603 /**************************************************************************
604 * SetSecurityDescriptorSacl [ADVAPI32.@]
606 BOOL WINAPI SetSecurityDescriptorSacl (
607 PSECURITY_DESCRIPTOR lpsd,
612 CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
614 /******************************************************************************
615 * MakeSelfRelativeSD [ADVAPI32.@]
624 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
625 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
626 IN OUT LPDWORD lpdwBufferLength)
628 CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
631 /******************************************************************************
632 * GetSecurityDescriptorControl [ADVAPI32.@]
635 BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
636 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
638 CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
641 /* ##############################
642 ###### ACL FUNCTIONS ######
643 ##############################
646 /*************************************************************************
647 * InitializeAcl [ADVAPI32.@]
649 DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
651 CallWin32ToNt (RtlCreateAcl(acl, size, rev));
654 /******************************************************************************
655 * AddAccessAllowedAce [ADVAPI32.@]
657 BOOL WINAPI AddAccessAllowedAce(
659 IN DWORD dwAceRevision,
663 CallWin32ToNt(RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
666 /******************************************************************************
667 * AddAccessDeniedAce [ADVAPI32.@]
669 BOOL WINAPI AddAccessDeniedAce(
671 IN DWORD dwAceRevision,
675 CallWin32ToNt(RtlAddAccessDeniedAce(pAcl, dwAceRevision, AccessMask, pSid));
678 /******************************************************************************
679 * AddAccessDeniedAce [ADVAPI32.@]
683 IN DWORD dwAceRevision,
684 IN DWORD dwStartingAceIndex,
686 DWORD nAceListLength)
688 CallWin32ToNt(RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, pAceList, nAceListLength));
691 /******************************************************************************
692 * FindFirstFreeAce [ADVAPI32.@]
694 BOOL WINAPI FindFirstFreeAce(IN PACL pAcl, LPVOID * pAce)
696 return RtlFirstFreeAce(pAcl, (PACE_HEADER *)pAce);
699 /******************************************************************************
700 * GetAce [ADVAPI32.@]
702 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
704 CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce));
707 /******************************************************************************
708 * IsValidAcl [ADVAPI32.@]
710 BOOL WINAPI IsValidAcl(IN PACL pAcl)
712 return RtlValidAcl(pAcl);
715 /* ##############################
716 ###### MISC FUNCTIONS ######
717 ##############################
720 /******************************************************************************
721 * LookupPrivilegeValueW [ADVAPI32.@]
723 * See LookupPrivilegeValueA.
726 LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid )
728 FIXME("(%s,%s,%p): stub\n",debugstr_w(lpSystemName),
729 debugstr_w(lpName), lpLuid);
730 lpLuid->LowPart = 0x12345678;
731 lpLuid->HighPart = 0x87654321;
735 /******************************************************************************
736 * LookupPrivilegeValueA [ADVAPI32.@]
738 * Retrieves LUID used on a system to represent the privilege name.
741 * lpSystemName [I] Name of the system
742 * lpName [I] Name of the privilege
743 * pLuid [O] Destination for the resulting LUD
746 * Success: TRUE. pLuid contains the requested LUID.
750 LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid )
752 UNICODE_STRING lpSystemNameW;
753 UNICODE_STRING lpNameW;
756 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
757 RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName);
758 ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid);
759 RtlFreeUnicodeString(&lpNameW);
760 RtlFreeUnicodeString(&lpSystemNameW);
764 /******************************************************************************
765 * GetFileSecurityA [ADVAPI32.@]
767 * Obtains Specified information about the security of a file or directory.
770 * lpFileName [I] Name of the file to get info for
771 * RequestedInformation [I] SE_ flags from "winnt.h"
772 * pSecurityDescriptor [O] Destination for security information
773 * nLength [I] Length of pSecurityDescriptor
774 * lpnLengthNeeded [O] Destination for length of returned security information
777 * Success: TRUE. pSecurityDescriptor contains the requested information.
778 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
781 * The information returned is constrained by the callers access rights and
785 GetFileSecurityA( LPCSTR lpFileName,
786 SECURITY_INFORMATION RequestedInformation,
787 PSECURITY_DESCRIPTOR pSecurityDescriptor,
788 DWORD nLength, LPDWORD lpnLengthNeeded )
790 FIXME("(%s) : stub\n", debugstr_a(lpFileName));
794 /******************************************************************************
795 * GetFileSecurityW [ADVAPI32.@]
797 * See GetFileSecurityA.
800 GetFileSecurityW( LPCWSTR lpFileName,
801 SECURITY_INFORMATION RequestedInformation,
802 PSECURITY_DESCRIPTOR pSecurityDescriptor,
803 DWORD nLength, LPDWORD lpnLengthNeeded )
805 FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
810 /******************************************************************************
811 * LookupAccountSidA [ADVAPI32.@]
818 IN OUT LPDWORD accountSize,
820 IN OUT LPDWORD domainSize,
821 OUT PSID_NAME_USE name_use )
823 static const char ac[] = "Administrator";
824 static const char dm[] = "DOMAIN";
825 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
826 debugstr_a(system),sid,
827 account,accountSize,accountSize?*accountSize:0,
828 domain,domainSize,domainSize?*domainSize:0,
831 if (accountSize) *accountSize = strlen(ac)+1;
832 if (account && (*accountSize > strlen(ac)))
835 if (domainSize) *domainSize = strlen(dm)+1;
836 if (domain && (*domainSize > strlen(dm)))
839 if (name_use) *name_use = SidTypeUser;
843 /******************************************************************************
844 * LookupAccountSidW [ADVAPI32.@]
860 IN OUT LPDWORD accountSize,
862 IN OUT LPDWORD domainSize,
863 OUT PSID_NAME_USE name_use )
865 static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
866 static const WCHAR dm[] = {'D','O','M','A','I','N',0};
867 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
868 debugstr_w(system),sid,
869 account,accountSize,accountSize?*accountSize:0,
870 domain,domainSize,domainSize?*domainSize:0,
873 if (accountSize) *accountSize = strlenW(ac)+1;
874 if (account && (*accountSize > strlenW(ac)))
875 strcpyW(account, ac);
877 if (domainSize) *domainSize = strlenW(dm)+1;
878 if (domain && (*domainSize > strlenW(dm)))
881 if (name_use) *name_use = SidTypeUser;
885 /******************************************************************************
886 * SetFileSecurityA [ADVAPI32.@]
887 * Sets the security of a file or directory
889 BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
890 SECURITY_INFORMATION RequestedInformation,
891 PSECURITY_DESCRIPTOR pSecurityDescriptor)
893 FIXME("(%s) : stub\n", debugstr_a(lpFileName));
897 /******************************************************************************
898 * SetFileSecurityW [ADVAPI32.@]
899 * Sets the security of a file or directory
903 * RequestedInformation []
904 * pSecurityDescriptor []
907 SetFileSecurityW( LPCWSTR lpFileName,
908 SECURITY_INFORMATION RequestedInformation,
909 PSECURITY_DESCRIPTOR pSecurityDescriptor )
911 FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
915 /******************************************************************************
916 * QueryWindows31FilesMigration [ADVAPI32.@]
922 QueryWindows31FilesMigration( DWORD x1 )
924 FIXME("(%ld):stub\n",x1);
928 /******************************************************************************
929 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
938 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
941 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
945 /******************************************************************************
946 * LsaOpenPolicy [ADVAPI32.@]
956 IN PLSA_UNICODE_STRING SystemName,
957 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
958 IN ACCESS_MASK DesiredAccess,
959 IN OUT PLSA_HANDLE PolicyHandle)
961 FIXME("(%s,%p,0x%08lx,%p):stub\n",
962 SystemName?debugstr_w(SystemName->Buffer):"null",
963 ObjectAttributes, DesiredAccess, PolicyHandle);
964 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
965 STATUS_ACCESS_VIOLATION);
966 dumpLsaAttributes(ObjectAttributes);
967 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
968 return STATUS_SUCCESS;
971 /******************************************************************************
972 * LsaQueryInformationPolicy [ADVAPI32.@]
975 LsaQueryInformationPolicy(
976 IN LSA_HANDLE PolicyHandle,
977 IN POLICY_INFORMATION_CLASS InformationClass,
980 FIXME("(%p,0x%08x,%p):stub\n",
981 PolicyHandle, InformationClass, Buffer);
983 if(!Buffer) return FALSE;
984 switch (InformationClass)
986 case PolicyAuditEventsInformation: /* 2 */
988 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
989 p->AuditingMode = FALSE; /* no auditing */
993 case PolicyPrimaryDomainInformation: /* 3 */
994 case PolicyAccountDomainInformation: /* 5 */
997 { POLICY_PRIMARY_DOMAIN_INFO ppdi;
1000 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
1002 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
1003 RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
1005 xdi->ppdi.Sid = &(xdi->sid);
1006 xdi->sid.Revision = SID_REVISION;
1007 xdi->sid.SubAuthorityCount = 1;
1008 xdi->sid.IdentifierAuthority = localSidAuthority;
1009 xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
1013 case PolicyAuditLogInformation:
1014 case PolicyPdAccountInformation:
1015 case PolicyLsaServerRoleInformation:
1016 case PolicyReplicaSourceInformation:
1017 case PolicyDefaultQuotaInformation:
1018 case PolicyModificationInformation:
1019 case PolicyAuditFullSetInformation:
1020 case PolicyAuditFullQueryInformation:
1021 case PolicyDnsDomainInformation:
1023 FIXME("category not implemented\n");
1030 /******************************************************************************
1031 * LsaLookupSids [ADVAPI32.@]
1036 LSA_UNICODE_STRING Name;
1038 } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
1042 LSA_UNICODE_STRING Name;
1044 } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
1049 PLSA_TRUST_INFORMATION Domains;
1050 } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
1054 IN LSA_HANDLE PolicyHandle,
1057 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
1058 OUT PLSA_TRANSLATED_NAME *Names )
1060 FIXME("%p %lu %p %p %p\n",
1061 PolicyHandle, Count, Sids, ReferencedDomains, Names);
1065 /******************************************************************************
1066 * LsaFreeMemory [ADVAPI32.@]
1069 LsaFreeMemory(IN PVOID Buffer)
1071 TRACE("(%p)\n",Buffer);
1072 return HeapFree(GetProcessHeap(), 0, Buffer);
1074 /******************************************************************************
1075 * LsaClose [ADVAPI32.@]
1078 LsaClose(IN LSA_HANDLE ObjectHandle)
1080 FIXME("(%p):stub\n",ObjectHandle);
1084 /******************************************************************************
1085 * LsaNtStatusToWinError [ADVAPI32.@]
1091 LsaNtStatusToWinError(NTSTATUS Status)
1093 return RtlNtStatusToDosError(Status);
1096 /******************************************************************************
1097 * NotifyBootConfigStatus [ADVAPI32.@]
1103 NotifyBootConfigStatus( DWORD x1 )
1105 FIXME("(0x%08lx):stub\n",x1);
1109 /******************************************************************************
1110 * RevertToSelf [ADVAPI32.@]
1116 RevertToSelf( void )
1118 FIXME("(), stub\n");
1122 /******************************************************************************
1123 * ImpersonateSelf [ADVAPI32.@]
1126 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
1128 return RtlImpersonateSelf(ImpersonationLevel);
1131 /******************************************************************************
1132 * ImpersonateLoggedOnUser [ADVAPI32.@]
1134 BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
1136 FIXME("(%p):stub returning FALSE\n", hToken);
1140 /******************************************************************************
1141 * AccessCheck [ADVAPI32.@]
1143 * FIXME check cast LPBOOL to PBOOLEAN
1147 PSECURITY_DESCRIPTOR SecurityDescriptor,
1149 DWORD DesiredAccess,
1150 PGENERIC_MAPPING GenericMapping,
1151 PPRIVILEGE_SET PrivilegeSet,
1152 LPDWORD PrivilegeSetLength,
1153 LPDWORD GrantedAccess,
1154 LPBOOL AccessStatus)
1156 CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
1157 GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
1160 /*************************************************************************
1161 * SetKernelObjectSecurity [ADVAPI32.@]
1163 BOOL WINAPI SetKernelObjectSecurity (
1165 IN SECURITY_INFORMATION SecurityInformation,
1166 IN PSECURITY_DESCRIPTOR SecurityDescriptor )
1168 CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
1171 /******************************************************************************
1172 * LookupAccountNameA [ADVAPI32.@]
1180 LPSTR ReferencedDomainName,
1181 IN OUT LPDWORD cbReferencedDomainName,
1182 OUT PSID_NAME_USE name_use )
1184 FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
1188 /******************************************************************************
1189 * PrivilegeCheck [ADVAPI32.@]
1191 BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
1193 FIXME("stub %p %p %p\n", ClientToken, RequiredPrivileges, pfResult);
1199 /******************************************************************************
1200 * AccessCheckAndAuditAlarmA [ADVAPI32.@]
1202 BOOL WINAPI AccessCheckAndAuditAlarmA(LPCSTR Subsystem, LPVOID HandleId, LPSTR ObjectTypeName,
1203 LPSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
1204 PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
1205 LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
1207 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem),
1208 HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName),
1209 SecurityDescriptor, DesiredAccess, GenericMapping,
1210 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
1214 /******************************************************************************
1215 * AccessCheckAndAuditAlarmW [ADVAPI32.@]
1217 BOOL WINAPI AccessCheckAndAuditAlarmW(LPCWSTR Subsystem, LPVOID HandleId, LPWSTR ObjectTypeName,
1218 LPWSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
1219 PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
1220 LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
1222 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem),
1223 HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName),
1224 SecurityDescriptor, DesiredAccess, GenericMapping,
1225 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
1230 /******************************************************************************
1231 * GetSecurityInfoExW [ADVAPI32.@]
1233 DWORD WINAPI GetSecurityInfoExW(
1234 HANDLE hObject, SE_OBJECT_TYPE ObjectType,
1235 SECURITY_INFORMATION SecurityInfo, LPCWSTR lpProvider,
1236 LPCWSTR lpProperty, PACTRL_ACCESSW *ppAccessList,
1237 PACTRL_AUDITW *ppAuditList, LPWSTR *lppOwner, LPWSTR *lppGroup
1241 return ERROR_BAD_PROVIDER;