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()
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39 #define CallWin32ToNt(func) \
42 if (ret !=STATUS_SUCCESS) \
43 { SetLastError (RtlNtStatusToDosError(ret)); return FALSE; } \
47 static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
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);
58 /************************************************************
59 * ADVAPI_IsLocalComputer
61 * Checks whether the server name indicates local machine.
63 BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
71 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
75 buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
76 Result = GetComputerNameW(buf, &dwSize);
77 if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
79 Result = Result && !lstrcmpW(ServerName, buf);
80 HeapFree(GetProcessHeap(), 0, buf);
86 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
87 if (!ADVAPI_IsLocalComputer(ServerName)) \
89 FIXME("Action Implemented for local computer only. " \
90 "Requested for server %s\n", debugstr_w(ServerName)); \
94 /* ##############################
95 ###### TOKEN FUNCTIONS ######
96 ##############################
99 /******************************************************************************
100 * OpenProcessToken [ADVAPI32.@]
101 * Opens the access token associated with a process handle.
104 * ProcessHandle [I] Handle to process
105 * DesiredAccess [I] Desired access to process
106 * TokenHandle [O] Pointer to handle of open access token
109 * Success: TRUE. TokenHandle contains the access token.
113 * See NtOpenProcessToken.
116 OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
117 HANDLE *TokenHandle )
119 CallWin32ToNt(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
122 /******************************************************************************
123 * OpenThreadToken [ADVAPI32.@]
125 * Opens the access token associated with a thread handle.
128 * ThreadHandle [I] Handle to process
129 * DesiredAccess [I] Desired access to the thread
131 * TokenHandle [O] Destination for the token handle
134 * Success: TRUE. TokenHandle contains the access token.
138 * See NtOpenThreadToken.
141 OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
142 BOOL OpenAsSelf, HANDLE *TokenHandle)
144 CallWin32ToNt (NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
147 /******************************************************************************
148 * AdjustTokenPrivileges [ADVAPI32.@]
150 * Adjust the privileges of an open token handle.
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
162 * Success: TRUE. Privileges are set to NewState and PreviousState is updated.
166 * See NtAdjustPrivilegesToken.
169 AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
170 LPVOID NewState, DWORD BufferLength,
171 LPVOID PreviousState, LPDWORD ReturnLength )
173 CallWin32ToNt(NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength));
176 /******************************************************************************
177 * CheckTokenMembership [ADVAPI32.@]
179 * Determine if an access token is a member of a SID.
182 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
183 * SidToCheck [I] SID that possibly contains the token
184 * IsMember [O] Destination for result.
187 * Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
191 CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
194 FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
200 /******************************************************************************
201 * GetTokenInformation [ADVAPI32.@]
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
211 * Success: TRUE. tokeninfo contains retlen bytes of token information
215 * See NtQueryInformationToken.
218 GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
219 LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
221 TRACE("(%p, %s, %p, %ld, %p): \n",
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" :
239 tokeninfo, tokeninfolength, retlen);
240 CallWin32ToNt (NtQueryInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength, retlen));
243 /******************************************************************************
244 * SetTokenInformation [ADVAPI32.@]
246 * Set information for an access token.
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
255 * Success: TRUE. The information for the token is set to tokeninfo.
259 SetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
260 LPVOID tokeninfo, DWORD tokeninfolength )
262 FIXME("(%p, %s, %p, %ld): stub\n",
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" :
280 tokeninfo, tokeninfolength);
282 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
287 /*************************************************************************
288 * SetThreadToken [ADVAPI32.@]
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.
295 * thread [O] Handle to thread to set the token for
296 * token [I] Token to set
299 * Success: TRUE. The threads access token is set to token
303 * Only supported on NT or higher. On Win9X this function does nothing.
304 * See SetTokenInformation.
306 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
308 FIXME("(%p, %p): stub (NT impl. only)\n", thread, token);
310 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
315 /* ##############################
316 ###### SID FUNCTIONS ######
317 ##############################
320 /******************************************************************************
321 * AllocateAndInitializeSid [ADVAPI32.@]
324 * pIdentifierAuthority []
325 * nSubAuthorityCount []
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,
345 CallWin32ToNt (RtlAllocateAndInitializeSid(
346 pIdentifierAuthority, nSubAuthorityCount,
347 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
348 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
352 /******************************************************************************
353 * FreeSid [ADVAPI32.@]
362 return NULL; /* is documented like this */
365 /******************************************************************************
366 * CopySid [ADVAPI32.@]
369 * nDestinationSidLength []
374 CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
376 return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
379 /******************************************************************************
380 * IsValidSid [ADVAPI32.@]
386 IsValidSid( PSID pSid )
388 return RtlValidSid( pSid );
391 /******************************************************************************
392 * EqualSid [ADVAPI32.@]
399 EqualSid( PSID pSid1, PSID pSid2 )
401 return RtlEqualSid( pSid1, pSid2 );
404 /******************************************************************************
405 * EqualPrefixSid [ADVAPI32.@]
407 BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
409 return RtlEqualPrefixSid(pSid1, pSid2);
412 /******************************************************************************
413 * GetSidLengthRequired [ADVAPI32.@]
416 * nSubAuthorityCount []
419 GetSidLengthRequired( BYTE nSubAuthorityCount )
421 return RtlLengthRequiredSid(nSubAuthorityCount);
424 /******************************************************************************
425 * InitializeSid [ADVAPI32.@]
428 * pIdentifierAuthority []
433 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
434 BYTE nSubAuthorityCount)
436 return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
439 /******************************************************************************
440 * GetSidIdentifierAuthority [ADVAPI32.@]
445 PSID_IDENTIFIER_AUTHORITY WINAPI
446 GetSidIdentifierAuthority( PSID pSid )
448 return RtlIdentifierAuthoritySid(pSid);
451 /******************************************************************************
452 * GetSidSubAuthority [ADVAPI32.@]
459 GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
461 return RtlSubAuthoritySid(pSid, nSubAuthority);
464 /******************************************************************************
465 * GetSidSubAuthorityCount [ADVAPI32.@]
471 GetSidSubAuthorityCount (PSID pSid)
473 return RtlSubAuthorityCountSid(pSid);
476 /******************************************************************************
477 * GetLengthSid [ADVAPI32.@]
483 GetLengthSid (PSID pSid)
485 return RtlLengthSid(pSid);
488 /* ##############################################
489 ###### SECURITY DESCRIPTOR FUNCTIONS ######
490 ##############################################
493 /******************************************************************************
494 * InitializeSecurityDescriptor [ADVAPI32.@]
501 InitializeSecurityDescriptor( SECURITY_DESCRIPTOR *pDescr, DWORD revision )
503 CallWin32ToNt (RtlCreateSecurityDescriptor(pDescr, revision ));
506 /******************************************************************************
507 * GetSecurityDescriptorLength [ADVAPI32.@]
509 DWORD WINAPI GetSecurityDescriptorLength( SECURITY_DESCRIPTOR *pDescr)
511 return (RtlLengthSecurityDescriptor(pDescr));
514 /******************************************************************************
515 * GetSecurityDescriptorOwner [ADVAPI32.@]
519 * lpbOwnerDefaulted []
522 GetSecurityDescriptorOwner( SECURITY_DESCRIPTOR *pDescr, PSID *pOwner,
523 LPBOOL lpbOwnerDefaulted )
525 CallWin32ToNt (RtlGetOwnerSecurityDescriptor( pDescr, pOwner, (PBOOLEAN)lpbOwnerDefaulted ));
528 /******************************************************************************
529 * SetSecurityDescriptorOwner [ADVAPI32.@]
533 BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
534 PSID pOwner, BOOL bOwnerDefaulted)
536 CallWin32ToNt (RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
538 /******************************************************************************
539 * GetSecurityDescriptorGroup [ADVAPI32.@]
541 BOOL WINAPI GetSecurityDescriptorGroup(
542 PSECURITY_DESCRIPTOR SecurityDescriptor,
544 LPBOOL GroupDefaulted)
546 CallWin32ToNt (RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, (PBOOLEAN)GroupDefaulted));
548 /******************************************************************************
549 * SetSecurityDescriptorGroup [ADVAPI32.@]
551 BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
552 PSID Group, BOOL GroupDefaulted)
554 CallWin32ToNt (RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
557 /******************************************************************************
558 * IsValidSecurityDescriptor [ADVAPI32.@]
564 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
566 CallWin32ToNt (RtlValidSecurityDescriptor(SecurityDescriptor));
569 /******************************************************************************
570 * GetSecurityDescriptorDacl [ADVAPI32.@]
572 BOOL WINAPI GetSecurityDescriptorDacl(
573 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
574 OUT LPBOOL lpbDaclPresent,
576 OUT LPBOOL lpbDaclDefaulted)
578 CallWin32ToNt (RtlGetDaclSecurityDescriptor(pSecurityDescriptor, (PBOOLEAN)lpbDaclPresent,
579 pDacl, (PBOOLEAN)lpbDaclDefaulted));
582 /******************************************************************************
583 * SetSecurityDescriptorDacl [ADVAPI32.@]
586 SetSecurityDescriptorDacl (
587 PSECURITY_DESCRIPTOR lpsd,
592 CallWin32ToNt (RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ));
594 /******************************************************************************
595 * GetSecurityDescriptorSacl [ADVAPI32.@]
597 BOOL WINAPI GetSecurityDescriptorSacl(
598 IN PSECURITY_DESCRIPTOR lpsd,
599 OUT LPBOOL lpbSaclPresent,
601 OUT LPBOOL lpbSaclDefaulted)
603 CallWin32ToNt (RtlGetSaclSecurityDescriptor(lpsd,
604 (PBOOLEAN)lpbSaclPresent, pSacl, (PBOOLEAN)lpbSaclDefaulted));
607 /**************************************************************************
608 * SetSecurityDescriptorSacl [ADVAPI32.@]
610 BOOL WINAPI SetSecurityDescriptorSacl (
611 PSECURITY_DESCRIPTOR lpsd,
616 CallWin32ToNt (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
618 /******************************************************************************
619 * MakeSelfRelativeSD [ADVAPI32.@]
628 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
629 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
630 IN OUT LPDWORD lpdwBufferLength)
632 CallWin32ToNt (RtlMakeSelfRelativeSD(pAbsoluteSecurityDescriptor,pSelfRelativeSecurityDescriptor, lpdwBufferLength));
635 /******************************************************************************
636 * GetSecurityDescriptorControl [ADVAPI32.@]
639 BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
640 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
642 CallWin32ToNt (RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
645 /* ##############################
646 ###### ACL FUNCTIONS ######
647 ##############################
650 /*************************************************************************
651 * InitializeAcl [ADVAPI32.@]
653 DWORD WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
655 CallWin32ToNt (RtlCreateAcl(acl, size, rev));
658 /******************************************************************************
659 * AddAccessAllowedAce [ADVAPI32.@]
661 BOOL WINAPI AddAccessAllowedAce(
663 IN DWORD dwAceRevision,
667 CallWin32ToNt(RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
670 /******************************************************************************
671 * AddAccessAllowedAceEx [ADVAPI32.@]
673 BOOL WINAPI AddAccessAllowedAceEx(
675 IN DWORD dwAceRevision,
680 CallWin32ToNt(RtlAddAccessAllowedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
683 /******************************************************************************
684 * AddAccessDeniedAce [ADVAPI32.@]
686 BOOL WINAPI AddAccessDeniedAce(
688 IN DWORD dwAceRevision,
692 CallWin32ToNt(RtlAddAccessDeniedAce(pAcl, dwAceRevision, AccessMask, pSid));
695 /******************************************************************************
696 * AddAccessDeniedAceEx [ADVAPI32.@]
698 BOOL WINAPI AddAccessDeniedAceEx(
700 IN DWORD dwAceRevision,
705 CallWin32ToNt(RtlAddAccessDeniedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
708 /******************************************************************************
709 * AddAce [ADVAPI32.@]
713 IN DWORD dwAceRevision,
714 IN DWORD dwStartingAceIndex,
716 DWORD nAceListLength)
718 CallWin32ToNt(RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, pAceList, nAceListLength));
721 /******************************************************************************
722 * FindFirstFreeAce [ADVAPI32.@]
724 BOOL WINAPI FindFirstFreeAce(IN PACL pAcl, LPVOID * pAce)
726 return RtlFirstFreeAce(pAcl, (PACE_HEADER *)pAce);
729 /******************************************************************************
730 * GetAce [ADVAPI32.@]
732 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
734 CallWin32ToNt(RtlGetAce(pAcl, dwAceIndex, pAce));
737 /******************************************************************************
738 * GetAclInformation [ADVAPI32.@]
740 BOOL WINAPI GetAclInformation(
742 LPVOID pAclInformation,
743 DWORD nAclInformationLength,
744 ACL_INFORMATION_CLASS dwAclInformationClass)
746 FIXME("(%p,%p,%ld,%d): stub\n",pAcl, pAclInformation,
747 nAclInformationLength, dwAclInformationClass);
751 /******************************************************************************
752 * IsValidAcl [ADVAPI32.@]
754 BOOL WINAPI IsValidAcl(IN PACL pAcl)
756 return RtlValidAcl(pAcl);
759 /* ##############################
760 ###### MISC FUNCTIONS ######
761 ##############################
764 static const char * const DefaultPrivNames[] =
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",
780 #define NUMPRIVS (sizeof DefaultPrivNames/sizeof DefaultPrivNames[0])
782 /******************************************************************************
783 * LookupPrivilegeValueW [ADVAPI32.@]
785 * See LookupPrivilegeValueA.
788 LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid )
793 TRACE("%s,%s,%p\n",debugstr_w(lpSystemName), debugstr_w(lpName), lpLuid);
795 for( i=0; i<NUMPRIVS; i++ )
797 if( !DefaultPrivNames[i] )
799 MultiByteToWideChar( CP_ACP, 0, DefaultPrivNames[i], -1,
801 if( strcmpW( priv, lpName) )
804 lpLuid->HighPart = 0;
805 TRACE( "%s -> %08lx-%08lx\n",debugstr_w( lpSystemName ),
806 lpLuid->HighPart, lpLuid->LowPart );
812 /******************************************************************************
813 * LookupPrivilegeValueA [ADVAPI32.@]
815 * Retrieves LUID used on a system to represent the privilege name.
818 * lpSystemName [I] Name of the system
819 * lpName [I] Name of the privilege
820 * pLuid [O] Destination for the resulting LUD
823 * Success: TRUE. pLuid contains the requested LUID.
827 LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid )
829 UNICODE_STRING lpSystemNameW;
830 UNICODE_STRING lpNameW;
833 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
834 RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName);
835 ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid);
836 RtlFreeUnicodeString(&lpNameW);
837 RtlFreeUnicodeString(&lpSystemNameW);
842 /******************************************************************************
843 * LookupPrivilegeNameA [ADVAPI32.@]
846 LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName, LPDWORD cchName)
848 FIXME("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
852 /******************************************************************************
853 * LookupPrivilegeNameW [ADVAPI32.@]
856 LookupPrivilegeNameW( LPCWSTR lpSystemName, PLUID lpLuid, LPSTR lpName, LPDWORD cchName)
858 FIXME("%s %p %p %p\n", debugstr_w(lpSystemName), lpLuid, lpName, cchName);
862 /******************************************************************************
863 * GetFileSecurityA [ADVAPI32.@]
865 * Obtains Specified information about the security of a file or directory.
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
875 * Success: TRUE. pSecurityDescriptor contains the requested information.
876 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
879 * The information returned is constrained by the callers access rights and
883 GetFileSecurityA( LPCSTR lpFileName,
884 SECURITY_INFORMATION RequestedInformation,
885 PSECURITY_DESCRIPTOR pSecurityDescriptor,
886 DWORD nLength, LPDWORD lpnLengthNeeded )
888 FIXME("(%s) : stub\n", debugstr_a(lpFileName));
892 /******************************************************************************
893 * GetFileSecurityW [ADVAPI32.@]
895 * See GetFileSecurityA.
898 GetFileSecurityW( LPCWSTR lpFileName,
899 SECURITY_INFORMATION RequestedInformation,
900 PSECURITY_DESCRIPTOR pSecurityDescriptor,
901 DWORD nLength, LPDWORD lpnLengthNeeded )
903 FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
908 /******************************************************************************
909 * LookupAccountSidA [ADVAPI32.@]
916 IN OUT LPDWORD accountSize,
918 IN OUT LPDWORD domainSize,
919 OUT PSID_NAME_USE name_use )
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,
929 if (accountSize) *accountSize = strlen(ac)+1;
930 if (account && (*accountSize > strlen(ac)))
933 if (domainSize) *domainSize = strlen(dm)+1;
934 if (domain && (*domainSize > strlen(dm)))
937 if (name_use) *name_use = SidTypeUser;
941 /******************************************************************************
942 * LookupAccountSidW [ADVAPI32.@]
958 IN OUT LPDWORD accountSize,
960 IN OUT LPDWORD domainSize,
961 OUT PSID_NAME_USE name_use )
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,
971 if (accountSize) *accountSize = strlenW(ac)+1;
972 if (account && (*accountSize > strlenW(ac)))
973 strcpyW(account, ac);
975 if (domainSize) *domainSize = strlenW(dm)+1;
976 if (domain && (*domainSize > strlenW(dm)))
979 if (name_use) *name_use = SidTypeUser;
983 /******************************************************************************
984 * SetFileSecurityA [ADVAPI32.@]
985 * Sets the security of a file or directory
987 BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
988 SECURITY_INFORMATION RequestedInformation,
989 PSECURITY_DESCRIPTOR pSecurityDescriptor)
991 FIXME("(%s) : stub\n", debugstr_a(lpFileName));
995 /******************************************************************************
996 * SetFileSecurityW [ADVAPI32.@]
997 * Sets the security of a file or directory
1001 * RequestedInformation []
1002 * pSecurityDescriptor []
1005 SetFileSecurityW( LPCWSTR lpFileName,
1006 SECURITY_INFORMATION RequestedInformation,
1007 PSECURITY_DESCRIPTOR pSecurityDescriptor )
1009 FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
1013 /******************************************************************************
1014 * QueryWindows31FilesMigration [ADVAPI32.@]
1020 QueryWindows31FilesMigration( DWORD x1 )
1022 FIXME("(%ld):stub\n",x1);
1026 /******************************************************************************
1027 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
1036 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
1039 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
1043 /******************************************************************************
1044 * LsaOpenPolicy [ADVAPI32.@]
1054 IN PLSA_UNICODE_STRING SystemName,
1055 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1056 IN ACCESS_MASK DesiredAccess,
1057 IN OUT PLSA_HANDLE PolicyHandle)
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;
1069 /******************************************************************************
1070 * LsaQueryInformationPolicy [ADVAPI32.@]
1073 LsaQueryInformationPolicy(
1074 IN LSA_HANDLE PolicyHandle,
1075 IN POLICY_INFORMATION_CLASS InformationClass,
1078 FIXME("(%p,0x%08x,%p):stub\n",
1079 PolicyHandle, InformationClass, Buffer);
1081 if(!Buffer) return FALSE;
1082 switch (InformationClass)
1084 case PolicyAuditEventsInformation: /* 2 */
1086 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
1087 p->AuditingMode = FALSE; /* no auditing */
1091 case PolicyPrimaryDomainInformation: /* 3 */
1092 case PolicyAccountDomainInformation: /* 5 */
1095 { POLICY_PRIMARY_DOMAIN_INFO ppdi;
1098 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
1100 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
1101 RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
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;
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:
1121 FIXME("category not implemented\n");
1128 /******************************************************************************
1129 * LsaLookupSids [ADVAPI32.@]
1134 LSA_UNICODE_STRING Name;
1136 } LSA_TRANSLATED_NAME, *PLSA_TRANSLATED_NAME;
1140 LSA_UNICODE_STRING Name;
1142 } LSA_TRUST_INFORMATION, *PLSA_TRUST_INFORMATION;
1147 PLSA_TRUST_INFORMATION Domains;
1148 } LSA_REFERENCED_DOMAIN_LIST, *PLSA_REFERENCED_DOMAIN_LIST;
1152 IN LSA_HANDLE PolicyHandle,
1155 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
1156 OUT PLSA_TRANSLATED_NAME *Names )
1158 FIXME("%p %lu %p %p %p\n",
1159 PolicyHandle, Count, Sids, ReferencedDomains, Names);
1163 /******************************************************************************
1164 * LsaFreeMemory [ADVAPI32.@]
1167 LsaFreeMemory(IN PVOID Buffer)
1169 TRACE("(%p)\n",Buffer);
1170 return HeapFree(GetProcessHeap(), 0, Buffer);
1172 /******************************************************************************
1173 * LsaClose [ADVAPI32.@]
1176 LsaClose(IN LSA_HANDLE ObjectHandle)
1178 FIXME("(%p):stub\n",ObjectHandle);
1182 /******************************************************************************
1183 * LsaNtStatusToWinError [ADVAPI32.@]
1189 LsaNtStatusToWinError(NTSTATUS Status)
1191 return RtlNtStatusToDosError(Status);
1194 /******************************************************************************
1195 * NotifyBootConfigStatus [ADVAPI32.@]
1201 NotifyBootConfigStatus( DWORD x1 )
1203 FIXME("(0x%08lx):stub\n",x1);
1207 /******************************************************************************
1208 * RevertToSelf [ADVAPI32.@]
1214 RevertToSelf( void )
1216 FIXME("(), stub\n");
1220 /******************************************************************************
1221 * ImpersonateSelf [ADVAPI32.@]
1224 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
1226 return RtlImpersonateSelf(ImpersonationLevel);
1229 /******************************************************************************
1230 * ImpersonateLoggedOnUser [ADVAPI32.@]
1232 BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
1234 FIXME("(%p):stub returning FALSE\n", hToken);
1238 /******************************************************************************
1239 * AccessCheck [ADVAPI32.@]
1241 * FIXME check cast LPBOOL to PBOOLEAN
1245 PSECURITY_DESCRIPTOR SecurityDescriptor,
1247 DWORD DesiredAccess,
1248 PGENERIC_MAPPING GenericMapping,
1249 PPRIVILEGE_SET PrivilegeSet,
1250 LPDWORD PrivilegeSetLength,
1251 LPDWORD GrantedAccess,
1252 LPBOOL AccessStatus)
1254 CallWin32ToNt (NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
1255 GenericMapping, PrivilegeSet, PrivilegeSetLength, GrantedAccess, (PBOOLEAN)AccessStatus));
1258 /*************************************************************************
1259 * SetKernelObjectSecurity [ADVAPI32.@]
1261 BOOL WINAPI SetKernelObjectSecurity (
1263 IN SECURITY_INFORMATION SecurityInformation,
1264 IN PSECURITY_DESCRIPTOR SecurityDescriptor )
1266 CallWin32ToNt (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
1269 /******************************************************************************
1270 * LookupAccountNameA [ADVAPI32.@]
1278 LPSTR ReferencedDomainName,
1279 IN OUT LPDWORD cbReferencedDomainName,
1280 OUT PSID_NAME_USE name_use )
1282 FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
1286 /******************************************************************************
1287 * PrivilegeCheck [ADVAPI32.@]
1289 BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
1291 FIXME("stub %p %p %p\n", ClientToken, RequiredPrivileges, pfResult);
1297 /******************************************************************************
1298 * AccessCheckAndAuditAlarmA [ADVAPI32.@]
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)
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);
1312 /******************************************************************************
1313 * AccessCheckAndAuditAlarmW [ADVAPI32.@]
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)
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);
1328 /******************************************************************************
1329 * GetSecurityInfoExW [ADVAPI32.@]
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
1339 return ERROR_BAD_PROVIDER;
1342 /******************************************************************************
1343 * BuildTrusteeWithSidA [ADVAPI32.@]
1345 VOID WINAPI BuildTrusteeWithSidA(PTRUSTEEA pTrustee, PSID pSid)
1347 FIXME("%p %p\n", pTrustee, pSid);
1350 /******************************************************************************
1351 * BuildTrusteeWithSidW [ADVAPI32.@]
1353 VOID WINAPI BuildTrusteeWithSidW(PTRUSTEEW pTrustee, PSID pSid)
1355 FIXME("%p %p\n", pTrustee, pSid);
1358 /******************************************************************************
1359 * SetEntriesInAclA [ADVAPI32.@]
1361 DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
1362 PACL OldAcl, PACL* NewAcl )
1364 FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
1365 return ERROR_CALL_NOT_IMPLEMENTED;
1368 /******************************************************************************
1369 * SetEntriesInAclW [ADVAPI32.@]
1371 DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
1372 PACL OldAcl, PACL* NewAcl )
1374 FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
1375 return ERROR_CALL_NOT_IMPLEMENTED;
1378 /******************************************************************************
1379 * SetNamedSecurityInfoA [ADVAPI32.@]
1381 DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
1382 SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
1383 PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
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;
1390 /******************************************************************************
1391 * SetNamedSecurityInfoW [ADVAPI32.@]
1393 DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
1394 SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
1395 PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
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;
1402 /******************************************************************************
1403 * GetExplicitEntriesFromAclA [ADVAPI32.@]
1405 DWORD WINAPI GetExplicitEntriesFromAclA( PACL pacl, PULONG pcCountOfExplicitEntries,
1406 PEXPLICIT_ACCESSA* pListOfExplicitEntries)
1408 FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
1409 return ERROR_CALL_NOT_IMPLEMENTED;
1412 /******************************************************************************
1413 * GetExplicitEntriesFromAclW [ADVAPI32.@]
1415 DWORD WINAPI GetExplicitEntriesFromAclW( PACL pacl, PULONG pcCountOfExplicitEntries,
1416 PEXPLICIT_ACCESSW* pListOfExplicitEntries)
1418 FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
1419 return ERROR_CALL_NOT_IMPLEMENTED;