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
38 #include "wine/debug.h"
39 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
43 static BOOL
ParseStringSidToSid(LPCWSTR StringSid
, PSID pSid
, LPDWORD cBytes
);
44 static BOOL
ParseStringAclToAcl(LPCWSTR StringAcl
, LPDWORD lpdwFlags
,
45 PACL pAcl
, LPDWORD cBytes
);
46 static BYTE
ParseAceStringFlags(LPCWSTR
* StringAcl
);
47 static BYTE
ParseAceStringType(LPCWSTR
* StringAcl
);
48 static DWORD
ParseAceStringRights(LPCWSTR
* StringAcl
);
49 static BOOL
ParseStringSecurityDescriptorToSecurityDescriptor(
50 LPCWSTR StringSecurityDescriptor
,
51 SECURITY_DESCRIPTOR
* SecurityDescriptor
,
53 static DWORD
ParseAclStringFlags(LPCWSTR
* StringAcl
);
55 typedef struct _ACEFLAG
59 } ACEFLAG
, *LPACEFLAG
;
61 static SID
const sidWorld
= { SID_REVISION
, 1, { SECURITY_WORLD_SID_AUTHORITY
} , { SECURITY_WORLD_RID
} };
66 static const WCHAR SDDL_READ_CONTROL
[] = {'R','C',0};
67 static const WCHAR SDDL_WRITE_DAC
[] = {'W','D',0};
68 static const WCHAR SDDL_WRITE_OWNER
[] = {'W','O',0};
69 static const WCHAR SDDL_STANDARD_DELETE
[] = {'S','D',0};
70 static const WCHAR SDDL_GENERIC_ALL
[] = {'G','A',0};
71 static const WCHAR SDDL_GENERIC_READ
[] = {'G','R',0};
72 static const WCHAR SDDL_GENERIC_WRITE
[] = {'G','W',0};
73 static const WCHAR SDDL_GENERIC_EXECUTE
[] = {'G','X',0};
78 static const WCHAR SDDL_ACCESS_ALLOWED
[] = {'A',0};
79 static const WCHAR SDDL_ACCESS_DENIED
[] = {'D',0};
80 static const WCHAR SDDL_OBJECT_ACCESS_ALLOWED
[] = {'O','A',0};
81 static const WCHAR SDDL_OBJECT_ACCESS_DENIED
[] = {'O','D',0};
82 static const WCHAR SDDL_AUDIT
[] = {'A','U',0};
83 static const WCHAR SDDL_ALARM
[] = {'A','L',0};
84 static const WCHAR SDDL_OBJECT_AUDIT
[] = {'O','U',0};
85 static const WCHAR SDDL_OBJECT_ALARMp
[] = {'O','L',0};
90 static const WCHAR SDDL_CONTAINER_INHERIT
[] = {'C','I',0};
91 static const WCHAR SDDL_OBJECT_INHERIT
[] = {'O','I',0};
92 static const WCHAR SDDL_NO_PROPAGATE
[] = {'N','P',0};
93 static const WCHAR SDDL_INHERIT_ONLY
[] = {'I','O',0};
94 static const WCHAR SDDL_INHERITED
[] = {'I','D',0};
95 static const WCHAR SDDL_AUDIT_SUCCESS
[] = {'S','A',0};
96 static const WCHAR SDDL_AUDIT_FAILURE
[] = {'F','A',0};
98 /* set last error code from NT status and get the proper boolean return value */
99 /* used for functions that are a simple wrapper around the corresponding ntdll API */
100 static inline BOOL
set_ntstatus( NTSTATUS status
)
102 if (status
) SetLastError( RtlNtStatusToDosError( status
));
106 #define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD))
108 static void GetWorldAccessACL(PACL pACL
)
110 PACCESS_ALLOWED_ACE pACE
= (PACCESS_ALLOWED_ACE
) (pACL
+ 1);
112 pACL
->AclRevision
= ACL_REVISION
;
114 pACL
->AclSize
= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
118 pACE
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
119 pACE
->Header
.AceFlags
= CONTAINER_INHERIT_ACE
;
120 pACE
->Header
.AceSize
= sizeof(ACCESS_ALLOWED_ACE
) + sizeof(sidWorld
) - sizeof(DWORD
);
121 pACE
->Mask
= 0xf3ffffff; /* Everything except reserved bits */
122 memcpy(&pACE
->SidStart
, &sidWorld
, sizeof(sidWorld
));
125 /************************************************************
126 * ADVAPI_IsLocalComputer
128 * Checks whether the server name indicates local machine.
130 static BOOL
ADVAPI_IsLocalComputer(LPCWSTR ServerName
)
132 DWORD dwSize
= MAX_COMPUTERNAME_LENGTH
+ 1;
136 if (!ServerName
|| !ServerName
[0])
139 buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
140 Result
= GetComputerNameW(buf
, &dwSize
);
141 if (Result
&& (ServerName
[0] == '\\') && (ServerName
[1] == '\\'))
143 Result
= Result
&& !lstrcmpW(ServerName
, buf
);
144 HeapFree(GetProcessHeap(), 0, buf
);
149 /* ##############################
150 ###### TOKEN FUNCTIONS ######
151 ##############################
154 /******************************************************************************
155 * OpenProcessToken [ADVAPI32.@]
156 * Opens the access token associated with a process handle.
159 * ProcessHandle [I] Handle to process
160 * DesiredAccess [I] Desired access to process
161 * TokenHandle [O] Pointer to handle of open access token
164 * Success: TRUE. TokenHandle contains the access token.
168 * See NtOpenProcessToken.
171 OpenProcessToken( HANDLE ProcessHandle
, DWORD DesiredAccess
,
172 HANDLE
*TokenHandle
)
174 return set_ntstatus(NtOpenProcessToken( ProcessHandle
, DesiredAccess
, TokenHandle
));
177 /******************************************************************************
178 * OpenThreadToken [ADVAPI32.@]
180 * Opens the access token associated with a thread handle.
183 * ThreadHandle [I] Handle to process
184 * DesiredAccess [I] Desired access to the thread
186 * TokenHandle [O] Destination for the token handle
189 * Success: TRUE. TokenHandle contains the access token.
193 * See NtOpenThreadToken.
196 OpenThreadToken( HANDLE ThreadHandle
, DWORD DesiredAccess
,
197 BOOL OpenAsSelf
, HANDLE
*TokenHandle
)
199 return set_ntstatus( NtOpenThreadToken(ThreadHandle
, DesiredAccess
, OpenAsSelf
, TokenHandle
));
203 AdjustTokenGroups( HANDLE TokenHandle
, BOOL ResetToDefault
, PTOKEN_GROUPS NewState
,
204 DWORD BufferLength
, PTOKEN_GROUPS PreviousState
, PDWORD ReturnLength
)
206 return set_ntstatus( NtAdjustGroupsToken(TokenHandle
, ResetToDefault
, NewState
, BufferLength
,
207 PreviousState
, ReturnLength
));
210 /******************************************************************************
211 * AdjustTokenPrivileges [ADVAPI32.@]
213 * Adjust the privileges of an open token handle.
216 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
217 * DisableAllPrivileges [I] TRUE=Remove all privileges, FALSE=Use NewState
218 * NewState [I] Desired new privileges of the token
219 * BufferLength [I] Length of NewState
220 * PreviousState [O] Destination for the previous state
221 * ReturnLength [I/O] Size of PreviousState
225 * Success: TRUE. Privileges are set to NewState and PreviousState is updated.
229 * See NtAdjustPrivilegesToken.
232 AdjustTokenPrivileges( HANDLE TokenHandle
, BOOL DisableAllPrivileges
,
233 LPVOID NewState
, DWORD BufferLength
,
234 LPVOID PreviousState
, LPDWORD ReturnLength
)
240 status
= NtAdjustPrivilegesToken(TokenHandle
, DisableAllPrivileges
,
241 NewState
, BufferLength
, PreviousState
,
243 SetLastError( RtlNtStatusToDosError( status
));
244 if ((status
== STATUS_SUCCESS
) || (status
== STATUS_NOT_ALL_ASSIGNED
))
250 /******************************************************************************
251 * CheckTokenMembership [ADVAPI32.@]
253 * Determine if an access token is a member of a SID.
256 * TokenHandle [I] Handle from OpenProcessToken() or OpenThreadToken()
257 * SidToCheck [I] SID that possibly contains the token
258 * IsMember [O] Destination for result.
261 * Success: TRUE. IsMember is TRUE if TokenHandle is a member, FALSE otherwise.
265 CheckTokenMembership( HANDLE TokenHandle
, PSID SidToCheck
,
268 FIXME("(%p %p %p) stub!\n", TokenHandle
, SidToCheck
, IsMember
);
274 /******************************************************************************
275 * GetTokenInformation [ADVAPI32.@]
277 * Get a type of information about an access token.
280 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
281 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
282 * tokeninfo [O] Destination for token information
283 * tokeninfolength [I] Length of tokeninfo
284 * retlen [O] Destination for returned token information length
287 * Success: TRUE. tokeninfo contains retlen bytes of token information
291 * See NtQueryInformationToken.
294 GetTokenInformation( HANDLE token
, TOKEN_INFORMATION_CLASS tokeninfoclass
,
295 LPVOID tokeninfo
, DWORD tokeninfolength
, LPDWORD retlen
)
297 TRACE("(%p, %s, %p, %ld, %p):\n",
299 (tokeninfoclass
== TokenUser
) ? "TokenUser" :
300 (tokeninfoclass
== TokenGroups
) ? "TokenGroups" :
301 (tokeninfoclass
== TokenPrivileges
) ? "TokenPrivileges" :
302 (tokeninfoclass
== TokenOwner
) ? "TokenOwner" :
303 (tokeninfoclass
== TokenPrimaryGroup
) ? "TokenPrimaryGroup" :
304 (tokeninfoclass
== TokenDefaultDacl
) ? "TokenDefaultDacl" :
305 (tokeninfoclass
== TokenSource
) ? "TokenSource" :
306 (tokeninfoclass
== TokenType
) ? "TokenType" :
307 (tokeninfoclass
== TokenImpersonationLevel
) ? "TokenImpersonationLevel" :
308 (tokeninfoclass
== TokenStatistics
) ? "TokenStatistics" :
309 (tokeninfoclass
== TokenRestrictedSids
) ? "TokenRestrictedSids" :
310 (tokeninfoclass
== TokenSessionId
) ? "TokenSessionId" :
311 (tokeninfoclass
== TokenGroupsAndPrivileges
) ? "TokenGroupsAndPrivileges" :
312 (tokeninfoclass
== TokenSessionReference
) ? "TokenSessionReference" :
313 (tokeninfoclass
== TokenSandBoxInert
) ? "TokenSandBoxInert" :
315 tokeninfo
, tokeninfolength
, retlen
);
316 return set_ntstatus( NtQueryInformationToken( token
, tokeninfoclass
, tokeninfo
,
317 tokeninfolength
, retlen
));
320 /******************************************************************************
321 * SetTokenInformation [ADVAPI32.@]
323 * Set information for an access token.
326 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
327 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
328 * tokeninfo [I] Token information to set
329 * tokeninfolength [I] Length of tokeninfo
332 * Success: TRUE. The information for the token is set to tokeninfo.
336 SetTokenInformation( HANDLE token
, TOKEN_INFORMATION_CLASS tokeninfoclass
,
337 LPVOID tokeninfo
, DWORD tokeninfolength
)
339 TRACE("(%p, %s, %p, %ld): stub\n",
341 (tokeninfoclass
== TokenUser
) ? "TokenUser" :
342 (tokeninfoclass
== TokenGroups
) ? "TokenGroups" :
343 (tokeninfoclass
== TokenPrivileges
) ? "TokenPrivileges" :
344 (tokeninfoclass
== TokenOwner
) ? "TokenOwner" :
345 (tokeninfoclass
== TokenPrimaryGroup
) ? "TokenPrimaryGroup" :
346 (tokeninfoclass
== TokenDefaultDacl
) ? "TokenDefaultDacl" :
347 (tokeninfoclass
== TokenSource
) ? "TokenSource" :
348 (tokeninfoclass
== TokenType
) ? "TokenType" :
349 (tokeninfoclass
== TokenImpersonationLevel
) ? "TokenImpersonationLevel" :
350 (tokeninfoclass
== TokenStatistics
) ? "TokenStatistics" :
351 (tokeninfoclass
== TokenRestrictedSids
) ? "TokenRestrictedSids" :
352 (tokeninfoclass
== TokenSessionId
) ? "TokenSessionId" :
353 (tokeninfoclass
== TokenGroupsAndPrivileges
) ? "TokenGroupsAndPrivileges" :
354 (tokeninfoclass
== TokenSessionReference
) ? "TokenSessionReference" :
355 (tokeninfoclass
== TokenSandBoxInert
) ? "TokenSandBoxInert" :
357 tokeninfo
, tokeninfolength
);
359 return set_ntstatus( NtSetInformationToken( token
, tokeninfoclass
, tokeninfo
, tokeninfolength
));
362 /*************************************************************************
363 * SetThreadToken [ADVAPI32.@]
365 * Assigns an 'impersonation token' to a thread so it can assume the
366 * security privileges of another thread or process. Can also remove
367 * a previously assigned token.
370 * thread [O] Handle to thread to set the token for
371 * token [I] Token to set
374 * Success: TRUE. The threads access token is set to token
378 * Only supported on NT or higher. On Win9X this function does nothing.
379 * See SetTokenInformation.
381 BOOL WINAPI
SetThreadToken(PHANDLE thread
, HANDLE token
)
383 return set_ntstatus( NtSetInformationThread( thread
? *thread
: GetCurrentThread(),
384 ThreadImpersonationToken
, &token
, sizeof token
));
387 /* ##############################
388 ###### SID FUNCTIONS ######
389 ##############################
392 /******************************************************************************
393 * AllocateAndInitializeSid [ADVAPI32.@]
396 * pIdentifierAuthority []
397 * nSubAuthorityCount []
409 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
410 BYTE nSubAuthorityCount
,
411 DWORD nSubAuthority0
, DWORD nSubAuthority1
,
412 DWORD nSubAuthority2
, DWORD nSubAuthority3
,
413 DWORD nSubAuthority4
, DWORD nSubAuthority5
,
414 DWORD nSubAuthority6
, DWORD nSubAuthority7
,
417 return set_ntstatus( RtlAllocateAndInitializeSid(
418 pIdentifierAuthority
, nSubAuthorityCount
,
419 nSubAuthority0
, nSubAuthority1
, nSubAuthority2
, nSubAuthority3
,
420 nSubAuthority4
, nSubAuthority5
, nSubAuthority6
, nSubAuthority7
,
424 /******************************************************************************
425 * FreeSid [ADVAPI32.@]
434 return NULL
; /* is documented like this */
437 /******************************************************************************
438 * CopySid [ADVAPI32.@]
441 * nDestinationSidLength []
446 CopySid( DWORD nDestinationSidLength
, PSID pDestinationSid
, PSID pSourceSid
)
448 return RtlCopySid(nDestinationSidLength
, pDestinationSid
, pSourceSid
);
452 IsTokenRestricted( HANDLE TokenHandle
)
454 TOKEN_GROUPS
*groups
;
459 TRACE("(%p)\n", TokenHandle
);
461 status
= NtQueryInformationToken(TokenHandle
, TokenRestrictedSids
, NULL
, 0, &size
);
462 if (status
!= STATUS_BUFFER_TOO_SMALL
)
465 groups
= HeapAlloc(GetProcessHeap(), 0, size
);
468 SetLastError(ERROR_OUTOFMEMORY
);
472 status
= NtQueryInformationToken(TokenHandle
, TokenRestrictedSids
, groups
, size
, &size
);
473 if (status
!= STATUS_SUCCESS
)
475 HeapFree(GetProcessHeap(), 0, groups
);
476 return set_ntstatus(status
);
479 if (groups
->GroupCount
)
484 HeapFree(GetProcessHeap(), 0, groups
);
489 /******************************************************************************
490 * IsValidSid [ADVAPI32.@]
496 IsValidSid( PSID pSid
)
498 return RtlValidSid( pSid
);
501 /******************************************************************************
502 * EqualSid [ADVAPI32.@]
509 EqualSid( PSID pSid1
, PSID pSid2
)
511 return RtlEqualSid( pSid1
, pSid2
);
514 /******************************************************************************
515 * EqualPrefixSid [ADVAPI32.@]
517 BOOL WINAPI
EqualPrefixSid (PSID pSid1
, PSID pSid2
)
519 return RtlEqualPrefixSid(pSid1
, pSid2
);
522 /******************************************************************************
523 * GetSidLengthRequired [ADVAPI32.@]
526 * nSubAuthorityCount []
529 GetSidLengthRequired( BYTE nSubAuthorityCount
)
531 return RtlLengthRequiredSid(nSubAuthorityCount
);
534 /******************************************************************************
535 * InitializeSid [ADVAPI32.@]
538 * pIdentifierAuthority []
543 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
544 BYTE nSubAuthorityCount
)
546 return RtlInitializeSid(pSid
, pIdentifierAuthority
, nSubAuthorityCount
);
550 GetEffectiveRightsFromAclA( PACL pacl
, PTRUSTEEA pTrustee
, PACCESS_MASK pAccessRights
)
552 FIXME("%p %p %p - stub\n", pacl
, pTrustee
, pAccessRights
);
558 GetEffectiveRightsFromAclW( PACL pacl
, PTRUSTEEW pTrustee
, PACCESS_MASK pAccessRights
)
560 FIXME("%p %p %p - stub\n", pacl
, pTrustee
, pAccessRights
);
565 /******************************************************************************
566 * GetSidIdentifierAuthority [ADVAPI32.@]
571 PSID_IDENTIFIER_AUTHORITY WINAPI
572 GetSidIdentifierAuthority( PSID pSid
)
574 return RtlIdentifierAuthoritySid(pSid
);
577 /******************************************************************************
578 * GetSidSubAuthority [ADVAPI32.@]
585 GetSidSubAuthority( PSID pSid
, DWORD nSubAuthority
)
587 return RtlSubAuthoritySid(pSid
, nSubAuthority
);
590 /******************************************************************************
591 * GetSidSubAuthorityCount [ADVAPI32.@]
597 GetSidSubAuthorityCount (PSID pSid
)
599 return RtlSubAuthorityCountSid(pSid
);
602 /******************************************************************************
603 * GetLengthSid [ADVAPI32.@]
609 GetLengthSid (PSID pSid
)
611 return RtlLengthSid(pSid
);
614 /* ##############################################
615 ###### SECURITY DESCRIPTOR FUNCTIONS ######
616 ##############################################
619 /******************************************************************************
620 * BuildSecurityDescriptorA [ADVAPI32.@]
627 * cCountOfAccessEntries [I]
628 * pListOfAccessEntries [I]
629 * cCountOfAuditEntries [I]
630 * pListofAuditEntries [I]
632 * lpdwBufferLength [I/O]
636 * Success: ERROR_SUCCESS
637 * Failure: nonzero error code from Winerror.h
639 DWORD WINAPI
BuildSecurityDescriptorA(
640 IN PTRUSTEE_A pOwner
,
641 IN PTRUSTEE_A pGroup
,
642 IN DWORD cCountOfAccessEntries
,
643 IN PEXPLICIT_ACCESS_A pListOfAccessEntries
,
644 IN DWORD cCountOfAuditEntries
,
645 IN PEXPLICIT_ACCESS_A pListofAuditEntries
,
646 IN PSECURITY_DESCRIPTOR pOldSD
,
647 IN OUT PDWORD lpdwBufferLength
,
648 OUT PSECURITY_DESCRIPTOR pNewSD
)
650 FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner
,pGroup
,
651 cCountOfAccessEntries
,pListOfAccessEntries
,cCountOfAuditEntries
,
652 pListofAuditEntries
,pOldSD
,lpdwBufferLength
,pNewSD
);
654 return ERROR_CALL_NOT_IMPLEMENTED
;
657 /******************************************************************************
658 * BuildSecurityDescriptorW [ADVAPI32.@]
660 * See BuildSecurityDescriptorA.
662 DWORD WINAPI
BuildSecurityDescriptorW(
663 IN PTRUSTEE_W pOwner
,
664 IN PTRUSTEE_W pGroup
,
665 IN DWORD cCountOfAccessEntries
,
666 IN PEXPLICIT_ACCESS_W pListOfAccessEntries
,
667 IN DWORD cCountOfAuditEntries
,
668 IN PEXPLICIT_ACCESS_W pListofAuditEntries
,
669 IN PSECURITY_DESCRIPTOR pOldSD
,
670 IN OUT PDWORD lpdwBufferLength
,
671 OUT PSECURITY_DESCRIPTOR pNewSD
)
673 FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner
,pGroup
,
674 cCountOfAccessEntries
,pListOfAccessEntries
,cCountOfAuditEntries
,
675 pListofAuditEntries
,pOldSD
,lpdwBufferLength
,pNewSD
);
677 return ERROR_CALL_NOT_IMPLEMENTED
;
680 /******************************************************************************
681 * InitializeSecurityDescriptor [ADVAPI32.@]
688 InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr
, DWORD revision
)
690 return set_ntstatus( RtlCreateSecurityDescriptor(pDescr
, revision
));
694 /******************************************************************************
695 * MakeAbsoluteSD [ADVAPI32.@]
697 BOOL WINAPI
MakeAbsoluteSD (
698 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
699 OUT PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
700 OUT LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
702 OUT LPDWORD lpdwDaclSize
,
704 OUT LPDWORD lpdwSaclSize
,
706 OUT LPDWORD lpdwOwnerSize
,
707 OUT PSID pPrimaryGroup
,
708 OUT LPDWORD lpdwPrimaryGroupSize
)
710 return set_ntstatus( RtlSelfRelativeToAbsoluteSD(pSelfRelativeSecurityDescriptor
,
711 pAbsoluteSecurityDescriptor
,
712 lpdwAbsoluteSecurityDescriptorSize
,
713 pDacl
, lpdwDaclSize
, pSacl
, lpdwSaclSize
,
714 pOwner
, lpdwOwnerSize
,
715 pPrimaryGroup
, lpdwPrimaryGroupSize
));
718 /******************************************************************************
719 * GetKernelObjectSecurity [ADVAPI32.@]
721 BOOL WINAPI
GetKernelObjectSecurity(
723 SECURITY_INFORMATION RequestedInformation
,
724 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
726 LPDWORD lpnLengthNeeded
)
728 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", Handle
, RequestedInformation
,
729 pSecurityDescriptor
, nLength
, lpnLengthNeeded
);
731 return set_ntstatus( NtQuerySecurityObject(Handle
, RequestedInformation
, pSecurityDescriptor
,
732 nLength
, lpnLengthNeeded
));
735 /******************************************************************************
736 * GetPrivateObjectSecurity [ADVAPI32.@]
738 BOOL WINAPI
GetPrivateObjectSecurity(
739 PSECURITY_DESCRIPTOR ObjectDescriptor
,
740 SECURITY_INFORMATION SecurityInformation
,
741 PSECURITY_DESCRIPTOR ResultantDescriptor
,
742 DWORD DescriptorLength
,
743 PDWORD ReturnLength
)
745 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", ObjectDescriptor
, SecurityInformation
,
746 ResultantDescriptor
, DescriptorLength
, ReturnLength
);
748 return set_ntstatus( NtQuerySecurityObject(ObjectDescriptor
, SecurityInformation
,
749 ResultantDescriptor
, DescriptorLength
, ReturnLength
));
752 /******************************************************************************
753 * GetSecurityDescriptorLength [ADVAPI32.@]
755 DWORD WINAPI
GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr
)
757 return RtlLengthSecurityDescriptor(pDescr
);
760 /******************************************************************************
761 * GetSecurityDescriptorOwner [ADVAPI32.@]
765 * lpbOwnerDefaulted []
768 GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr
, PSID
*pOwner
,
769 LPBOOL lpbOwnerDefaulted
)
772 BOOL ret
= set_ntstatus( RtlGetOwnerSecurityDescriptor( pDescr
, pOwner
, &defaulted
));
773 *lpbOwnerDefaulted
= defaulted
;
777 /******************************************************************************
778 * SetSecurityDescriptorOwner [ADVAPI32.@]
782 BOOL WINAPI
SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
783 PSID pOwner
, BOOL bOwnerDefaulted
)
785 return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor
, pOwner
, bOwnerDefaulted
));
787 /******************************************************************************
788 * GetSecurityDescriptorGroup [ADVAPI32.@]
790 BOOL WINAPI
GetSecurityDescriptorGroup(
791 PSECURITY_DESCRIPTOR SecurityDescriptor
,
793 LPBOOL GroupDefaulted
)
796 BOOL ret
= set_ntstatus( RtlGetGroupSecurityDescriptor(SecurityDescriptor
, Group
, &defaulted
));
797 *GroupDefaulted
= defaulted
;
800 /******************************************************************************
801 * SetSecurityDescriptorGroup [ADVAPI32.@]
803 BOOL WINAPI
SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor
,
804 PSID Group
, BOOL GroupDefaulted
)
806 return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor
, Group
, GroupDefaulted
));
809 /******************************************************************************
810 * IsValidSecurityDescriptor [ADVAPI32.@]
816 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor
)
818 return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor
));
821 /******************************************************************************
822 * GetSecurityDescriptorDacl [ADVAPI32.@]
824 BOOL WINAPI
GetSecurityDescriptorDacl(
825 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
826 OUT LPBOOL lpbDaclPresent
,
828 OUT LPBOOL lpbDaclDefaulted
)
830 BOOLEAN present
, defaulted
;
831 BOOL ret
= set_ntstatus( RtlGetDaclSecurityDescriptor(pSecurityDescriptor
, &present
, pDacl
, &defaulted
));
832 *lpbDaclPresent
= present
;
833 *lpbDaclDefaulted
= defaulted
;
837 /******************************************************************************
838 * SetSecurityDescriptorDacl [ADVAPI32.@]
841 SetSecurityDescriptorDacl (
842 PSECURITY_DESCRIPTOR lpsd
,
847 return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd
, daclpresent
, dacl
, dacldefaulted
) );
849 /******************************************************************************
850 * GetSecurityDescriptorSacl [ADVAPI32.@]
852 BOOL WINAPI
GetSecurityDescriptorSacl(
853 IN PSECURITY_DESCRIPTOR lpsd
,
854 OUT LPBOOL lpbSaclPresent
,
856 OUT LPBOOL lpbSaclDefaulted
)
858 BOOLEAN present
, defaulted
;
859 BOOL ret
= set_ntstatus( RtlGetSaclSecurityDescriptor(lpsd
, &present
, pSacl
, &defaulted
) );
860 *lpbSaclPresent
= present
;
861 *lpbSaclDefaulted
= defaulted
;
865 /**************************************************************************
866 * SetSecurityDescriptorSacl [ADVAPI32.@]
868 BOOL WINAPI
SetSecurityDescriptorSacl (
869 PSECURITY_DESCRIPTOR lpsd
,
874 return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd
, saclpresent
, lpsacl
, sacldefaulted
));
876 /******************************************************************************
877 * MakeSelfRelativeSD [ADVAPI32.@]
886 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
887 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
888 IN OUT LPDWORD lpdwBufferLength
)
890 return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor
,
891 pSelfRelativeSecurityDescriptor
, lpdwBufferLength
));
894 /******************************************************************************
895 * GetSecurityDescriptorControl [ADVAPI32.@]
898 BOOL WINAPI
GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
899 PSECURITY_DESCRIPTOR_CONTROL pControl
, LPDWORD lpdwRevision
)
901 return set_ntstatus( RtlGetControlSecurityDescriptor(pSecurityDescriptor
,pControl
,lpdwRevision
));
904 /* ##############################
905 ###### ACL FUNCTIONS ######
906 ##############################
909 /*************************************************************************
910 * InitializeAcl [ADVAPI32.@]
912 BOOL WINAPI
InitializeAcl(PACL acl
, DWORD size
, DWORD rev
)
914 return set_ntstatus( RtlCreateAcl(acl
, size
, rev
));
917 BOOL WINAPI
ImpersonateNamedPipeClient( HANDLE hNamedPipe
)
919 TRACE("(%p)\n", hNamedPipe
);
921 return set_ntstatus( NtFsControlFile(hNamedPipe
, NULL
, NULL
, NULL
, NULL
,
922 FSCTL_PIPE_IMPERSONATE
, NULL
, 0, NULL
, 0) );
925 /******************************************************************************
926 * AddAccessAllowedAce [ADVAPI32.@]
928 BOOL WINAPI
AddAccessAllowedAce(
930 IN DWORD dwAceRevision
,
934 return set_ntstatus(RtlAddAccessAllowedAce(pAcl
, dwAceRevision
, AccessMask
, pSid
));
937 /******************************************************************************
938 * AddAccessAllowedAceEx [ADVAPI32.@]
940 BOOL WINAPI
AddAccessAllowedAceEx(
942 IN DWORD dwAceRevision
,
947 return set_ntstatus(RtlAddAccessAllowedAceEx(pAcl
, dwAceRevision
, AceFlags
, AccessMask
, pSid
));
950 /******************************************************************************
951 * AddAccessDeniedAce [ADVAPI32.@]
953 BOOL WINAPI
AddAccessDeniedAce(
955 IN DWORD dwAceRevision
,
959 return set_ntstatus(RtlAddAccessDeniedAce(pAcl
, dwAceRevision
, AccessMask
, pSid
));
962 /******************************************************************************
963 * AddAccessDeniedAceEx [ADVAPI32.@]
965 BOOL WINAPI
AddAccessDeniedAceEx(
967 IN DWORD dwAceRevision
,
972 return set_ntstatus(RtlAddAccessDeniedAceEx(pAcl
, dwAceRevision
, AceFlags
, AccessMask
, pSid
));
975 /******************************************************************************
976 * AddAce [ADVAPI32.@]
980 IN DWORD dwAceRevision
,
981 IN DWORD dwStartingAceIndex
,
983 DWORD nAceListLength
)
985 return set_ntstatus(RtlAddAce(pAcl
, dwAceRevision
, dwStartingAceIndex
, pAceList
, nAceListLength
));
988 /******************************************************************************
989 * DeleteAce [ADVAPI32.@]
991 BOOL WINAPI
DeleteAce(PACL pAcl
, DWORD dwAceIndex
)
993 return set_ntstatus(RtlDeleteAce(pAcl
, dwAceIndex
));
996 /******************************************************************************
997 * FindFirstFreeAce [ADVAPI32.@]
999 BOOL WINAPI
FindFirstFreeAce(IN PACL pAcl
, LPVOID
* pAce
)
1001 return RtlFirstFreeAce(pAcl
, (PACE_HEADER
*)pAce
);
1004 /******************************************************************************
1005 * GetAce [ADVAPI32.@]
1007 BOOL WINAPI
GetAce(PACL pAcl
,DWORD dwAceIndex
,LPVOID
*pAce
)
1009 return set_ntstatus(RtlGetAce(pAcl
, dwAceIndex
, pAce
));
1012 /******************************************************************************
1013 * GetAclInformation [ADVAPI32.@]
1015 BOOL WINAPI
GetAclInformation(
1017 LPVOID pAclInformation
,
1018 DWORD nAclInformationLength
,
1019 ACL_INFORMATION_CLASS dwAclInformationClass
)
1021 return set_ntstatus(RtlQueryInformationAcl(pAcl
, pAclInformation
,
1022 nAclInformationLength
, dwAclInformationClass
));
1025 /******************************************************************************
1026 * IsValidAcl [ADVAPI32.@]
1028 BOOL WINAPI
IsValidAcl(IN PACL pAcl
)
1030 return RtlValidAcl(pAcl
);
1033 /* ##############################
1034 ###### MISC FUNCTIONS ######
1035 ##############################
1038 /******************************************************************************
1039 * AllocateLocallyUniqueId [ADVAPI32.@]
1044 BOOL WINAPI
AllocateLocallyUniqueId( PLUID lpLuid
)
1046 return set_ntstatus(NtAllocateLocallyUniqueId(lpLuid
));
1049 static const WCHAR SE_CREATE_TOKEN_NAME_W
[] =
1050 { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
1051 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W
[] =
1052 { '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 };
1053 static const WCHAR SE_LOCK_MEMORY_NAME_W
[] =
1054 { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
1055 static const WCHAR SE_INCREASE_QUOTA_NAME_W
[] =
1056 { '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 };
1057 static const WCHAR SE_MACHINE_ACCOUNT_NAME_W
[] =
1058 { '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 };
1059 static const WCHAR SE_TCB_NAME_W
[] =
1060 { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
1061 static const WCHAR SE_SECURITY_NAME_W
[] =
1062 { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
1063 static const WCHAR SE_TAKE_OWNERSHIP_NAME_W
[] =
1064 { '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 };
1065 static const WCHAR SE_LOAD_DRIVER_NAME_W
[] =
1066 { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
1067 static const WCHAR SE_SYSTEM_PROFILE_NAME_W
[] =
1068 { '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 };
1069 static const WCHAR SE_SYSTEMTIME_NAME_W
[] =
1070 { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
1071 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W
[] =
1072 { '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 };
1073 static const WCHAR SE_INC_BASE_PRIORITY_NAME_W
[] =
1074 { '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 };
1075 static const WCHAR SE_CREATE_PAGEFILE_NAME_W
[] =
1076 { '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 };
1077 static const WCHAR SE_CREATE_PERMANENT_NAME_W
[] =
1078 { '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 };
1079 static const WCHAR SE_BACKUP_NAME_W
[] =
1080 { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
1081 static const WCHAR SE_RESTORE_NAME_W
[] =
1082 { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
1083 static const WCHAR SE_SHUTDOWN_NAME_W
[] =
1084 { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
1085 static const WCHAR SE_DEBUG_NAME_W
[] =
1086 { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
1087 static const WCHAR SE_AUDIT_NAME_W
[] =
1088 { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
1089 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W
[] =
1090 { '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 };
1091 static const WCHAR SE_CHANGE_NOTIFY_NAME_W
[] =
1092 { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
1093 static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W
[] =
1094 { '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 };
1095 static const WCHAR SE_UNDOCK_NAME_W
[] =
1096 { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
1097 static const WCHAR SE_SYNC_AGENT_NAME_W
[] =
1098 { 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
1099 static const WCHAR SE_ENABLE_DELEGATION_NAME_W
[] =
1100 { '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 };
1101 static const WCHAR SE_MANAGE_VOLUME_NAME_W
[] =
1102 { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
1103 static const WCHAR SE_IMPERSONATE_NAME_W
[] =
1104 { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
1105 static const WCHAR SE_CREATE_GLOBAL_NAME_W
[] =
1106 { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
1108 static const WCHAR
* const WellKnownPrivNames
[SE_MAX_WELL_KNOWN_PRIVILEGE
+ 1] =
1112 SE_CREATE_TOKEN_NAME_W
,
1113 SE_ASSIGNPRIMARYTOKEN_NAME_W
,
1114 SE_LOCK_MEMORY_NAME_W
,
1115 SE_INCREASE_QUOTA_NAME_W
,
1116 SE_MACHINE_ACCOUNT_NAME_W
,
1119 SE_TAKE_OWNERSHIP_NAME_W
,
1120 SE_LOAD_DRIVER_NAME_W
,
1121 SE_SYSTEM_PROFILE_NAME_W
,
1122 SE_SYSTEMTIME_NAME_W
,
1123 SE_PROF_SINGLE_PROCESS_NAME_W
,
1124 SE_INC_BASE_PRIORITY_NAME_W
,
1125 SE_CREATE_PAGEFILE_NAME_W
,
1126 SE_CREATE_PERMANENT_NAME_W
,
1132 SE_SYSTEM_ENVIRONMENT_NAME_W
,
1133 SE_CHANGE_NOTIFY_NAME_W
,
1134 SE_REMOTE_SHUTDOWN_NAME_W
,
1136 SE_SYNC_AGENT_NAME_W
,
1137 SE_ENABLE_DELEGATION_NAME_W
,
1138 SE_MANAGE_VOLUME_NAME_W
,
1139 SE_IMPERSONATE_NAME_W
,
1140 SE_CREATE_GLOBAL_NAME_W
,
1143 /******************************************************************************
1144 * LookupPrivilegeValueW [ADVAPI32.@]
1146 * See LookupPrivilegeValueA.
1149 LookupPrivilegeValueW( LPCWSTR lpSystemName
, LPCWSTR lpName
, PLUID lpLuid
)
1153 TRACE("%s,%s,%p\n",debugstr_w(lpSystemName
), debugstr_w(lpName
), lpLuid
);
1155 if (!ADVAPI_IsLocalComputer(lpSystemName
))
1157 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
1162 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1165 for( i
=SE_MIN_WELL_KNOWN_PRIVILEGE
; i
<SE_MAX_WELL_KNOWN_PRIVILEGE
; i
++ )
1167 if( !WellKnownPrivNames
[i
] )
1169 if( strcmpiW( WellKnownPrivNames
[i
], lpName
) )
1171 lpLuid
->LowPart
= i
;
1172 lpLuid
->HighPart
= 0;
1173 TRACE( "%s -> %08lx-%08lx\n",debugstr_w( lpSystemName
),
1174 lpLuid
->HighPart
, lpLuid
->LowPart
);
1177 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1181 /******************************************************************************
1182 * LookupPrivilegeValueA [ADVAPI32.@]
1184 * Retrieves LUID used on a system to represent the privilege name.
1187 * lpSystemName [I] Name of the system
1188 * lpName [I] Name of the privilege
1189 * lpLuid [O] Destination for the resulting LUID
1192 * Success: TRUE. lpLuid contains the requested LUID.
1196 LookupPrivilegeValueA( LPCSTR lpSystemName
, LPCSTR lpName
, PLUID lpLuid
)
1198 UNICODE_STRING lpSystemNameW
;
1199 UNICODE_STRING lpNameW
;
1202 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW
, lpSystemName
);
1203 RtlCreateUnicodeStringFromAsciiz(&lpNameW
,lpName
);
1204 ret
= LookupPrivilegeValueW(lpSystemNameW
.Buffer
, lpNameW
.Buffer
, lpLuid
);
1205 RtlFreeUnicodeString(&lpNameW
);
1206 RtlFreeUnicodeString(&lpSystemNameW
);
1210 BOOL WINAPI
LookupPrivilegeDisplayNameA( LPCSTR lpSystemName
, LPCSTR lpName
, LPSTR lpDisplayName
,
1211 LPDWORD cchDisplayName
, LPDWORD lpLanguageId
)
1213 FIXME("%s %s %s %p %p - stub\n", debugstr_a(lpSystemName
), debugstr_a(lpName
),
1214 debugstr_a(lpDisplayName
), cchDisplayName
, lpLanguageId
);
1219 BOOL WINAPI
LookupPrivilegeDisplayNameW( LPCWSTR lpSystemName
, LPCWSTR lpName
, LPWSTR lpDisplayName
,
1220 LPDWORD cchDisplayName
, LPDWORD lpLanguageId
)
1222 FIXME("%s %s %s %p %p - stub\n", debugstr_w(lpSystemName
), debugstr_w(lpName
),
1223 debugstr_w(lpDisplayName
), cchDisplayName
, lpLanguageId
);
1228 /******************************************************************************
1229 * LookupPrivilegeNameA [ADVAPI32.@]
1231 * See LookupPrivilegeNameW.
1234 LookupPrivilegeNameA( LPCSTR lpSystemName
, PLUID lpLuid
, LPSTR lpName
,
1237 UNICODE_STRING lpSystemNameW
;
1241 TRACE("%s %p %p %p\n", debugstr_a(lpSystemName
), lpLuid
, lpName
, cchName
);
1243 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW
, lpSystemName
);
1244 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, NULL
, &wLen
);
1245 if (!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1247 LPWSTR lpNameW
= HeapAlloc(GetProcessHeap(), 0, wLen
* sizeof(WCHAR
));
1249 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, lpNameW
,
1253 /* Windows crashes if cchName is NULL, so will I */
1254 int len
= WideCharToMultiByte(CP_ACP
, 0, lpNameW
, -1, lpName
,
1255 *cchName
, NULL
, NULL
);
1259 /* WideCharToMultiByte failed */
1262 else if (len
> *cchName
)
1265 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1270 /* WideCharToMultiByte succeeded, output length needs to be
1271 * length not including NULL terminator
1276 HeapFree(GetProcessHeap(), 0, lpNameW
);
1278 RtlFreeUnicodeString(&lpSystemNameW
);
1282 /******************************************************************************
1283 * LookupPrivilegeNameW [ADVAPI32.@]
1285 * Retrieves the privilege name referred to by the LUID lpLuid.
1288 * lpSystemName [I] Name of the system
1289 * lpLuid [I] Privilege value
1290 * lpName [O] Name of the privilege
1291 * cchName [I/O] Number of characters in lpName.
1294 * Success: TRUE. lpName contains the name of the privilege whose value is
1299 * Only well-known privilege names (those defined in winnt.h) can be retrieved
1300 * using this function.
1301 * If the length of lpName is too small, on return *cchName will contain the
1302 * number of WCHARs needed to contain the privilege, including the NULL
1303 * terminator, and GetLastError will return ERROR_INSUFFICIENT_BUFFER.
1304 * On success, *cchName will contain the number of characters stored in
1305 * lpName, NOT including the NULL terminator.
1308 LookupPrivilegeNameW( LPCWSTR lpSystemName
, PLUID lpLuid
, LPWSTR lpName
,
1313 TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName
), lpLuid
, lpName
, cchName
);
1315 if (!ADVAPI_IsLocalComputer(lpSystemName
))
1317 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
1320 if (lpLuid
->HighPart
|| (lpLuid
->LowPart
< SE_MIN_WELL_KNOWN_PRIVILEGE
||
1321 lpLuid
->LowPart
> SE_MAX_WELL_KNOWN_PRIVILEGE
))
1323 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1326 privNameLen
= strlenW(WellKnownPrivNames
[lpLuid
->LowPart
]);
1327 /* Windows crashes if cchName is NULL, so will I */
1328 if (*cchName
<= privNameLen
)
1330 *cchName
= privNameLen
+ 1;
1331 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1336 strcpyW(lpName
, WellKnownPrivNames
[lpLuid
->LowPart
]);
1337 *cchName
= privNameLen
;
1342 /******************************************************************************
1343 * GetFileSecurityA [ADVAPI32.@]
1345 * Obtains Specified information about the security of a file or directory.
1348 * lpFileName [I] Name of the file to get info for
1349 * RequestedInformation [I] SE_ flags from "winnt.h"
1350 * pSecurityDescriptor [O] Destination for security information
1351 * nLength [I] Length of pSecurityDescriptor
1352 * lpnLengthNeeded [O] Destination for length of returned security information
1355 * Success: TRUE. pSecurityDescriptor contains the requested information.
1356 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
1359 * The information returned is constrained by the callers access rights and
1363 GetFileSecurityA( LPCSTR lpFileName
,
1364 SECURITY_INFORMATION RequestedInformation
,
1365 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1366 DWORD nLength
, LPDWORD lpnLengthNeeded
)
1374 len
= MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, NULL
, 0 );
1375 name
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
1376 MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, name
, len
);
1379 r
= GetFileSecurityW( name
, RequestedInformation
, pSecurityDescriptor
,
1380 nLength
, lpnLengthNeeded
);
1381 HeapFree( GetProcessHeap(), 0, name
);
1386 /******************************************************************************
1387 * GetFileSecurityW [ADVAPI32.@]
1389 * See GetFileSecurityA.
1392 GetFileSecurityW( LPCWSTR lpFileName
,
1393 SECURITY_INFORMATION RequestedInformation
,
1394 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1395 DWORD nLength
, LPDWORD lpnLengthNeeded
)
1400 SECURITY_DESCRIPTOR_RELATIVE
*pSDRelative
;
1402 if(INVALID_FILE_ATTRIBUTES
== GetFileAttributesW(lpFileName
))
1405 FIXME("(%s) : returns fake SECURITY_DESCRIPTOR\n", debugstr_w(lpFileName
) );
1407 nNeeded
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
1408 if (RequestedInformation
& OWNER_SECURITY_INFORMATION
)
1409 nNeeded
+= sizeof(sidWorld
);
1410 if (RequestedInformation
& GROUP_SECURITY_INFORMATION
)
1411 nNeeded
+= sizeof(sidWorld
);
1412 if (RequestedInformation
& DACL_SECURITY_INFORMATION
)
1413 nNeeded
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1414 if (RequestedInformation
& SACL_SECURITY_INFORMATION
)
1415 nNeeded
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1417 *lpnLengthNeeded
= nNeeded
;
1419 if (nNeeded
> nLength
)
1422 if (!InitializeSecurityDescriptor(pSecurityDescriptor
, SECURITY_DESCRIPTOR_REVISION
))
1425 pSDRelative
= (PISECURITY_DESCRIPTOR_RELATIVE
) pSecurityDescriptor
;
1426 pSDRelative
->Control
|= SE_SELF_RELATIVE
;
1427 pBuffer
= (LPBYTE
) pSDRelative
;
1428 iLocNow
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
1430 if (RequestedInformation
& OWNER_SECURITY_INFORMATION
)
1432 memcpy(pBuffer
+ iLocNow
, &sidWorld
, sizeof(sidWorld
));
1433 pSDRelative
->Owner
= iLocNow
;
1434 iLocNow
+= sizeof(sidWorld
);
1436 if (RequestedInformation
& GROUP_SECURITY_INFORMATION
)
1438 memcpy(pBuffer
+ iLocNow
, &sidWorld
, sizeof(sidWorld
));
1439 pSDRelative
->Group
= iLocNow
;
1440 iLocNow
+= sizeof(sidWorld
);
1442 if (RequestedInformation
& DACL_SECURITY_INFORMATION
)
1444 GetWorldAccessACL((PACL
) (pBuffer
+ iLocNow
));
1445 pSDRelative
->Dacl
= iLocNow
;
1446 iLocNow
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1448 if (RequestedInformation
& SACL_SECURITY_INFORMATION
)
1450 GetWorldAccessACL((PACL
) (pBuffer
+ iLocNow
));
1451 pSDRelative
->Sacl
= iLocNow
;
1452 /* iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL; */
1458 /******************************************************************************
1459 * LookupAccountSidA [ADVAPI32.@]
1466 IN OUT LPDWORD accountSize
,
1468 IN OUT LPDWORD domainSize
,
1469 OUT PSID_NAME_USE name_use
)
1471 static const char ac
[] = "Administrator";
1472 static const char dm
[] = "DOMAIN";
1473 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1474 debugstr_a(system
),sid
,
1475 account
,accountSize
,accountSize
?*accountSize
:0,
1476 domain
,domainSize
,domainSize
?*domainSize
:0,
1479 if (accountSize
) *accountSize
= strlen(ac
)+1;
1480 if (account
&& (*accountSize
> strlen(ac
)))
1481 strcpy(account
, ac
);
1483 if (domainSize
) *domainSize
= strlen(dm
)+1;
1484 if (domain
&& (*domainSize
> strlen(dm
)))
1487 if (name_use
) *name_use
= SidTypeUser
;
1491 /******************************************************************************
1492 * LookupAccountSidW [ADVAPI32.@]
1508 IN OUT LPDWORD accountSize
,
1510 IN OUT LPDWORD domainSize
,
1511 OUT PSID_NAME_USE name_use
)
1513 static const WCHAR ac
[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
1514 static const WCHAR dm
[] = {'D','O','M','A','I','N',0};
1515 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1516 debugstr_w(system
),sid
,
1517 account
,accountSize
,accountSize
?*accountSize
:0,
1518 domain
,domainSize
,domainSize
?*domainSize
:0,
1521 if (accountSize
) *accountSize
= strlenW(ac
)+1;
1522 if (account
&& (*accountSize
> strlenW(ac
)))
1523 strcpyW(account
, ac
);
1525 if (domainSize
) *domainSize
= strlenW(dm
)+1;
1526 if (domain
&& (*domainSize
> strlenW(dm
)))
1529 if (name_use
) *name_use
= SidTypeUser
;
1533 /******************************************************************************
1534 * SetFileSecurityA [ADVAPI32.@]
1536 * See SetFileSecurityW.
1538 BOOL WINAPI
SetFileSecurityA( LPCSTR lpFileName
,
1539 SECURITY_INFORMATION RequestedInformation
,
1540 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
1548 len
= MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, NULL
, 0 );
1549 name
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
1550 MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, name
, len
);
1553 r
= SetFileSecurityW( name
, RequestedInformation
, pSecurityDescriptor
);
1554 HeapFree( GetProcessHeap(), 0, name
);
1559 /******************************************************************************
1560 * SetFileSecurityW [ADVAPI32.@]
1562 * Sets the security of a file or directory.
1566 * RequestedInformation []
1567 * pSecurityDescriptor []
1574 SetFileSecurityW( LPCWSTR lpFileName
,
1575 SECURITY_INFORMATION RequestedInformation
,
1576 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
1578 FIXME("(%s) : stub\n", debugstr_w(lpFileName
) );
1582 /******************************************************************************
1583 * QueryWindows31FilesMigration [ADVAPI32.@]
1589 QueryWindows31FilesMigration( DWORD x1
)
1591 FIXME("(%ld):stub\n",x1
);
1595 /******************************************************************************
1596 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
1605 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1
, DWORD x2
, DWORD x3
,
1608 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1
,x2
,x3
,x4
);
1612 /******************************************************************************
1613 * NotifyBootConfigStatus [ADVAPI32.@]
1619 NotifyBootConfigStatus( DWORD x1
)
1621 FIXME("(0x%08lx):stub\n",x1
);
1625 /******************************************************************************
1626 * RevertToSelf [ADVAPI32.@]
1628 * Ends the impersonation of a user.
1638 RevertToSelf( void )
1640 HANDLE Token
= NULL
;
1641 return set_ntstatus( NtSetInformationThread( GetCurrentThread(),
1642 ThreadImpersonationToken
, &Token
, sizeof(Token
) ) );
1645 /******************************************************************************
1646 * ImpersonateSelf [ADVAPI32.@]
1648 * Makes an impersonation token that represents the process user and assigns
1649 * to the current thread.
1652 * ImpersonationLevel [I] Level at which to impersonate.
1659 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
1661 return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel
) );
1664 /******************************************************************************
1665 * ImpersonateLoggedOnUser [ADVAPI32.@]
1667 BOOL WINAPI
ImpersonateLoggedOnUser(HANDLE hToken
)
1669 FIXME("(%p):stub returning FALSE\n", hToken
);
1673 /******************************************************************************
1674 * AccessCheck [ADVAPI32.@]
1678 PSECURITY_DESCRIPTOR SecurityDescriptor
,
1680 DWORD DesiredAccess
,
1681 PGENERIC_MAPPING GenericMapping
,
1682 PPRIVILEGE_SET PrivilegeSet
,
1683 LPDWORD PrivilegeSetLength
,
1684 LPDWORD GrantedAccess
,
1685 LPBOOL AccessStatus
)
1687 NTSTATUS access_status
;
1688 BOOL ret
= set_ntstatus( NtAccessCheck(SecurityDescriptor
, ClientToken
, DesiredAccess
,
1689 GenericMapping
, PrivilegeSet
, PrivilegeSetLength
,
1690 GrantedAccess
, &access_status
) );
1691 if (ret
) *AccessStatus
= set_ntstatus( access_status
);
1696 /******************************************************************************
1697 * AccessCheckByType [ADVAPI32.@]
1699 BOOL WINAPI
AccessCheckByType(
1700 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1701 PSID PrincipalSelfSid
,
1703 DWORD DesiredAccess
,
1704 POBJECT_TYPE_LIST ObjectTypeList
,
1705 DWORD ObjectTypeListLength
,
1706 PGENERIC_MAPPING GenericMapping
,
1707 PPRIVILEGE_SET PrivilegeSet
,
1708 LPDWORD PrivilegeSetLength
,
1709 LPDWORD GrantedAccess
,
1710 LPBOOL AccessStatus
)
1714 *AccessStatus
= TRUE
;
1716 return !*AccessStatus
;
1719 /******************************************************************************
1720 * MapGenericMask [ADVAPI32.@]
1722 * Maps generic access rights into specific access rights according to the
1726 * AccessMask [I/O] Access rights.
1727 * GenericMapping [I] The mapping between generic and specific rights.
1732 VOID WINAPI
MapGenericMask( PDWORD AccessMask
, PGENERIC_MAPPING GenericMapping
)
1734 RtlMapGenericMask( AccessMask
, GenericMapping
);
1737 /*************************************************************************
1738 * SetKernelObjectSecurity [ADVAPI32.@]
1740 BOOL WINAPI
SetKernelObjectSecurity (
1742 IN SECURITY_INFORMATION SecurityInformation
,
1743 IN PSECURITY_DESCRIPTOR SecurityDescriptor
)
1745 return set_ntstatus (NtSetSecurityObject (Handle
, SecurityInformation
, SecurityDescriptor
));
1749 /******************************************************************************
1750 * AddAuditAccessAce [ADVAPI32.@]
1752 BOOL WINAPI
AddAuditAccessAce(
1754 IN DWORD dwAceRevision
,
1755 IN DWORD dwAccessMask
,
1757 IN BOOL bAuditSuccess
,
1758 IN BOOL bAuditFailure
)
1760 return set_ntstatus( RtlAddAuditAccessAce(pAcl
, dwAceRevision
, dwAccessMask
, pSid
,
1761 bAuditSuccess
, bAuditFailure
) );
1764 /******************************************************************************
1765 * LookupAccountNameA [ADVAPI32.@]
1773 LPSTR ReferencedDomainName
,
1774 IN OUT LPDWORD cbReferencedDomainName
,
1775 OUT PSID_NAME_USE name_use
)
1777 /* Default implementation: Always return a default SID */
1778 SID_IDENTIFIER_AUTHORITY identifierAuthority
= {SECURITY_NT_AUTHORITY
};
1781 static const char dm
[] = "DOMAIN";
1783 FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system
,account
,sid
,cbSid
,ReferencedDomainName
,cbReferencedDomainName
,name_use
);
1785 ret
= AllocateAndInitializeSid(&identifierAuthority
,
1787 SECURITY_BUILTIN_DOMAIN_RID
,
1788 DOMAIN_ALIAS_RID_ADMINS
,
1794 if(!RtlValidSid(pSid
))
1800 if (sid
!= NULL
&& (*cbSid
>= GetLengthSid(pSid
)))
1801 CopySid(*cbSid
, sid
, pSid
);
1802 if (*cbSid
< GetLengthSid(pSid
))
1804 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1807 *cbSid
= GetLengthSid(pSid
);
1809 if (ReferencedDomainName
!= NULL
&& (*cbReferencedDomainName
> strlen(dm
)))
1810 strcpy(ReferencedDomainName
, dm
);
1811 if (*cbReferencedDomainName
<= strlen(dm
))
1813 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1816 *cbReferencedDomainName
= strlen(dm
)+1;
1823 /******************************************************************************
1824 * LookupAccountNameW [ADVAPI32.@]
1826 BOOL WINAPI
LookupAccountNameW( LPCWSTR lpSystemName
, LPCWSTR lpAccountName
, PSID Sid
,
1827 LPDWORD cbSid
, LPWSTR ReferencedDomainName
,
1828 LPDWORD cchReferencedDomainName
, PSID_NAME_USE peUse
)
1830 FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName
), debugstr_w(lpAccountName
),
1831 Sid
, cbSid
, ReferencedDomainName
, cchReferencedDomainName
, peUse
);
1836 /******************************************************************************
1837 * PrivilegeCheck [ADVAPI32.@]
1839 BOOL WINAPI
PrivilegeCheck( HANDLE ClientToken
, PPRIVILEGE_SET RequiredPrivileges
, LPBOOL pfResult
)
1844 TRACE("%p %p %p\n", ClientToken
, RequiredPrivileges
, pfResult
);
1846 ret
= set_ntstatus (NtPrivilegeCheck (ClientToken
, RequiredPrivileges
, &Result
));
1852 /******************************************************************************
1853 * AccessCheckAndAuditAlarmA [ADVAPI32.@]
1855 BOOL WINAPI
AccessCheckAndAuditAlarmA(LPCSTR Subsystem
, LPVOID HandleId
, LPSTR ObjectTypeName
,
1856 LPSTR ObjectName
, PSECURITY_DESCRIPTOR SecurityDescriptor
, DWORD DesiredAccess
,
1857 PGENERIC_MAPPING GenericMapping
, BOOL ObjectCreation
, LPDWORD GrantedAccess
,
1858 LPBOOL AccessStatus
, LPBOOL pfGenerateOnClose
)
1860 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem
),
1861 HandleId
, debugstr_a(ObjectTypeName
), debugstr_a(ObjectName
),
1862 SecurityDescriptor
, DesiredAccess
, GenericMapping
,
1863 ObjectCreation
, GrantedAccess
, AccessStatus
, pfGenerateOnClose
);
1867 /******************************************************************************
1868 * AccessCheckAndAuditAlarmW [ADVAPI32.@]
1870 BOOL WINAPI
AccessCheckAndAuditAlarmW(LPCWSTR Subsystem
, LPVOID HandleId
, LPWSTR ObjectTypeName
,
1871 LPWSTR ObjectName
, PSECURITY_DESCRIPTOR SecurityDescriptor
, DWORD DesiredAccess
,
1872 PGENERIC_MAPPING GenericMapping
, BOOL ObjectCreation
, LPDWORD GrantedAccess
,
1873 LPBOOL AccessStatus
, LPBOOL pfGenerateOnClose
)
1875 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem
),
1876 HandleId
, debugstr_w(ObjectTypeName
), debugstr_w(ObjectName
),
1877 SecurityDescriptor
, DesiredAccess
, GenericMapping
,
1878 ObjectCreation
, GrantedAccess
, AccessStatus
, pfGenerateOnClose
);
1882 BOOL WINAPI
ObjectCloseAuditAlarmA(LPCSTR SubsystemName
, LPVOID HandleId
, BOOL GenerateOnClose
)
1884 FIXME("stub (%s,%p,%x)\n", debugstr_a(SubsystemName
), HandleId
, GenerateOnClose
);
1889 BOOL WINAPI
ObjectCloseAuditAlarmW(LPCWSTR SubsystemName
, LPVOID HandleId
, BOOL GenerateOnClose
)
1891 FIXME("stub (%s,%p,%x)\n", debugstr_w(SubsystemName
), HandleId
, GenerateOnClose
);
1896 BOOL WINAPI
ObjectOpenAuditAlarmA(LPCSTR SubsystemName
, LPVOID HandleId
, LPSTR ObjectTypeName
,
1897 LPSTR ObjectName
, PSECURITY_DESCRIPTOR pSecurityDescriptor
, HANDLE ClientToken
, DWORD DesiredAccess
,
1898 DWORD GrantedAccess
, PPRIVILEGE_SET Privileges
, BOOL ObjectCreation
, BOOL AccessGranted
,
1899 LPBOOL GenerateOnClose
)
1901 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_a(SubsystemName
),
1902 HandleId
, debugstr_a(ObjectTypeName
), debugstr_a(ObjectName
), pSecurityDescriptor
,
1903 ClientToken
, DesiredAccess
, GrantedAccess
, Privileges
, ObjectCreation
, AccessGranted
,
1909 BOOL WINAPI
ObjectOpenAuditAlarmW(LPCWSTR SubsystemName
, LPVOID HandleId
, LPWSTR ObjectTypeName
,
1910 LPWSTR ObjectName
, PSECURITY_DESCRIPTOR pSecurityDescriptor
, HANDLE ClientToken
, DWORD DesiredAccess
,
1911 DWORD GrantedAccess
, PPRIVILEGE_SET Privileges
, BOOL ObjectCreation
, BOOL AccessGranted
,
1912 LPBOOL GenerateOnClose
)
1914 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_w(SubsystemName
),
1915 HandleId
, debugstr_w(ObjectTypeName
), debugstr_w(ObjectName
), pSecurityDescriptor
,
1916 ClientToken
, DesiredAccess
, GrantedAccess
, Privileges
, ObjectCreation
, AccessGranted
,
1922 BOOL WINAPI
ObjectPrivilegeAuditAlarmA( LPCSTR SubsystemName
, LPVOID HandleId
, HANDLE ClientToken
,
1923 DWORD DesiredAccess
, PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1925 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_a(SubsystemName
), HandleId
, ClientToken
,
1926 DesiredAccess
, Privileges
, AccessGranted
);
1931 BOOL WINAPI
ObjectPrivilegeAuditAlarmW( LPCWSTR SubsystemName
, LPVOID HandleId
, HANDLE ClientToken
,
1932 DWORD DesiredAccess
, PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1934 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_w(SubsystemName
), HandleId
, ClientToken
,
1935 DesiredAccess
, Privileges
, AccessGranted
);
1940 BOOL WINAPI
PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName
, LPCSTR ServiceName
, HANDLE ClientToken
,
1941 PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1943 FIXME("stub (%s,%s,%p,%p,%x)\n", debugstr_a(SubsystemName
), debugstr_a(ServiceName
),
1944 ClientToken
, Privileges
, AccessGranted
);
1949 BOOL WINAPI
PrivilegedServiceAuditAlarmW( LPCWSTR SubsystemName
, LPCWSTR ServiceName
, HANDLE ClientToken
,
1950 PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1952 FIXME("stub %s,%s,%p,%p,%x)\n", debugstr_w(SubsystemName
), debugstr_w(ServiceName
),
1953 ClientToken
, Privileges
, AccessGranted
);
1958 /******************************************************************************
1959 * GetSecurityInfo [ADVAPI32.@]
1961 DWORD WINAPI
GetSecurityInfo(
1962 HANDLE hObject
, SE_OBJECT_TYPE ObjectType
,
1963 SECURITY_INFORMATION SecurityInfo
, PSID
*ppsidOwner
,
1964 PSID
*ppsidGroup
, PACL
*ppDacl
, PACL
*ppSacl
,
1965 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
1969 return ERROR_BAD_PROVIDER
;
1972 /******************************************************************************
1973 * GetSecurityInfoExW [ADVAPI32.@]
1975 DWORD WINAPI
GetSecurityInfoExW(
1976 HANDLE hObject
, SE_OBJECT_TYPE ObjectType
,
1977 SECURITY_INFORMATION SecurityInfo
, LPCWSTR lpProvider
,
1978 LPCWSTR lpProperty
, PACTRL_ACCESSW
*ppAccessList
,
1979 PACTRL_AUDITW
*ppAuditList
, LPWSTR
*lppOwner
, LPWSTR
*lppGroup
1983 return ERROR_BAD_PROVIDER
;
1986 /******************************************************************************
1987 * BuildExplicitAccessWithNameA [ADVAPI32.@]
1989 VOID WINAPI
BuildExplicitAccessWithNameA( PEXPLICIT_ACCESSA pExplicitAccess
,
1990 LPSTR pTrusteeName
, DWORD AccessPermissions
,
1991 ACCESS_MODE AccessMode
, DWORD Inheritance
)
1993 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess
, debugstr_a(pTrusteeName
),
1994 AccessPermissions
, AccessMode
, Inheritance
);
1996 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
1997 pExplicitAccess
->grfAccessMode
= AccessMode
;
1998 pExplicitAccess
->grfInheritance
= Inheritance
;
2000 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
2001 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2002 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
2003 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2004 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
2007 /******************************************************************************
2008 * BuildExplicitAccessWithNameW [ADVAPI32.@]
2010 VOID WINAPI
BuildExplicitAccessWithNameW( PEXPLICIT_ACCESSW pExplicitAccess
,
2011 LPWSTR pTrusteeName
, DWORD AccessPermissions
,
2012 ACCESS_MODE AccessMode
, DWORD Inheritance
)
2014 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess
, debugstr_w(pTrusteeName
),
2015 AccessPermissions
, AccessMode
, Inheritance
);
2017 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
2018 pExplicitAccess
->grfAccessMode
= AccessMode
;
2019 pExplicitAccess
->grfInheritance
= Inheritance
;
2021 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
2022 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2023 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
2024 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2025 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
2028 /******************************************************************************
2029 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
2031 VOID WINAPI
BuildTrusteeWithObjectsAndNameA( PTRUSTEEA pTrustee
, POBJECTS_AND_NAME_A pObjName
,
2032 SE_OBJECT_TYPE ObjectType
, LPSTR ObjectTypeName
,
2033 LPSTR InheritedObjectTypeName
, LPSTR Name
)
2035 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
2036 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, debugstr_a(Name
));
2038 pTrustee
->pMultipleTrustee
= NULL
;
2039 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2040 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
2041 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2042 pTrustee
->ptstrName
= Name
;
2045 /******************************************************************************
2046 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
2048 VOID WINAPI
BuildTrusteeWithObjectsAndNameW( PTRUSTEEW pTrustee
, POBJECTS_AND_NAME_W pObjName
,
2049 SE_OBJECT_TYPE ObjectType
, LPWSTR ObjectTypeName
,
2050 LPWSTR InheritedObjectTypeName
, LPWSTR Name
)
2052 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
2053 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, debugstr_w(Name
));
2055 pTrustee
->pMultipleTrustee
= NULL
;
2056 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2057 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
2058 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2059 pTrustee
->ptstrName
= Name
;
2062 VOID WINAPI
BuildTrusteeWithObjectsAndSidA( PTRUSTEEA pTrustee
, POBJECTS_AND_SID pObjSid
,
2063 GUID
* pObjectGuid
, GUID
* pInheritedObjectGuid
, PSID pSid
)
2065 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
2067 pTrustee
->pMultipleTrustee
= NULL
;
2068 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2069 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
2070 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2071 pTrustee
->ptstrName
= (LPSTR
) pSid
;
2074 VOID WINAPI
BuildTrusteeWithObjectsAndSidW( PTRUSTEEW pTrustee
, POBJECTS_AND_SID pObjSid
,
2075 GUID
* pObjectGuid
, GUID
* pInheritedObjectGuid
, PSID pSid
)
2077 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
2079 pTrustee
->pMultipleTrustee
= NULL
;
2080 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2081 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
2082 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2083 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
2086 /******************************************************************************
2087 * BuildTrusteeWithSidA [ADVAPI32.@]
2089 VOID WINAPI
BuildTrusteeWithSidA(PTRUSTEEA pTrustee
, PSID pSid
)
2091 TRACE("%p %p\n", pTrustee
, pSid
);
2093 pTrustee
->pMultipleTrustee
= NULL
;
2094 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2095 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
2096 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2097 pTrustee
->ptstrName
= (LPSTR
) pSid
;
2100 /******************************************************************************
2101 * BuildTrusteeWithSidW [ADVAPI32.@]
2103 VOID WINAPI
BuildTrusteeWithSidW(PTRUSTEEW pTrustee
, PSID pSid
)
2105 TRACE("%p %p\n", pTrustee
, pSid
);
2107 pTrustee
->pMultipleTrustee
= NULL
;
2108 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2109 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
2110 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2111 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
2114 /******************************************************************************
2115 * BuildTrusteeWithNameA [ADVAPI32.@]
2117 VOID WINAPI
BuildTrusteeWithNameA(PTRUSTEEA pTrustee
, LPSTR name
)
2119 TRACE("%p %s\n", pTrustee
, debugstr_a(name
) );
2121 pTrustee
->pMultipleTrustee
= NULL
;
2122 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2123 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
2124 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2125 pTrustee
->ptstrName
= name
;
2128 /******************************************************************************
2129 * BuildTrusteeWithNameW [ADVAPI32.@]
2131 VOID WINAPI
BuildTrusteeWithNameW(PTRUSTEEW pTrustee
, LPWSTR name
)
2133 TRACE("%p %s\n", pTrustee
, debugstr_w(name
) );
2135 pTrustee
->pMultipleTrustee
= NULL
;
2136 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2137 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
2138 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2139 pTrustee
->ptstrName
= name
;
2142 /******************************************************************************
2143 * GetTrusteeFormA [ADVAPI32.@]
2145 TRUSTEE_FORM WINAPI
GetTrusteeFormA(PTRUSTEEA pTrustee
)
2147 TRACE("(%p)\n", pTrustee
);
2150 return TRUSTEE_BAD_FORM
;
2152 return pTrustee
->TrusteeForm
;
2155 /******************************************************************************
2156 * GetTrusteeFormW [ADVAPI32.@]
2158 TRUSTEE_FORM WINAPI
GetTrusteeFormW(PTRUSTEEW pTrustee
)
2160 TRACE("(%p)\n", pTrustee
);
2163 return TRUSTEE_BAD_FORM
;
2165 return pTrustee
->TrusteeForm
;
2168 /******************************************************************************
2169 * GetTrusteeNameA [ADVAPI32.@]
2171 LPSTR WINAPI
GetTrusteeNameA(PTRUSTEEA pTrustee
)
2173 TRACE("(%p)\n", pTrustee
);
2178 return pTrustee
->ptstrName
;
2181 /******************************************************************************
2182 * GetTrusteeNameW [ADVAPI32.@]
2184 LPWSTR WINAPI
GetTrusteeNameW(PTRUSTEEW pTrustee
)
2186 TRACE("(%p)\n", pTrustee
);
2191 return pTrustee
->ptstrName
;
2194 /******************************************************************************
2195 * GetTrusteeTypeA [ADVAPI32.@]
2197 TRUSTEE_TYPE WINAPI
GetTrusteeTypeA(PTRUSTEEA pTrustee
)
2199 TRACE("(%p)\n", pTrustee
);
2202 return TRUSTEE_IS_UNKNOWN
;
2204 return pTrustee
->TrusteeType
;
2207 /******************************************************************************
2208 * GetTrusteeTypeW [ADVAPI32.@]
2210 TRUSTEE_TYPE WINAPI
GetTrusteeTypeW(PTRUSTEEW pTrustee
)
2212 TRACE("(%p)\n", pTrustee
);
2215 return TRUSTEE_IS_UNKNOWN
;
2217 return pTrustee
->TrusteeType
;
2220 BOOL WINAPI
SetAclInformation( PACL pAcl
, LPVOID pAclInformation
,
2221 DWORD nAclInformationLength
,
2222 ACL_INFORMATION_CLASS dwAclInformationClass
)
2224 FIXME("%p %p 0x%08lx 0x%08x - stub\n", pAcl
, pAclInformation
,
2225 nAclInformationLength
, dwAclInformationClass
);
2230 /******************************************************************************
2231 * SetEntriesInAclA [ADVAPI32.@]
2233 DWORD WINAPI
SetEntriesInAclA( ULONG count
, PEXPLICIT_ACCESSA pEntries
,
2234 PACL OldAcl
, PACL
* NewAcl
)
2236 FIXME("%ld %p %p %p\n",count
,pEntries
,OldAcl
,NewAcl
);
2237 return ERROR_CALL_NOT_IMPLEMENTED
;
2240 /******************************************************************************
2241 * SetEntriesInAclW [ADVAPI32.@]
2243 DWORD WINAPI
SetEntriesInAclW( ULONG count
, PEXPLICIT_ACCESSW pEntries
,
2244 PACL OldAcl
, PACL
* NewAcl
)
2246 FIXME("%ld %p %p %p\n",count
,pEntries
,OldAcl
,NewAcl
);
2247 return ERROR_CALL_NOT_IMPLEMENTED
;
2250 /******************************************************************************
2251 * SetNamedSecurityInfoA [ADVAPI32.@]
2253 DWORD WINAPI
SetNamedSecurityInfoA(LPSTR pObjectName
,
2254 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
2255 PSID psidOwner
, PSID psidGroup
, PACL pDacl
, PACL pSacl
)
2261 TRACE("%s %d %ld %p %p %p %p\n", debugstr_a(pObjectName
), ObjectType
,
2262 SecurityInfo
, psidOwner
, psidGroup
, pDacl
, pSacl
);
2266 len
= MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, NULL
, 0 );
2267 wstr
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
));
2268 MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, wstr
, len
);
2271 r
= SetNamedSecurityInfoW( wstr
, ObjectType
, SecurityInfo
, psidOwner
,
2272 psidGroup
, pDacl
, pSacl
);
2274 HeapFree( GetProcessHeap(), 0, wstr
);
2279 BOOL WINAPI
SetPrivateObjectSecurity( SECURITY_INFORMATION SecurityInformation
,
2280 PSECURITY_DESCRIPTOR ModificationDescriptor
,
2281 PSECURITY_DESCRIPTOR
* ObjectsSecurityDescriptor
,
2282 PGENERIC_MAPPING GenericMapping
,
2285 FIXME("0x%08lx %p %p %p %p - stub\n", SecurityInformation
, ModificationDescriptor
,
2286 ObjectsSecurityDescriptor
, GenericMapping
, Token
);
2291 BOOL WINAPI
SetSecurityDescriptorControl( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
2292 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
2293 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
)
2295 FIXME("%p 0x%08x 0x%08x - stub\n", pSecurityDescriptor
, ControlBitsOfInterest
,
2301 BOOL WINAPI
AreAllAccessesGranted( DWORD GrantedAccess
, DWORD DesiredAccess
)
2303 return RtlAreAllAccessesGranted( GrantedAccess
, DesiredAccess
);
2306 /******************************************************************************
2307 * AreAnyAccessesGranted [ADVAPI32.@]
2309 * Determines whether or not any of a set of specified access permissions have
2310 * been granted or not.
2313 * GrantedAccess [I] The permissions that have been granted.
2314 * DesiredAccess [I] The permissions that you want to have.
2317 * Nonzero if any of the permissions have been granted, zero if none of the
2318 * permissions have been granted.
2321 BOOL WINAPI
AreAnyAccessesGranted( DWORD GrantedAccess
, DWORD DesiredAccess
)
2323 return RtlAreAnyAccessesGranted( GrantedAccess
, DesiredAccess
);
2326 /******************************************************************************
2327 * SetNamedSecurityInfoW [ADVAPI32.@]
2329 DWORD WINAPI
SetNamedSecurityInfoW(LPWSTR pObjectName
,
2330 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
2331 PSID psidOwner
, PSID psidGroup
, PACL pDacl
, PACL pSacl
)
2333 FIXME("%s %d %ld %p %p %p %p\n", debugstr_w(pObjectName
), ObjectType
,
2334 SecurityInfo
, psidOwner
, psidGroup
, pDacl
, pSacl
);
2335 return ERROR_SUCCESS
;
2338 /******************************************************************************
2339 * GetExplicitEntriesFromAclA [ADVAPI32.@]
2341 DWORD WINAPI
GetExplicitEntriesFromAclA( PACL pacl
, PULONG pcCountOfExplicitEntries
,
2342 PEXPLICIT_ACCESSA
* pListOfExplicitEntries
)
2344 FIXME("%p %p %p\n",pacl
, pcCountOfExplicitEntries
, pListOfExplicitEntries
);
2345 return ERROR_CALL_NOT_IMPLEMENTED
;
2348 /******************************************************************************
2349 * GetExplicitEntriesFromAclW [ADVAPI32.@]
2351 DWORD WINAPI
GetExplicitEntriesFromAclW( PACL pacl
, PULONG pcCountOfExplicitEntries
,
2352 PEXPLICIT_ACCESSW
* pListOfExplicitEntries
)
2354 FIXME("%p %p %p\n",pacl
, pcCountOfExplicitEntries
, pListOfExplicitEntries
);
2355 return ERROR_CALL_NOT_IMPLEMENTED
;
2359 /******************************************************************************
2360 * ParseAclStringFlags
2362 static DWORD
ParseAclStringFlags(LPCWSTR
* StringAcl
)
2365 LPCWSTR szAcl
= *StringAcl
;
2367 while (*szAcl
!= '(')
2371 flags
|= SE_DACL_PROTECTED
;
2373 else if (*szAcl
== 'A')
2377 flags
|= SE_DACL_AUTO_INHERIT_REQ
;
2378 else if (*szAcl
== 'I')
2379 flags
|= SE_DACL_AUTO_INHERITED
;
2388 /******************************************************************************
2389 * ParseAceStringType
2393 { SDDL_ACCESS_ALLOWED
, ACCESS_ALLOWED_ACE_TYPE
},
2394 { SDDL_ALARM
, SYSTEM_ALARM_ACE_TYPE
},
2395 { SDDL_AUDIT
, SYSTEM_AUDIT_ACE_TYPE
},
2396 { SDDL_ACCESS_DENIED
, ACCESS_DENIED_ACE_TYPE
},
2398 { SDDL_OBJECT_ACCESS_ALLOWED, ACCESS_ALLOWED_OBJECT_ACE_TYPE },
2399 { SDDL_OBJECT_ACCESS_DENIED, ACCESS_DENIED_OBJECT_ACE_TYPE },
2400 { SDDL_OBJECT_ALARM, SYSTEM_ALARM_OBJECT_ACE_TYPE },
2401 { SDDL_OBJECT_AUDIT, SYSTEM_AUDIT_OBJECT_ACE_TYPE },
2406 static BYTE
ParseAceStringType(LPCWSTR
* StringAcl
)
2409 LPCWSTR szAcl
= *StringAcl
;
2410 LPACEFLAG lpaf
= AceType
;
2412 while (lpaf
->wstr
&&
2413 (len
= strlenW(lpaf
->wstr
)) &&
2414 strncmpW(lpaf
->wstr
, szAcl
, len
))
2425 /******************************************************************************
2426 * ParseAceStringFlags
2428 ACEFLAG AceFlags
[] =
2430 { SDDL_CONTAINER_INHERIT
, CONTAINER_INHERIT_ACE
},
2431 { SDDL_AUDIT_FAILURE
, FAILED_ACCESS_ACE_FLAG
},
2432 { SDDL_INHERITED
, INHERITED_ACE
},
2433 { SDDL_INHERIT_ONLY
, INHERIT_ONLY_ACE
},
2434 { SDDL_NO_PROPAGATE
, NO_PROPAGATE_INHERIT_ACE
},
2435 { SDDL_OBJECT_INHERIT
, OBJECT_INHERIT_ACE
},
2436 { SDDL_AUDIT_SUCCESS
, SUCCESSFUL_ACCESS_ACE_FLAG
},
2440 static BYTE
ParseAceStringFlags(LPCWSTR
* StringAcl
)
2444 LPCWSTR szAcl
= *StringAcl
;
2446 while (*szAcl
!= ';')
2448 LPACEFLAG lpaf
= AceFlags
;
2450 while (lpaf
->wstr
&&
2451 (len
= strlenW(lpaf
->wstr
)) &&
2452 strncmpW(lpaf
->wstr
, szAcl
, len
))
2458 flags
|= lpaf
->value
;
2467 /******************************************************************************
2468 * ParseAceStringRights
2470 ACEFLAG AceRights
[] =
2472 { SDDL_GENERIC_ALL
, GENERIC_ALL
},
2473 { SDDL_GENERIC_READ
, GENERIC_READ
},
2474 { SDDL_GENERIC_WRITE
, GENERIC_WRITE
},
2475 { SDDL_GENERIC_EXECUTE
, GENERIC_EXECUTE
},
2476 { SDDL_READ_CONTROL
, READ_CONTROL
},
2477 { SDDL_STANDARD_DELETE
, DELETE
},
2478 { SDDL_WRITE_DAC
, WRITE_DAC
},
2479 { SDDL_WRITE_OWNER
, WRITE_OWNER
},
2483 static DWORD
ParseAceStringRights(LPCWSTR
* StringAcl
)
2487 LPCWSTR szAcl
= *StringAcl
;
2489 if ((*szAcl
== '0') && (*(szAcl
+ 1) == 'x'))
2493 while (*p
&& *p
!= ';')
2498 rights
= strtoulW(szAcl
, NULL
, 16);
2502 WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl
, p
- szAcl
));
2506 while (*szAcl
!= ';')
2508 LPACEFLAG lpaf
= AceRights
;
2510 while (lpaf
->wstr
&&
2511 (len
= strlenW(lpaf
->wstr
)) &&
2512 strncmpW(lpaf
->wstr
, szAcl
, len
))
2520 rights
|= lpaf
->value
;
2530 /******************************************************************************
2531 * ParseStringAclToAcl
2533 * dacl_flags(string_ace1)(string_ace2)... (string_acen)
2535 static BOOL
ParseStringAclToAcl(LPCWSTR StringAcl
, LPDWORD lpdwFlags
,
2536 PACL pAcl
, LPDWORD cBytes
)
2540 DWORD length
= sizeof(ACL
);
2541 PACCESS_ALLOWED_ACE pAce
= NULL
; /* pointer to current ACE */
2543 TRACE("%s\n", debugstr_w(StringAcl
));
2548 if (pAcl
) /* pAce is only useful if we're setting values */
2549 pAce
= (PACCESS_ALLOWED_ACE
) ((LPBYTE
)pAcl
+ sizeof(PACL
));
2551 /* Parse ACL flags */
2552 *lpdwFlags
= ParseAclStringFlags(&StringAcl
);
2555 while (*StringAcl
== '(')
2559 /* Parse ACE type */
2560 val
= ParseAceStringType(&StringAcl
);
2562 pAce
->Header
.AceType
= (BYTE
) val
;
2563 if (*StringAcl
!= ';')
2567 /* Parse ACE flags */
2568 val
= ParseAceStringFlags(&StringAcl
);
2570 pAce
->Header
.AceFlags
= (BYTE
) val
;
2571 if (*StringAcl
!= ';')
2575 /* Parse ACE rights */
2576 val
= ParseAceStringRights(&StringAcl
);
2579 if (*StringAcl
!= ';')
2583 /* Parse ACE object guid */
2584 if (*StringAcl
!= ';')
2586 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2591 /* Parse ACE inherit object guid */
2592 if (*StringAcl
!= ';')
2594 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2599 /* Parse ACE account sid */
2600 if (ParseStringSidToSid(StringAcl
, pAce
? (PSID
)&pAce
->SidStart
: NULL
, &sidlen
))
2602 while (*StringAcl
&& *StringAcl
!= ')')
2606 if (*StringAcl
!= ')')
2610 length
+= sizeof(ACCESS_ALLOWED_ACE
) - sizeof(DWORD
) + sidlen
;
2617 WARN("Invalid ACE string format\n");
2622 /******************************************************************************
2623 * ParseStringSecurityDescriptorToSecurityDescriptor
2625 static BOOL
ParseStringSecurityDescriptorToSecurityDescriptor(
2626 LPCWSTR StringSecurityDescriptor
,
2627 SECURITY_DESCRIPTOR
* SecurityDescriptor
,
2632 WCHAR tok
[MAX_PATH
];
2634 LPBYTE lpNext
= NULL
;
2639 if (SecurityDescriptor
)
2640 lpNext
= ((LPBYTE
) SecurityDescriptor
) + sizeof(SECURITY_DESCRIPTOR
);
2642 while (*StringSecurityDescriptor
)
2644 toktype
= *StringSecurityDescriptor
;
2646 /* Expect char identifier followed by ':' */
2647 StringSecurityDescriptor
++;
2648 if (*StringSecurityDescriptor
!= ':')
2650 SetLastError(ERROR_INVALID_PARAMETER
);
2653 StringSecurityDescriptor
++;
2656 lptoken
= StringSecurityDescriptor
;
2657 while (*lptoken
&& *lptoken
!= ':')
2663 len
= lptoken
- StringSecurityDescriptor
;
2664 memcpy( tok
, StringSecurityDescriptor
, len
* sizeof(WCHAR
) );
2673 if (!ParseStringSidToSid(tok
, (PSID
)lpNext
, &bytes
))
2676 if (SecurityDescriptor
)
2678 SecurityDescriptor
->Owner
= (PSID
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2679 lpNext
+= bytes
; /* Advance to next token */
2691 if (!ParseStringSidToSid(tok
, (PSID
)lpNext
, &bytes
))
2694 if (SecurityDescriptor
)
2696 SecurityDescriptor
->Group
= (PSID
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2697 lpNext
+= bytes
; /* Advance to next token */
2710 if (!ParseStringAclToAcl(tok
, &flags
, (PACL
)lpNext
, &bytes
))
2713 if (SecurityDescriptor
)
2715 SecurityDescriptor
->Control
|= SE_DACL_PRESENT
| flags
;
2716 SecurityDescriptor
->Dacl
= (PACL
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2717 lpNext
+= bytes
; /* Advance to next token */
2730 if (!ParseStringAclToAcl(tok
, &flags
, (PACL
)lpNext
, &bytes
))
2733 if (SecurityDescriptor
)
2735 SecurityDescriptor
->Control
|= SE_SACL_PRESENT
| flags
;
2736 SecurityDescriptor
->Sacl
= (PACL
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2737 lpNext
+= bytes
; /* Advance to next token */
2746 FIXME("Unknown token\n");
2747 SetLastError(ERROR_INVALID_PARAMETER
);
2751 StringSecurityDescriptor
= lptoken
;
2760 /******************************************************************************
2761 * ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@]
2763 BOOL WINAPI
ConvertStringSecurityDescriptorToSecurityDescriptorA(
2764 LPCSTR StringSecurityDescriptor
,
2765 DWORD StringSDRevision
,
2766 PSECURITY_DESCRIPTOR
* SecurityDescriptor
,
2767 PULONG SecurityDescriptorSize
)
2771 LPWSTR StringSecurityDescriptorW
;
2773 len
= MultiByteToWideChar(CP_ACP
, 0, StringSecurityDescriptor
, -1, NULL
, 0);
2774 StringSecurityDescriptorW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2776 if (StringSecurityDescriptorW
)
2778 MultiByteToWideChar(CP_ACP
, 0, StringSecurityDescriptor
, -1, StringSecurityDescriptorW
, len
);
2780 ret
= ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW
,
2781 StringSDRevision
, SecurityDescriptor
,
2782 SecurityDescriptorSize
);
2783 HeapFree(GetProcessHeap(), 0, StringSecurityDescriptorW
);
2789 /******************************************************************************
2790 * ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@]
2792 BOOL WINAPI
ConvertStringSecurityDescriptorToSecurityDescriptorW(
2793 LPCWSTR StringSecurityDescriptor
,
2794 DWORD StringSDRevision
,
2795 PSECURITY_DESCRIPTOR
* SecurityDescriptor
,
2796 PULONG SecurityDescriptorSize
)
2799 SECURITY_DESCRIPTOR
* psd
;
2802 TRACE("%s\n", debugstr_w(StringSecurityDescriptor
));
2804 if (GetVersion() & 0x80000000)
2806 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2809 else if (StringSDRevision
!= SID_REVISION
)
2811 SetLastError(ERROR_UNKNOWN_REVISION
);
2815 /* Compute security descriptor length */
2816 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor
,
2820 psd
= *SecurityDescriptor
= (SECURITY_DESCRIPTOR
*) LocalAlloc(
2821 GMEM_ZEROINIT
, cBytes
);
2823 psd
->Revision
= SID_REVISION
;
2824 psd
->Control
|= SE_SELF_RELATIVE
;
2826 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor
,
2833 if (SecurityDescriptorSize
)
2834 *SecurityDescriptorSize
= cBytes
;
2839 TRACE(" ret=%d\n", bret
);
2843 /******************************************************************************
2844 * ConvertStringSidToSidW [ADVAPI32.@]
2846 BOOL WINAPI
ConvertStringSidToSidW(LPCWSTR StringSid
, PSID
* Sid
)
2851 TRACE("%s, %p\n", debugstr_w(StringSid
), Sid
);
2852 if (GetVersion() & 0x80000000)
2853 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2854 else if (!StringSid
|| !Sid
)
2855 SetLastError(ERROR_INVALID_PARAMETER
);
2856 else if (ParseStringSidToSid(StringSid
, NULL
, &cBytes
))
2858 PSID pSid
= *Sid
= (PSID
) LocalAlloc(0, cBytes
);
2860 bret
= ParseStringSidToSid(StringSid
, pSid
, &cBytes
);
2864 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
2868 /******************************************************************************
2869 * ConvertStringSidToSidA [ADVAPI32.@]
2871 BOOL WINAPI
ConvertStringSidToSidA(LPCSTR StringSid
, PSID
* Sid
)
2875 TRACE("%s, %p\n", debugstr_a(StringSid
), Sid
);
2876 if (GetVersion() & 0x80000000)
2877 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2878 else if (!StringSid
|| !Sid
)
2879 SetLastError(ERROR_INVALID_PARAMETER
);
2882 UINT len
= MultiByteToWideChar(CP_ACP
, 0, StringSid
, -1, NULL
, 0);
2883 LPWSTR wStringSid
= HeapAlloc(GetProcessHeap(), 0,
2884 len
* sizeof(WCHAR
));
2886 MultiByteToWideChar(CP_ACP
, 0, StringSid
, -1, wStringSid
, len
);
2887 bret
= ConvertStringSidToSidW(wStringSid
, Sid
);
2888 HeapFree(GetProcessHeap(), 0, wStringSid
);
2890 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
2894 /******************************************************************************
2895 * ConvertSidToStringSidW [ADVAPI32.@]
2897 * format of SID string is:
2898 * S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>...
2900 * <rev> is the revision of the SID encoded as decimal
2901 * <auth> is the identifier authority encoded as hex
2902 * <subauthN> is the subauthority id encoded as decimal
2904 BOOL WINAPI
ConvertSidToStringSidW( PSID pSid
, LPWSTR
*pstr
)
2908 WCHAR fmt
[] = { 'S','-','%','u','-','%','d',0 };
2909 WCHAR subauthfmt
[] = { '-','%','u',0 };
2912 TRACE("%p %p\n", pSid
, pstr
);
2914 if( !IsValidSid( pSid
) )
2917 if (pisid
->Revision
!= SDDL_REVISION
)
2919 if (pisid
->IdentifierAuthority
.Value
[0] ||
2920 pisid
->IdentifierAuthority
.Value
[1])
2922 FIXME("not matching MS' bugs\n");
2926 sz
= 14 + pisid
->SubAuthorityCount
* 11;
2927 str
= LocalAlloc( 0, sz
*sizeof(WCHAR
) );
2928 sprintfW( str
, fmt
, pisid
->Revision
, MAKELONG(
2929 MAKEWORD( pisid
->IdentifierAuthority
.Value
[5],
2930 pisid
->IdentifierAuthority
.Value
[4] ),
2931 MAKEWORD( pisid
->IdentifierAuthority
.Value
[3],
2932 pisid
->IdentifierAuthority
.Value
[2] ) ) );
2933 for( i
=0; i
<pisid
->SubAuthorityCount
; i
++ )
2934 sprintfW( str
+ strlenW(str
), subauthfmt
, pisid
->SubAuthority
[i
] );
2940 /******************************************************************************
2941 * ConvertSidToStringSidA [ADVAPI32.@]
2943 BOOL WINAPI
ConvertSidToStringSidA(PSID pSid
, LPSTR
*pstr
)
2949 TRACE("%p %p\n", pSid
, pstr
);
2951 if( !ConvertSidToStringSidW( pSid
, &wstr
) )
2954 len
= WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, NULL
, 0, NULL
, NULL
);
2955 str
= LocalAlloc( 0, len
);
2956 WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, str
, len
, NULL
, NULL
);
2964 BOOL WINAPI
CreatePrivateObjectSecurity(
2965 PSECURITY_DESCRIPTOR ParentDescriptor
,
2966 PSECURITY_DESCRIPTOR CreatorDescriptor
,
2967 PSECURITY_DESCRIPTOR
* NewDescriptor
,
2968 BOOL IsDirectoryObject
,
2970 PGENERIC_MAPPING GenericMapping
)
2972 FIXME("%p %p %p %d %p %p - stub\n", ParentDescriptor
, CreatorDescriptor
,
2973 NewDescriptor
, IsDirectoryObject
, Token
, GenericMapping
);
2978 BOOL WINAPI
DestroyPrivateObjectSecurity( PSECURITY_DESCRIPTOR
* ObjectDescriptor
)
2980 FIXME("%p - stub\n", ObjectDescriptor
);
2985 BOOL WINAPI
CreateProcessAsUserA(
2987 LPCSTR lpApplicationName
,
2988 LPSTR lpCommandLine
,
2989 LPSECURITY_ATTRIBUTES lpProcessAttributes
,
2990 LPSECURITY_ATTRIBUTES lpThreadAttributes
,
2991 BOOL bInheritHandles
,
2992 DWORD dwCreationFlags
,
2993 LPVOID lpEnvironment
,
2994 LPCSTR lpCurrentDirectory
,
2995 LPSTARTUPINFOA lpStartupInfo
,
2996 LPPROCESS_INFORMATION lpProcessInformation
)
2998 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - stub\n", hToken
, debugstr_a(lpApplicationName
),
2999 debugstr_a(lpCommandLine
), lpProcessAttributes
, lpThreadAttributes
, bInheritHandles
,
3000 dwCreationFlags
, lpEnvironment
, debugstr_a(lpCurrentDirectory
), lpStartupInfo
, lpProcessInformation
);
3005 BOOL WINAPI
CreateProcessAsUserW(
3007 LPCWSTR lpApplicationName
,
3008 LPWSTR lpCommandLine
,
3009 LPSECURITY_ATTRIBUTES lpProcessAttributes
,
3010 LPSECURITY_ATTRIBUTES lpThreadAttributes
,
3011 BOOL bInheritHandles
,
3012 DWORD dwCreationFlags
,
3013 LPVOID lpEnvironment
,
3014 LPCWSTR lpCurrentDirectory
,
3015 LPSTARTUPINFOW lpStartupInfo
,
3016 LPPROCESS_INFORMATION lpProcessInformation
)
3018 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - semi- stub\n", hToken
,
3019 debugstr_w(lpApplicationName
), debugstr_w(lpCommandLine
), lpProcessAttributes
,
3020 lpThreadAttributes
, bInheritHandles
, dwCreationFlags
, lpEnvironment
,
3021 debugstr_w(lpCurrentDirectory
), lpStartupInfo
, lpProcessInformation
);
3023 /* We should create the process with a suspended main thread */
3024 if (!CreateProcessW (lpApplicationName
,
3026 lpProcessAttributes
,
3029 dwCreationFlags
, /* CREATE_SUSPENDED */
3033 lpProcessInformation
))
3041 /******************************************************************************
3042 * ComputeStringSidSize
3044 static DWORD
ComputeStringSidSize(LPCWSTR StringSid
)
3047 DWORD size
= sizeof(SID
);
3051 if (*StringSid
== '-')
3057 size
+= (ctok
- 3) * sizeof(DWORD
);
3062 BOOL WINAPI
DuplicateTokenEx(
3063 HANDLE ExistingTokenHandle
, DWORD dwDesiredAccess
,
3064 LPSECURITY_ATTRIBUTES lpTokenAttributes
,
3065 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
3066 TOKEN_TYPE TokenType
,
3067 PHANDLE DuplicateTokenHandle
)
3069 OBJECT_ATTRIBUTES ObjectAttributes
;
3071 TRACE("%p 0x%08lx 0x%08x 0x%08x %p\n", ExistingTokenHandle
, dwDesiredAccess
,
3072 ImpersonationLevel
, TokenType
, DuplicateTokenHandle
);
3074 InitializeObjectAttributes(
3077 (lpTokenAttributes
&& lpTokenAttributes
->bInheritHandle
) ? OBJ_INHERIT
: 0,
3079 lpTokenAttributes
? lpTokenAttributes
->lpSecurityDescriptor
: NULL
);
3081 return set_ntstatus( NtDuplicateToken( ExistingTokenHandle
,
3086 DuplicateTokenHandle
) );
3089 BOOL WINAPI
DuplicateToken(
3090 HANDLE ExistingTokenHandle
,
3091 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
3092 PHANDLE DuplicateTokenHandle
)
3094 return DuplicateTokenEx( ExistingTokenHandle
, TOKEN_IMPERSONATE
| TOKEN_QUERY
,
3095 NULL
, ImpersonationLevel
, TokenImpersonation
,
3096 DuplicateTokenHandle
);
3099 BOOL WINAPI
EnumDependentServicesA(
3101 DWORD dwServiceState
,
3102 LPENUM_SERVICE_STATUSA lpServices
,
3104 LPDWORD pcbBytesNeeded
,
3105 LPDWORD lpServicesReturned
)
3107 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService
, dwServiceState
,
3108 lpServices
, cbBufSize
, pcbBytesNeeded
, lpServicesReturned
);
3113 BOOL WINAPI
EnumDependentServicesW(
3115 DWORD dwServiceState
,
3116 LPENUM_SERVICE_STATUSW lpServices
,
3118 LPDWORD pcbBytesNeeded
,
3119 LPDWORD lpServicesReturned
)
3121 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService
, dwServiceState
,
3122 lpServices
, cbBufSize
, pcbBytesNeeded
, lpServicesReturned
);
3127 /******************************************************************************
3128 * ParseStringSidToSid
3130 static BOOL
ParseStringSidToSid(LPCWSTR StringSid
, PSID pSid
, LPDWORD cBytes
)
3135 TRACE("%s, %p, %p\n", debugstr_w(StringSid
), pSid
, cBytes
);
3138 SetLastError(ERROR_INVALID_PARAMETER
);
3139 TRACE("StringSid is NULL, returning FALSE\n");
3143 *cBytes
= ComputeStringSidSize(StringSid
);
3144 if (!pisid
) /* Simply compute the size */
3146 TRACE("only size requested, returning TRUE\n");
3150 if (StringSid
[0] == 'S' && StringSid
[1] == '-') /* S-R-I-S-S */
3152 DWORD i
= 0, identAuth
;
3153 DWORD csubauth
= ((*cBytes
- sizeof(SID
)) / sizeof(DWORD
)) + 1;
3155 StringSid
+= 2; /* Advance to Revision */
3156 pisid
->Revision
= atoiW(StringSid
);
3158 if (pisid
->Revision
!= SDDL_REVISION
)
3160 TRACE("Revision %d is unknown\n", pisid
->Revision
);
3161 goto lend
; /* ERROR_INVALID_SID */
3165 TRACE("SubAuthorityCount is 0\n");
3166 goto lend
; /* ERROR_INVALID_SID */
3169 pisid
->SubAuthorityCount
= csubauth
;
3171 /* Advance to identifier authority */
3172 while (*StringSid
&& *StringSid
!= '-')
3174 if (*StringSid
== '-')
3177 /* MS' implementation can't handle values greater than 2^32 - 1, so
3178 * we don't either; assume most significant bytes are always 0
3180 pisid
->IdentifierAuthority
.Value
[0] = 0;
3181 pisid
->IdentifierAuthority
.Value
[1] = 0;
3182 identAuth
= atoiW(StringSid
);
3183 pisid
->IdentifierAuthority
.Value
[5] = identAuth
& 0xff;
3184 pisid
->IdentifierAuthority
.Value
[4] = (identAuth
& 0xff00) >> 8;
3185 pisid
->IdentifierAuthority
.Value
[3] = (identAuth
& 0xff0000) >> 16;
3186 pisid
->IdentifierAuthority
.Value
[2] = (identAuth
& 0xff000000) >> 24;
3188 /* Advance to first sub authority */
3189 while (*StringSid
&& *StringSid
!= '-')
3191 if (*StringSid
== '-')
3196 while (*StringSid
&& *StringSid
!= '-')
3199 pisid
->SubAuthority
[i
++] = atoiW(StringSid
);
3202 if (i
!= pisid
->SubAuthorityCount
)
3203 goto lend
; /* ERROR_INVALID_SID */
3207 else /* String constant format - Only available in winxp and above */
3209 pisid
->Revision
= SDDL_REVISION
;
3210 pisid
->SubAuthorityCount
= 1;
3212 FIXME("String constant not supported: %s\n", debugstr_wn(StringSid
, 2));
3214 /* TODO: Lookup string of well-known SIDs in table */
3215 pisid
->IdentifierAuthority
.Value
[5] = 0;
3216 pisid
->SubAuthority
[0] = 0;
3223 SetLastError(ERROR_INVALID_SID
);
3225 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
3229 /******************************************************************************
3230 * GetNamedSecurityInfoA [ADVAPI32.@]
3232 DWORD WINAPI
GetNamedSecurityInfoA(LPSTR pObjectName
,
3233 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
3234 PSID
* ppsidOwner
, PSID
* ppsidGroup
, PACL
* ppDacl
, PACL
* ppSacl
,
3235 PSECURITY_DESCRIPTOR
* ppSecurityDescriptor
)
3241 TRACE("%s %d %ld %p %p %p %p %p\n", pObjectName
, ObjectType
, SecurityInfo
,
3242 ppsidOwner
, ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
3246 len
= MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, NULL
, 0 );
3247 wstr
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
));
3248 MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, wstr
, len
);
3251 r
= GetNamedSecurityInfoW( wstr
, ObjectType
, SecurityInfo
, ppsidOwner
,
3252 ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
3254 HeapFree( GetProcessHeap(), 0, wstr
);
3259 /******************************************************************************
3260 * GetNamedSecurityInfoW [ADVAPI32.@]
3262 DWORD WINAPI
GetNamedSecurityInfoW( LPWSTR name
, SE_OBJECT_TYPE type
,
3263 SECURITY_INFORMATION info
, PSID
* owner
, PSID
* group
, PACL
* dacl
,
3264 PACL
* sacl
, PSECURITY_DESCRIPTOR
* descriptor
)
3266 DWORD needed
, offset
;
3267 SECURITY_DESCRIPTOR_RELATIVE
*relative
;
3270 TRACE( "%s %d %ld %p %p %p %p %p\n", debugstr_w(name
), type
, info
, owner
,
3271 group
, dacl
, sacl
, descriptor
);
3273 if (!name
|| !descriptor
) return ERROR_INVALID_PARAMETER
;
3275 needed
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
3276 if (info
& OWNER_SECURITY_INFORMATION
)
3277 needed
+= sizeof(sidWorld
);
3278 if (info
& GROUP_SECURITY_INFORMATION
)
3279 needed
+= sizeof(sidWorld
);
3280 if (info
& DACL_SECURITY_INFORMATION
)
3281 needed
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3282 if (info
& SACL_SECURITY_INFORMATION
)
3283 needed
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3285 /* must be freed by caller */
3286 *descriptor
= HeapAlloc( GetProcessHeap(), 0, needed
);
3287 if (!*descriptor
) return ERROR_NOT_ENOUGH_MEMORY
;
3289 if (!InitializeSecurityDescriptor( *descriptor
, SECURITY_DESCRIPTOR_REVISION
))
3291 HeapFree( GetProcessHeap(), 0, *descriptor
);
3292 return ERROR_INVALID_SECURITY_DESCR
;
3295 relative
= (SECURITY_DESCRIPTOR_RELATIVE
*)*descriptor
;
3296 relative
->Control
|= SE_SELF_RELATIVE
;
3297 buffer
= (BYTE
*)relative
;
3298 offset
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
3300 if (owner
&& (info
& OWNER_SECURITY_INFORMATION
))
3302 memcpy( buffer
+ offset
, &sidWorld
, sizeof(sidWorld
) );
3303 relative
->Owner
= offset
;
3304 *owner
= buffer
+ offset
;
3305 offset
+= sizeof(sidWorld
);
3307 if (group
&& (info
& GROUP_SECURITY_INFORMATION
))
3309 memcpy( buffer
+ offset
, &sidWorld
, sizeof(sidWorld
) );
3310 relative
->Group
= offset
;
3311 *group
= buffer
+ offset
;
3312 offset
+= sizeof(sidWorld
);
3314 if (dacl
&& (info
& DACL_SECURITY_INFORMATION
))
3316 GetWorldAccessACL( (PACL
)(buffer
+ offset
) );
3317 relative
->Dacl
= offset
;
3318 *dacl
= (PACL
)(buffer
+ offset
);
3319 offset
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3321 if (sacl
&& (info
& SACL_SECURITY_INFORMATION
))
3323 GetWorldAccessACL( (PACL
)(buffer
+ offset
) );
3324 relative
->Sacl
= offset
;
3325 *sacl
= (PACL
)(buffer
+ offset
);
3327 return ERROR_SUCCESS
;
3330 /******************************************************************************
3331 * DecryptFileW [ADVAPI32.@]
3333 BOOL WINAPI
DecryptFileW(LPCWSTR lpFileName
, DWORD dwReserved
)
3335 FIXME("%s %08lx\n", debugstr_w(lpFileName
), dwReserved
);
3339 /******************************************************************************
3340 * DecryptFileA [ADVAPI32.@]
3342 BOOL WINAPI
DecryptFileA(LPCSTR lpFileName
, DWORD dwReserved
)
3344 FIXME("%s %08lx\n", debugstr_a(lpFileName
), dwReserved
);
3348 /******************************************************************************
3349 * EncryptFileW [ADVAPI32.@]
3351 BOOL WINAPI
EncryptFileW(LPCWSTR lpFileName
)
3353 FIXME("%s\n", debugstr_w(lpFileName
));
3357 /******************************************************************************
3358 * EncryptFileA [ADVAPI32.@]
3360 BOOL WINAPI
EncryptFileA(LPCSTR lpFileName
)
3362 FIXME("%s\n", debugstr_a(lpFileName
));
3366 /******************************************************************************
3367 * SetSecurityInfo [ADVAPI32.@]
3369 DWORD WINAPI
SetSecurityInfo(HANDLE handle
, SE_OBJECT_TYPE ObjectType
,
3370 SECURITY_INFORMATION SecurityInfo
, PSID psidOwner
,
3371 PSID psidGroup
, PACL pDacl
, PACL pSacl
) {
3373 return ERROR_SUCCESS
;