2 * Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
3 * Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
42 static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes);
43 static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
44 PACL pAcl, LPDWORD cBytes);
45 static BYTE ParseAceStringFlags(LPCWSTR* StringAcl);
46 static BYTE ParseAceStringType(LPCWSTR* StringAcl);
47 static DWORD ParseAceStringRights(LPCWSTR* StringAcl);
48 static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
49 LPCWSTR StringSecurityDescriptor,
50 SECURITY_DESCRIPTOR* SecurityDescriptor,
52 static DWORD ParseAclStringFlags(LPCWSTR* StringAcl);
54 typedef struct _ACEFLAG
58 } ACEFLAG, *LPACEFLAG;
60 static SID const sidWorld = { SID_REVISION, 1, { SECURITY_WORLD_SID_AUTHORITY} , { SECURITY_WORLD_RID } };
65 static const WCHAR SDDL_READ_CONTROL[] = {'R','C',0};
66 static const WCHAR SDDL_WRITE_DAC[] = {'W','D',0};
67 static const WCHAR SDDL_WRITE_OWNER[] = {'W','O',0};
68 static const WCHAR SDDL_STANDARD_DELETE[] = {'S','D',0};
69 static const WCHAR SDDL_GENERIC_ALL[] = {'G','A',0};
70 static const WCHAR SDDL_GENERIC_READ[] = {'G','R',0};
71 static const WCHAR SDDL_GENERIC_WRITE[] = {'G','W',0};
72 static const WCHAR SDDL_GENERIC_EXECUTE[] = {'G','X',0};
77 static const WCHAR SDDL_ACCESS_ALLOWED[] = {'A',0};
78 static const WCHAR SDDL_ACCESS_DENIED[] = {'D',0};
79 static const WCHAR SDDL_OBJECT_ACCESS_ALLOWED[] = {'O','A',0};
80 static const WCHAR SDDL_OBJECT_ACCESS_DENIED[] = {'O','D',0};
81 static const WCHAR SDDL_AUDIT[] = {'A','U',0};
82 static const WCHAR SDDL_ALARM[] = {'A','L',0};
83 static const WCHAR SDDL_OBJECT_AUDIT[] = {'O','U',0};
84 static const WCHAR SDDL_OBJECT_ALARMp[] = {'O','L',0};
89 static const WCHAR SDDL_CONTAINER_INHERIT[] = {'C','I',0};
90 static const WCHAR SDDL_OBJECT_INHERIT[] = {'O','I',0};
91 static const WCHAR SDDL_NO_PROPAGATE[] = {'N','P',0};
92 static const WCHAR SDDL_INHERIT_ONLY[] = {'I','O',0};
93 static const WCHAR SDDL_INHERITED[] = {'I','D',0};
94 static const WCHAR SDDL_AUDIT_SUCCESS[] = {'S','A',0};
95 static const WCHAR SDDL_AUDIT_FAILURE[] = {'F','A',0};
97 /* set last error code from NT status and get the proper boolean return value */
98 /* used for functions that are a simple wrapper around the corresponding ntdll API */
99 static inline BOOL set_ntstatus( NTSTATUS status )
101 if (status) SetLastError( RtlNtStatusToDosError( status ));
105 static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa )
109 TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
110 oa->Length, oa->RootDirectory,
111 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
112 oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
116 #define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD))
118 static void GetWorldAccessACL(PACL pACL)
120 PACCESS_ALLOWED_ACE pACE = (PACCESS_ALLOWED_ACE) (pACL + 1);
122 pACL->AclRevision = ACL_REVISION;
124 pACL->AclSize = WINE_SIZE_OF_WORLD_ACCESS_ACL;
128 pACE->Header.AceType = ACCESS_ALLOWED_ACE_TYPE;
129 pACE->Header.AceFlags = CONTAINER_INHERIT_ACE;
130 pACE->Header.AceSize = sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD);
131 pACE->Mask = 0xf3ffffff; /* Everything except reserved bits */
132 memcpy(&pACE->SidStart, &sidWorld, sizeof(sidWorld));
135 /************************************************************
136 * ADVAPI_IsLocalComputer
138 * Checks whether the server name indicates local machine.
140 static BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
142 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
146 if (!ServerName || !ServerName[0])
149 buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
150 Result = GetComputerNameW(buf, &dwSize);
151 if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
153 Result = Result && !lstrcmpW(ServerName, buf);
154 HeapFree(GetProcessHeap(), 0, buf);
159 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
160 if (!ADVAPI_IsLocalComputer(ServerName)) \
162 FIXME("Action Implemented for local computer only. " \
163 "Requested for server %s\n", debugstr_w(ServerName)); \
164 return FailureCode; \
167 /* ##############################
168 ###### TOKEN FUNCTIONS ######
169 ##############################
172 /******************************************************************************
173 * OpenProcessToken [ADVAPI32.@]
174 * Opens the access token associated with a process handle.
177 * ProcessHandle [I] Handle to process
178 * DesiredAccess [I] Desired access to process
179 * TokenHandle [O] Pointer to handle of open access token
182 * Success: TRUE. TokenHandle contains the access token.
186 * See NtOpenProcessToken.
189 OpenProcessToken( HANDLE ProcessHandle, DWORD DesiredAccess,
190 HANDLE *TokenHandle )
192 return set_ntstatus(NtOpenProcessToken( ProcessHandle, DesiredAccess, TokenHandle ));
195 /******************************************************************************
196 * OpenThreadToken [ADVAPI32.@]
198 * Opens the access token associated with a thread handle.
201 * ThreadHandle [I] Handle to process
202 * DesiredAccess [I] Desired access to the thread
204 * TokenHandle [O] Destination for the token handle
207 * Success: TRUE. TokenHandle contains the access token.
211 * See NtOpenThreadToken.
214 OpenThreadToken( HANDLE ThreadHandle, DWORD DesiredAccess,
215 BOOL OpenAsSelf, HANDLE *TokenHandle)
217 return set_ntstatus( NtOpenThreadToken(ThreadHandle, DesiredAccess, OpenAsSelf, TokenHandle));
221 AdjustTokenGroups( HANDLE TokenHandle, BOOL ResetToDefault, PTOKEN_GROUPS NewState,
222 DWORD BufferLength, PTOKEN_GROUPS PreviousState, PDWORD ReturnLength )
224 return set_ntstatus( NtAdjustGroupsToken(TokenHandle, ResetToDefault, NewState, BufferLength,
225 PreviousState, ReturnLength));
228 /******************************************************************************
229 * AdjustTokenPrivileges [ADVAPI32.@]
231 * Adjust the privileges of an open token handle.
234 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
235 * DisableAllPrivileges [I] TRUE=Remove all privileges, FALSE=Use NewState
236 * NewState [I] Desired new privileges of the token
237 * BufferLength [I] Length of NewState
238 * PreviousState [O] Destination for the previous state
239 * ReturnLength [I/O] Size of PreviousState
243 * Success: TRUE. Privileges are set to NewState and PreviousState is updated.
247 * See NtAdjustPrivilegesToken.
250 AdjustTokenPrivileges( HANDLE TokenHandle, BOOL DisableAllPrivileges,
251 LPVOID NewState, DWORD BufferLength,
252 LPVOID PreviousState, LPDWORD ReturnLength )
258 status = NtAdjustPrivilegesToken(TokenHandle, DisableAllPrivileges,
259 NewState, BufferLength, PreviousState,
261 SetLastError( RtlNtStatusToDosError( status ));
262 if ((status == STATUS_SUCCESS) || (status == STATUS_NOT_ALL_ASSIGNED))
268 /******************************************************************************
269 * CheckTokenMembership [ADVAPI32.@]
271 * Determine if an access token is a member of a SID.
274 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
275 * SidToCheck [I] SID that possibly contains the token
276 * IsMember [O] Destination for result.
279 * Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
283 CheckTokenMembership( HANDLE TokenHandle, PSID SidToCheck,
286 FIXME("(%p %p %p) stub!\n", TokenHandle, SidToCheck, IsMember);
292 /******************************************************************************
293 * GetTokenInformation [ADVAPI32.@]
296 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
297 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
298 * tokeninfo [O] Destination for token information
299 * tokeninfolength [I] Length of tokeninfo
300 * retlen [O] Destination for returned token information length
303 * Success: TRUE. tokeninfo contains retlen bytes of token information
307 * See NtQueryInformationToken.
310 GetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
311 LPVOID tokeninfo, DWORD tokeninfolength, LPDWORD retlen )
313 TRACE("(%p, %s, %p, %ld, %p): \n",
315 (tokeninfoclass == TokenUser) ? "TokenUser" :
316 (tokeninfoclass == TokenGroups) ? "TokenGroups" :
317 (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
318 (tokeninfoclass == TokenOwner) ? "TokenOwner" :
319 (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
320 (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
321 (tokeninfoclass == TokenSource) ? "TokenSource" :
322 (tokeninfoclass == TokenType) ? "TokenType" :
323 (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
324 (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
325 (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
326 (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
327 (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
328 (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
329 (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
331 tokeninfo, tokeninfolength, retlen);
332 return set_ntstatus( NtQueryInformationToken( token, tokeninfoclass, tokeninfo,
333 tokeninfolength, retlen));
336 /******************************************************************************
337 * SetTokenInformation [ADVAPI32.@]
339 * Set information for an access token.
342 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
343 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
344 * tokeninfo [I] Token information to set
345 * tokeninfolength [I] Length of tokeninfo
348 * Success: TRUE. The information for the token is set to tokeninfo.
352 SetTokenInformation( HANDLE token, TOKEN_INFORMATION_CLASS tokeninfoclass,
353 LPVOID tokeninfo, DWORD tokeninfolength )
355 TRACE("(%p, %s, %p, %ld): stub\n",
357 (tokeninfoclass == TokenUser) ? "TokenUser" :
358 (tokeninfoclass == TokenGroups) ? "TokenGroups" :
359 (tokeninfoclass == TokenPrivileges) ? "TokenPrivileges" :
360 (tokeninfoclass == TokenOwner) ? "TokenOwner" :
361 (tokeninfoclass == TokenPrimaryGroup) ? "TokenPrimaryGroup" :
362 (tokeninfoclass == TokenDefaultDacl) ? "TokenDefaultDacl" :
363 (tokeninfoclass == TokenSource) ? "TokenSource" :
364 (tokeninfoclass == TokenType) ? "TokenType" :
365 (tokeninfoclass == TokenImpersonationLevel) ? "TokenImpersonationLevel" :
366 (tokeninfoclass == TokenStatistics) ? "TokenStatistics" :
367 (tokeninfoclass == TokenRestrictedSids) ? "TokenRestrictedSids" :
368 (tokeninfoclass == TokenSessionId) ? "TokenSessionId" :
369 (tokeninfoclass == TokenGroupsAndPrivileges) ? "TokenGroupsAndPrivileges" :
370 (tokeninfoclass == TokenSessionReference) ? "TokenSessionReference" :
371 (tokeninfoclass == TokenSandBoxInert) ? "TokenSandBoxInert" :
373 tokeninfo, tokeninfolength);
375 return set_ntstatus( NtSetInformationToken( token, tokeninfoclass, tokeninfo, tokeninfolength ));
378 /*************************************************************************
379 * SetThreadToken [ADVAPI32.@]
381 * Assigns an 'impersonation token' to a thread so it can assume the
382 * security privileges of another thread or process. Can also remove
383 * a previously assigned token.
386 * thread [O] Handle to thread to set the token for
387 * token [I] Token to set
390 * Success: TRUE. The threads access token is set to token
394 * Only supported on NT or higher. On Win9X this function does nothing.
395 * See SetTokenInformation.
397 BOOL WINAPI SetThreadToken(PHANDLE thread, HANDLE token)
399 return set_ntstatus( NtSetInformationThread( thread ? *thread : GetCurrentThread(),
400 ThreadImpersonationToken, &token, sizeof token ));
403 /* ##############################
404 ###### SID FUNCTIONS ######
405 ##############################
408 /******************************************************************************
409 * AllocateAndInitializeSid [ADVAPI32.@]
412 * pIdentifierAuthority []
413 * nSubAuthorityCount []
425 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
426 BYTE nSubAuthorityCount,
427 DWORD nSubAuthority0, DWORD nSubAuthority1,
428 DWORD nSubAuthority2, DWORD nSubAuthority3,
429 DWORD nSubAuthority4, DWORD nSubAuthority5,
430 DWORD nSubAuthority6, DWORD nSubAuthority7,
433 return set_ntstatus( RtlAllocateAndInitializeSid(
434 pIdentifierAuthority, nSubAuthorityCount,
435 nSubAuthority0, nSubAuthority1, nSubAuthority2, nSubAuthority3,
436 nSubAuthority4, nSubAuthority5, nSubAuthority6, nSubAuthority7,
440 /******************************************************************************
441 * FreeSid [ADVAPI32.@]
450 return NULL; /* is documented like this */
453 /******************************************************************************
454 * CopySid [ADVAPI32.@]
457 * nDestinationSidLength []
462 CopySid( DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid )
464 return RtlCopySid(nDestinationSidLength, pDestinationSid, pSourceSid);
468 IsTokenRestricted( HANDLE TokenHandle )
470 TOKEN_GROUPS *groups;
475 TRACE("(%p)\n", TokenHandle);
477 status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, NULL, 0, &size);
478 if (status != STATUS_BUFFER_TOO_SMALL)
481 groups = HeapAlloc(GetProcessHeap(), 0, size);
484 SetLastError(ERROR_OUTOFMEMORY);
488 status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, groups, size, &size);
489 if (status != STATUS_SUCCESS)
491 HeapFree(GetProcessHeap(), 0, groups);
492 return set_ntstatus(status);
495 if (groups->GroupCount)
500 HeapFree(GetProcessHeap(), 0, groups);
505 /******************************************************************************
506 * IsValidSid [ADVAPI32.@]
512 IsValidSid( PSID pSid )
514 return RtlValidSid( pSid );
517 /******************************************************************************
518 * EqualSid [ADVAPI32.@]
525 EqualSid( PSID pSid1, PSID pSid2 )
527 return RtlEqualSid( pSid1, pSid2 );
530 /******************************************************************************
531 * EqualPrefixSid [ADVAPI32.@]
533 BOOL WINAPI EqualPrefixSid (PSID pSid1, PSID pSid2)
535 return RtlEqualPrefixSid(pSid1, pSid2);
538 /******************************************************************************
539 * GetSidLengthRequired [ADVAPI32.@]
542 * nSubAuthorityCount []
545 GetSidLengthRequired( BYTE nSubAuthorityCount )
547 return RtlLengthRequiredSid(nSubAuthorityCount);
550 /******************************************************************************
551 * InitializeSid [ADVAPI32.@]
554 * pIdentifierAuthority []
559 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
560 BYTE nSubAuthorityCount)
562 return RtlInitializeSid(pSid, pIdentifierAuthority, nSubAuthorityCount);
566 GetEffectiveRightsFromAclA( PACL pacl, PTRUSTEEA pTrustee, PACCESS_MASK pAccessRights )
568 FIXME("%p %p %p - stub\n", pacl, pTrustee, pAccessRights);
574 GetEffectiveRightsFromAclW( PACL pacl, PTRUSTEEW pTrustee, PACCESS_MASK pAccessRights )
576 FIXME("%p %p %p - stub\n", pacl, pTrustee, pAccessRights);
581 /******************************************************************************
582 * GetSidIdentifierAuthority [ADVAPI32.@]
587 PSID_IDENTIFIER_AUTHORITY WINAPI
588 GetSidIdentifierAuthority( PSID pSid )
590 return RtlIdentifierAuthoritySid(pSid);
593 /******************************************************************************
594 * GetSidSubAuthority [ADVAPI32.@]
601 GetSidSubAuthority( PSID pSid, DWORD nSubAuthority )
603 return RtlSubAuthoritySid(pSid, nSubAuthority);
606 /******************************************************************************
607 * GetSidSubAuthorityCount [ADVAPI32.@]
613 GetSidSubAuthorityCount (PSID pSid)
615 return RtlSubAuthorityCountSid(pSid);
618 /******************************************************************************
619 * GetLengthSid [ADVAPI32.@]
625 GetLengthSid (PSID pSid)
627 return RtlLengthSid(pSid);
630 /* ##############################################
631 ###### SECURITY DESCRIPTOR FUNCTIONS ######
632 ##############################################
635 /******************************************************************************
636 * InitializeSecurityDescriptor [ADVAPI32.@]
643 InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr, DWORD revision )
645 return set_ntstatus( RtlCreateSecurityDescriptor(pDescr, revision ));
649 /******************************************************************************
650 * MakeAbsoluteSD [ADVAPI32.@]
652 BOOL WINAPI MakeAbsoluteSD (
653 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
654 OUT PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
655 OUT LPDWORD lpdwAbsoluteSecurityDescriptorSize,
657 OUT LPDWORD lpdwDaclSize,
659 OUT LPDWORD lpdwSaclSize,
661 OUT LPDWORD lpdwOwnerSize,
662 OUT PSID pPrimaryGroup,
663 OUT LPDWORD lpdwPrimaryGroupSize)
665 return set_ntstatus( RtlSelfRelativeToAbsoluteSD(pSelfRelativeSecurityDescriptor,
666 pAbsoluteSecurityDescriptor,
667 lpdwAbsoluteSecurityDescriptorSize,
668 pDacl, lpdwDaclSize, pSacl, lpdwSaclSize,
669 pOwner, lpdwOwnerSize,
670 pPrimaryGroup, lpdwPrimaryGroupSize));
673 /******************************************************************************
674 * GetKernelObjectSecurity [ADVAPI32.@]
676 BOOL WINAPI GetKernelObjectSecurity(
678 SECURITY_INFORMATION RequestedInformation,
679 PSECURITY_DESCRIPTOR pSecurityDescriptor,
681 LPDWORD lpnLengthNeeded )
683 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", Handle, RequestedInformation,
684 pSecurityDescriptor, nLength, lpnLengthNeeded);
686 return set_ntstatus( NtQuerySecurityObject(Handle, RequestedInformation, pSecurityDescriptor,
687 nLength, lpnLengthNeeded ));
690 /******************************************************************************
691 * GetPrivateObjectSecurity [ADVAPI32.@]
693 BOOL WINAPI GetPrivateObjectSecurity(
694 PSECURITY_DESCRIPTOR ObjectDescriptor,
695 SECURITY_INFORMATION SecurityInformation,
696 PSECURITY_DESCRIPTOR ResultantDescriptor,
697 DWORD DescriptorLength,
698 PDWORD ReturnLength )
700 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", ObjectDescriptor, SecurityInformation,
701 ResultantDescriptor, DescriptorLength, ReturnLength);
703 return set_ntstatus( NtQuerySecurityObject(ObjectDescriptor, SecurityInformation,
704 ResultantDescriptor, DescriptorLength, ReturnLength ));
707 /******************************************************************************
708 * GetSecurityDescriptorLength [ADVAPI32.@]
710 DWORD WINAPI GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr)
712 return RtlLengthSecurityDescriptor(pDescr);
715 /******************************************************************************
716 * GetSecurityDescriptorOwner [ADVAPI32.@]
720 * lpbOwnerDefaulted []
723 GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr, PSID *pOwner,
724 LPBOOL lpbOwnerDefaulted )
727 BOOL ret = set_ntstatus( RtlGetOwnerSecurityDescriptor( pDescr, pOwner, &defaulted ));
728 *lpbOwnerDefaulted = defaulted;
732 /******************************************************************************
733 * SetSecurityDescriptorOwner [ADVAPI32.@]
737 BOOL WINAPI SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor,
738 PSID pOwner, BOOL bOwnerDefaulted)
740 return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor, pOwner, bOwnerDefaulted));
742 /******************************************************************************
743 * GetSecurityDescriptorGroup [ADVAPI32.@]
745 BOOL WINAPI GetSecurityDescriptorGroup(
746 PSECURITY_DESCRIPTOR SecurityDescriptor,
748 LPBOOL GroupDefaulted)
751 BOOL ret = set_ntstatus( RtlGetGroupSecurityDescriptor(SecurityDescriptor, Group, &defaulted ));
752 *GroupDefaulted = defaulted;
755 /******************************************************************************
756 * SetSecurityDescriptorGroup [ADVAPI32.@]
758 BOOL WINAPI SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor,
759 PSID Group, BOOL GroupDefaulted)
761 return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor, Group, GroupDefaulted));
764 /******************************************************************************
765 * IsValidSecurityDescriptor [ADVAPI32.@]
771 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor )
773 return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor));
776 /******************************************************************************
777 * GetSecurityDescriptorDacl [ADVAPI32.@]
779 BOOL WINAPI GetSecurityDescriptorDacl(
780 IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
781 OUT LPBOOL lpbDaclPresent,
783 OUT LPBOOL lpbDaclDefaulted)
785 BOOLEAN present, defaulted;
786 BOOL ret = set_ntstatus( RtlGetDaclSecurityDescriptor(pSecurityDescriptor, &present, pDacl, &defaulted));
787 *lpbDaclPresent = present;
788 *lpbDaclDefaulted = defaulted;
792 /******************************************************************************
793 * SetSecurityDescriptorDacl [ADVAPI32.@]
796 SetSecurityDescriptorDacl (
797 PSECURITY_DESCRIPTOR lpsd,
802 return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd, daclpresent, dacl, dacldefaulted ) );
804 /******************************************************************************
805 * GetSecurityDescriptorSacl [ADVAPI32.@]
807 BOOL WINAPI GetSecurityDescriptorSacl(
808 IN PSECURITY_DESCRIPTOR lpsd,
809 OUT LPBOOL lpbSaclPresent,
811 OUT LPBOOL lpbSaclDefaulted)
813 BOOLEAN present, defaulted;
814 BOOL ret = set_ntstatus( RtlGetSaclSecurityDescriptor(lpsd, &present, pSacl, &defaulted) );
815 *lpbSaclPresent = present;
816 *lpbSaclDefaulted = defaulted;
820 /**************************************************************************
821 * SetSecurityDescriptorSacl [ADVAPI32.@]
823 BOOL WINAPI SetSecurityDescriptorSacl (
824 PSECURITY_DESCRIPTOR lpsd,
829 return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd, saclpresent, lpsacl, sacldefaulted));
831 /******************************************************************************
832 * MakeSelfRelativeSD [ADVAPI32.@]
841 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
842 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
843 IN OUT LPDWORD lpdwBufferLength)
845 return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor,
846 pSelfRelativeSecurityDescriptor, lpdwBufferLength));
849 /******************************************************************************
850 * GetSecurityDescriptorControl [ADVAPI32.@]
853 BOOL WINAPI GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor,
854 PSECURITY_DESCRIPTOR_CONTROL pControl, LPDWORD lpdwRevision)
856 return set_ntstatus( RtlGetControlSecurityDescriptor(pSecurityDescriptor,pControl,lpdwRevision));
859 /* ##############################
860 ###### ACL FUNCTIONS ######
861 ##############################
864 /*************************************************************************
865 * InitializeAcl [ADVAPI32.@]
867 BOOL WINAPI InitializeAcl(PACL acl, DWORD size, DWORD rev)
869 return set_ntstatus( RtlCreateAcl(acl, size, rev));
872 BOOL WINAPI ImpersonateNamedPipeClient( HANDLE hNamedPipe )
874 FIXME("%p - stub\n", hNamedPipe);
879 /******************************************************************************
880 * AddAccessAllowedAce [ADVAPI32.@]
882 BOOL WINAPI AddAccessAllowedAce(
884 IN DWORD dwAceRevision,
888 return set_ntstatus(RtlAddAccessAllowedAce(pAcl, dwAceRevision, AccessMask, pSid));
891 /******************************************************************************
892 * AddAccessAllowedAceEx [ADVAPI32.@]
894 BOOL WINAPI AddAccessAllowedAceEx(
896 IN DWORD dwAceRevision,
901 return set_ntstatus(RtlAddAccessAllowedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
904 /******************************************************************************
905 * AddAccessDeniedAce [ADVAPI32.@]
907 BOOL WINAPI AddAccessDeniedAce(
909 IN DWORD dwAceRevision,
913 return set_ntstatus(RtlAddAccessDeniedAce(pAcl, dwAceRevision, AccessMask, pSid));
916 /******************************************************************************
917 * AddAccessDeniedAceEx [ADVAPI32.@]
919 BOOL WINAPI AddAccessDeniedAceEx(
921 IN DWORD dwAceRevision,
926 return set_ntstatus(RtlAddAccessDeniedAceEx(pAcl, dwAceRevision, AceFlags, AccessMask, pSid));
929 /******************************************************************************
930 * AddAce [ADVAPI32.@]
934 IN DWORD dwAceRevision,
935 IN DWORD dwStartingAceIndex,
937 DWORD nAceListLength)
939 return set_ntstatus(RtlAddAce(pAcl, dwAceRevision, dwStartingAceIndex, pAceList, nAceListLength));
942 /******************************************************************************
943 * DeleteAce [ADVAPI32.@]
945 BOOL WINAPI DeleteAce(PACL pAcl, DWORD dwAceIndex)
947 return set_ntstatus(RtlDeleteAce(pAcl, dwAceIndex));
950 /******************************************************************************
951 * FindFirstFreeAce [ADVAPI32.@]
953 BOOL WINAPI FindFirstFreeAce(IN PACL pAcl, LPVOID * pAce)
955 return RtlFirstFreeAce(pAcl, (PACE_HEADER *)pAce);
958 /******************************************************************************
959 * GetAce [ADVAPI32.@]
961 BOOL WINAPI GetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce )
963 return set_ntstatus(RtlGetAce(pAcl, dwAceIndex, pAce));
966 /******************************************************************************
967 * GetAclInformation [ADVAPI32.@]
969 BOOL WINAPI GetAclInformation(
971 LPVOID pAclInformation,
972 DWORD nAclInformationLength,
973 ACL_INFORMATION_CLASS dwAclInformationClass)
975 return set_ntstatus(RtlQueryInformationAcl(pAcl, pAclInformation,
976 nAclInformationLength, dwAclInformationClass));
979 /******************************************************************************
980 * IsValidAcl [ADVAPI32.@]
982 BOOL WINAPI IsValidAcl(IN PACL pAcl)
984 return RtlValidAcl(pAcl);
987 /* ##############################
988 ###### MISC FUNCTIONS ######
989 ##############################
992 /******************************************************************************
993 * AllocateLocallyUniqueId [ADVAPI32.@]
998 BOOL WINAPI AllocateLocallyUniqueId( PLUID lpLuid )
1000 return set_ntstatus(NtAllocateLocallyUniqueId(lpLuid));
1003 static const WCHAR SE_CREATE_TOKEN_NAME_W[] =
1004 { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
1005 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W[] =
1006 { 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
1007 static const WCHAR SE_LOCK_MEMORY_NAME_W[] =
1008 { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
1009 static const WCHAR SE_INCREASE_QUOTA_NAME_W[] =
1010 { 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
1011 static const WCHAR SE_MACHINE_ACCOUNT_NAME_W[] =
1012 { 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
1013 static const WCHAR SE_TCB_NAME_W[] =
1014 { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
1015 static const WCHAR SE_SECURITY_NAME_W[] =
1016 { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
1017 static const WCHAR SE_TAKE_OWNERSHIP_NAME_W[] =
1018 { 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
1019 static const WCHAR SE_LOAD_DRIVER_NAME_W[] =
1020 { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
1021 static const WCHAR SE_SYSTEM_PROFILE_NAME_W[] =
1022 { 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
1023 static const WCHAR SE_SYSTEMTIME_NAME_W[] =
1024 { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
1025 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W[] =
1026 { 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
1027 static const WCHAR SE_INC_BASE_PRIORITY_NAME_W[] =
1028 { 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
1029 static const WCHAR SE_CREATE_PAGEFILE_NAME_W[] =
1030 { 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
1031 static const WCHAR SE_CREATE_PERMANENT_NAME_W[] =
1032 { 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
1033 static const WCHAR SE_BACKUP_NAME_W[] =
1034 { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
1035 static const WCHAR SE_RESTORE_NAME_W[] =
1036 { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
1037 static const WCHAR SE_SHUTDOWN_NAME_W[] =
1038 { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
1039 static const WCHAR SE_DEBUG_NAME_W[] =
1040 { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
1041 static const WCHAR SE_AUDIT_NAME_W[] =
1042 { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
1043 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W[] =
1044 { 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
1045 static const WCHAR SE_CHANGE_NOTIFY_NAME_W[] =
1046 { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
1047 static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W[] =
1048 { 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
1049 static const WCHAR SE_UNDOCK_NAME_W[] =
1050 { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
1051 static const WCHAR SE_SYNC_AGENT_NAME_W[] =
1052 { 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
1053 static const WCHAR SE_ENABLE_DELEGATION_NAME_W[] =
1054 { 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
1055 static const WCHAR SE_MANAGE_VOLUME_NAME_W[] =
1056 { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
1057 static const WCHAR SE_IMPERSONATE_NAME_W[] =
1058 { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
1059 static const WCHAR SE_CREATE_GLOBAL_NAME_W[] =
1060 { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
1062 static const WCHAR * const WellKnownPrivNames[SE_MAX_WELL_KNOWN_PRIVILEGE + 1] =
1066 SE_CREATE_TOKEN_NAME_W,
1067 SE_ASSIGNPRIMARYTOKEN_NAME_W,
1068 SE_LOCK_MEMORY_NAME_W,
1069 SE_INCREASE_QUOTA_NAME_W,
1070 SE_MACHINE_ACCOUNT_NAME_W,
1073 SE_TAKE_OWNERSHIP_NAME_W,
1074 SE_LOAD_DRIVER_NAME_W,
1075 SE_SYSTEM_PROFILE_NAME_W,
1076 SE_SYSTEMTIME_NAME_W,
1077 SE_PROF_SINGLE_PROCESS_NAME_W,
1078 SE_INC_BASE_PRIORITY_NAME_W,
1079 SE_CREATE_PAGEFILE_NAME_W,
1080 SE_CREATE_PERMANENT_NAME_W,
1086 SE_SYSTEM_ENVIRONMENT_NAME_W,
1087 SE_CHANGE_NOTIFY_NAME_W,
1088 SE_REMOTE_SHUTDOWN_NAME_W,
1090 SE_SYNC_AGENT_NAME_W,
1091 SE_ENABLE_DELEGATION_NAME_W,
1092 SE_MANAGE_VOLUME_NAME_W,
1093 SE_IMPERSONATE_NAME_W,
1094 SE_CREATE_GLOBAL_NAME_W,
1097 /******************************************************************************
1098 * LookupPrivilegeValueW [ADVAPI32.@]
1100 * See LookupPrivilegeValueA.
1103 LookupPrivilegeValueW( LPCWSTR lpSystemName, LPCWSTR lpName, PLUID lpLuid )
1107 TRACE("%s,%s,%p\n",debugstr_w(lpSystemName), debugstr_w(lpName), lpLuid);
1109 if (!ADVAPI_IsLocalComputer(lpSystemName))
1111 SetLastError(RPC_S_SERVER_UNAVAILABLE);
1116 SetLastError(ERROR_NO_SUCH_PRIVILEGE);
1119 for( i=SE_MIN_WELL_KNOWN_PRIVILEGE; i<SE_MAX_WELL_KNOWN_PRIVILEGE; i++ )
1121 if( !WellKnownPrivNames[i] )
1123 if( strcmpiW( WellKnownPrivNames[i], lpName) )
1125 lpLuid->LowPart = i;
1126 lpLuid->HighPart = 0;
1127 TRACE( "%s -> %08lx-%08lx\n",debugstr_w( lpSystemName ),
1128 lpLuid->HighPart, lpLuid->LowPart );
1131 SetLastError(ERROR_NO_SUCH_PRIVILEGE);
1135 /******************************************************************************
1136 * LookupPrivilegeValueA [ADVAPI32.@]
1138 * Retrieves LUID used on a system to represent the privilege name.
1141 * lpSystemName [I] Name of the system
1142 * lpName [I] Name of the privilege
1143 * lpLuid [O] Destination for the resulting LUID
1146 * Success: TRUE. lpLuid contains the requested LUID.
1150 LookupPrivilegeValueA( LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid )
1152 UNICODE_STRING lpSystemNameW;
1153 UNICODE_STRING lpNameW;
1156 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
1157 RtlCreateUnicodeStringFromAsciiz(&lpNameW,lpName);
1158 ret = LookupPrivilegeValueW(lpSystemNameW.Buffer, lpNameW.Buffer, lpLuid);
1159 RtlFreeUnicodeString(&lpNameW);
1160 RtlFreeUnicodeString(&lpSystemNameW);
1164 BOOL WINAPI LookupPrivilegeDisplayNameA( LPCSTR lpSystemName, LPCSTR lpName, LPSTR lpDisplayName,
1165 LPDWORD cchDisplayName, LPDWORD lpLanguageId )
1167 FIXME("%s %s %s %p %p - stub\n", debugstr_a(lpSystemName), debugstr_a(lpName),
1168 debugstr_a(lpDisplayName), cchDisplayName, lpLanguageId);
1173 BOOL WINAPI LookupPrivilegeDisplayNameW( LPCWSTR lpSystemName, LPCWSTR lpName, LPWSTR lpDisplayName,
1174 LPDWORD cchDisplayName, LPDWORD lpLanguageId )
1176 FIXME("%s %s %s %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpName),
1177 debugstr_w(lpDisplayName), cchDisplayName, lpLanguageId);
1182 /******************************************************************************
1183 * LookupPrivilegeNameA [ADVAPI32.@]
1185 * See LookupPrivilegeNameW
1188 LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
1191 UNICODE_STRING lpSystemNameW;
1195 TRACE("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
1197 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
1198 ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, NULL, &wLen);
1199 if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
1201 LPWSTR lpNameW = HeapAlloc(GetProcessHeap(), 0, wLen * sizeof(WCHAR));
1203 ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, lpNameW,
1207 /* Windows crashes if cchName is NULL, so will I */
1208 int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
1209 *cchName, NULL, NULL);
1213 /* WideCharToMultiByte failed */
1216 else if (len > *cchName)
1219 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1224 /* WideCharToMultiByte succeeded, output length needs to be
1225 * length not including NULL terminator
1230 HeapFree(GetProcessHeap(), 0, lpNameW);
1232 RtlFreeUnicodeString(&lpSystemNameW);
1236 /******************************************************************************
1237 * LookupPrivilegeNameW [ADVAPI32.@]
1239 * Retrieves the privilege name referred to by the LUID lpLuid.
1242 * lpSystemName [I] Name of the system
1243 * lpLuid [I] Privilege value
1244 * lpName [O] Name of the privilege
1245 * cchName [I/O] Number of characters in lpName.
1248 * Success: TRUE. lpName contains the name of the privilege whose value is
1253 * Only well-known privilege names (those defined in winnt.h) can be retrieved
1254 * using this function.
1255 * If the length of lpName is too small, on return *cchName will contain the
1256 * number of WCHARs needed to contain the privilege, including the NULL
1257 * terminator, and GetLastError will return ERROR_INSUFFICIENT_BUFFER.
1258 * On success, *cchName will contain the number of characters stored in
1259 * lpName, NOT including the NULL terminator.
1262 LookupPrivilegeNameW( LPCWSTR lpSystemName, PLUID lpLuid, LPWSTR lpName,
1267 TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName), lpLuid, lpName, cchName);
1269 if (!ADVAPI_IsLocalComputer(lpSystemName))
1271 SetLastError(RPC_S_SERVER_UNAVAILABLE);
1274 if (lpLuid->HighPart || (lpLuid->LowPart < SE_MIN_WELL_KNOWN_PRIVILEGE ||
1275 lpLuid->LowPart > SE_MAX_WELL_KNOWN_PRIVILEGE))
1277 SetLastError(ERROR_NO_SUCH_PRIVILEGE);
1280 privNameLen = strlenW(WellKnownPrivNames[lpLuid->LowPart]);
1281 /* Windows crashes if cchName is NULL, so will I */
1282 if (*cchName <= privNameLen)
1284 *cchName = privNameLen + 1;
1285 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1290 strcpyW(lpName, WellKnownPrivNames[lpLuid->LowPart]);
1291 *cchName = privNameLen;
1296 /******************************************************************************
1297 * GetFileSecurityA [ADVAPI32.@]
1299 * Obtains Specified information about the security of a file or directory.
1302 * lpFileName [I] Name of the file to get info for
1303 * RequestedInformation [I] SE_ flags from "winnt.h"
1304 * pSecurityDescriptor [O] Destination for security information
1305 * nLength [I] Length of pSecurityDescriptor
1306 * lpnLengthNeeded [O] Destination for length of returned security information
1309 * Success: TRUE. pSecurityDescriptor contains the requested information.
1310 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
1313 * The information returned is constrained by the callers access rights and
1317 GetFileSecurityA( LPCSTR lpFileName,
1318 SECURITY_INFORMATION RequestedInformation,
1319 PSECURITY_DESCRIPTOR pSecurityDescriptor,
1320 DWORD nLength, LPDWORD lpnLengthNeeded )
1328 len = MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, NULL, 0 );
1329 name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1330 MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, name, len );
1333 r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor,
1334 nLength, lpnLengthNeeded );
1335 HeapFree( GetProcessHeap(), 0, name );
1340 /******************************************************************************
1341 * GetFileSecurityW [ADVAPI32.@]
1343 * See GetFileSecurityA.
1346 GetFileSecurityW( LPCWSTR lpFileName,
1347 SECURITY_INFORMATION RequestedInformation,
1348 PSECURITY_DESCRIPTOR pSecurityDescriptor,
1349 DWORD nLength, LPDWORD lpnLengthNeeded )
1354 SECURITY_DESCRIPTOR_RELATIVE *pSDRelative;
1356 if(INVALID_FILE_ATTRIBUTES == GetFileAttributesW(lpFileName))
1359 FIXME("(%s) : returns fake SECURITY_DESCRIPTOR\n", debugstr_w(lpFileName) );
1361 nNeeded = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
1362 if (RequestedInformation & OWNER_SECURITY_INFORMATION)
1363 nNeeded += sizeof(sidWorld);
1364 if (RequestedInformation & GROUP_SECURITY_INFORMATION)
1365 nNeeded += sizeof(sidWorld);
1366 if (RequestedInformation & DACL_SECURITY_INFORMATION)
1367 nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
1368 if (RequestedInformation & SACL_SECURITY_INFORMATION)
1369 nNeeded += WINE_SIZE_OF_WORLD_ACCESS_ACL;
1371 *lpnLengthNeeded = nNeeded;
1373 if (nNeeded > nLength)
1376 if (!InitializeSecurityDescriptor(pSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
1379 pSDRelative = (PISECURITY_DESCRIPTOR_RELATIVE) pSecurityDescriptor;
1380 pSDRelative->Control |= SE_SELF_RELATIVE;
1381 pBuffer = (LPBYTE) pSDRelative;
1382 iLocNow = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
1384 if (RequestedInformation & OWNER_SECURITY_INFORMATION)
1386 memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
1387 pSDRelative->Owner = iLocNow;
1388 iLocNow += sizeof(sidWorld);
1390 if (RequestedInformation & GROUP_SECURITY_INFORMATION)
1392 memcpy(pBuffer + iLocNow, &sidWorld, sizeof(sidWorld));
1393 pSDRelative->Group = iLocNow;
1394 iLocNow += sizeof(sidWorld);
1396 if (RequestedInformation & DACL_SECURITY_INFORMATION)
1398 GetWorldAccessACL((PACL) (pBuffer + iLocNow));
1399 pSDRelative->Dacl = iLocNow;
1400 iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL;
1402 if (RequestedInformation & SACL_SECURITY_INFORMATION)
1404 GetWorldAccessACL((PACL) (pBuffer + iLocNow));
1405 pSDRelative->Sacl = iLocNow;
1406 /* iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL; */
1412 /******************************************************************************
1413 * LookupAccountSidA [ADVAPI32.@]
1420 IN OUT LPDWORD accountSize,
1422 IN OUT LPDWORD domainSize,
1423 OUT PSID_NAME_USE name_use )
1425 static const char ac[] = "Administrator";
1426 static const char dm[] = "DOMAIN";
1427 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1428 debugstr_a(system),sid,
1429 account,accountSize,accountSize?*accountSize:0,
1430 domain,domainSize,domainSize?*domainSize:0,
1433 if (accountSize) *accountSize = strlen(ac)+1;
1434 if (account && (*accountSize > strlen(ac)))
1435 strcpy(account, ac);
1437 if (domainSize) *domainSize = strlen(dm)+1;
1438 if (domain && (*domainSize > strlen(dm)))
1441 if (name_use) *name_use = SidTypeUser;
1445 /******************************************************************************
1446 * LookupAccountSidW [ADVAPI32.@]
1462 IN OUT LPDWORD accountSize,
1464 IN OUT LPDWORD domainSize,
1465 OUT PSID_NAME_USE name_use )
1467 static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
1468 static const WCHAR dm[] = {'D','O','M','A','I','N',0};
1469 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1470 debugstr_w(system),sid,
1471 account,accountSize,accountSize?*accountSize:0,
1472 domain,domainSize,domainSize?*domainSize:0,
1475 if (accountSize) *accountSize = strlenW(ac)+1;
1476 if (account && (*accountSize > strlenW(ac)))
1477 strcpyW(account, ac);
1479 if (domainSize) *domainSize = strlenW(dm)+1;
1480 if (domain && (*domainSize > strlenW(dm)))
1483 if (name_use) *name_use = SidTypeUser;
1487 /******************************************************************************
1488 * SetFileSecurityA [ADVAPI32.@]
1489 * Sets the security of a file or directory
1491 BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
1492 SECURITY_INFORMATION RequestedInformation,
1493 PSECURITY_DESCRIPTOR pSecurityDescriptor)
1501 len = MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, NULL, 0 );
1502 name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1503 MultiByteToWideChar( CP_ACP, 0, lpFileName, -1, name, len );
1506 r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor );
1507 HeapFree( GetProcessHeap(), 0, name );
1512 /******************************************************************************
1513 * SetFileSecurityW [ADVAPI32.@]
1514 * Sets the security of a file or directory
1518 * RequestedInformation []
1519 * pSecurityDescriptor []
1522 SetFileSecurityW( LPCWSTR lpFileName,
1523 SECURITY_INFORMATION RequestedInformation,
1524 PSECURITY_DESCRIPTOR pSecurityDescriptor )
1526 FIXME("(%s) : stub\n", debugstr_w(lpFileName) );
1530 /******************************************************************************
1531 * QueryWindows31FilesMigration [ADVAPI32.@]
1537 QueryWindows31FilesMigration( DWORD x1 )
1539 FIXME("(%ld):stub\n",x1);
1543 /******************************************************************************
1544 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
1553 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1, DWORD x2, DWORD x3,
1556 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1,x2,x3,x4);
1561 LsaEnumerateTrustedDomains(
1562 LSA_HANDLE PolicyHandle,
1563 PLSA_ENUMERATION_HANDLE EnumerationContext,
1565 ULONG PreferedMaximumLength,
1566 PULONG CountReturned)
1568 FIXME("(%p,%p,%p,0x%08lx,%p):stub\n", PolicyHandle, EnumerationContext,
1569 Buffer, PreferedMaximumLength, CountReturned);
1571 if (CountReturned) *CountReturned = 0;
1572 return STATUS_SUCCESS;
1577 LSA_HANDLE PolicyHandle,
1579 PLSA_UNICODE_STRING Names,
1580 PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains,
1581 PLSA_TRANSLATED_SID* Sids)
1583 FIXME("(%p,0x%08lx,%p,%p,%p):stub\n", PolicyHandle, Count, Names,
1584 ReferencedDomains, Sids);
1586 return STATUS_NONE_MAPPED;
1589 /******************************************************************************
1590 * LsaOpenPolicy [ADVAPI32.@]
1594 * ObjectAttributes [I]
1596 * PolicyHandle [I/O]
1600 IN PLSA_UNICODE_STRING SystemName,
1601 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1602 IN ACCESS_MASK DesiredAccess,
1603 IN OUT PLSA_HANDLE PolicyHandle)
1605 FIXME("(%s,%p,0x%08lx,%p):stub\n",
1606 SystemName?debugstr_w(SystemName->Buffer):"null",
1607 ObjectAttributes, DesiredAccess, PolicyHandle);
1608 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
1609 STATUS_ACCESS_VIOLATION);
1610 dumpLsaAttributes(ObjectAttributes);
1611 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
1612 return STATUS_SUCCESS;
1615 /******************************************************************************
1616 * LsaQueryInformationPolicy [ADVAPI32.@]
1619 LsaQueryInformationPolicy(
1620 IN LSA_HANDLE PolicyHandle,
1621 IN POLICY_INFORMATION_CLASS InformationClass,
1624 FIXME("(%p,0x%08x,%p):stub\n",
1625 PolicyHandle, InformationClass, Buffer);
1627 if(!Buffer) return FALSE;
1628 switch (InformationClass)
1630 case PolicyAuditEventsInformation: /* 2 */
1632 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO));
1633 p->AuditingMode = FALSE; /* no auditing */
1637 case PolicyPrimaryDomainInformation: /* 3 */
1638 case PolicyAccountDomainInformation: /* 5 */
1641 { POLICY_PRIMARY_DOMAIN_INFO ppdi;
1644 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
1646 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi));
1648 BOOL useDefault = TRUE;
1651 if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1652 "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
1653 KEY_READ, &key)) == ERROR_SUCCESS)
1656 static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
1658 ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
1659 if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
1661 xdi->ppdi.Name.Buffer = HeapAlloc(GetProcessHeap(),
1662 HEAP_ZERO_MEMORY, size);
1663 if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
1664 (LPBYTE)xdi->ppdi.Name.Buffer, &size)) == ERROR_SUCCESS)
1666 xdi->ppdi.Name.Length = (USHORT)size;
1671 HeapFree(GetProcessHeap(), 0, xdi->ppdi.Name.Buffer);
1672 xdi->ppdi.Name.Buffer = NULL;
1678 RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
1679 TRACE("setting domain to %s\n", debugstr_w(xdi->ppdi.Name.Buffer));
1681 xdi->ppdi.Sid = &(xdi->sid);
1682 xdi->sid.Revision = SID_REVISION;
1683 xdi->sid.SubAuthorityCount = 1;
1684 xdi->sid.IdentifierAuthority = localSidAuthority;
1685 xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
1689 case PolicyAuditLogInformation:
1690 case PolicyPdAccountInformation:
1691 case PolicyLsaServerRoleInformation:
1692 case PolicyReplicaSourceInformation:
1693 case PolicyDefaultQuotaInformation:
1694 case PolicyModificationInformation:
1695 case PolicyAuditFullSetInformation:
1696 case PolicyAuditFullQueryInformation:
1697 case PolicyDnsDomainInformation:
1699 FIXME("category not implemented\n");
1706 /******************************************************************************
1707 * LsaSetInformationPolicy [ADVAPI32.@]
1710 LsaSetInformationPolicy(
1711 LSA_HANDLE PolicyHandle,
1712 POLICY_INFORMATION_CLASS InformationClass,
1715 FIXME("(%p,0x%08x,%p):stub\n", PolicyHandle, InformationClass, Buffer);
1717 return STATUS_UNSUCCESSFUL;
1720 /******************************************************************************
1721 * LsaLookupSids [ADVAPI32.@]
1725 IN LSA_HANDLE PolicyHandle,
1728 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
1729 OUT PLSA_TRANSLATED_NAME *Names )
1731 FIXME("%p %lu %p %p %p\n",
1732 PolicyHandle, Count, Sids, ReferencedDomains, Names);
1736 /******************************************************************************
1737 * LsaFreeMemory [ADVAPI32.@]
1740 LsaFreeMemory(IN PVOID Buffer)
1742 TRACE("(%p)\n",Buffer);
1743 return HeapFree(GetProcessHeap(), 0, Buffer);
1745 /******************************************************************************
1746 * LsaClose [ADVAPI32.@]
1749 LsaClose(IN LSA_HANDLE ObjectHandle)
1751 FIXME("(%p):stub\n",ObjectHandle);
1755 /******************************************************************************
1756 * LsaStorePrivateData [ADVAPI32.@]
1758 NTSTATUS WINAPI LsaStorePrivateData( LSA_HANDLE PolicyHandle,
1759 PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING PrivateData)
1761 FIXME("%p %p %p\n", PolicyHandle, KeyName, PrivateData);
1762 return STATUS_OBJECT_NAME_NOT_FOUND;
1765 /******************************************************************************
1766 * LsaRetrievePrivateData [ADVAPI32.@]
1768 NTSTATUS WINAPI LsaRetrievePrivateData( LSA_HANDLE PolicyHandle,
1769 PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING* PrivateData)
1771 FIXME("%p %p %p\n", PolicyHandle, KeyName, PrivateData);
1772 return STATUS_OBJECT_NAME_NOT_FOUND;
1775 /******************************************************************************
1776 * LsaNtStatusToWinError [ADVAPI32.@]
1782 LsaNtStatusToWinError(NTSTATUS Status)
1784 return RtlNtStatusToDosError(Status);
1787 /******************************************************************************
1788 * NotifyBootConfigStatus [ADVAPI32.@]
1794 NotifyBootConfigStatus( DWORD x1 )
1796 FIXME("(0x%08lx):stub\n",x1);
1800 /******************************************************************************
1801 * RevertToSelf [ADVAPI32.@]
1803 * Ends the impersonation of a user.
1813 RevertToSelf( void )
1815 HANDLE Token = NULL;
1816 return set_ntstatus( NtSetInformationThread( GetCurrentThread(),
1817 ThreadImpersonationToken, &Token, sizeof(Token) ) );
1820 /******************************************************************************
1821 * ImpersonateSelf [ADVAPI32.@]
1823 * Makes an impersonation token that represents the process user and assigns
1824 * to the current thread.
1827 * ImpersonationLevel [I] Level at which to impersonate.
1834 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
1836 return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel ) );
1839 /******************************************************************************
1840 * ImpersonateLoggedOnUser [ADVAPI32.@]
1842 BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
1844 FIXME("(%p):stub returning FALSE\n", hToken);
1848 /******************************************************************************
1849 * AccessCheck [ADVAPI32.@]
1853 PSECURITY_DESCRIPTOR SecurityDescriptor,
1855 DWORD DesiredAccess,
1856 PGENERIC_MAPPING GenericMapping,
1857 PPRIVILEGE_SET PrivilegeSet,
1858 LPDWORD PrivilegeSetLength,
1859 LPDWORD GrantedAccess,
1860 LPBOOL AccessStatus)
1862 NTSTATUS access_status;
1863 BOOL ret = set_ntstatus( NtAccessCheck(SecurityDescriptor, ClientToken, DesiredAccess,
1864 GenericMapping, PrivilegeSet, PrivilegeSetLength,
1865 GrantedAccess, &access_status) );
1866 if (ret) *AccessStatus = set_ntstatus( access_status );
1871 /******************************************************************************
1872 * AccessCheckByType [ADVAPI32.@]
1874 BOOL WINAPI AccessCheckByType(
1875 PSECURITY_DESCRIPTOR pSecurityDescriptor,
1876 PSID PrincipalSelfSid,
1878 DWORD DesiredAccess,
1879 POBJECT_TYPE_LIST ObjectTypeList,
1880 DWORD ObjectTypeListLength,
1881 PGENERIC_MAPPING GenericMapping,
1882 PPRIVILEGE_SET PrivilegeSet,
1883 LPDWORD PrivilegeSetLength,
1884 LPDWORD GrantedAccess,
1885 LPBOOL AccessStatus)
1889 *AccessStatus = TRUE;
1891 return !*AccessStatus;
1894 /******************************************************************************
1895 * MapGenericMask [ADVAPI32.@]
1897 * Maps generic access rights into specific access rights according to the
1901 * AccessMask [I/O] Access rights.
1902 * GenericMapping [I] The mapping between generic and specific rights.
1907 VOID WINAPI MapGenericMask( PDWORD AccessMask, PGENERIC_MAPPING GenericMapping )
1909 RtlMapGenericMask( AccessMask, GenericMapping );
1912 /*************************************************************************
1913 * SetKernelObjectSecurity [ADVAPI32.@]
1915 BOOL WINAPI SetKernelObjectSecurity (
1917 IN SECURITY_INFORMATION SecurityInformation,
1918 IN PSECURITY_DESCRIPTOR SecurityDescriptor )
1920 return set_ntstatus (NtSetSecurityObject (Handle, SecurityInformation, SecurityDescriptor));
1924 /******************************************************************************
1925 * AddAuditAccessAce [ADVAPI32.@]
1927 BOOL WINAPI AddAuditAccessAce(
1929 IN DWORD dwAceRevision,
1930 IN DWORD dwAccessMask,
1932 IN BOOL bAuditSuccess,
1933 IN BOOL bAuditFailure)
1939 /******************************************************************************
1940 * LookupAccountNameA [ADVAPI32.@]
1948 LPSTR ReferencedDomainName,
1949 IN OUT LPDWORD cbReferencedDomainName,
1950 OUT PSID_NAME_USE name_use )
1952 /* Default implementation: Always return a default SID */
1953 SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY};
1956 static const char dm[] = "DOMAIN";
1958 FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system,account,sid,cbSid,ReferencedDomainName,cbReferencedDomainName,name_use);
1960 ret = AllocateAndInitializeSid(&identifierAuthority,
1962 SECURITY_BUILTIN_DOMAIN_RID,
1963 DOMAIN_ALIAS_RID_ADMINS,
1969 if(!RtlValidSid(pSid))
1975 if (sid != NULL && (*cbSid >= GetLengthSid(pSid)))
1976 CopySid(*cbSid, sid, pSid);
1977 if (*cbSid < GetLengthSid(pSid))
1979 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1982 *cbSid = GetLengthSid(pSid);
1984 if (ReferencedDomainName != NULL && (*cbReferencedDomainName > strlen(dm)))
1985 strcpy(ReferencedDomainName, dm);
1986 if (*cbReferencedDomainName <= strlen(dm))
1988 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1991 *cbReferencedDomainName = strlen(dm)+1;
1998 /******************************************************************************
1999 * LookupAccountNameW [ADVAPI32.@]
2001 BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSID Sid,
2002 LPDWORD cbSid, LPWSTR ReferencedDomainName,
2003 LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse )
2005 FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName), debugstr_w(lpAccountName),
2006 Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse);
2011 /******************************************************************************
2012 * PrivilegeCheck [ADVAPI32.@]
2014 BOOL WINAPI PrivilegeCheck( HANDLE ClientToken, PPRIVILEGE_SET RequiredPrivileges, LPBOOL pfResult)
2019 TRACE("%p %p %p\n", ClientToken, RequiredPrivileges, pfResult);
2021 ret = set_ntstatus (NtPrivilegeCheck (ClientToken, RequiredPrivileges, &Result));
2027 /******************************************************************************
2028 * AccessCheckAndAuditAlarmA [ADVAPI32.@]
2030 BOOL WINAPI AccessCheckAndAuditAlarmA(LPCSTR Subsystem, LPVOID HandleId, LPSTR ObjectTypeName,
2031 LPSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
2032 PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
2033 LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
2035 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem),
2036 HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName),
2037 SecurityDescriptor, DesiredAccess, GenericMapping,
2038 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
2042 /******************************************************************************
2043 * AccessCheckAndAuditAlarmW [ADVAPI32.@]
2045 BOOL WINAPI AccessCheckAndAuditAlarmW(LPCWSTR Subsystem, LPVOID HandleId, LPWSTR ObjectTypeName,
2046 LPWSTR ObjectName, PSECURITY_DESCRIPTOR SecurityDescriptor, DWORD DesiredAccess,
2047 PGENERIC_MAPPING GenericMapping, BOOL ObjectCreation, LPDWORD GrantedAccess,
2048 LPBOOL AccessStatus, LPBOOL pfGenerateOnClose)
2050 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem),
2051 HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName),
2052 SecurityDescriptor, DesiredAccess, GenericMapping,
2053 ObjectCreation, GrantedAccess, AccessStatus, pfGenerateOnClose);
2057 BOOL WINAPI ObjectCloseAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose)
2059 FIXME("stub (%s,%p,%x)\n", debugstr_a(SubsystemName), HandleId, GenerateOnClose);
2064 BOOL WINAPI ObjectCloseAuditAlarmW(LPCWSTR SubsystemName, LPVOID HandleId, BOOL GenerateOnClose)
2066 FIXME("stub (%s,%p,%x)\n", debugstr_w(SubsystemName), HandleId, GenerateOnClose);
2071 BOOL WINAPI ObjectOpenAuditAlarmA(LPCSTR SubsystemName, LPVOID HandleId, LPSTR ObjectTypeName,
2072 LPSTR ObjectName, PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess,
2073 DWORD GrantedAccess, PPRIVILEGE_SET Privileges, BOOL ObjectCreation, BOOL AccessGranted,
2074 LPBOOL GenerateOnClose)
2076 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_a(SubsystemName),
2077 HandleId, debugstr_a(ObjectTypeName), debugstr_a(ObjectName), pSecurityDescriptor,
2078 ClientToken, DesiredAccess, GrantedAccess, Privileges, ObjectCreation, AccessGranted,
2084 BOOL WINAPI ObjectOpenAuditAlarmW(LPCWSTR SubsystemName, LPVOID HandleId, LPWSTR ObjectTypeName,
2085 LPWSTR ObjectName, PSECURITY_DESCRIPTOR pSecurityDescriptor, HANDLE ClientToken, DWORD DesiredAccess,
2086 DWORD GrantedAccess, PPRIVILEGE_SET Privileges, BOOL ObjectCreation, BOOL AccessGranted,
2087 LPBOOL GenerateOnClose)
2089 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_w(SubsystemName),
2090 HandleId, debugstr_w(ObjectTypeName), debugstr_w(ObjectName), pSecurityDescriptor,
2091 ClientToken, DesiredAccess, GrantedAccess, Privileges, ObjectCreation, AccessGranted,
2097 BOOL WINAPI ObjectPrivilegeAuditAlarmA( LPCSTR SubsystemName, LPVOID HandleId, HANDLE ClientToken,
2098 DWORD DesiredAccess, PPRIVILEGE_SET Privileges, BOOL AccessGranted)
2100 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_a(SubsystemName), HandleId, ClientToken,
2101 DesiredAccess, Privileges, AccessGranted);
2106 BOOL WINAPI ObjectPrivilegeAuditAlarmW( LPCWSTR SubsystemName, LPVOID HandleId, HANDLE ClientToken,
2107 DWORD DesiredAccess, PPRIVILEGE_SET Privileges, BOOL AccessGranted)
2109 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_w(SubsystemName), HandleId, ClientToken,
2110 DesiredAccess, Privileges, AccessGranted);
2115 BOOL WINAPI PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName, LPCSTR ServiceName, HANDLE ClientToken,
2116 PPRIVILEGE_SET Privileges, BOOL AccessGranted)
2118 FIXME("stub (%s,%s,%p,%p,%x)\n", debugstr_a(SubsystemName), debugstr_a(ServiceName),
2119 ClientToken, Privileges, AccessGranted);
2124 BOOL WINAPI PrivilegedServiceAuditAlarmW( LPCWSTR SubsystemName, LPCWSTR ServiceName, HANDLE ClientToken,
2125 PPRIVILEGE_SET Privileges, BOOL AccessGranted)
2127 FIXME("stub %s,%s,%p,%p,%x)\n", debugstr_w(SubsystemName), debugstr_w(ServiceName),
2128 ClientToken, Privileges, AccessGranted);
2133 /******************************************************************************
2134 * GetSecurityInfo [ADVAPI32.@]
2136 DWORD WINAPI GetSecurityInfo(
2137 HANDLE hObject, SE_OBJECT_TYPE ObjectType,
2138 SECURITY_INFORMATION SecurityInfo, PSID *ppsidOwner,
2139 PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl,
2140 PSECURITY_DESCRIPTOR *ppSecurityDescriptor
2144 return ERROR_BAD_PROVIDER;
2147 /******************************************************************************
2148 * GetSecurityInfoExW [ADVAPI32.@]
2150 DWORD WINAPI GetSecurityInfoExW(
2151 HANDLE hObject, SE_OBJECT_TYPE ObjectType,
2152 SECURITY_INFORMATION SecurityInfo, LPCWSTR lpProvider,
2153 LPCWSTR lpProperty, PACTRL_ACCESSW *ppAccessList,
2154 PACTRL_AUDITW *ppAuditList, LPWSTR *lppOwner, LPWSTR *lppGroup
2158 return ERROR_BAD_PROVIDER;
2161 /******************************************************************************
2162 * BuildExplicitAccessWithNameA [ADVAPI32.@]
2164 VOID WINAPI BuildExplicitAccessWithNameA( PEXPLICIT_ACCESSA pExplicitAccess,
2165 LPSTR pTrusteeName, DWORD AccessPermissions,
2166 ACCESS_MODE AccessMode, DWORD Inheritance )
2168 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess, debugstr_a(pTrusteeName),
2169 AccessPermissions, AccessMode, Inheritance);
2171 pExplicitAccess->grfAccessPermissions = AccessPermissions;
2172 pExplicitAccess->grfAccessMode = AccessMode;
2173 pExplicitAccess->grfInheritance = Inheritance;
2175 pExplicitAccess->Trustee.pMultipleTrustee = NULL;
2176 pExplicitAccess->Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2177 pExplicitAccess->Trustee.TrusteeForm = TRUSTEE_IS_NAME;
2178 pExplicitAccess->Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
2179 pExplicitAccess->Trustee.ptstrName = pTrusteeName;
2182 /******************************************************************************
2183 * BuildExplicitAccessWithNameW [ADVAPI32.@]
2185 VOID WINAPI BuildExplicitAccessWithNameW( PEXPLICIT_ACCESSW pExplicitAccess,
2186 LPWSTR pTrusteeName, DWORD AccessPermissions,
2187 ACCESS_MODE AccessMode, DWORD Inheritance )
2189 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess, debugstr_w(pTrusteeName),
2190 AccessPermissions, AccessMode, Inheritance);
2192 pExplicitAccess->grfAccessPermissions = AccessPermissions;
2193 pExplicitAccess->grfAccessMode = AccessMode;
2194 pExplicitAccess->grfInheritance = Inheritance;
2196 pExplicitAccess->Trustee.pMultipleTrustee = NULL;
2197 pExplicitAccess->Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2198 pExplicitAccess->Trustee.TrusteeForm = TRUSTEE_IS_NAME;
2199 pExplicitAccess->Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
2200 pExplicitAccess->Trustee.ptstrName = pTrusteeName;
2203 /******************************************************************************
2204 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
2206 VOID WINAPI BuildTrusteeWithObjectsAndNameA( PTRUSTEEA pTrustee, POBJECTS_AND_NAME_A pObjName,
2207 SE_OBJECT_TYPE ObjectType, LPSTR ObjectTypeName,
2208 LPSTR InheritedObjectTypeName, LPSTR Name )
2210 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
2211 ObjectType, ObjectTypeName, InheritedObjectTypeName, debugstr_a(Name));
2213 pTrustee->pMultipleTrustee = NULL;
2214 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2215 pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_NAME;
2216 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2217 pTrustee->ptstrName = Name;
2220 /******************************************************************************
2221 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
2223 VOID WINAPI BuildTrusteeWithObjectsAndNameW( PTRUSTEEW pTrustee, POBJECTS_AND_NAME_W pObjName,
2224 SE_OBJECT_TYPE ObjectType, LPWSTR ObjectTypeName,
2225 LPWSTR InheritedObjectTypeName, LPWSTR Name )
2227 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee, pObjName,
2228 ObjectType, ObjectTypeName, InheritedObjectTypeName, debugstr_w(Name));
2230 pTrustee->pMultipleTrustee = NULL;
2231 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2232 pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_NAME;
2233 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2234 pTrustee->ptstrName = Name;
2237 VOID WINAPI BuildTrusteeWithObjectsAndSidA( PTRUSTEEA pTrustee, POBJECTS_AND_SID pObjSid,
2238 GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid )
2240 TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
2242 pTrustee->pMultipleTrustee = NULL;
2243 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2244 pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_SID;
2245 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2246 pTrustee->ptstrName = (LPSTR) pSid;
2249 VOID WINAPI BuildTrusteeWithObjectsAndSidW( PTRUSTEEW pTrustee, POBJECTS_AND_SID pObjSid,
2250 GUID* pObjectGuid, GUID* pInheritedObjectGuid, PSID pSid )
2252 TRACE("%p %p %p %p %p\n", pTrustee, pObjSid, pObjectGuid, pInheritedObjectGuid, pSid);
2254 pTrustee->pMultipleTrustee = NULL;
2255 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2256 pTrustee->TrusteeForm = TRUSTEE_IS_OBJECTS_AND_SID;
2257 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2258 pTrustee->ptstrName = (LPWSTR) pSid;
2261 /******************************************************************************
2262 * BuildTrusteeWithSidA [ADVAPI32.@]
2264 VOID WINAPI BuildTrusteeWithSidA(PTRUSTEEA pTrustee, PSID pSid)
2266 TRACE("%p %p\n", pTrustee, pSid);
2268 pTrustee->pMultipleTrustee = NULL;
2269 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2270 pTrustee->TrusteeForm = TRUSTEE_IS_SID;
2271 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2272 pTrustee->ptstrName = (LPSTR) pSid;
2275 /******************************************************************************
2276 * BuildTrusteeWithSidW [ADVAPI32.@]
2278 VOID WINAPI BuildTrusteeWithSidW(PTRUSTEEW pTrustee, PSID pSid)
2280 TRACE("%p %p\n", pTrustee, pSid);
2282 pTrustee->pMultipleTrustee = NULL;
2283 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2284 pTrustee->TrusteeForm = TRUSTEE_IS_SID;
2285 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2286 pTrustee->ptstrName = (LPWSTR) pSid;
2289 /******************************************************************************
2290 * BuildTrusteeWithNameA [ADVAPI32.@]
2292 VOID WINAPI BuildTrusteeWithNameA(PTRUSTEEA pTrustee, LPSTR name)
2294 TRACE("%p %s\n", pTrustee, debugstr_a(name) );
2296 pTrustee->pMultipleTrustee = NULL;
2297 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2298 pTrustee->TrusteeForm = TRUSTEE_IS_NAME;
2299 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2300 pTrustee->ptstrName = name;
2303 /******************************************************************************
2304 * BuildTrusteeWithNameW [ADVAPI32.@]
2306 VOID WINAPI BuildTrusteeWithNameW(PTRUSTEEW pTrustee, LPWSTR name)
2308 TRACE("%p %s\n", pTrustee, debugstr_w(name) );
2310 pTrustee->pMultipleTrustee = NULL;
2311 pTrustee->MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
2312 pTrustee->TrusteeForm = TRUSTEE_IS_NAME;
2313 pTrustee->TrusteeType = TRUSTEE_IS_UNKNOWN;
2314 pTrustee->ptstrName = name;
2317 /******************************************************************************
2318 * GetTrusteeFormA [ADVAPI32.@]
2320 TRUSTEE_FORM WINAPI GetTrusteeFormA(PTRUSTEEA pTrustee)
2322 TRACE("(%p)\n", pTrustee);
2325 return TRUSTEE_BAD_FORM;
2327 return pTrustee->TrusteeForm;
2330 /******************************************************************************
2331 * GetTrusteeFormW [ADVAPI32.@]
2333 TRUSTEE_FORM WINAPI GetTrusteeFormW(PTRUSTEEW pTrustee)
2335 TRACE("(%p)\n", pTrustee);
2338 return TRUSTEE_BAD_FORM;
2340 return pTrustee->TrusteeForm;
2343 /******************************************************************************
2344 * GetTrusteeNameA [ADVAPI32.@]
2346 LPSTR WINAPI GetTrusteeNameA(PTRUSTEEA pTrustee)
2348 TRACE("(%p)\n", pTrustee);
2353 return pTrustee->ptstrName;
2356 /******************************************************************************
2357 * GetTrusteeNameW [ADVAPI32.@]
2359 LPWSTR WINAPI GetTrusteeNameW(PTRUSTEEW pTrustee)
2361 TRACE("(%p)\n", pTrustee);
2366 return pTrustee->ptstrName;
2369 /******************************************************************************
2370 * GetTrusteeTypeA [ADVAPI32.@]
2372 TRUSTEE_TYPE WINAPI GetTrusteeTypeA(PTRUSTEEA pTrustee)
2374 TRACE("(%p)\n", pTrustee);
2377 return TRUSTEE_IS_UNKNOWN;
2379 return pTrustee->TrusteeType;
2382 /******************************************************************************
2383 * GetTrusteeTypeW [ADVAPI32.@]
2385 TRUSTEE_TYPE WINAPI GetTrusteeTypeW(PTRUSTEEW pTrustee)
2387 TRACE("(%p)\n", pTrustee);
2390 return TRUSTEE_IS_UNKNOWN;
2392 return pTrustee->TrusteeType;
2395 BOOL WINAPI SetAclInformation( PACL pAcl, LPVOID pAclInformation,
2396 DWORD nAclInformationLength,
2397 ACL_INFORMATION_CLASS dwAclInformationClass )
2399 FIXME("%p %p 0x%08lx 0x%08x - stub\n", pAcl, pAclInformation,
2400 nAclInformationLength, dwAclInformationClass);
2405 /******************************************************************************
2406 * SetEntriesInAclA [ADVAPI32.@]
2408 DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
2409 PACL OldAcl, PACL* NewAcl )
2411 FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
2412 return ERROR_CALL_NOT_IMPLEMENTED;
2415 /******************************************************************************
2416 * SetEntriesInAclW [ADVAPI32.@]
2418 DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
2419 PACL OldAcl, PACL* NewAcl )
2421 FIXME("%ld %p %p %p\n",count,pEntries,OldAcl,NewAcl);
2422 return ERROR_CALL_NOT_IMPLEMENTED;
2425 /******************************************************************************
2426 * SetNamedSecurityInfoA [ADVAPI32.@]
2428 DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
2429 SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
2430 PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
2436 TRACE("%s %d %ld %p %p %p %p\n", debugstr_a(pObjectName), ObjectType,
2437 SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
2441 len = MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, NULL, 0 );
2442 wstr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
2443 MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, wstr, len );
2446 r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner,
2447 psidGroup, pDacl, pSacl );
2449 HeapFree( GetProcessHeap(), 0, wstr );
2454 BOOL WINAPI SetPrivateObjectSecurity( SECURITY_INFORMATION SecurityInformation,
2455 PSECURITY_DESCRIPTOR ModificationDescriptor,
2456 PSECURITY_DESCRIPTOR* ObjectsSecurityDescriptor,
2457 PGENERIC_MAPPING GenericMapping,
2460 FIXME("0x%08lx %p %p %p %p - stub\n", SecurityInformation, ModificationDescriptor,
2461 ObjectsSecurityDescriptor, GenericMapping, Token);
2466 BOOL WINAPI SetSecurityDescriptorControl( PSECURITY_DESCRIPTOR pSecurityDescriptor,
2467 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
2468 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet )
2470 FIXME("%p 0x%08x 0x%08x - stub\n", pSecurityDescriptor, ControlBitsOfInterest,
2476 BOOL WINAPI AreAllAccessesGranted( DWORD GrantedAccess, DWORD DesiredAccess )
2478 return RtlAreAllAccessesGranted( GrantedAccess, DesiredAccess );
2481 /******************************************************************************
2482 * AreAnyAccessesGranted [ADVAPI32.@]
2484 * Determines whether or not any of a set of specified access permissions have
2485 * been granted or not.
2488 * GrantedAccess [I] The permissions that have been granted.
2489 * DesiredAccess [I] The permissions that you want to have.
2492 * Nonzero if any of the permissions have been granted, zero if none of the
2493 * permissions have been granted.
2496 BOOL WINAPI AreAnyAccessesGranted( DWORD GrantedAccess, DWORD DesiredAccess )
2498 return RtlAreAnyAccessesGranted( GrantedAccess, DesiredAccess );
2501 /******************************************************************************
2502 * SetNamedSecurityInfoW [ADVAPI32.@]
2504 DWORD WINAPI SetNamedSecurityInfoW(LPWSTR pObjectName,
2505 SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
2506 PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl)
2508 FIXME("%s %d %ld %p %p %p %p\n", debugstr_w(pObjectName), ObjectType,
2509 SecurityInfo, psidOwner, psidGroup, pDacl, pSacl);
2510 return ERROR_SUCCESS;
2513 /******************************************************************************
2514 * GetExplicitEntriesFromAclA [ADVAPI32.@]
2516 DWORD WINAPI GetExplicitEntriesFromAclA( PACL pacl, PULONG pcCountOfExplicitEntries,
2517 PEXPLICIT_ACCESSA* pListOfExplicitEntries)
2519 FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
2520 return ERROR_CALL_NOT_IMPLEMENTED;
2523 /******************************************************************************
2524 * GetExplicitEntriesFromAclW [ADVAPI32.@]
2526 DWORD WINAPI GetExplicitEntriesFromAclW( PACL pacl, PULONG pcCountOfExplicitEntries,
2527 PEXPLICIT_ACCESSW* pListOfExplicitEntries)
2529 FIXME("%p %p %p\n",pacl, pcCountOfExplicitEntries, pListOfExplicitEntries);
2530 return ERROR_CALL_NOT_IMPLEMENTED;
2534 /******************************************************************************
2535 * ParseAclStringFlags
2537 static DWORD ParseAclStringFlags(LPCWSTR* StringAcl)
2540 LPCWSTR szAcl = *StringAcl;
2542 while (*szAcl != '(')
2546 flags |= SE_DACL_PROTECTED;
2548 else if (*szAcl == 'A')
2552 flags |= SE_DACL_AUTO_INHERIT_REQ;
2553 else if (*szAcl == 'I')
2554 flags |= SE_DACL_AUTO_INHERITED;
2563 /******************************************************************************
2564 * ParseAceStringType
2568 { SDDL_ACCESS_ALLOWED, ACCESS_ALLOWED_ACE_TYPE },
2569 { SDDL_ALARM, SYSTEM_ALARM_ACE_TYPE },
2570 { SDDL_AUDIT, SYSTEM_AUDIT_ACE_TYPE },
2571 { SDDL_ACCESS_DENIED, ACCESS_DENIED_ACE_TYPE },
2573 { SDDL_OBJECT_ACCESS_ALLOWED, ACCESS_ALLOWED_OBJECT_ACE_TYPE },
2574 { SDDL_OBJECT_ACCESS_DENIED, ACCESS_DENIED_OBJECT_ACE_TYPE },
2575 { SDDL_OBJECT_ALARM, SYSTEM_ALARM_OBJECT_ACE_TYPE },
2576 { SDDL_OBJECT_AUDIT, SYSTEM_AUDIT_OBJECT_ACE_TYPE },
2581 static BYTE ParseAceStringType(LPCWSTR* StringAcl)
2584 LPCWSTR szAcl = *StringAcl;
2585 LPACEFLAG lpaf = AceType;
2587 while (lpaf->wstr &&
2588 (len = strlenW(lpaf->wstr)) &&
2589 strncmpW(lpaf->wstr, szAcl, len))
2600 /******************************************************************************
2601 * ParseAceStringFlags
2603 ACEFLAG AceFlags[] =
2605 { SDDL_CONTAINER_INHERIT, CONTAINER_INHERIT_ACE },
2606 { SDDL_AUDIT_FAILURE, FAILED_ACCESS_ACE_FLAG },
2607 { SDDL_INHERITED, INHERITED_ACE },
2608 { SDDL_INHERIT_ONLY, INHERIT_ONLY_ACE },
2609 { SDDL_NO_PROPAGATE, NO_PROPAGATE_INHERIT_ACE },
2610 { SDDL_OBJECT_INHERIT, OBJECT_INHERIT_ACE },
2611 { SDDL_AUDIT_SUCCESS, SUCCESSFUL_ACCESS_ACE_FLAG },
2615 static BYTE ParseAceStringFlags(LPCWSTR* StringAcl)
2619 LPCWSTR szAcl = *StringAcl;
2621 while (*szAcl != ';')
2623 LPACEFLAG lpaf = AceFlags;
2625 while (lpaf->wstr &&
2626 (len = strlenW(lpaf->wstr)) &&
2627 strncmpW(lpaf->wstr, szAcl, len))
2633 flags |= lpaf->value;
2642 /******************************************************************************
2643 * ParseAceStringRights
2645 ACEFLAG AceRights[] =
2647 { SDDL_GENERIC_ALL, GENERIC_ALL },
2648 { SDDL_GENERIC_READ, GENERIC_READ },
2649 { SDDL_GENERIC_WRITE, GENERIC_WRITE },
2650 { SDDL_GENERIC_EXECUTE, GENERIC_EXECUTE },
2651 { SDDL_READ_CONTROL, READ_CONTROL },
2652 { SDDL_STANDARD_DELETE, DELETE },
2653 { SDDL_WRITE_DAC, WRITE_DAC },
2654 { SDDL_WRITE_OWNER, WRITE_OWNER },
2658 static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
2662 LPCWSTR szAcl = *StringAcl;
2664 if ((*szAcl == '0') && (*(szAcl + 1) == 'x'))
2668 while (*p && *p != ';')
2673 rights = strtoulW(szAcl, NULL, 16);
2677 WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl, p - szAcl));
2681 while (*szAcl != ';')
2683 LPACEFLAG lpaf = AceRights;
2685 while (lpaf->wstr &&
2686 (len = strlenW(lpaf->wstr)) &&
2687 strncmpW(lpaf->wstr, szAcl, len))
2695 rights |= lpaf->value;
2705 /******************************************************************************
2706 * ParseStringAclToAcl
2708 * dacl_flags(string_ace1)(string_ace2)... (string_acen)
2710 static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
2711 PACL pAcl, LPDWORD cBytes)
2715 DWORD length = sizeof(ACL);
2716 PACCESS_ALLOWED_ACE pAce = NULL; /* pointer to current ACE */
2718 TRACE("%s\n", debugstr_w(StringAcl));
2723 if (pAcl) /* pAce is only useful if we're setting values */
2724 pAce = (PACCESS_ALLOWED_ACE) ((LPBYTE)pAcl + sizeof(PACL));
2726 /* Parse ACL flags */
2727 *lpdwFlags = ParseAclStringFlags(&StringAcl);
2730 while (*StringAcl == '(')
2734 /* Parse ACE type */
2735 val = ParseAceStringType(&StringAcl);
2737 pAce->Header.AceType = (BYTE) val;
2738 if (*StringAcl != ';')
2742 /* Parse ACE flags */
2743 val = ParseAceStringFlags(&StringAcl);
2745 pAce->Header.AceFlags = (BYTE) val;
2746 if (*StringAcl != ';')
2750 /* Parse ACE rights */
2751 val = ParseAceStringRights(&StringAcl);
2754 if (*StringAcl != ';')
2758 /* Parse ACE object guid */
2759 if (*StringAcl != ';')
2761 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2766 /* Parse ACE inherit object guid */
2767 if (*StringAcl != ';')
2769 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2774 /* Parse ACE account sid */
2775 if (ParseStringSidToSid(StringAcl, pAce ? (PSID)&pAce->SidStart : NULL, &sidlen))
2777 while (*StringAcl && *StringAcl != ')')
2781 if (*StringAcl != ')')
2785 length += sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + sidlen;
2792 WARN("Invalid ACE string format\n");
2797 /******************************************************************************
2798 * ParseStringSecurityDescriptorToSecurityDescriptor
2800 static BOOL ParseStringSecurityDescriptorToSecurityDescriptor(
2801 LPCWSTR StringSecurityDescriptor,
2802 SECURITY_DESCRIPTOR* SecurityDescriptor,
2807 WCHAR tok[MAX_PATH];
2809 LPBYTE lpNext = NULL;
2814 if (SecurityDescriptor)
2815 lpNext = ((LPBYTE) SecurityDescriptor) + sizeof(SECURITY_DESCRIPTOR);
2817 while (*StringSecurityDescriptor)
2819 toktype = *StringSecurityDescriptor;
2821 /* Expect char identifier followed by ':' */
2822 StringSecurityDescriptor++;
2823 if (*StringSecurityDescriptor != ':')
2825 SetLastError(ERROR_INVALID_PARAMETER);
2828 StringSecurityDescriptor++;
2831 lptoken = StringSecurityDescriptor;
2832 while (*lptoken && *lptoken != ':')
2838 len = lptoken - StringSecurityDescriptor;
2839 memcpy( tok, StringSecurityDescriptor, len * sizeof(WCHAR) );
2848 if (!ParseStringSidToSid(tok, (PSID)lpNext, &bytes))
2851 if (SecurityDescriptor)
2853 SecurityDescriptor->Owner = (PSID) ((DWORD) lpNext -
2854 (DWORD) SecurityDescriptor);
2855 lpNext += bytes; /* Advance to next token */
2867 if (!ParseStringSidToSid(tok, (PSID)lpNext, &bytes))
2870 if (SecurityDescriptor)
2872 SecurityDescriptor->Group = (PSID) ((DWORD) lpNext -
2873 (DWORD) SecurityDescriptor);
2874 lpNext += bytes; /* Advance to next token */
2887 if (!ParseStringAclToAcl(tok, &flags, (PACL)lpNext, &bytes))
2890 if (SecurityDescriptor)
2892 SecurityDescriptor->Control |= SE_DACL_PRESENT | flags;
2893 SecurityDescriptor->Dacl = (PACL) ((DWORD) lpNext -
2894 (DWORD) SecurityDescriptor);
2895 lpNext += bytes; /* Advance to next token */
2908 if (!ParseStringAclToAcl(tok, &flags, (PACL)lpNext, &bytes))
2911 if (SecurityDescriptor)
2913 SecurityDescriptor->Control |= SE_SACL_PRESENT | flags;
2914 SecurityDescriptor->Sacl = (PACL) ((DWORD) lpNext -
2915 (DWORD) SecurityDescriptor);
2916 lpNext += bytes; /* Advance to next token */
2925 FIXME("Unknown token\n");
2926 SetLastError(ERROR_INVALID_PARAMETER);
2930 StringSecurityDescriptor = lptoken;
2939 /******************************************************************************
2940 * ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@]
2942 BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
2943 LPCSTR StringSecurityDescriptor,
2944 DWORD StringSDRevision,
2945 PSECURITY_DESCRIPTOR* SecurityDescriptor,
2946 PULONG SecurityDescriptorSize)
2950 LPWSTR StringSecurityDescriptorW;
2952 len = MultiByteToWideChar(CP_ACP, 0, StringSecurityDescriptor, -1, NULL, 0);
2953 StringSecurityDescriptorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2955 if (StringSecurityDescriptorW)
2957 MultiByteToWideChar(CP_ACP, 0, StringSecurityDescriptor, -1, StringSecurityDescriptorW, len);
2959 ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW,
2960 StringSDRevision, SecurityDescriptor,
2961 SecurityDescriptorSize);
2962 HeapFree(GetProcessHeap(), 0, StringSecurityDescriptorW);
2968 /******************************************************************************
2969 * ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@]
2971 BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW(
2972 LPCWSTR StringSecurityDescriptor,
2973 DWORD StringSDRevision,
2974 PSECURITY_DESCRIPTOR* SecurityDescriptor,
2975 PULONG SecurityDescriptorSize)
2978 SECURITY_DESCRIPTOR* psd;
2981 TRACE("%s\n", debugstr_w(StringSecurityDescriptor));
2983 if (GetVersion() & 0x80000000)
2985 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
2988 else if (StringSDRevision != SID_REVISION)
2990 SetLastError(ERROR_UNKNOWN_REVISION);
2994 /* Compute security descriptor length */
2995 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor,
2999 psd = *SecurityDescriptor = (SECURITY_DESCRIPTOR*) LocalAlloc(
3000 GMEM_ZEROINIT, cBytes);
3002 psd->Revision = SID_REVISION;
3003 psd->Control |= SE_SELF_RELATIVE;
3005 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor,
3012 if (SecurityDescriptorSize)
3013 *SecurityDescriptorSize = cBytes;
3018 TRACE(" ret=%d\n", bret);
3022 /******************************************************************************
3023 * ConvertStringSidToSidW [ADVAPI32.@]
3025 BOOL WINAPI ConvertStringSidToSidW(LPCWSTR StringSid, PSID* Sid)
3030 TRACE("%s, %p\n", debugstr_w(StringSid), Sid);
3031 if (GetVersion() & 0x80000000)
3032 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3033 else if (!StringSid || !Sid)
3034 SetLastError(ERROR_INVALID_PARAMETER);
3035 else if (ParseStringSidToSid(StringSid, NULL, &cBytes))
3037 PSID pSid = *Sid = (PSID) LocalAlloc(0, cBytes);
3039 bret = ParseStringSidToSid(StringSid, pSid, &cBytes);
3043 TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
3047 /******************************************************************************
3048 * ConvertStringSidToSidA [ADVAPI32.@]
3050 BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
3054 TRACE("%s, %p\n", debugstr_a(StringSid), Sid);
3055 if (GetVersion() & 0x80000000)
3056 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
3057 else if (!StringSid || !Sid)
3058 SetLastError(ERROR_INVALID_PARAMETER);
3061 UINT len = MultiByteToWideChar(CP_ACP, 0, StringSid, -1, NULL, 0);
3062 LPWSTR wStringSid = HeapAlloc(GetProcessHeap(), 0,
3063 len * sizeof(WCHAR));
3065 MultiByteToWideChar(CP_ACP, 0, StringSid, -1, wStringSid, len);
3066 bret = ConvertStringSidToSidW(wStringSid, Sid);
3067 HeapFree(GetProcessHeap(), 0, wStringSid);
3069 TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
3073 /******************************************************************************
3074 * ConvertSidToStringSidW [ADVAPI32.@]
3076 * format of SID string is:
3077 * S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>...
3079 * <rev> is the revision of the SID encoded as decimal
3080 * <auth> is the identifier authority encoded as hex
3081 * <subauthN> is the subauthority id encoded as decimal
3083 BOOL WINAPI ConvertSidToStringSidW( PSID pSid, LPWSTR *pstr )
3087 WCHAR fmt[] = { 'S','-','%','u','-','%','d',0 };
3088 WCHAR subauthfmt[] = { '-','%','u',0 };
3091 TRACE("%p %p\n", pSid, pstr );
3093 if( !IsValidSid( pSid ) )
3096 if (pisid->Revision != SDDL_REVISION)
3098 if (pisid->IdentifierAuthority.Value[0] ||
3099 pisid->IdentifierAuthority.Value[1])
3101 FIXME("not matching MS' bugs\n");
3105 sz = 14 + pisid->SubAuthorityCount * 11;
3106 str = LocalAlloc( 0, sz*sizeof(WCHAR) );
3107 sprintfW( str, fmt, pisid->Revision, MAKELONG(
3108 MAKEWORD( pisid->IdentifierAuthority.Value[5],
3109 pisid->IdentifierAuthority.Value[4] ),
3110 MAKEWORD( pisid->IdentifierAuthority.Value[3],
3111 pisid->IdentifierAuthority.Value[2] ) ) );
3112 for( i=0; i<pisid->SubAuthorityCount; i++ )
3113 sprintfW( str + strlenW(str), subauthfmt, pisid->SubAuthority[i] );
3119 /******************************************************************************
3120 * ConvertSidToStringSidA [ADVAPI32.@]
3122 BOOL WINAPI ConvertSidToStringSidA(PSID pSid, LPSTR *pstr)
3128 TRACE("%p %p\n", pSid, pstr );
3130 if( !ConvertSidToStringSidW( pSid, &wstr ) )
3133 len = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL );
3134 str = LocalAlloc( 0, len );
3135 WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, len, NULL, NULL );
3143 BOOL WINAPI CreatePrivateObjectSecurity(
3144 PSECURITY_DESCRIPTOR ParentDescriptor,
3145 PSECURITY_DESCRIPTOR CreatorDescriptor,
3146 PSECURITY_DESCRIPTOR* NewDescriptor,
3147 BOOL IsDirectoryObject,
3149 PGENERIC_MAPPING GenericMapping )
3151 FIXME("%p %p %p %d %p %p - stub\n", ParentDescriptor, CreatorDescriptor,
3152 NewDescriptor, IsDirectoryObject, Token, GenericMapping);
3157 BOOL WINAPI DestroyPrivateObjectSecurity( PSECURITY_DESCRIPTOR* ObjectDescriptor )
3159 FIXME("%p - stub\n", ObjectDescriptor);
3164 BOOL WINAPI CreateProcessAsUserA(
3166 LPCSTR lpApplicationName,
3167 LPSTR lpCommandLine,
3168 LPSECURITY_ATTRIBUTES lpProcessAttributes,
3169 LPSECURITY_ATTRIBUTES lpThreadAttributes,
3170 BOOL bInheritHandles,
3171 DWORD dwCreationFlags,
3172 LPVOID lpEnvironment,
3173 LPCSTR lpCurrentDirectory,
3174 LPSTARTUPINFOA lpStartupInfo,
3175 LPPROCESS_INFORMATION lpProcessInformation )
3177 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - stub\n", hToken, debugstr_a(lpApplicationName),
3178 debugstr_a(lpCommandLine), lpProcessAttributes, lpThreadAttributes, bInheritHandles,
3179 dwCreationFlags, lpEnvironment, debugstr_a(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
3184 BOOL WINAPI CreateProcessAsUserW(
3186 LPCWSTR lpApplicationName,
3187 LPWSTR lpCommandLine,
3188 LPSECURITY_ATTRIBUTES lpProcessAttributes,
3189 LPSECURITY_ATTRIBUTES lpThreadAttributes,
3190 BOOL bInheritHandles,
3191 DWORD dwCreationFlags,
3192 LPVOID lpEnvironment,
3193 LPCWSTR lpCurrentDirectory,
3194 LPSTARTUPINFOW lpStartupInfo,
3195 LPPROCESS_INFORMATION lpProcessInformation )
3197 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - semi- stub\n", hToken,
3198 debugstr_w(lpApplicationName), debugstr_w(lpCommandLine), lpProcessAttributes,
3199 lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment,
3200 debugstr_w(lpCurrentDirectory), lpStartupInfo, lpProcessInformation);
3202 /* We should create the process with a suspended main thread */
3203 if (!CreateProcessW (lpApplicationName,
3205 lpProcessAttributes,
3208 dwCreationFlags, /* CREATE_SUSPENDED */
3212 lpProcessInformation))
3220 /******************************************************************************
3221 * ComputeStringSidSize
3223 static DWORD ComputeStringSidSize(LPCWSTR StringSid)
3226 DWORD size = sizeof(SID);
3230 if (*StringSid == '-')
3236 size += (ctok - 3) * sizeof(DWORD);
3241 BOOL WINAPI DuplicateTokenEx(
3242 HANDLE ExistingTokenHandle, DWORD dwDesiredAccess,
3243 LPSECURITY_ATTRIBUTES lpTokenAttributes,
3244 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
3245 TOKEN_TYPE TokenType,
3246 PHANDLE DuplicateTokenHandle )
3248 OBJECT_ATTRIBUTES ObjectAttributes;
3250 TRACE("%p 0x%08lx 0x%08x 0x%08x %p\n", ExistingTokenHandle, dwDesiredAccess,
3251 ImpersonationLevel, TokenType, DuplicateTokenHandle);
3253 InitializeObjectAttributes(
3256 (lpTokenAttributes && lpTokenAttributes->bInheritHandle) ? OBJ_INHERIT : 0,
3258 lpTokenAttributes ? lpTokenAttributes->lpSecurityDescriptor : NULL );
3260 return set_ntstatus( NtDuplicateToken( ExistingTokenHandle,
3265 DuplicateTokenHandle ) );
3268 BOOL WINAPI DuplicateToken(
3269 HANDLE ExistingTokenHandle,
3270 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
3271 PHANDLE DuplicateTokenHandle )
3273 return DuplicateTokenEx( ExistingTokenHandle, TOKEN_IMPERSONATE | TOKEN_QUERY,
3274 NULL, ImpersonationLevel, TokenImpersonation,
3275 DuplicateTokenHandle );
3278 BOOL WINAPI EnumDependentServicesA(
3280 DWORD dwServiceState,
3281 LPENUM_SERVICE_STATUSA lpServices,
3283 LPDWORD pcbBytesNeeded,
3284 LPDWORD lpServicesReturned )
3286 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService, dwServiceState,
3287 lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned);
3292 BOOL WINAPI EnumDependentServicesW(
3294 DWORD dwServiceState,
3295 LPENUM_SERVICE_STATUSW lpServices,
3297 LPDWORD pcbBytesNeeded,
3298 LPDWORD lpServicesReturned )
3300 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService, dwServiceState,
3301 lpServices, cbBufSize, pcbBytesNeeded, lpServicesReturned);
3306 /******************************************************************************
3307 * ParseStringSidToSid
3309 static BOOL ParseStringSidToSid(LPCWSTR StringSid, PSID pSid, LPDWORD cBytes)
3314 TRACE("%s, %p, %p\n", debugstr_w(StringSid), pSid, cBytes);
3317 SetLastError(ERROR_INVALID_PARAMETER);
3318 TRACE("StringSid is NULL, returning FALSE\n");
3322 *cBytes = ComputeStringSidSize(StringSid);
3323 if (!pisid) /* Simply compute the size */
3325 TRACE("only size requested, returning TRUE\n");
3329 if (*StringSid != 'S' || *StringSid != '-') /* S-R-I-S-S */
3331 DWORD i = 0, identAuth;
3332 DWORD csubauth = ((*cBytes - sizeof(SID)) / sizeof(DWORD)) + 1;
3334 StringSid += 2; /* Advance to Revision */
3335 pisid->Revision = atoiW(StringSid);
3337 if (pisid->Revision != SDDL_REVISION)
3339 TRACE("Revision %d is unknown\n", pisid->Revision);
3340 goto lend; /* ERROR_INVALID_SID */
3344 TRACE("SubAuthorityCount is 0\n");
3345 goto lend; /* ERROR_INVALID_SID */
3348 pisid->SubAuthorityCount = csubauth;
3350 /* Advance to identifier authority */
3351 while (*StringSid && *StringSid != '-')
3353 if (*StringSid == '-')
3356 /* MS' implementation can't handle values greater than 2^32 - 1, so
3357 * we don't either; assume most significant bytes are always 0
3359 pisid->IdentifierAuthority.Value[0] = 0;
3360 pisid->IdentifierAuthority.Value[1] = 0;
3361 identAuth = atoiW(StringSid);
3362 pisid->IdentifierAuthority.Value[5] = identAuth & 0xff;
3363 pisid->IdentifierAuthority.Value[4] = (identAuth & 0xff00) >> 8;
3364 pisid->IdentifierAuthority.Value[3] = (identAuth & 0xff0000) >> 16;
3365 pisid->IdentifierAuthority.Value[2] = (identAuth & 0xff000000) >> 24;
3367 /* Advance to first sub authority */
3368 while (*StringSid && *StringSid != '-')
3370 if (*StringSid == '-')
3375 while (*StringSid && *StringSid != '-')
3378 pisid->SubAuthority[i++] = atoiW(StringSid);
3381 if (i != pisid->SubAuthorityCount)
3382 goto lend; /* ERROR_INVALID_SID */
3386 else /* String constant format - Only available in winxp and above */
3388 pisid->Revision = SDDL_REVISION;
3389 pisid->SubAuthorityCount = 1;
3391 FIXME("String constant not supported: %s\n", debugstr_wn(StringSid, 2));
3393 /* TODO: Lookup string of well-known SIDs in table */
3394 pisid->IdentifierAuthority.Value[5] = 0;
3395 pisid->SubAuthority[0] = 0;
3402 SetLastError(ERROR_INVALID_SID);
3404 TRACE("returning %s\n", bret ? "TRUE" : "FALSE");
3408 /******************************************************************************
3409 * GetNamedSecurityInfoA [ADVAPI32.@]
3411 DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName,
3412 SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
3413 PSID* ppsidOwner, PSID* ppsidGroup, PACL* ppDacl, PACL* ppSacl,
3414 PSECURITY_DESCRIPTOR* ppSecurityDescriptor)
3420 TRACE("%s %d %ld %p %p %p %p %p\n", pObjectName, ObjectType, SecurityInfo,
3421 ppsidOwner, ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor);
3425 len = MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, NULL, 0 );
3426 wstr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
3427 MultiByteToWideChar( CP_ACP, 0, pObjectName, -1, wstr, len );
3430 r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner,
3431 ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
3433 HeapFree( GetProcessHeap(), 0, wstr );
3438 /******************************************************************************
3439 * GetNamedSecurityInfoW [ADVAPI32.@]
3441 DWORD WINAPI GetNamedSecurityInfoW( LPWSTR name, SE_OBJECT_TYPE type,
3442 SECURITY_INFORMATION info, PSID* owner, PSID* group, PACL* dacl,
3443 PACL* sacl, PSECURITY_DESCRIPTOR* descriptor )
3445 DWORD needed, offset;
3446 SECURITY_DESCRIPTOR_RELATIVE *relative;
3449 TRACE( "%s %d %ld %p %p %p %p %p\n", debugstr_w(name), type, info, owner,
3450 group, dacl, sacl, descriptor );
3452 if (!name || !descriptor) return ERROR_INVALID_PARAMETER;
3454 needed = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
3455 if (info & OWNER_SECURITY_INFORMATION)
3456 needed += sizeof(sidWorld);
3457 if (info & GROUP_SECURITY_INFORMATION)
3458 needed += sizeof(sidWorld);
3459 if (info & DACL_SECURITY_INFORMATION)
3460 needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
3461 if (info & SACL_SECURITY_INFORMATION)
3462 needed += WINE_SIZE_OF_WORLD_ACCESS_ACL;
3464 /* must be freed by caller */
3465 *descriptor = HeapAlloc( GetProcessHeap(), 0, needed );
3466 if (!*descriptor) return ERROR_NOT_ENOUGH_MEMORY;
3468 if (!InitializeSecurityDescriptor( *descriptor, SECURITY_DESCRIPTOR_REVISION ))
3470 HeapFree( GetProcessHeap(), 0, *descriptor );
3471 return ERROR_INVALID_SECURITY_DESCR;
3474 relative = (SECURITY_DESCRIPTOR_RELATIVE *)*descriptor;
3475 relative->Control |= SE_SELF_RELATIVE;
3476 buffer = (BYTE *)relative;
3477 offset = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
3479 if (owner && (info & OWNER_SECURITY_INFORMATION))
3481 memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
3482 relative->Owner = offset;
3483 *owner = buffer + offset;
3484 offset += sizeof(sidWorld);
3486 if (group && (info & GROUP_SECURITY_INFORMATION))
3488 memcpy( buffer + offset, &sidWorld, sizeof(sidWorld) );
3489 relative->Group = offset;
3490 *group = buffer + offset;
3491 offset += sizeof(sidWorld);
3493 if (dacl && (info & DACL_SECURITY_INFORMATION))
3495 GetWorldAccessACL( (PACL)(buffer + offset) );
3496 relative->Dacl = offset;
3497 *dacl = (PACL)(buffer + offset);
3498 offset += WINE_SIZE_OF_WORLD_ACCESS_ACL;
3500 if (sacl && (info & SACL_SECURITY_INFORMATION))
3502 GetWorldAccessACL( (PACL)(buffer + offset) );
3503 relative->Sacl = offset;
3504 *sacl = (PACL)(buffer + offset);
3506 return ERROR_SUCCESS;
3509 /******************************************************************************
3510 * DecryptFileW [ADVAPI32.@]
3512 BOOL WINAPI DecryptFileW(LPCWSTR lpFileName, DWORD dwReserved)
3514 FIXME("%s %08lx\n", debugstr_w(lpFileName), dwReserved);
3518 /******************************************************************************
3519 * DecryptFileA [ADVAPI32.@]
3521 BOOL WINAPI DecryptFileA(LPCSTR lpFileName, DWORD dwReserved)
3523 FIXME("%s %08lx\n", debugstr_a(lpFileName), dwReserved);
3527 /******************************************************************************
3528 * EncryptFileW [ADVAPI32.@]
3530 BOOL WINAPI EncryptFileW(LPCWSTR lpFileName)
3532 FIXME("%s\n", debugstr_w(lpFileName));
3536 /******************************************************************************
3537 * EncryptFileA [ADVAPI32.@]
3539 BOOL WINAPI EncryptFileA(LPCSTR lpFileName)
3541 FIXME("%s\n", debugstr_a(lpFileName));
3545 /******************************************************************************
3546 * SetSecurityInfo [ADVAPI32.@]
3548 DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
3549 SECURITY_INFORMATION SecurityInfo, PSID psidOwner,
3550 PSID psidGroup, PACL pDacl, PACL pSacl) {
3552 return ERROR_SUCCESS;