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.@]
278 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
279 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
280 * tokeninfo [O] Destination for token information
281 * tokeninfolength [I] Length of tokeninfo
282 * retlen [O] Destination for returned token information length
285 * Success: TRUE. tokeninfo contains retlen bytes of token information
289 * See NtQueryInformationToken.
292 GetTokenInformation( HANDLE token
, TOKEN_INFORMATION_CLASS tokeninfoclass
,
293 LPVOID tokeninfo
, DWORD tokeninfolength
, LPDWORD retlen
)
295 TRACE("(%p, %s, %p, %ld, %p): \n",
297 (tokeninfoclass
== TokenUser
) ? "TokenUser" :
298 (tokeninfoclass
== TokenGroups
) ? "TokenGroups" :
299 (tokeninfoclass
== TokenPrivileges
) ? "TokenPrivileges" :
300 (tokeninfoclass
== TokenOwner
) ? "TokenOwner" :
301 (tokeninfoclass
== TokenPrimaryGroup
) ? "TokenPrimaryGroup" :
302 (tokeninfoclass
== TokenDefaultDacl
) ? "TokenDefaultDacl" :
303 (tokeninfoclass
== TokenSource
) ? "TokenSource" :
304 (tokeninfoclass
== TokenType
) ? "TokenType" :
305 (tokeninfoclass
== TokenImpersonationLevel
) ? "TokenImpersonationLevel" :
306 (tokeninfoclass
== TokenStatistics
) ? "TokenStatistics" :
307 (tokeninfoclass
== TokenRestrictedSids
) ? "TokenRestrictedSids" :
308 (tokeninfoclass
== TokenSessionId
) ? "TokenSessionId" :
309 (tokeninfoclass
== TokenGroupsAndPrivileges
) ? "TokenGroupsAndPrivileges" :
310 (tokeninfoclass
== TokenSessionReference
) ? "TokenSessionReference" :
311 (tokeninfoclass
== TokenSandBoxInert
) ? "TokenSandBoxInert" :
313 tokeninfo
, tokeninfolength
, retlen
);
314 return set_ntstatus( NtQueryInformationToken( token
, tokeninfoclass
, tokeninfo
,
315 tokeninfolength
, retlen
));
318 /******************************************************************************
319 * SetTokenInformation [ADVAPI32.@]
321 * Set information for an access token.
324 * token [I] Handle from OpenProcessToken() or OpenThreadToken()
325 * tokeninfoclass [I] A TOKEN_INFORMATION_CLASS from "winnt.h"
326 * tokeninfo [I] Token information to set
327 * tokeninfolength [I] Length of tokeninfo
330 * Success: TRUE. The information for the token is set to tokeninfo.
334 SetTokenInformation( HANDLE token
, TOKEN_INFORMATION_CLASS tokeninfoclass
,
335 LPVOID tokeninfo
, DWORD tokeninfolength
)
337 TRACE("(%p, %s, %p, %ld): stub\n",
339 (tokeninfoclass
== TokenUser
) ? "TokenUser" :
340 (tokeninfoclass
== TokenGroups
) ? "TokenGroups" :
341 (tokeninfoclass
== TokenPrivileges
) ? "TokenPrivileges" :
342 (tokeninfoclass
== TokenOwner
) ? "TokenOwner" :
343 (tokeninfoclass
== TokenPrimaryGroup
) ? "TokenPrimaryGroup" :
344 (tokeninfoclass
== TokenDefaultDacl
) ? "TokenDefaultDacl" :
345 (tokeninfoclass
== TokenSource
) ? "TokenSource" :
346 (tokeninfoclass
== TokenType
) ? "TokenType" :
347 (tokeninfoclass
== TokenImpersonationLevel
) ? "TokenImpersonationLevel" :
348 (tokeninfoclass
== TokenStatistics
) ? "TokenStatistics" :
349 (tokeninfoclass
== TokenRestrictedSids
) ? "TokenRestrictedSids" :
350 (tokeninfoclass
== TokenSessionId
) ? "TokenSessionId" :
351 (tokeninfoclass
== TokenGroupsAndPrivileges
) ? "TokenGroupsAndPrivileges" :
352 (tokeninfoclass
== TokenSessionReference
) ? "TokenSessionReference" :
353 (tokeninfoclass
== TokenSandBoxInert
) ? "TokenSandBoxInert" :
355 tokeninfo
, tokeninfolength
);
357 return set_ntstatus( NtSetInformationToken( token
, tokeninfoclass
, tokeninfo
, tokeninfolength
));
360 /*************************************************************************
361 * SetThreadToken [ADVAPI32.@]
363 * Assigns an 'impersonation token' to a thread so it can assume the
364 * security privileges of another thread or process. Can also remove
365 * a previously assigned token.
368 * thread [O] Handle to thread to set the token for
369 * token [I] Token to set
372 * Success: TRUE. The threads access token is set to token
376 * Only supported on NT or higher. On Win9X this function does nothing.
377 * See SetTokenInformation.
379 BOOL WINAPI
SetThreadToken(PHANDLE thread
, HANDLE token
)
381 return set_ntstatus( NtSetInformationThread( thread
? *thread
: GetCurrentThread(),
382 ThreadImpersonationToken
, &token
, sizeof token
));
385 /* ##############################
386 ###### SID FUNCTIONS ######
387 ##############################
390 /******************************************************************************
391 * AllocateAndInitializeSid [ADVAPI32.@]
394 * pIdentifierAuthority []
395 * nSubAuthorityCount []
407 AllocateAndInitializeSid( PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
408 BYTE nSubAuthorityCount
,
409 DWORD nSubAuthority0
, DWORD nSubAuthority1
,
410 DWORD nSubAuthority2
, DWORD nSubAuthority3
,
411 DWORD nSubAuthority4
, DWORD nSubAuthority5
,
412 DWORD nSubAuthority6
, DWORD nSubAuthority7
,
415 return set_ntstatus( RtlAllocateAndInitializeSid(
416 pIdentifierAuthority
, nSubAuthorityCount
,
417 nSubAuthority0
, nSubAuthority1
, nSubAuthority2
, nSubAuthority3
,
418 nSubAuthority4
, nSubAuthority5
, nSubAuthority6
, nSubAuthority7
,
422 /******************************************************************************
423 * FreeSid [ADVAPI32.@]
432 return NULL
; /* is documented like this */
435 /******************************************************************************
436 * CopySid [ADVAPI32.@]
439 * nDestinationSidLength []
444 CopySid( DWORD nDestinationSidLength
, PSID pDestinationSid
, PSID pSourceSid
)
446 return RtlCopySid(nDestinationSidLength
, pDestinationSid
, pSourceSid
);
450 IsTokenRestricted( HANDLE TokenHandle
)
452 TOKEN_GROUPS
*groups
;
457 TRACE("(%p)\n", TokenHandle
);
459 status
= NtQueryInformationToken(TokenHandle
, TokenRestrictedSids
, NULL
, 0, &size
);
460 if (status
!= STATUS_BUFFER_TOO_SMALL
)
463 groups
= HeapAlloc(GetProcessHeap(), 0, size
);
466 SetLastError(ERROR_OUTOFMEMORY
);
470 status
= NtQueryInformationToken(TokenHandle
, TokenRestrictedSids
, groups
, size
, &size
);
471 if (status
!= STATUS_SUCCESS
)
473 HeapFree(GetProcessHeap(), 0, groups
);
474 return set_ntstatus(status
);
477 if (groups
->GroupCount
)
482 HeapFree(GetProcessHeap(), 0, groups
);
487 /******************************************************************************
488 * IsValidSid [ADVAPI32.@]
494 IsValidSid( PSID pSid
)
496 return RtlValidSid( pSid
);
499 /******************************************************************************
500 * EqualSid [ADVAPI32.@]
507 EqualSid( PSID pSid1
, PSID pSid2
)
509 return RtlEqualSid( pSid1
, pSid2
);
512 /******************************************************************************
513 * EqualPrefixSid [ADVAPI32.@]
515 BOOL WINAPI
EqualPrefixSid (PSID pSid1
, PSID pSid2
)
517 return RtlEqualPrefixSid(pSid1
, pSid2
);
520 /******************************************************************************
521 * GetSidLengthRequired [ADVAPI32.@]
524 * nSubAuthorityCount []
527 GetSidLengthRequired( BYTE nSubAuthorityCount
)
529 return RtlLengthRequiredSid(nSubAuthorityCount
);
532 /******************************************************************************
533 * InitializeSid [ADVAPI32.@]
536 * pIdentifierAuthority []
541 PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority
,
542 BYTE nSubAuthorityCount
)
544 return RtlInitializeSid(pSid
, pIdentifierAuthority
, nSubAuthorityCount
);
548 GetEffectiveRightsFromAclA( PACL pacl
, PTRUSTEEA pTrustee
, PACCESS_MASK pAccessRights
)
550 FIXME("%p %p %p - stub\n", pacl
, pTrustee
, pAccessRights
);
556 GetEffectiveRightsFromAclW( PACL pacl
, PTRUSTEEW pTrustee
, PACCESS_MASK pAccessRights
)
558 FIXME("%p %p %p - stub\n", pacl
, pTrustee
, pAccessRights
);
563 /******************************************************************************
564 * GetSidIdentifierAuthority [ADVAPI32.@]
569 PSID_IDENTIFIER_AUTHORITY WINAPI
570 GetSidIdentifierAuthority( PSID pSid
)
572 return RtlIdentifierAuthoritySid(pSid
);
575 /******************************************************************************
576 * GetSidSubAuthority [ADVAPI32.@]
583 GetSidSubAuthority( PSID pSid
, DWORD nSubAuthority
)
585 return RtlSubAuthoritySid(pSid
, nSubAuthority
);
588 /******************************************************************************
589 * GetSidSubAuthorityCount [ADVAPI32.@]
595 GetSidSubAuthorityCount (PSID pSid
)
597 return RtlSubAuthorityCountSid(pSid
);
600 /******************************************************************************
601 * GetLengthSid [ADVAPI32.@]
607 GetLengthSid (PSID pSid
)
609 return RtlLengthSid(pSid
);
612 /* ##############################################
613 ###### SECURITY DESCRIPTOR FUNCTIONS ######
614 ##############################################
617 /******************************************************************************
618 * BuildSecurityDescriptorA [ADVAPI32.@]
625 * cCountOfAccessEntries [I]
626 * pListOfAccessEntries [I]
627 * cCountOfAuditEntries [I]
628 * pListofAuditEntries [I]
630 * lpdwBufferLength [I/O]
633 DWORD WINAPI
BuildSecurityDescriptorA(
634 IN PTRUSTEE_A pOwner
,
635 IN PTRUSTEE_A pGroup
,
636 IN DWORD cCountOfAccessEntries
,
637 IN PEXPLICIT_ACCESS_A pListOfAccessEntries
,
638 IN DWORD cCountOfAuditEntries
,
639 IN PEXPLICIT_ACCESS_A pListofAuditEntries
,
640 IN PSECURITY_DESCRIPTOR pOldSD
,
641 IN OUT PDWORD lpdwBufferLength
,
642 OUT PSECURITY_DESCRIPTOR pNewSD
)
644 FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner
,pGroup
,
645 cCountOfAccessEntries
,pListOfAccessEntries
,cCountOfAuditEntries
,
646 pListofAuditEntries
,pOldSD
,lpdwBufferLength
,pNewSD
);
648 return ERROR_CALL_NOT_IMPLEMENTED
;
651 /******************************************************************************
652 * BuildSecurityDescriptorW [ADVAPI32.@]
654 * See BuildSecurityDescriptorA.
656 DWORD WINAPI
BuildSecurityDescriptorW(
657 IN PTRUSTEE_W pOwner
,
658 IN PTRUSTEE_W pGroup
,
659 IN DWORD cCountOfAccessEntries
,
660 IN PEXPLICIT_ACCESS_W pListOfAccessEntries
,
661 IN DWORD cCountOfAuditEntries
,
662 IN PEXPLICIT_ACCESS_W pListofAuditEntries
,
663 IN PSECURITY_DESCRIPTOR pOldSD
,
664 IN OUT PDWORD lpdwBufferLength
,
665 OUT PSECURITY_DESCRIPTOR pNewSD
)
667 FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner
,pGroup
,
668 cCountOfAccessEntries
,pListOfAccessEntries
,cCountOfAuditEntries
,
669 pListofAuditEntries
,pOldSD
,lpdwBufferLength
,pNewSD
);
671 return ERROR_CALL_NOT_IMPLEMENTED
;
674 /******************************************************************************
675 * InitializeSecurityDescriptor [ADVAPI32.@]
682 InitializeSecurityDescriptor( PSECURITY_DESCRIPTOR pDescr
, DWORD revision
)
684 return set_ntstatus( RtlCreateSecurityDescriptor(pDescr
, revision
));
688 /******************************************************************************
689 * MakeAbsoluteSD [ADVAPI32.@]
691 BOOL WINAPI
MakeAbsoluteSD (
692 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
693 OUT PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
694 OUT LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
696 OUT LPDWORD lpdwDaclSize
,
698 OUT LPDWORD lpdwSaclSize
,
700 OUT LPDWORD lpdwOwnerSize
,
701 OUT PSID pPrimaryGroup
,
702 OUT LPDWORD lpdwPrimaryGroupSize
)
704 return set_ntstatus( RtlSelfRelativeToAbsoluteSD(pSelfRelativeSecurityDescriptor
,
705 pAbsoluteSecurityDescriptor
,
706 lpdwAbsoluteSecurityDescriptorSize
,
707 pDacl
, lpdwDaclSize
, pSacl
, lpdwSaclSize
,
708 pOwner
, lpdwOwnerSize
,
709 pPrimaryGroup
, lpdwPrimaryGroupSize
));
712 /******************************************************************************
713 * GetKernelObjectSecurity [ADVAPI32.@]
715 BOOL WINAPI
GetKernelObjectSecurity(
717 SECURITY_INFORMATION RequestedInformation
,
718 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
720 LPDWORD lpnLengthNeeded
)
722 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", Handle
, RequestedInformation
,
723 pSecurityDescriptor
, nLength
, lpnLengthNeeded
);
725 return set_ntstatus( NtQuerySecurityObject(Handle
, RequestedInformation
, pSecurityDescriptor
,
726 nLength
, lpnLengthNeeded
));
729 /******************************************************************************
730 * GetPrivateObjectSecurity [ADVAPI32.@]
732 BOOL WINAPI
GetPrivateObjectSecurity(
733 PSECURITY_DESCRIPTOR ObjectDescriptor
,
734 SECURITY_INFORMATION SecurityInformation
,
735 PSECURITY_DESCRIPTOR ResultantDescriptor
,
736 DWORD DescriptorLength
,
737 PDWORD ReturnLength
)
739 TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", ObjectDescriptor
, SecurityInformation
,
740 ResultantDescriptor
, DescriptorLength
, ReturnLength
);
742 return set_ntstatus( NtQuerySecurityObject(ObjectDescriptor
, SecurityInformation
,
743 ResultantDescriptor
, DescriptorLength
, ReturnLength
));
746 /******************************************************************************
747 * GetSecurityDescriptorLength [ADVAPI32.@]
749 DWORD WINAPI
GetSecurityDescriptorLength( PSECURITY_DESCRIPTOR pDescr
)
751 return RtlLengthSecurityDescriptor(pDescr
);
754 /******************************************************************************
755 * GetSecurityDescriptorOwner [ADVAPI32.@]
759 * lpbOwnerDefaulted []
762 GetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pDescr
, PSID
*pOwner
,
763 LPBOOL lpbOwnerDefaulted
)
766 BOOL ret
= set_ntstatus( RtlGetOwnerSecurityDescriptor( pDescr
, pOwner
, &defaulted
));
767 *lpbOwnerDefaulted
= defaulted
;
771 /******************************************************************************
772 * SetSecurityDescriptorOwner [ADVAPI32.@]
776 BOOL WINAPI
SetSecurityDescriptorOwner( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
777 PSID pOwner
, BOOL bOwnerDefaulted
)
779 return set_ntstatus( RtlSetOwnerSecurityDescriptor(pSecurityDescriptor
, pOwner
, bOwnerDefaulted
));
781 /******************************************************************************
782 * GetSecurityDescriptorGroup [ADVAPI32.@]
784 BOOL WINAPI
GetSecurityDescriptorGroup(
785 PSECURITY_DESCRIPTOR SecurityDescriptor
,
787 LPBOOL GroupDefaulted
)
790 BOOL ret
= set_ntstatus( RtlGetGroupSecurityDescriptor(SecurityDescriptor
, Group
, &defaulted
));
791 *GroupDefaulted
= defaulted
;
794 /******************************************************************************
795 * SetSecurityDescriptorGroup [ADVAPI32.@]
797 BOOL WINAPI
SetSecurityDescriptorGroup ( PSECURITY_DESCRIPTOR SecurityDescriptor
,
798 PSID Group
, BOOL GroupDefaulted
)
800 return set_ntstatus( RtlSetGroupSecurityDescriptor( SecurityDescriptor
, Group
, GroupDefaulted
));
803 /******************************************************************************
804 * IsValidSecurityDescriptor [ADVAPI32.@]
810 IsValidSecurityDescriptor( PSECURITY_DESCRIPTOR SecurityDescriptor
)
812 return set_ntstatus( RtlValidSecurityDescriptor(SecurityDescriptor
));
815 /******************************************************************************
816 * GetSecurityDescriptorDacl [ADVAPI32.@]
818 BOOL WINAPI
GetSecurityDescriptorDacl(
819 IN PSECURITY_DESCRIPTOR pSecurityDescriptor
,
820 OUT LPBOOL lpbDaclPresent
,
822 OUT LPBOOL lpbDaclDefaulted
)
824 BOOLEAN present
, defaulted
;
825 BOOL ret
= set_ntstatus( RtlGetDaclSecurityDescriptor(pSecurityDescriptor
, &present
, pDacl
, &defaulted
));
826 *lpbDaclPresent
= present
;
827 *lpbDaclDefaulted
= defaulted
;
831 /******************************************************************************
832 * SetSecurityDescriptorDacl [ADVAPI32.@]
835 SetSecurityDescriptorDacl (
836 PSECURITY_DESCRIPTOR lpsd
,
841 return set_ntstatus( RtlSetDaclSecurityDescriptor (lpsd
, daclpresent
, dacl
, dacldefaulted
) );
843 /******************************************************************************
844 * GetSecurityDescriptorSacl [ADVAPI32.@]
846 BOOL WINAPI
GetSecurityDescriptorSacl(
847 IN PSECURITY_DESCRIPTOR lpsd
,
848 OUT LPBOOL lpbSaclPresent
,
850 OUT LPBOOL lpbSaclDefaulted
)
852 BOOLEAN present
, defaulted
;
853 BOOL ret
= set_ntstatus( RtlGetSaclSecurityDescriptor(lpsd
, &present
, pSacl
, &defaulted
) );
854 *lpbSaclPresent
= present
;
855 *lpbSaclDefaulted
= defaulted
;
859 /**************************************************************************
860 * SetSecurityDescriptorSacl [ADVAPI32.@]
862 BOOL WINAPI
SetSecurityDescriptorSacl (
863 PSECURITY_DESCRIPTOR lpsd
,
868 return set_ntstatus (RtlSetSaclSecurityDescriptor(lpsd
, saclpresent
, lpsacl
, sacldefaulted
));
870 /******************************************************************************
871 * MakeSelfRelativeSD [ADVAPI32.@]
880 IN PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
881 IN PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
882 IN OUT LPDWORD lpdwBufferLength
)
884 return set_ntstatus( RtlMakeSelfRelativeSD( pAbsoluteSecurityDescriptor
,
885 pSelfRelativeSecurityDescriptor
, lpdwBufferLength
));
888 /******************************************************************************
889 * GetSecurityDescriptorControl [ADVAPI32.@]
892 BOOL WINAPI
GetSecurityDescriptorControl ( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
893 PSECURITY_DESCRIPTOR_CONTROL pControl
, LPDWORD lpdwRevision
)
895 return set_ntstatus( RtlGetControlSecurityDescriptor(pSecurityDescriptor
,pControl
,lpdwRevision
));
898 /* ##############################
899 ###### ACL FUNCTIONS ######
900 ##############################
903 /*************************************************************************
904 * InitializeAcl [ADVAPI32.@]
906 BOOL WINAPI
InitializeAcl(PACL acl
, DWORD size
, DWORD rev
)
908 return set_ntstatus( RtlCreateAcl(acl
, size
, rev
));
911 BOOL WINAPI
ImpersonateNamedPipeClient( HANDLE hNamedPipe
)
913 TRACE("(%p)\n", hNamedPipe
);
915 return set_ntstatus( NtFsControlFile(hNamedPipe
, NULL
, NULL
, NULL
, NULL
,
916 FSCTL_PIPE_IMPERSONATE
, NULL
, 0, NULL
, 0) );
919 /******************************************************************************
920 * AddAccessAllowedAce [ADVAPI32.@]
922 BOOL WINAPI
AddAccessAllowedAce(
924 IN DWORD dwAceRevision
,
928 return set_ntstatus(RtlAddAccessAllowedAce(pAcl
, dwAceRevision
, AccessMask
, pSid
));
931 /******************************************************************************
932 * AddAccessAllowedAceEx [ADVAPI32.@]
934 BOOL WINAPI
AddAccessAllowedAceEx(
936 IN DWORD dwAceRevision
,
941 return set_ntstatus(RtlAddAccessAllowedAceEx(pAcl
, dwAceRevision
, AceFlags
, AccessMask
, pSid
));
944 /******************************************************************************
945 * AddAccessDeniedAce [ADVAPI32.@]
947 BOOL WINAPI
AddAccessDeniedAce(
949 IN DWORD dwAceRevision
,
953 return set_ntstatus(RtlAddAccessDeniedAce(pAcl
, dwAceRevision
, AccessMask
, pSid
));
956 /******************************************************************************
957 * AddAccessDeniedAceEx [ADVAPI32.@]
959 BOOL WINAPI
AddAccessDeniedAceEx(
961 IN DWORD dwAceRevision
,
966 return set_ntstatus(RtlAddAccessDeniedAceEx(pAcl
, dwAceRevision
, AceFlags
, AccessMask
, pSid
));
969 /******************************************************************************
970 * AddAce [ADVAPI32.@]
974 IN DWORD dwAceRevision
,
975 IN DWORD dwStartingAceIndex
,
977 DWORD nAceListLength
)
979 return set_ntstatus(RtlAddAce(pAcl
, dwAceRevision
, dwStartingAceIndex
, pAceList
, nAceListLength
));
982 /******************************************************************************
983 * DeleteAce [ADVAPI32.@]
985 BOOL WINAPI
DeleteAce(PACL pAcl
, DWORD dwAceIndex
)
987 return set_ntstatus(RtlDeleteAce(pAcl
, dwAceIndex
));
990 /******************************************************************************
991 * FindFirstFreeAce [ADVAPI32.@]
993 BOOL WINAPI
FindFirstFreeAce(IN PACL pAcl
, LPVOID
* pAce
)
995 return RtlFirstFreeAce(pAcl
, (PACE_HEADER
*)pAce
);
998 /******************************************************************************
999 * GetAce [ADVAPI32.@]
1001 BOOL WINAPI
GetAce(PACL pAcl
,DWORD dwAceIndex
,LPVOID
*pAce
)
1003 return set_ntstatus(RtlGetAce(pAcl
, dwAceIndex
, pAce
));
1006 /******************************************************************************
1007 * GetAclInformation [ADVAPI32.@]
1009 BOOL WINAPI
GetAclInformation(
1011 LPVOID pAclInformation
,
1012 DWORD nAclInformationLength
,
1013 ACL_INFORMATION_CLASS dwAclInformationClass
)
1015 return set_ntstatus(RtlQueryInformationAcl(pAcl
, pAclInformation
,
1016 nAclInformationLength
, dwAclInformationClass
));
1019 /******************************************************************************
1020 * IsValidAcl [ADVAPI32.@]
1022 BOOL WINAPI
IsValidAcl(IN PACL pAcl
)
1024 return RtlValidAcl(pAcl
);
1027 /* ##############################
1028 ###### MISC FUNCTIONS ######
1029 ##############################
1032 /******************************************************************************
1033 * AllocateLocallyUniqueId [ADVAPI32.@]
1038 BOOL WINAPI
AllocateLocallyUniqueId( PLUID lpLuid
)
1040 return set_ntstatus(NtAllocateLocallyUniqueId(lpLuid
));
1043 static const WCHAR SE_CREATE_TOKEN_NAME_W
[] =
1044 { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
1045 static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W
[] =
1046 { '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 };
1047 static const WCHAR SE_LOCK_MEMORY_NAME_W
[] =
1048 { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
1049 static const WCHAR SE_INCREASE_QUOTA_NAME_W
[] =
1050 { '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 };
1051 static const WCHAR SE_MACHINE_ACCOUNT_NAME_W
[] =
1052 { '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 };
1053 static const WCHAR SE_TCB_NAME_W
[] =
1054 { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
1055 static const WCHAR SE_SECURITY_NAME_W
[] =
1056 { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
1057 static const WCHAR SE_TAKE_OWNERSHIP_NAME_W
[] =
1058 { '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 };
1059 static const WCHAR SE_LOAD_DRIVER_NAME_W
[] =
1060 { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
1061 static const WCHAR SE_SYSTEM_PROFILE_NAME_W
[] =
1062 { '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 };
1063 static const WCHAR SE_SYSTEMTIME_NAME_W
[] =
1064 { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
1065 static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W
[] =
1066 { '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 };
1067 static const WCHAR SE_INC_BASE_PRIORITY_NAME_W
[] =
1068 { '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 };
1069 static const WCHAR SE_CREATE_PAGEFILE_NAME_W
[] =
1070 { '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 };
1071 static const WCHAR SE_CREATE_PERMANENT_NAME_W
[] =
1072 { '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 };
1073 static const WCHAR SE_BACKUP_NAME_W
[] =
1074 { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
1075 static const WCHAR SE_RESTORE_NAME_W
[] =
1076 { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
1077 static const WCHAR SE_SHUTDOWN_NAME_W
[] =
1078 { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
1079 static const WCHAR SE_DEBUG_NAME_W
[] =
1080 { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
1081 static const WCHAR SE_AUDIT_NAME_W
[] =
1082 { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
1083 static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W
[] =
1084 { '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 };
1085 static const WCHAR SE_CHANGE_NOTIFY_NAME_W
[] =
1086 { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
1087 static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W
[] =
1088 { '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 };
1089 static const WCHAR SE_UNDOCK_NAME_W
[] =
1090 { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
1091 static const WCHAR SE_SYNC_AGENT_NAME_W
[] =
1092 { 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
1093 static const WCHAR SE_ENABLE_DELEGATION_NAME_W
[] =
1094 { '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 };
1095 static const WCHAR SE_MANAGE_VOLUME_NAME_W
[] =
1096 { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
1097 static const WCHAR SE_IMPERSONATE_NAME_W
[] =
1098 { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
1099 static const WCHAR SE_CREATE_GLOBAL_NAME_W
[] =
1100 { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
1102 static const WCHAR
* const WellKnownPrivNames
[SE_MAX_WELL_KNOWN_PRIVILEGE
+ 1] =
1106 SE_CREATE_TOKEN_NAME_W
,
1107 SE_ASSIGNPRIMARYTOKEN_NAME_W
,
1108 SE_LOCK_MEMORY_NAME_W
,
1109 SE_INCREASE_QUOTA_NAME_W
,
1110 SE_MACHINE_ACCOUNT_NAME_W
,
1113 SE_TAKE_OWNERSHIP_NAME_W
,
1114 SE_LOAD_DRIVER_NAME_W
,
1115 SE_SYSTEM_PROFILE_NAME_W
,
1116 SE_SYSTEMTIME_NAME_W
,
1117 SE_PROF_SINGLE_PROCESS_NAME_W
,
1118 SE_INC_BASE_PRIORITY_NAME_W
,
1119 SE_CREATE_PAGEFILE_NAME_W
,
1120 SE_CREATE_PERMANENT_NAME_W
,
1126 SE_SYSTEM_ENVIRONMENT_NAME_W
,
1127 SE_CHANGE_NOTIFY_NAME_W
,
1128 SE_REMOTE_SHUTDOWN_NAME_W
,
1130 SE_SYNC_AGENT_NAME_W
,
1131 SE_ENABLE_DELEGATION_NAME_W
,
1132 SE_MANAGE_VOLUME_NAME_W
,
1133 SE_IMPERSONATE_NAME_W
,
1134 SE_CREATE_GLOBAL_NAME_W
,
1137 /******************************************************************************
1138 * LookupPrivilegeValueW [ADVAPI32.@]
1140 * See LookupPrivilegeValueA.
1143 LookupPrivilegeValueW( LPCWSTR lpSystemName
, LPCWSTR lpName
, PLUID lpLuid
)
1147 TRACE("%s,%s,%p\n",debugstr_w(lpSystemName
), debugstr_w(lpName
), lpLuid
);
1149 if (!ADVAPI_IsLocalComputer(lpSystemName
))
1151 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
1156 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1159 for( i
=SE_MIN_WELL_KNOWN_PRIVILEGE
; i
<SE_MAX_WELL_KNOWN_PRIVILEGE
; i
++ )
1161 if( !WellKnownPrivNames
[i
] )
1163 if( strcmpiW( WellKnownPrivNames
[i
], lpName
) )
1165 lpLuid
->LowPart
= i
;
1166 lpLuid
->HighPart
= 0;
1167 TRACE( "%s -> %08lx-%08lx\n",debugstr_w( lpSystemName
),
1168 lpLuid
->HighPart
, lpLuid
->LowPart
);
1171 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1175 /******************************************************************************
1176 * LookupPrivilegeValueA [ADVAPI32.@]
1178 * Retrieves LUID used on a system to represent the privilege name.
1181 * lpSystemName [I] Name of the system
1182 * lpName [I] Name of the privilege
1183 * lpLuid [O] Destination for the resulting LUID
1186 * Success: TRUE. lpLuid contains the requested LUID.
1190 LookupPrivilegeValueA( LPCSTR lpSystemName
, LPCSTR lpName
, PLUID lpLuid
)
1192 UNICODE_STRING lpSystemNameW
;
1193 UNICODE_STRING lpNameW
;
1196 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW
, lpSystemName
);
1197 RtlCreateUnicodeStringFromAsciiz(&lpNameW
,lpName
);
1198 ret
= LookupPrivilegeValueW(lpSystemNameW
.Buffer
, lpNameW
.Buffer
, lpLuid
);
1199 RtlFreeUnicodeString(&lpNameW
);
1200 RtlFreeUnicodeString(&lpSystemNameW
);
1204 BOOL WINAPI
LookupPrivilegeDisplayNameA( LPCSTR lpSystemName
, LPCSTR lpName
, LPSTR lpDisplayName
,
1205 LPDWORD cchDisplayName
, LPDWORD lpLanguageId
)
1207 FIXME("%s %s %s %p %p - stub\n", debugstr_a(lpSystemName
), debugstr_a(lpName
),
1208 debugstr_a(lpDisplayName
), cchDisplayName
, lpLanguageId
);
1213 BOOL WINAPI
LookupPrivilegeDisplayNameW( LPCWSTR lpSystemName
, LPCWSTR lpName
, LPWSTR lpDisplayName
,
1214 LPDWORD cchDisplayName
, LPDWORD lpLanguageId
)
1216 FIXME("%s %s %s %p %p - stub\n", debugstr_w(lpSystemName
), debugstr_w(lpName
),
1217 debugstr_w(lpDisplayName
), cchDisplayName
, lpLanguageId
);
1222 /******************************************************************************
1223 * LookupPrivilegeNameA [ADVAPI32.@]
1225 * See LookupPrivilegeNameW.
1228 LookupPrivilegeNameA( LPCSTR lpSystemName
, PLUID lpLuid
, LPSTR lpName
,
1231 UNICODE_STRING lpSystemNameW
;
1235 TRACE("%s %p %p %p\n", debugstr_a(lpSystemName
), lpLuid
, lpName
, cchName
);
1237 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW
, lpSystemName
);
1238 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, NULL
, &wLen
);
1239 if (!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1241 LPWSTR lpNameW
= HeapAlloc(GetProcessHeap(), 0, wLen
* sizeof(WCHAR
));
1243 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, lpNameW
,
1247 /* Windows crashes if cchName is NULL, so will I */
1248 int len
= WideCharToMultiByte(CP_ACP
, 0, lpNameW
, -1, lpName
,
1249 *cchName
, NULL
, NULL
);
1253 /* WideCharToMultiByte failed */
1256 else if (len
> *cchName
)
1259 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1264 /* WideCharToMultiByte succeeded, output length needs to be
1265 * length not including NULL terminator
1270 HeapFree(GetProcessHeap(), 0, lpNameW
);
1272 RtlFreeUnicodeString(&lpSystemNameW
);
1276 /******************************************************************************
1277 * LookupPrivilegeNameW [ADVAPI32.@]
1279 * Retrieves the privilege name referred to by the LUID lpLuid.
1282 * lpSystemName [I] Name of the system
1283 * lpLuid [I] Privilege value
1284 * lpName [O] Name of the privilege
1285 * cchName [I/O] Number of characters in lpName.
1288 * Success: TRUE. lpName contains the name of the privilege whose value is
1293 * Only well-known privilege names (those defined in winnt.h) can be retrieved
1294 * using this function.
1295 * If the length of lpName is too small, on return *cchName will contain the
1296 * number of WCHARs needed to contain the privilege, including the NULL
1297 * terminator, and GetLastError will return ERROR_INSUFFICIENT_BUFFER.
1298 * On success, *cchName will contain the number of characters stored in
1299 * lpName, NOT including the NULL terminator.
1302 LookupPrivilegeNameW( LPCWSTR lpSystemName
, PLUID lpLuid
, LPWSTR lpName
,
1307 TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName
), lpLuid
, lpName
, cchName
);
1309 if (!ADVAPI_IsLocalComputer(lpSystemName
))
1311 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
1314 if (lpLuid
->HighPart
|| (lpLuid
->LowPart
< SE_MIN_WELL_KNOWN_PRIVILEGE
||
1315 lpLuid
->LowPart
> SE_MAX_WELL_KNOWN_PRIVILEGE
))
1317 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1320 privNameLen
= strlenW(WellKnownPrivNames
[lpLuid
->LowPart
]);
1321 /* Windows crashes if cchName is NULL, so will I */
1322 if (*cchName
<= privNameLen
)
1324 *cchName
= privNameLen
+ 1;
1325 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1330 strcpyW(lpName
, WellKnownPrivNames
[lpLuid
->LowPart
]);
1331 *cchName
= privNameLen
;
1336 /******************************************************************************
1337 * GetFileSecurityA [ADVAPI32.@]
1339 * Obtains Specified information about the security of a file or directory.
1342 * lpFileName [I] Name of the file to get info for
1343 * RequestedInformation [I] SE_ flags from "winnt.h"
1344 * pSecurityDescriptor [O] Destination for security information
1345 * nLength [I] Length of pSecurityDescriptor
1346 * lpnLengthNeeded [O] Destination for length of returned security information
1349 * Success: TRUE. pSecurityDescriptor contains the requested information.
1350 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
1353 * The information returned is constrained by the callers access rights and
1357 GetFileSecurityA( LPCSTR lpFileName
,
1358 SECURITY_INFORMATION RequestedInformation
,
1359 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1360 DWORD nLength
, LPDWORD lpnLengthNeeded
)
1368 len
= MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, NULL
, 0 );
1369 name
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
1370 MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, name
, len
);
1373 r
= GetFileSecurityW( name
, RequestedInformation
, pSecurityDescriptor
,
1374 nLength
, lpnLengthNeeded
);
1375 HeapFree( GetProcessHeap(), 0, name
);
1380 /******************************************************************************
1381 * GetFileSecurityW [ADVAPI32.@]
1383 * See GetFileSecurityA.
1386 GetFileSecurityW( LPCWSTR lpFileName
,
1387 SECURITY_INFORMATION RequestedInformation
,
1388 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1389 DWORD nLength
, LPDWORD lpnLengthNeeded
)
1394 SECURITY_DESCRIPTOR_RELATIVE
*pSDRelative
;
1396 if(INVALID_FILE_ATTRIBUTES
== GetFileAttributesW(lpFileName
))
1399 FIXME("(%s) : returns fake SECURITY_DESCRIPTOR\n", debugstr_w(lpFileName
) );
1401 nNeeded
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
1402 if (RequestedInformation
& OWNER_SECURITY_INFORMATION
)
1403 nNeeded
+= sizeof(sidWorld
);
1404 if (RequestedInformation
& GROUP_SECURITY_INFORMATION
)
1405 nNeeded
+= sizeof(sidWorld
);
1406 if (RequestedInformation
& DACL_SECURITY_INFORMATION
)
1407 nNeeded
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1408 if (RequestedInformation
& SACL_SECURITY_INFORMATION
)
1409 nNeeded
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1411 *lpnLengthNeeded
= nNeeded
;
1413 if (nNeeded
> nLength
)
1416 if (!InitializeSecurityDescriptor(pSecurityDescriptor
, SECURITY_DESCRIPTOR_REVISION
))
1419 pSDRelative
= (PISECURITY_DESCRIPTOR_RELATIVE
) pSecurityDescriptor
;
1420 pSDRelative
->Control
|= SE_SELF_RELATIVE
;
1421 pBuffer
= (LPBYTE
) pSDRelative
;
1422 iLocNow
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
1424 if (RequestedInformation
& OWNER_SECURITY_INFORMATION
)
1426 memcpy(pBuffer
+ iLocNow
, &sidWorld
, sizeof(sidWorld
));
1427 pSDRelative
->Owner
= iLocNow
;
1428 iLocNow
+= sizeof(sidWorld
);
1430 if (RequestedInformation
& GROUP_SECURITY_INFORMATION
)
1432 memcpy(pBuffer
+ iLocNow
, &sidWorld
, sizeof(sidWorld
));
1433 pSDRelative
->Group
= iLocNow
;
1434 iLocNow
+= sizeof(sidWorld
);
1436 if (RequestedInformation
& DACL_SECURITY_INFORMATION
)
1438 GetWorldAccessACL((PACL
) (pBuffer
+ iLocNow
));
1439 pSDRelative
->Dacl
= iLocNow
;
1440 iLocNow
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
1442 if (RequestedInformation
& SACL_SECURITY_INFORMATION
)
1444 GetWorldAccessACL((PACL
) (pBuffer
+ iLocNow
));
1445 pSDRelative
->Sacl
= iLocNow
;
1446 /* iLocNow += WINE_SIZE_OF_WORLD_ACCESS_ACL; */
1452 /******************************************************************************
1453 * LookupAccountSidA [ADVAPI32.@]
1460 IN OUT LPDWORD accountSize
,
1462 IN OUT LPDWORD domainSize
,
1463 OUT PSID_NAME_USE name_use
)
1465 static const char ac
[] = "Administrator";
1466 static const char dm
[] = "DOMAIN";
1467 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1468 debugstr_a(system
),sid
,
1469 account
,accountSize
,accountSize
?*accountSize
:0,
1470 domain
,domainSize
,domainSize
?*domainSize
:0,
1473 if (accountSize
) *accountSize
= strlen(ac
)+1;
1474 if (account
&& (*accountSize
> strlen(ac
)))
1475 strcpy(account
, ac
);
1477 if (domainSize
) *domainSize
= strlen(dm
)+1;
1478 if (domain
&& (*domainSize
> strlen(dm
)))
1481 if (name_use
) *name_use
= SidTypeUser
;
1485 /******************************************************************************
1486 * LookupAccountSidW [ADVAPI32.@]
1502 IN OUT LPDWORD accountSize
,
1504 IN OUT LPDWORD domainSize
,
1505 OUT PSID_NAME_USE name_use
)
1507 static const WCHAR ac
[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0};
1508 static const WCHAR dm
[] = {'D','O','M','A','I','N',0};
1509 FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n",
1510 debugstr_w(system
),sid
,
1511 account
,accountSize
,accountSize
?*accountSize
:0,
1512 domain
,domainSize
,domainSize
?*domainSize
:0,
1515 if (accountSize
) *accountSize
= strlenW(ac
)+1;
1516 if (account
&& (*accountSize
> strlenW(ac
)))
1517 strcpyW(account
, ac
);
1519 if (domainSize
) *domainSize
= strlenW(dm
)+1;
1520 if (domain
&& (*domainSize
> strlenW(dm
)))
1523 if (name_use
) *name_use
= SidTypeUser
;
1527 /******************************************************************************
1528 * SetFileSecurityA [ADVAPI32.@]
1530 * See SetFileSecurityW.
1532 BOOL WINAPI
SetFileSecurityA( LPCSTR lpFileName
,
1533 SECURITY_INFORMATION RequestedInformation
,
1534 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
1542 len
= MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, NULL
, 0 );
1543 name
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
1544 MultiByteToWideChar( CP_ACP
, 0, lpFileName
, -1, name
, len
);
1547 r
= SetFileSecurityW( name
, RequestedInformation
, pSecurityDescriptor
);
1548 HeapFree( GetProcessHeap(), 0, name
);
1553 /******************************************************************************
1554 * SetFileSecurityW [ADVAPI32.@]
1556 * Sets the security of a file or directory.
1560 * RequestedInformation []
1561 * pSecurityDescriptor []
1568 SetFileSecurityW( LPCWSTR lpFileName
,
1569 SECURITY_INFORMATION RequestedInformation
,
1570 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
1572 FIXME("(%s) : stub\n", debugstr_w(lpFileName
) );
1576 /******************************************************************************
1577 * QueryWindows31FilesMigration [ADVAPI32.@]
1583 QueryWindows31FilesMigration( DWORD x1
)
1585 FIXME("(%ld):stub\n",x1
);
1589 /******************************************************************************
1590 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
1599 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1
, DWORD x2
, DWORD x3
,
1602 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx):stub\n",x1
,x2
,x3
,x4
);
1606 /******************************************************************************
1607 * NotifyBootConfigStatus [ADVAPI32.@]
1613 NotifyBootConfigStatus( DWORD x1
)
1615 FIXME("(0x%08lx):stub\n",x1
);
1619 /******************************************************************************
1620 * RevertToSelf [ADVAPI32.@]
1622 * Ends the impersonation of a user.
1632 RevertToSelf( void )
1634 HANDLE Token
= NULL
;
1635 return set_ntstatus( NtSetInformationThread( GetCurrentThread(),
1636 ThreadImpersonationToken
, &Token
, sizeof(Token
) ) );
1639 /******************************************************************************
1640 * ImpersonateSelf [ADVAPI32.@]
1642 * Makes an impersonation token that represents the process user and assigns
1643 * to the current thread.
1646 * ImpersonationLevel [I] Level at which to impersonate.
1653 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
1655 return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel
) );
1658 /******************************************************************************
1659 * ImpersonateLoggedOnUser [ADVAPI32.@]
1661 BOOL WINAPI
ImpersonateLoggedOnUser(HANDLE hToken
)
1663 FIXME("(%p):stub returning FALSE\n", hToken
);
1667 /******************************************************************************
1668 * AccessCheck [ADVAPI32.@]
1672 PSECURITY_DESCRIPTOR SecurityDescriptor
,
1674 DWORD DesiredAccess
,
1675 PGENERIC_MAPPING GenericMapping
,
1676 PPRIVILEGE_SET PrivilegeSet
,
1677 LPDWORD PrivilegeSetLength
,
1678 LPDWORD GrantedAccess
,
1679 LPBOOL AccessStatus
)
1681 NTSTATUS access_status
;
1682 BOOL ret
= set_ntstatus( NtAccessCheck(SecurityDescriptor
, ClientToken
, DesiredAccess
,
1683 GenericMapping
, PrivilegeSet
, PrivilegeSetLength
,
1684 GrantedAccess
, &access_status
) );
1685 if (ret
) *AccessStatus
= set_ntstatus( access_status
);
1690 /******************************************************************************
1691 * AccessCheckByType [ADVAPI32.@]
1693 BOOL WINAPI
AccessCheckByType(
1694 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1695 PSID PrincipalSelfSid
,
1697 DWORD DesiredAccess
,
1698 POBJECT_TYPE_LIST ObjectTypeList
,
1699 DWORD ObjectTypeListLength
,
1700 PGENERIC_MAPPING GenericMapping
,
1701 PPRIVILEGE_SET PrivilegeSet
,
1702 LPDWORD PrivilegeSetLength
,
1703 LPDWORD GrantedAccess
,
1704 LPBOOL AccessStatus
)
1708 *AccessStatus
= TRUE
;
1710 return !*AccessStatus
;
1713 /******************************************************************************
1714 * MapGenericMask [ADVAPI32.@]
1716 * Maps generic access rights into specific access rights according to the
1720 * AccessMask [I/O] Access rights.
1721 * GenericMapping [I] The mapping between generic and specific rights.
1726 VOID WINAPI
MapGenericMask( PDWORD AccessMask
, PGENERIC_MAPPING GenericMapping
)
1728 RtlMapGenericMask( AccessMask
, GenericMapping
);
1731 /*************************************************************************
1732 * SetKernelObjectSecurity [ADVAPI32.@]
1734 BOOL WINAPI
SetKernelObjectSecurity (
1736 IN SECURITY_INFORMATION SecurityInformation
,
1737 IN PSECURITY_DESCRIPTOR SecurityDescriptor
)
1739 return set_ntstatus (NtSetSecurityObject (Handle
, SecurityInformation
, SecurityDescriptor
));
1743 /******************************************************************************
1744 * AddAuditAccessAce [ADVAPI32.@]
1746 BOOL WINAPI
AddAuditAccessAce(
1748 IN DWORD dwAceRevision
,
1749 IN DWORD dwAccessMask
,
1751 IN BOOL bAuditSuccess
,
1752 IN BOOL bAuditFailure
)
1754 return set_ntstatus( RtlAddAuditAccessAce(pAcl
, dwAceRevision
, dwAccessMask
, pSid
,
1755 bAuditSuccess
, bAuditFailure
) );
1758 /******************************************************************************
1759 * LookupAccountNameA [ADVAPI32.@]
1767 LPSTR ReferencedDomainName
,
1768 IN OUT LPDWORD cbReferencedDomainName
,
1769 OUT PSID_NAME_USE name_use
)
1771 /* Default implementation: Always return a default SID */
1772 SID_IDENTIFIER_AUTHORITY identifierAuthority
= {SECURITY_NT_AUTHORITY
};
1775 static const char dm
[] = "DOMAIN";
1777 FIXME("(%s,%s,%p,%p,%p,%p,%p), stub.\n",system
,account
,sid
,cbSid
,ReferencedDomainName
,cbReferencedDomainName
,name_use
);
1779 ret
= AllocateAndInitializeSid(&identifierAuthority
,
1781 SECURITY_BUILTIN_DOMAIN_RID
,
1782 DOMAIN_ALIAS_RID_ADMINS
,
1788 if(!RtlValidSid(pSid
))
1794 if (sid
!= NULL
&& (*cbSid
>= GetLengthSid(pSid
)))
1795 CopySid(*cbSid
, sid
, pSid
);
1796 if (*cbSid
< GetLengthSid(pSid
))
1798 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1801 *cbSid
= GetLengthSid(pSid
);
1803 if (ReferencedDomainName
!= NULL
&& (*cbReferencedDomainName
> strlen(dm
)))
1804 strcpy(ReferencedDomainName
, dm
);
1805 if (*cbReferencedDomainName
<= strlen(dm
))
1807 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1810 *cbReferencedDomainName
= strlen(dm
)+1;
1817 /******************************************************************************
1818 * LookupAccountNameW [ADVAPI32.@]
1820 BOOL WINAPI
LookupAccountNameW( LPCWSTR lpSystemName
, LPCWSTR lpAccountName
, PSID Sid
,
1821 LPDWORD cbSid
, LPWSTR ReferencedDomainName
,
1822 LPDWORD cchReferencedDomainName
, PSID_NAME_USE peUse
)
1824 FIXME("%s %s %p %p %p %p %p - stub\n", debugstr_w(lpSystemName
), debugstr_w(lpAccountName
),
1825 Sid
, cbSid
, ReferencedDomainName
, cchReferencedDomainName
, peUse
);
1830 /******************************************************************************
1831 * PrivilegeCheck [ADVAPI32.@]
1833 BOOL WINAPI
PrivilegeCheck( HANDLE ClientToken
, PPRIVILEGE_SET RequiredPrivileges
, LPBOOL pfResult
)
1838 TRACE("%p %p %p\n", ClientToken
, RequiredPrivileges
, pfResult
);
1840 ret
= set_ntstatus (NtPrivilegeCheck (ClientToken
, RequiredPrivileges
, &Result
));
1846 /******************************************************************************
1847 * AccessCheckAndAuditAlarmA [ADVAPI32.@]
1849 BOOL WINAPI
AccessCheckAndAuditAlarmA(LPCSTR Subsystem
, LPVOID HandleId
, LPSTR ObjectTypeName
,
1850 LPSTR ObjectName
, PSECURITY_DESCRIPTOR SecurityDescriptor
, DWORD DesiredAccess
,
1851 PGENERIC_MAPPING GenericMapping
, BOOL ObjectCreation
, LPDWORD GrantedAccess
,
1852 LPBOOL AccessStatus
, LPBOOL pfGenerateOnClose
)
1854 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_a(Subsystem
),
1855 HandleId
, debugstr_a(ObjectTypeName
), debugstr_a(ObjectName
),
1856 SecurityDescriptor
, DesiredAccess
, GenericMapping
,
1857 ObjectCreation
, GrantedAccess
, AccessStatus
, pfGenerateOnClose
);
1861 /******************************************************************************
1862 * AccessCheckAndAuditAlarmW [ADVAPI32.@]
1864 BOOL WINAPI
AccessCheckAndAuditAlarmW(LPCWSTR Subsystem
, LPVOID HandleId
, LPWSTR ObjectTypeName
,
1865 LPWSTR ObjectName
, PSECURITY_DESCRIPTOR SecurityDescriptor
, DWORD DesiredAccess
,
1866 PGENERIC_MAPPING GenericMapping
, BOOL ObjectCreation
, LPDWORD GrantedAccess
,
1867 LPBOOL AccessStatus
, LPBOOL pfGenerateOnClose
)
1869 FIXME("stub (%s,%p,%s,%s,%p,%08lx,%p,%x,%p,%p,%p)\n", debugstr_w(Subsystem
),
1870 HandleId
, debugstr_w(ObjectTypeName
), debugstr_w(ObjectName
),
1871 SecurityDescriptor
, DesiredAccess
, GenericMapping
,
1872 ObjectCreation
, GrantedAccess
, AccessStatus
, pfGenerateOnClose
);
1876 BOOL WINAPI
ObjectCloseAuditAlarmA(LPCSTR SubsystemName
, LPVOID HandleId
, BOOL GenerateOnClose
)
1878 FIXME("stub (%s,%p,%x)\n", debugstr_a(SubsystemName
), HandleId
, GenerateOnClose
);
1883 BOOL WINAPI
ObjectCloseAuditAlarmW(LPCWSTR SubsystemName
, LPVOID HandleId
, BOOL GenerateOnClose
)
1885 FIXME("stub (%s,%p,%x)\n", debugstr_w(SubsystemName
), HandleId
, GenerateOnClose
);
1890 BOOL WINAPI
ObjectOpenAuditAlarmA(LPCSTR SubsystemName
, LPVOID HandleId
, LPSTR ObjectTypeName
,
1891 LPSTR ObjectName
, PSECURITY_DESCRIPTOR pSecurityDescriptor
, HANDLE ClientToken
, DWORD DesiredAccess
,
1892 DWORD GrantedAccess
, PPRIVILEGE_SET Privileges
, BOOL ObjectCreation
, BOOL AccessGranted
,
1893 LPBOOL GenerateOnClose
)
1895 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_a(SubsystemName
),
1896 HandleId
, debugstr_a(ObjectTypeName
), debugstr_a(ObjectName
), pSecurityDescriptor
,
1897 ClientToken
, DesiredAccess
, GrantedAccess
, Privileges
, ObjectCreation
, AccessGranted
,
1903 BOOL WINAPI
ObjectOpenAuditAlarmW(LPCWSTR SubsystemName
, LPVOID HandleId
, LPWSTR ObjectTypeName
,
1904 LPWSTR ObjectName
, PSECURITY_DESCRIPTOR pSecurityDescriptor
, HANDLE ClientToken
, DWORD DesiredAccess
,
1905 DWORD GrantedAccess
, PPRIVILEGE_SET Privileges
, BOOL ObjectCreation
, BOOL AccessGranted
,
1906 LPBOOL GenerateOnClose
)
1908 FIXME("stub (%s,%p,%s,%s,%p,%p,0x%08lx,0x%08lx,%p,%x,%x,%p)\n", debugstr_w(SubsystemName
),
1909 HandleId
, debugstr_w(ObjectTypeName
), debugstr_w(ObjectName
), pSecurityDescriptor
,
1910 ClientToken
, DesiredAccess
, GrantedAccess
, Privileges
, ObjectCreation
, AccessGranted
,
1916 BOOL WINAPI
ObjectPrivilegeAuditAlarmA( LPCSTR SubsystemName
, LPVOID HandleId
, HANDLE ClientToken
,
1917 DWORD DesiredAccess
, PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1919 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_a(SubsystemName
), HandleId
, ClientToken
,
1920 DesiredAccess
, Privileges
, AccessGranted
);
1925 BOOL WINAPI
ObjectPrivilegeAuditAlarmW( LPCWSTR SubsystemName
, LPVOID HandleId
, HANDLE ClientToken
,
1926 DWORD DesiredAccess
, PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1928 FIXME("stub (%s,%p,%p,0x%08lx,%p,%x)\n", debugstr_w(SubsystemName
), HandleId
, ClientToken
,
1929 DesiredAccess
, Privileges
, AccessGranted
);
1934 BOOL WINAPI
PrivilegedServiceAuditAlarmA( LPCSTR SubsystemName
, LPCSTR ServiceName
, HANDLE ClientToken
,
1935 PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1937 FIXME("stub (%s,%s,%p,%p,%x)\n", debugstr_a(SubsystemName
), debugstr_a(ServiceName
),
1938 ClientToken
, Privileges
, AccessGranted
);
1943 BOOL WINAPI
PrivilegedServiceAuditAlarmW( LPCWSTR SubsystemName
, LPCWSTR ServiceName
, HANDLE ClientToken
,
1944 PPRIVILEGE_SET Privileges
, BOOL AccessGranted
)
1946 FIXME("stub %s,%s,%p,%p,%x)\n", debugstr_w(SubsystemName
), debugstr_w(ServiceName
),
1947 ClientToken
, Privileges
, AccessGranted
);
1952 /******************************************************************************
1953 * GetSecurityInfo [ADVAPI32.@]
1955 DWORD WINAPI
GetSecurityInfo(
1956 HANDLE hObject
, SE_OBJECT_TYPE ObjectType
,
1957 SECURITY_INFORMATION SecurityInfo
, PSID
*ppsidOwner
,
1958 PSID
*ppsidGroup
, PACL
*ppDacl
, PACL
*ppSacl
,
1959 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
1963 return ERROR_BAD_PROVIDER
;
1966 /******************************************************************************
1967 * GetSecurityInfoExW [ADVAPI32.@]
1969 DWORD WINAPI
GetSecurityInfoExW(
1970 HANDLE hObject
, SE_OBJECT_TYPE ObjectType
,
1971 SECURITY_INFORMATION SecurityInfo
, LPCWSTR lpProvider
,
1972 LPCWSTR lpProperty
, PACTRL_ACCESSW
*ppAccessList
,
1973 PACTRL_AUDITW
*ppAuditList
, LPWSTR
*lppOwner
, LPWSTR
*lppGroup
1977 return ERROR_BAD_PROVIDER
;
1980 /******************************************************************************
1981 * BuildExplicitAccessWithNameA [ADVAPI32.@]
1983 VOID WINAPI
BuildExplicitAccessWithNameA( PEXPLICIT_ACCESSA pExplicitAccess
,
1984 LPSTR pTrusteeName
, DWORD AccessPermissions
,
1985 ACCESS_MODE AccessMode
, DWORD Inheritance
)
1987 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess
, debugstr_a(pTrusteeName
),
1988 AccessPermissions
, AccessMode
, Inheritance
);
1990 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
1991 pExplicitAccess
->grfAccessMode
= AccessMode
;
1992 pExplicitAccess
->grfInheritance
= Inheritance
;
1994 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
1995 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
1996 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
1997 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
1998 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
2001 /******************************************************************************
2002 * BuildExplicitAccessWithNameW [ADVAPI32.@]
2004 VOID WINAPI
BuildExplicitAccessWithNameW( PEXPLICIT_ACCESSW pExplicitAccess
,
2005 LPWSTR pTrusteeName
, DWORD AccessPermissions
,
2006 ACCESS_MODE AccessMode
, DWORD Inheritance
)
2008 TRACE("%p %s 0x%08lx 0x%08x 0x%08lx\n", pExplicitAccess
, debugstr_w(pTrusteeName
),
2009 AccessPermissions
, AccessMode
, Inheritance
);
2011 pExplicitAccess
->grfAccessPermissions
= AccessPermissions
;
2012 pExplicitAccess
->grfAccessMode
= AccessMode
;
2013 pExplicitAccess
->grfInheritance
= Inheritance
;
2015 pExplicitAccess
->Trustee
.pMultipleTrustee
= NULL
;
2016 pExplicitAccess
->Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2017 pExplicitAccess
->Trustee
.TrusteeForm
= TRUSTEE_IS_NAME
;
2018 pExplicitAccess
->Trustee
.TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2019 pExplicitAccess
->Trustee
.ptstrName
= pTrusteeName
;
2022 /******************************************************************************
2023 * BuildTrusteeWithObjectsAndNameA [ADVAPI32.@]
2025 VOID WINAPI
BuildTrusteeWithObjectsAndNameA( PTRUSTEEA pTrustee
, POBJECTS_AND_NAME_A pObjName
,
2026 SE_OBJECT_TYPE ObjectType
, LPSTR ObjectTypeName
,
2027 LPSTR InheritedObjectTypeName
, LPSTR Name
)
2029 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
2030 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, debugstr_a(Name
));
2032 pTrustee
->pMultipleTrustee
= NULL
;
2033 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2034 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
2035 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2036 pTrustee
->ptstrName
= Name
;
2039 /******************************************************************************
2040 * BuildTrusteeWithObjectsAndNameW [ADVAPI32.@]
2042 VOID WINAPI
BuildTrusteeWithObjectsAndNameW( PTRUSTEEW pTrustee
, POBJECTS_AND_NAME_W pObjName
,
2043 SE_OBJECT_TYPE ObjectType
, LPWSTR ObjectTypeName
,
2044 LPWSTR InheritedObjectTypeName
, LPWSTR Name
)
2046 TRACE("%p %p 0x%08x %p %p %s\n", pTrustee
, pObjName
,
2047 ObjectType
, ObjectTypeName
, InheritedObjectTypeName
, debugstr_w(Name
));
2049 pTrustee
->pMultipleTrustee
= NULL
;
2050 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2051 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_NAME
;
2052 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2053 pTrustee
->ptstrName
= Name
;
2056 VOID WINAPI
BuildTrusteeWithObjectsAndSidA( PTRUSTEEA pTrustee
, POBJECTS_AND_SID pObjSid
,
2057 GUID
* pObjectGuid
, GUID
* pInheritedObjectGuid
, PSID pSid
)
2059 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
2061 pTrustee
->pMultipleTrustee
= NULL
;
2062 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2063 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
2064 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2065 pTrustee
->ptstrName
= (LPSTR
) pSid
;
2068 VOID WINAPI
BuildTrusteeWithObjectsAndSidW( PTRUSTEEW pTrustee
, POBJECTS_AND_SID pObjSid
,
2069 GUID
* pObjectGuid
, GUID
* pInheritedObjectGuid
, PSID pSid
)
2071 TRACE("%p %p %p %p %p\n", pTrustee
, pObjSid
, pObjectGuid
, pInheritedObjectGuid
, pSid
);
2073 pTrustee
->pMultipleTrustee
= NULL
;
2074 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2075 pTrustee
->TrusteeForm
= TRUSTEE_IS_OBJECTS_AND_SID
;
2076 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2077 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
2080 /******************************************************************************
2081 * BuildTrusteeWithSidA [ADVAPI32.@]
2083 VOID WINAPI
BuildTrusteeWithSidA(PTRUSTEEA pTrustee
, PSID pSid
)
2085 TRACE("%p %p\n", pTrustee
, pSid
);
2087 pTrustee
->pMultipleTrustee
= NULL
;
2088 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2089 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
2090 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2091 pTrustee
->ptstrName
= (LPSTR
) pSid
;
2094 /******************************************************************************
2095 * BuildTrusteeWithSidW [ADVAPI32.@]
2097 VOID WINAPI
BuildTrusteeWithSidW(PTRUSTEEW pTrustee
, PSID pSid
)
2099 TRACE("%p %p\n", pTrustee
, pSid
);
2101 pTrustee
->pMultipleTrustee
= NULL
;
2102 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2103 pTrustee
->TrusteeForm
= TRUSTEE_IS_SID
;
2104 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2105 pTrustee
->ptstrName
= (LPWSTR
) pSid
;
2108 /******************************************************************************
2109 * BuildTrusteeWithNameA [ADVAPI32.@]
2111 VOID WINAPI
BuildTrusteeWithNameA(PTRUSTEEA pTrustee
, LPSTR name
)
2113 TRACE("%p %s\n", pTrustee
, debugstr_a(name
) );
2115 pTrustee
->pMultipleTrustee
= NULL
;
2116 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2117 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
2118 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2119 pTrustee
->ptstrName
= name
;
2122 /******************************************************************************
2123 * BuildTrusteeWithNameW [ADVAPI32.@]
2125 VOID WINAPI
BuildTrusteeWithNameW(PTRUSTEEW pTrustee
, LPWSTR name
)
2127 TRACE("%p %s\n", pTrustee
, debugstr_w(name
) );
2129 pTrustee
->pMultipleTrustee
= NULL
;
2130 pTrustee
->MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
2131 pTrustee
->TrusteeForm
= TRUSTEE_IS_NAME
;
2132 pTrustee
->TrusteeType
= TRUSTEE_IS_UNKNOWN
;
2133 pTrustee
->ptstrName
= name
;
2136 /******************************************************************************
2137 * GetTrusteeFormA [ADVAPI32.@]
2139 TRUSTEE_FORM WINAPI
GetTrusteeFormA(PTRUSTEEA pTrustee
)
2141 TRACE("(%p)\n", pTrustee
);
2144 return TRUSTEE_BAD_FORM
;
2146 return pTrustee
->TrusteeForm
;
2149 /******************************************************************************
2150 * GetTrusteeFormW [ADVAPI32.@]
2152 TRUSTEE_FORM WINAPI
GetTrusteeFormW(PTRUSTEEW pTrustee
)
2154 TRACE("(%p)\n", pTrustee
);
2157 return TRUSTEE_BAD_FORM
;
2159 return pTrustee
->TrusteeForm
;
2162 /******************************************************************************
2163 * GetTrusteeNameA [ADVAPI32.@]
2165 LPSTR WINAPI
GetTrusteeNameA(PTRUSTEEA pTrustee
)
2167 TRACE("(%p)\n", pTrustee
);
2172 return pTrustee
->ptstrName
;
2175 /******************************************************************************
2176 * GetTrusteeNameW [ADVAPI32.@]
2178 LPWSTR WINAPI
GetTrusteeNameW(PTRUSTEEW pTrustee
)
2180 TRACE("(%p)\n", pTrustee
);
2185 return pTrustee
->ptstrName
;
2188 /******************************************************************************
2189 * GetTrusteeTypeA [ADVAPI32.@]
2191 TRUSTEE_TYPE WINAPI
GetTrusteeTypeA(PTRUSTEEA pTrustee
)
2193 TRACE("(%p)\n", pTrustee
);
2196 return TRUSTEE_IS_UNKNOWN
;
2198 return pTrustee
->TrusteeType
;
2201 /******************************************************************************
2202 * GetTrusteeTypeW [ADVAPI32.@]
2204 TRUSTEE_TYPE WINAPI
GetTrusteeTypeW(PTRUSTEEW pTrustee
)
2206 TRACE("(%p)\n", pTrustee
);
2209 return TRUSTEE_IS_UNKNOWN
;
2211 return pTrustee
->TrusteeType
;
2214 BOOL WINAPI
SetAclInformation( PACL pAcl
, LPVOID pAclInformation
,
2215 DWORD nAclInformationLength
,
2216 ACL_INFORMATION_CLASS dwAclInformationClass
)
2218 FIXME("%p %p 0x%08lx 0x%08x - stub\n", pAcl
, pAclInformation
,
2219 nAclInformationLength
, dwAclInformationClass
);
2224 /******************************************************************************
2225 * SetEntriesInAclA [ADVAPI32.@]
2227 DWORD WINAPI
SetEntriesInAclA( ULONG count
, PEXPLICIT_ACCESSA pEntries
,
2228 PACL OldAcl
, PACL
* NewAcl
)
2230 FIXME("%ld %p %p %p\n",count
,pEntries
,OldAcl
,NewAcl
);
2231 return ERROR_CALL_NOT_IMPLEMENTED
;
2234 /******************************************************************************
2235 * SetEntriesInAclW [ADVAPI32.@]
2237 DWORD WINAPI
SetEntriesInAclW( ULONG count
, PEXPLICIT_ACCESSW pEntries
,
2238 PACL OldAcl
, PACL
* NewAcl
)
2240 FIXME("%ld %p %p %p\n",count
,pEntries
,OldAcl
,NewAcl
);
2241 return ERROR_CALL_NOT_IMPLEMENTED
;
2244 /******************************************************************************
2245 * SetNamedSecurityInfoA [ADVAPI32.@]
2247 DWORD WINAPI
SetNamedSecurityInfoA(LPSTR pObjectName
,
2248 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
2249 PSID psidOwner
, PSID psidGroup
, PACL pDacl
, PACL pSacl
)
2255 TRACE("%s %d %ld %p %p %p %p\n", debugstr_a(pObjectName
), ObjectType
,
2256 SecurityInfo
, psidOwner
, psidGroup
, pDacl
, pSacl
);
2260 len
= MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, NULL
, 0 );
2261 wstr
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
));
2262 MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, wstr
, len
);
2265 r
= SetNamedSecurityInfoW( wstr
, ObjectType
, SecurityInfo
, psidOwner
,
2266 psidGroup
, pDacl
, pSacl
);
2268 HeapFree( GetProcessHeap(), 0, wstr
);
2273 BOOL WINAPI
SetPrivateObjectSecurity( SECURITY_INFORMATION SecurityInformation
,
2274 PSECURITY_DESCRIPTOR ModificationDescriptor
,
2275 PSECURITY_DESCRIPTOR
* ObjectsSecurityDescriptor
,
2276 PGENERIC_MAPPING GenericMapping
,
2279 FIXME("0x%08lx %p %p %p %p - stub\n", SecurityInformation
, ModificationDescriptor
,
2280 ObjectsSecurityDescriptor
, GenericMapping
, Token
);
2285 BOOL WINAPI
SetSecurityDescriptorControl( PSECURITY_DESCRIPTOR pSecurityDescriptor
,
2286 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
2287 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
)
2289 FIXME("%p 0x%08x 0x%08x - stub\n", pSecurityDescriptor
, ControlBitsOfInterest
,
2295 BOOL WINAPI
AreAllAccessesGranted( DWORD GrantedAccess
, DWORD DesiredAccess
)
2297 return RtlAreAllAccessesGranted( GrantedAccess
, DesiredAccess
);
2300 /******************************************************************************
2301 * AreAnyAccessesGranted [ADVAPI32.@]
2303 * Determines whether or not any of a set of specified access permissions have
2304 * been granted or not.
2307 * GrantedAccess [I] The permissions that have been granted.
2308 * DesiredAccess [I] The permissions that you want to have.
2311 * Nonzero if any of the permissions have been granted, zero if none of the
2312 * permissions have been granted.
2315 BOOL WINAPI
AreAnyAccessesGranted( DWORD GrantedAccess
, DWORD DesiredAccess
)
2317 return RtlAreAnyAccessesGranted( GrantedAccess
, DesiredAccess
);
2320 /******************************************************************************
2321 * SetNamedSecurityInfoW [ADVAPI32.@]
2323 DWORD WINAPI
SetNamedSecurityInfoW(LPWSTR pObjectName
,
2324 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
2325 PSID psidOwner
, PSID psidGroup
, PACL pDacl
, PACL pSacl
)
2327 FIXME("%s %d %ld %p %p %p %p\n", debugstr_w(pObjectName
), ObjectType
,
2328 SecurityInfo
, psidOwner
, psidGroup
, pDacl
, pSacl
);
2329 return ERROR_SUCCESS
;
2332 /******************************************************************************
2333 * GetExplicitEntriesFromAclA [ADVAPI32.@]
2335 DWORD WINAPI
GetExplicitEntriesFromAclA( PACL pacl
, PULONG pcCountOfExplicitEntries
,
2336 PEXPLICIT_ACCESSA
* pListOfExplicitEntries
)
2338 FIXME("%p %p %p\n",pacl
, pcCountOfExplicitEntries
, pListOfExplicitEntries
);
2339 return ERROR_CALL_NOT_IMPLEMENTED
;
2342 /******************************************************************************
2343 * GetExplicitEntriesFromAclW [ADVAPI32.@]
2345 DWORD WINAPI
GetExplicitEntriesFromAclW( PACL pacl
, PULONG pcCountOfExplicitEntries
,
2346 PEXPLICIT_ACCESSW
* pListOfExplicitEntries
)
2348 FIXME("%p %p %p\n",pacl
, pcCountOfExplicitEntries
, pListOfExplicitEntries
);
2349 return ERROR_CALL_NOT_IMPLEMENTED
;
2353 /******************************************************************************
2354 * ParseAclStringFlags
2356 static DWORD
ParseAclStringFlags(LPCWSTR
* StringAcl
)
2359 LPCWSTR szAcl
= *StringAcl
;
2361 while (*szAcl
!= '(')
2365 flags
|= SE_DACL_PROTECTED
;
2367 else if (*szAcl
== 'A')
2371 flags
|= SE_DACL_AUTO_INHERIT_REQ
;
2372 else if (*szAcl
== 'I')
2373 flags
|= SE_DACL_AUTO_INHERITED
;
2382 /******************************************************************************
2383 * ParseAceStringType
2387 { SDDL_ACCESS_ALLOWED
, ACCESS_ALLOWED_ACE_TYPE
},
2388 { SDDL_ALARM
, SYSTEM_ALARM_ACE_TYPE
},
2389 { SDDL_AUDIT
, SYSTEM_AUDIT_ACE_TYPE
},
2390 { SDDL_ACCESS_DENIED
, ACCESS_DENIED_ACE_TYPE
},
2392 { SDDL_OBJECT_ACCESS_ALLOWED, ACCESS_ALLOWED_OBJECT_ACE_TYPE },
2393 { SDDL_OBJECT_ACCESS_DENIED, ACCESS_DENIED_OBJECT_ACE_TYPE },
2394 { SDDL_OBJECT_ALARM, SYSTEM_ALARM_OBJECT_ACE_TYPE },
2395 { SDDL_OBJECT_AUDIT, SYSTEM_AUDIT_OBJECT_ACE_TYPE },
2400 static BYTE
ParseAceStringType(LPCWSTR
* StringAcl
)
2403 LPCWSTR szAcl
= *StringAcl
;
2404 LPACEFLAG lpaf
= AceType
;
2406 while (lpaf
->wstr
&&
2407 (len
= strlenW(lpaf
->wstr
)) &&
2408 strncmpW(lpaf
->wstr
, szAcl
, len
))
2419 /******************************************************************************
2420 * ParseAceStringFlags
2422 ACEFLAG AceFlags
[] =
2424 { SDDL_CONTAINER_INHERIT
, CONTAINER_INHERIT_ACE
},
2425 { SDDL_AUDIT_FAILURE
, FAILED_ACCESS_ACE_FLAG
},
2426 { SDDL_INHERITED
, INHERITED_ACE
},
2427 { SDDL_INHERIT_ONLY
, INHERIT_ONLY_ACE
},
2428 { SDDL_NO_PROPAGATE
, NO_PROPAGATE_INHERIT_ACE
},
2429 { SDDL_OBJECT_INHERIT
, OBJECT_INHERIT_ACE
},
2430 { SDDL_AUDIT_SUCCESS
, SUCCESSFUL_ACCESS_ACE_FLAG
},
2434 static BYTE
ParseAceStringFlags(LPCWSTR
* StringAcl
)
2438 LPCWSTR szAcl
= *StringAcl
;
2440 while (*szAcl
!= ';')
2442 LPACEFLAG lpaf
= AceFlags
;
2444 while (lpaf
->wstr
&&
2445 (len
= strlenW(lpaf
->wstr
)) &&
2446 strncmpW(lpaf
->wstr
, szAcl
, len
))
2452 flags
|= lpaf
->value
;
2461 /******************************************************************************
2462 * ParseAceStringRights
2464 ACEFLAG AceRights
[] =
2466 { SDDL_GENERIC_ALL
, GENERIC_ALL
},
2467 { SDDL_GENERIC_READ
, GENERIC_READ
},
2468 { SDDL_GENERIC_WRITE
, GENERIC_WRITE
},
2469 { SDDL_GENERIC_EXECUTE
, GENERIC_EXECUTE
},
2470 { SDDL_READ_CONTROL
, READ_CONTROL
},
2471 { SDDL_STANDARD_DELETE
, DELETE
},
2472 { SDDL_WRITE_DAC
, WRITE_DAC
},
2473 { SDDL_WRITE_OWNER
, WRITE_OWNER
},
2477 static DWORD
ParseAceStringRights(LPCWSTR
* StringAcl
)
2481 LPCWSTR szAcl
= *StringAcl
;
2483 if ((*szAcl
== '0') && (*(szAcl
+ 1) == 'x'))
2487 while (*p
&& *p
!= ';')
2492 rights
= strtoulW(szAcl
, NULL
, 16);
2496 WARN("Invalid rights string format: %s\n", debugstr_wn(szAcl
, p
- szAcl
));
2500 while (*szAcl
!= ';')
2502 LPACEFLAG lpaf
= AceRights
;
2504 while (lpaf
->wstr
&&
2505 (len
= strlenW(lpaf
->wstr
)) &&
2506 strncmpW(lpaf
->wstr
, szAcl
, len
))
2514 rights
|= lpaf
->value
;
2524 /******************************************************************************
2525 * ParseStringAclToAcl
2527 * dacl_flags(string_ace1)(string_ace2)... (string_acen)
2529 static BOOL
ParseStringAclToAcl(LPCWSTR StringAcl
, LPDWORD lpdwFlags
,
2530 PACL pAcl
, LPDWORD cBytes
)
2534 DWORD length
= sizeof(ACL
);
2535 PACCESS_ALLOWED_ACE pAce
= NULL
; /* pointer to current ACE */
2537 TRACE("%s\n", debugstr_w(StringAcl
));
2542 if (pAcl
) /* pAce is only useful if we're setting values */
2543 pAce
= (PACCESS_ALLOWED_ACE
) ((LPBYTE
)pAcl
+ sizeof(PACL
));
2545 /* Parse ACL flags */
2546 *lpdwFlags
= ParseAclStringFlags(&StringAcl
);
2549 while (*StringAcl
== '(')
2553 /* Parse ACE type */
2554 val
= ParseAceStringType(&StringAcl
);
2556 pAce
->Header
.AceType
= (BYTE
) val
;
2557 if (*StringAcl
!= ';')
2561 /* Parse ACE flags */
2562 val
= ParseAceStringFlags(&StringAcl
);
2564 pAce
->Header
.AceFlags
= (BYTE
) val
;
2565 if (*StringAcl
!= ';')
2569 /* Parse ACE rights */
2570 val
= ParseAceStringRights(&StringAcl
);
2573 if (*StringAcl
!= ';')
2577 /* Parse ACE object guid */
2578 if (*StringAcl
!= ';')
2580 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2585 /* Parse ACE inherit object guid */
2586 if (*StringAcl
!= ';')
2588 FIXME("Support for *_OBJECT_ACE_TYPE not implemented\n");
2593 /* Parse ACE account sid */
2594 if (ParseStringSidToSid(StringAcl
, pAce
? (PSID
)&pAce
->SidStart
: NULL
, &sidlen
))
2596 while (*StringAcl
&& *StringAcl
!= ')')
2600 if (*StringAcl
!= ')')
2604 length
+= sizeof(ACCESS_ALLOWED_ACE
) - sizeof(DWORD
) + sidlen
;
2611 WARN("Invalid ACE string format\n");
2616 /******************************************************************************
2617 * ParseStringSecurityDescriptorToSecurityDescriptor
2619 static BOOL
ParseStringSecurityDescriptorToSecurityDescriptor(
2620 LPCWSTR StringSecurityDescriptor
,
2621 SECURITY_DESCRIPTOR
* SecurityDescriptor
,
2626 WCHAR tok
[MAX_PATH
];
2628 LPBYTE lpNext
= NULL
;
2633 if (SecurityDescriptor
)
2634 lpNext
= ((LPBYTE
) SecurityDescriptor
) + sizeof(SECURITY_DESCRIPTOR
);
2636 while (*StringSecurityDescriptor
)
2638 toktype
= *StringSecurityDescriptor
;
2640 /* Expect char identifier followed by ':' */
2641 StringSecurityDescriptor
++;
2642 if (*StringSecurityDescriptor
!= ':')
2644 SetLastError(ERROR_INVALID_PARAMETER
);
2647 StringSecurityDescriptor
++;
2650 lptoken
= StringSecurityDescriptor
;
2651 while (*lptoken
&& *lptoken
!= ':')
2657 len
= lptoken
- StringSecurityDescriptor
;
2658 memcpy( tok
, StringSecurityDescriptor
, len
* sizeof(WCHAR
) );
2667 if (!ParseStringSidToSid(tok
, (PSID
)lpNext
, &bytes
))
2670 if (SecurityDescriptor
)
2672 SecurityDescriptor
->Owner
= (PSID
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2673 lpNext
+= bytes
; /* Advance to next token */
2685 if (!ParseStringSidToSid(tok
, (PSID
)lpNext
, &bytes
))
2688 if (SecurityDescriptor
)
2690 SecurityDescriptor
->Group
= (PSID
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2691 lpNext
+= bytes
; /* Advance to next token */
2704 if (!ParseStringAclToAcl(tok
, &flags
, (PACL
)lpNext
, &bytes
))
2707 if (SecurityDescriptor
)
2709 SecurityDescriptor
->Control
|= SE_DACL_PRESENT
| flags
;
2710 SecurityDescriptor
->Dacl
= (PACL
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2711 lpNext
+= bytes
; /* Advance to next token */
2724 if (!ParseStringAclToAcl(tok
, &flags
, (PACL
)lpNext
, &bytes
))
2727 if (SecurityDescriptor
)
2729 SecurityDescriptor
->Control
|= SE_SACL_PRESENT
| flags
;
2730 SecurityDescriptor
->Sacl
= (PACL
)(lpNext
- (LPBYTE
)SecurityDescriptor
);
2731 lpNext
+= bytes
; /* Advance to next token */
2740 FIXME("Unknown token\n");
2741 SetLastError(ERROR_INVALID_PARAMETER
);
2745 StringSecurityDescriptor
= lptoken
;
2754 /******************************************************************************
2755 * ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@]
2757 BOOL WINAPI
ConvertStringSecurityDescriptorToSecurityDescriptorA(
2758 LPCSTR StringSecurityDescriptor
,
2759 DWORD StringSDRevision
,
2760 PSECURITY_DESCRIPTOR
* SecurityDescriptor
,
2761 PULONG SecurityDescriptorSize
)
2765 LPWSTR StringSecurityDescriptorW
;
2767 len
= MultiByteToWideChar(CP_ACP
, 0, StringSecurityDescriptor
, -1, NULL
, 0);
2768 StringSecurityDescriptorW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
2770 if (StringSecurityDescriptorW
)
2772 MultiByteToWideChar(CP_ACP
, 0, StringSecurityDescriptor
, -1, StringSecurityDescriptorW
, len
);
2774 ret
= ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW
,
2775 StringSDRevision
, SecurityDescriptor
,
2776 SecurityDescriptorSize
);
2777 HeapFree(GetProcessHeap(), 0, StringSecurityDescriptorW
);
2783 /******************************************************************************
2784 * ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@]
2786 BOOL WINAPI
ConvertStringSecurityDescriptorToSecurityDescriptorW(
2787 LPCWSTR StringSecurityDescriptor
,
2788 DWORD StringSDRevision
,
2789 PSECURITY_DESCRIPTOR
* SecurityDescriptor
,
2790 PULONG SecurityDescriptorSize
)
2793 SECURITY_DESCRIPTOR
* psd
;
2796 TRACE("%s\n", debugstr_w(StringSecurityDescriptor
));
2798 if (GetVersion() & 0x80000000)
2800 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2803 else if (StringSDRevision
!= SID_REVISION
)
2805 SetLastError(ERROR_UNKNOWN_REVISION
);
2809 /* Compute security descriptor length */
2810 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor
,
2814 psd
= *SecurityDescriptor
= (SECURITY_DESCRIPTOR
*) LocalAlloc(
2815 GMEM_ZEROINIT
, cBytes
);
2817 psd
->Revision
= SID_REVISION
;
2818 psd
->Control
|= SE_SELF_RELATIVE
;
2820 if (!ParseStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptor
,
2827 if (SecurityDescriptorSize
)
2828 *SecurityDescriptorSize
= cBytes
;
2833 TRACE(" ret=%d\n", bret
);
2837 /******************************************************************************
2838 * ConvertStringSidToSidW [ADVAPI32.@]
2840 BOOL WINAPI
ConvertStringSidToSidW(LPCWSTR StringSid
, PSID
* Sid
)
2845 TRACE("%s, %p\n", debugstr_w(StringSid
), Sid
);
2846 if (GetVersion() & 0x80000000)
2847 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2848 else if (!StringSid
|| !Sid
)
2849 SetLastError(ERROR_INVALID_PARAMETER
);
2850 else if (ParseStringSidToSid(StringSid
, NULL
, &cBytes
))
2852 PSID pSid
= *Sid
= (PSID
) LocalAlloc(0, cBytes
);
2854 bret
= ParseStringSidToSid(StringSid
, pSid
, &cBytes
);
2858 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
2862 /******************************************************************************
2863 * ConvertStringSidToSidA [ADVAPI32.@]
2865 BOOL WINAPI
ConvertStringSidToSidA(LPCSTR StringSid
, PSID
* Sid
)
2869 TRACE("%s, %p\n", debugstr_a(StringSid
), Sid
);
2870 if (GetVersion() & 0x80000000)
2871 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2872 else if (!StringSid
|| !Sid
)
2873 SetLastError(ERROR_INVALID_PARAMETER
);
2876 UINT len
= MultiByteToWideChar(CP_ACP
, 0, StringSid
, -1, NULL
, 0);
2877 LPWSTR wStringSid
= HeapAlloc(GetProcessHeap(), 0,
2878 len
* sizeof(WCHAR
));
2880 MultiByteToWideChar(CP_ACP
, 0, StringSid
, -1, wStringSid
, len
);
2881 bret
= ConvertStringSidToSidW(wStringSid
, Sid
);
2882 HeapFree(GetProcessHeap(), 0, wStringSid
);
2884 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
2888 /******************************************************************************
2889 * ConvertSidToStringSidW [ADVAPI32.@]
2891 * format of SID string is:
2892 * S-<count>-<auth>-<subauth1>-<subauth2>-<subauth3>...
2894 * <rev> is the revision of the SID encoded as decimal
2895 * <auth> is the identifier authority encoded as hex
2896 * <subauthN> is the subauthority id encoded as decimal
2898 BOOL WINAPI
ConvertSidToStringSidW( PSID pSid
, LPWSTR
*pstr
)
2902 WCHAR fmt
[] = { 'S','-','%','u','-','%','d',0 };
2903 WCHAR subauthfmt
[] = { '-','%','u',0 };
2906 TRACE("%p %p\n", pSid
, pstr
);
2908 if( !IsValidSid( pSid
) )
2911 if (pisid
->Revision
!= SDDL_REVISION
)
2913 if (pisid
->IdentifierAuthority
.Value
[0] ||
2914 pisid
->IdentifierAuthority
.Value
[1])
2916 FIXME("not matching MS' bugs\n");
2920 sz
= 14 + pisid
->SubAuthorityCount
* 11;
2921 str
= LocalAlloc( 0, sz
*sizeof(WCHAR
) );
2922 sprintfW( str
, fmt
, pisid
->Revision
, MAKELONG(
2923 MAKEWORD( pisid
->IdentifierAuthority
.Value
[5],
2924 pisid
->IdentifierAuthority
.Value
[4] ),
2925 MAKEWORD( pisid
->IdentifierAuthority
.Value
[3],
2926 pisid
->IdentifierAuthority
.Value
[2] ) ) );
2927 for( i
=0; i
<pisid
->SubAuthorityCount
; i
++ )
2928 sprintfW( str
+ strlenW(str
), subauthfmt
, pisid
->SubAuthority
[i
] );
2934 /******************************************************************************
2935 * ConvertSidToStringSidA [ADVAPI32.@]
2937 BOOL WINAPI
ConvertSidToStringSidA(PSID pSid
, LPSTR
*pstr
)
2943 TRACE("%p %p\n", pSid
, pstr
);
2945 if( !ConvertSidToStringSidW( pSid
, &wstr
) )
2948 len
= WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, NULL
, 0, NULL
, NULL
);
2949 str
= LocalAlloc( 0, len
);
2950 WideCharToMultiByte( CP_ACP
, 0, wstr
, -1, str
, len
, NULL
, NULL
);
2958 BOOL WINAPI
CreatePrivateObjectSecurity(
2959 PSECURITY_DESCRIPTOR ParentDescriptor
,
2960 PSECURITY_DESCRIPTOR CreatorDescriptor
,
2961 PSECURITY_DESCRIPTOR
* NewDescriptor
,
2962 BOOL IsDirectoryObject
,
2964 PGENERIC_MAPPING GenericMapping
)
2966 FIXME("%p %p %p %d %p %p - stub\n", ParentDescriptor
, CreatorDescriptor
,
2967 NewDescriptor
, IsDirectoryObject
, Token
, GenericMapping
);
2972 BOOL WINAPI
DestroyPrivateObjectSecurity( PSECURITY_DESCRIPTOR
* ObjectDescriptor
)
2974 FIXME("%p - stub\n", ObjectDescriptor
);
2979 BOOL WINAPI
CreateProcessAsUserA(
2981 LPCSTR lpApplicationName
,
2982 LPSTR lpCommandLine
,
2983 LPSECURITY_ATTRIBUTES lpProcessAttributes
,
2984 LPSECURITY_ATTRIBUTES lpThreadAttributes
,
2985 BOOL bInheritHandles
,
2986 DWORD dwCreationFlags
,
2987 LPVOID lpEnvironment
,
2988 LPCSTR lpCurrentDirectory
,
2989 LPSTARTUPINFOA lpStartupInfo
,
2990 LPPROCESS_INFORMATION lpProcessInformation
)
2992 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - stub\n", hToken
, debugstr_a(lpApplicationName
),
2993 debugstr_a(lpCommandLine
), lpProcessAttributes
, lpThreadAttributes
, bInheritHandles
,
2994 dwCreationFlags
, lpEnvironment
, debugstr_a(lpCurrentDirectory
), lpStartupInfo
, lpProcessInformation
);
2999 BOOL WINAPI
CreateProcessAsUserW(
3001 LPCWSTR lpApplicationName
,
3002 LPWSTR lpCommandLine
,
3003 LPSECURITY_ATTRIBUTES lpProcessAttributes
,
3004 LPSECURITY_ATTRIBUTES lpThreadAttributes
,
3005 BOOL bInheritHandles
,
3006 DWORD dwCreationFlags
,
3007 LPVOID lpEnvironment
,
3008 LPCWSTR lpCurrentDirectory
,
3009 LPSTARTUPINFOW lpStartupInfo
,
3010 LPPROCESS_INFORMATION lpProcessInformation
)
3012 FIXME("%p %s %s %p %p %d 0x%08lx %p %s %p %p - semi- stub\n", hToken
,
3013 debugstr_w(lpApplicationName
), debugstr_w(lpCommandLine
), lpProcessAttributes
,
3014 lpThreadAttributes
, bInheritHandles
, dwCreationFlags
, lpEnvironment
,
3015 debugstr_w(lpCurrentDirectory
), lpStartupInfo
, lpProcessInformation
);
3017 /* We should create the process with a suspended main thread */
3018 if (!CreateProcessW (lpApplicationName
,
3020 lpProcessAttributes
,
3023 dwCreationFlags
, /* CREATE_SUSPENDED */
3027 lpProcessInformation
))
3035 /******************************************************************************
3036 * ComputeStringSidSize
3038 static DWORD
ComputeStringSidSize(LPCWSTR StringSid
)
3041 DWORD size
= sizeof(SID
);
3045 if (*StringSid
== '-')
3051 size
+= (ctok
- 3) * sizeof(DWORD
);
3056 BOOL WINAPI
DuplicateTokenEx(
3057 HANDLE ExistingTokenHandle
, DWORD dwDesiredAccess
,
3058 LPSECURITY_ATTRIBUTES lpTokenAttributes
,
3059 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
3060 TOKEN_TYPE TokenType
,
3061 PHANDLE DuplicateTokenHandle
)
3063 OBJECT_ATTRIBUTES ObjectAttributes
;
3065 TRACE("%p 0x%08lx 0x%08x 0x%08x %p\n", ExistingTokenHandle
, dwDesiredAccess
,
3066 ImpersonationLevel
, TokenType
, DuplicateTokenHandle
);
3068 InitializeObjectAttributes(
3071 (lpTokenAttributes
&& lpTokenAttributes
->bInheritHandle
) ? OBJ_INHERIT
: 0,
3073 lpTokenAttributes
? lpTokenAttributes
->lpSecurityDescriptor
: NULL
);
3075 return set_ntstatus( NtDuplicateToken( ExistingTokenHandle
,
3080 DuplicateTokenHandle
) );
3083 BOOL WINAPI
DuplicateToken(
3084 HANDLE ExistingTokenHandle
,
3085 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
3086 PHANDLE DuplicateTokenHandle
)
3088 return DuplicateTokenEx( ExistingTokenHandle
, TOKEN_IMPERSONATE
| TOKEN_QUERY
,
3089 NULL
, ImpersonationLevel
, TokenImpersonation
,
3090 DuplicateTokenHandle
);
3093 BOOL WINAPI
EnumDependentServicesA(
3095 DWORD dwServiceState
,
3096 LPENUM_SERVICE_STATUSA lpServices
,
3098 LPDWORD pcbBytesNeeded
,
3099 LPDWORD lpServicesReturned
)
3101 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService
, dwServiceState
,
3102 lpServices
, cbBufSize
, pcbBytesNeeded
, lpServicesReturned
);
3107 BOOL WINAPI
EnumDependentServicesW(
3109 DWORD dwServiceState
,
3110 LPENUM_SERVICE_STATUSW lpServices
,
3112 LPDWORD pcbBytesNeeded
,
3113 LPDWORD lpServicesReturned
)
3115 FIXME("%p 0x%08lx %p 0x%08lx %p %p - stub\n", hService
, dwServiceState
,
3116 lpServices
, cbBufSize
, pcbBytesNeeded
, lpServicesReturned
);
3121 /******************************************************************************
3122 * ParseStringSidToSid
3124 static BOOL
ParseStringSidToSid(LPCWSTR StringSid
, PSID pSid
, LPDWORD cBytes
)
3129 TRACE("%s, %p, %p\n", debugstr_w(StringSid
), pSid
, cBytes
);
3132 SetLastError(ERROR_INVALID_PARAMETER
);
3133 TRACE("StringSid is NULL, returning FALSE\n");
3137 *cBytes
= ComputeStringSidSize(StringSid
);
3138 if (!pisid
) /* Simply compute the size */
3140 TRACE("only size requested, returning TRUE\n");
3144 if (StringSid
[0] == 'S' && StringSid
[1] == '-') /* S-R-I-S-S */
3146 DWORD i
= 0, identAuth
;
3147 DWORD csubauth
= ((*cBytes
- sizeof(SID
)) / sizeof(DWORD
)) + 1;
3149 StringSid
+= 2; /* Advance to Revision */
3150 pisid
->Revision
= atoiW(StringSid
);
3152 if (pisid
->Revision
!= SDDL_REVISION
)
3154 TRACE("Revision %d is unknown\n", pisid
->Revision
);
3155 goto lend
; /* ERROR_INVALID_SID */
3159 TRACE("SubAuthorityCount is 0\n");
3160 goto lend
; /* ERROR_INVALID_SID */
3163 pisid
->SubAuthorityCount
= csubauth
;
3165 /* Advance to identifier authority */
3166 while (*StringSid
&& *StringSid
!= '-')
3168 if (*StringSid
== '-')
3171 /* MS' implementation can't handle values greater than 2^32 - 1, so
3172 * we don't either; assume most significant bytes are always 0
3174 pisid
->IdentifierAuthority
.Value
[0] = 0;
3175 pisid
->IdentifierAuthority
.Value
[1] = 0;
3176 identAuth
= atoiW(StringSid
);
3177 pisid
->IdentifierAuthority
.Value
[5] = identAuth
& 0xff;
3178 pisid
->IdentifierAuthority
.Value
[4] = (identAuth
& 0xff00) >> 8;
3179 pisid
->IdentifierAuthority
.Value
[3] = (identAuth
& 0xff0000) >> 16;
3180 pisid
->IdentifierAuthority
.Value
[2] = (identAuth
& 0xff000000) >> 24;
3182 /* Advance to first sub authority */
3183 while (*StringSid
&& *StringSid
!= '-')
3185 if (*StringSid
== '-')
3190 while (*StringSid
&& *StringSid
!= '-')
3193 pisid
->SubAuthority
[i
++] = atoiW(StringSid
);
3196 if (i
!= pisid
->SubAuthorityCount
)
3197 goto lend
; /* ERROR_INVALID_SID */
3201 else /* String constant format - Only available in winxp and above */
3203 pisid
->Revision
= SDDL_REVISION
;
3204 pisid
->SubAuthorityCount
= 1;
3206 FIXME("String constant not supported: %s\n", debugstr_wn(StringSid
, 2));
3208 /* TODO: Lookup string of well-known SIDs in table */
3209 pisid
->IdentifierAuthority
.Value
[5] = 0;
3210 pisid
->SubAuthority
[0] = 0;
3217 SetLastError(ERROR_INVALID_SID
);
3219 TRACE("returning %s\n", bret
? "TRUE" : "FALSE");
3223 /******************************************************************************
3224 * GetNamedSecurityInfoA [ADVAPI32.@]
3226 DWORD WINAPI
GetNamedSecurityInfoA(LPSTR pObjectName
,
3227 SE_OBJECT_TYPE ObjectType
, SECURITY_INFORMATION SecurityInfo
,
3228 PSID
* ppsidOwner
, PSID
* ppsidGroup
, PACL
* ppDacl
, PACL
* ppSacl
,
3229 PSECURITY_DESCRIPTOR
* ppSecurityDescriptor
)
3235 TRACE("%s %d %ld %p %p %p %p %p\n", pObjectName
, ObjectType
, SecurityInfo
,
3236 ppsidOwner
, ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
3240 len
= MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, NULL
, 0 );
3241 wstr
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
));
3242 MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, wstr
, len
);
3245 r
= GetNamedSecurityInfoW( wstr
, ObjectType
, SecurityInfo
, ppsidOwner
,
3246 ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
3248 HeapFree( GetProcessHeap(), 0, wstr
);
3253 /******************************************************************************
3254 * GetNamedSecurityInfoW [ADVAPI32.@]
3256 DWORD WINAPI
GetNamedSecurityInfoW( LPWSTR name
, SE_OBJECT_TYPE type
,
3257 SECURITY_INFORMATION info
, PSID
* owner
, PSID
* group
, PACL
* dacl
,
3258 PACL
* sacl
, PSECURITY_DESCRIPTOR
* descriptor
)
3260 DWORD needed
, offset
;
3261 SECURITY_DESCRIPTOR_RELATIVE
*relative
;
3264 TRACE( "%s %d %ld %p %p %p %p %p\n", debugstr_w(name
), type
, info
, owner
,
3265 group
, dacl
, sacl
, descriptor
);
3267 if (!name
|| !descriptor
) return ERROR_INVALID_PARAMETER
;
3269 needed
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
3270 if (info
& OWNER_SECURITY_INFORMATION
)
3271 needed
+= sizeof(sidWorld
);
3272 if (info
& GROUP_SECURITY_INFORMATION
)
3273 needed
+= sizeof(sidWorld
);
3274 if (info
& DACL_SECURITY_INFORMATION
)
3275 needed
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3276 if (info
& SACL_SECURITY_INFORMATION
)
3277 needed
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3279 /* must be freed by caller */
3280 *descriptor
= HeapAlloc( GetProcessHeap(), 0, needed
);
3281 if (!*descriptor
) return ERROR_NOT_ENOUGH_MEMORY
;
3283 if (!InitializeSecurityDescriptor( *descriptor
, SECURITY_DESCRIPTOR_REVISION
))
3285 HeapFree( GetProcessHeap(), 0, *descriptor
);
3286 return ERROR_INVALID_SECURITY_DESCR
;
3289 relative
= (SECURITY_DESCRIPTOR_RELATIVE
*)*descriptor
;
3290 relative
->Control
|= SE_SELF_RELATIVE
;
3291 buffer
= (BYTE
*)relative
;
3292 offset
= sizeof(SECURITY_DESCRIPTOR_RELATIVE
);
3294 if (owner
&& (info
& OWNER_SECURITY_INFORMATION
))
3296 memcpy( buffer
+ offset
, &sidWorld
, sizeof(sidWorld
) );
3297 relative
->Owner
= offset
;
3298 *owner
= buffer
+ offset
;
3299 offset
+= sizeof(sidWorld
);
3301 if (group
&& (info
& GROUP_SECURITY_INFORMATION
))
3303 memcpy( buffer
+ offset
, &sidWorld
, sizeof(sidWorld
) );
3304 relative
->Group
= offset
;
3305 *group
= buffer
+ offset
;
3306 offset
+= sizeof(sidWorld
);
3308 if (dacl
&& (info
& DACL_SECURITY_INFORMATION
))
3310 GetWorldAccessACL( (PACL
)(buffer
+ offset
) );
3311 relative
->Dacl
= offset
;
3312 *dacl
= (PACL
)(buffer
+ offset
);
3313 offset
+= WINE_SIZE_OF_WORLD_ACCESS_ACL
;
3315 if (sacl
&& (info
& SACL_SECURITY_INFORMATION
))
3317 GetWorldAccessACL( (PACL
)(buffer
+ offset
) );
3318 relative
->Sacl
= offset
;
3319 *sacl
= (PACL
)(buffer
+ offset
);
3321 return ERROR_SUCCESS
;
3324 /******************************************************************************
3325 * DecryptFileW [ADVAPI32.@]
3327 BOOL WINAPI
DecryptFileW(LPCWSTR lpFileName
, DWORD dwReserved
)
3329 FIXME("%s %08lx\n", debugstr_w(lpFileName
), dwReserved
);
3333 /******************************************************************************
3334 * DecryptFileA [ADVAPI32.@]
3336 BOOL WINAPI
DecryptFileA(LPCSTR lpFileName
, DWORD dwReserved
)
3338 FIXME("%s %08lx\n", debugstr_a(lpFileName
), dwReserved
);
3342 /******************************************************************************
3343 * EncryptFileW [ADVAPI32.@]
3345 BOOL WINAPI
EncryptFileW(LPCWSTR lpFileName
)
3347 FIXME("%s\n", debugstr_w(lpFileName
));
3351 /******************************************************************************
3352 * EncryptFileA [ADVAPI32.@]
3354 BOOL WINAPI
EncryptFileA(LPCSTR lpFileName
)
3356 FIXME("%s\n", debugstr_a(lpFileName
));
3360 /******************************************************************************
3361 * SetSecurityInfo [ADVAPI32.@]
3363 DWORD WINAPI
SetSecurityInfo(HANDLE handle
, SE_OBJECT_TYPE ObjectType
,
3364 SECURITY_INFORMATION SecurityInfo
, PSID psidOwner
,
3365 PSID psidGroup
, PACL pDacl
, PACL pSacl
) {
3367 return ERROR_SUCCESS
;