2 * COPYRIGHT: See COPYING in the top level directory
4 * Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
5 * Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
6 * Copyright 2006 Robert Reif
8 * PROJECT: ReactOS system libraries
9 * FILE: dll/win32/advapi32/sec/misc.c
10 * PURPOSE: Miscellaneous security functions (some ported from Wine)
14 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
17 /* Interface to ntmarta.dll ***************************************************/
19 NTMARTA NtMartaStatic
= { 0 };
20 static PNTMARTA NtMarta
= NULL
;
22 #define FindNtMartaProc(Name) \
23 NtMartaStatic.Name = (PVOID)GetProcAddress(NtMartaStatic.hDllInstance, \
25 if (NtMartaStatic.Name == NULL) \
27 return GetLastError(); \
32 LoadAndInitializeNtMarta(VOID
)
34 /* this code may be executed simultaneously by multiple threads in case they're
35 trying to initialize the interface at the same time, but that's no problem
36 because the pointers returned by GetProcAddress will be the same. However,
37 only one of the threads will change the NtMarta pointer to the NtMartaStatic
38 structure, the others threads will detect that there were other threads
39 initializing the structure faster and will release the reference to the
42 NtMartaStatic
.hDllInstance
= LoadLibraryW(L
"ntmarta.dll");
43 if (NtMartaStatic
.hDllInstance
== NULL
)
45 return GetLastError();
49 FindNtMartaProc(LookupAccountTrustee
);
50 FindNtMartaProc(LookupAccountName
);
51 FindNtMartaProc(LookupAccountSid
);
52 FindNtMartaProc(SetEntriesInAList
);
53 FindNtMartaProc(ConvertAccessToSecurityDescriptor
);
54 FindNtMartaProc(ConvertSDToAccess
);
55 FindNtMartaProc(ConvertAclToAccess
);
56 FindNtMartaProc(GetAccessForTrustee
);
57 FindNtMartaProc(GetExplicitEntries
);
59 FindNtMartaProc(RewriteGetNamedRights
);
60 FindNtMartaProc(RewriteSetNamedRights
);
61 FindNtMartaProc(RewriteGetHandleRights
);
62 FindNtMartaProc(RewriteSetHandleRights
);
63 FindNtMartaProc(RewriteSetEntriesInAcl
);
64 FindNtMartaProc(RewriteGetExplicitEntriesFromAcl
);
65 FindNtMartaProc(TreeResetNamedSecurityInfo
);
66 FindNtMartaProc(GetInheritanceSource
);
67 FindNtMartaProc(FreeIndexArray
);
74 CheckNtMartaPresent(VOID
)
78 if (InterlockedCompareExchangePointer((PVOID
)&NtMarta
,
82 /* we're the first one trying to use ntmarta, initialize it and change
83 the pointer after initialization */
84 ErrorCode
= LoadAndInitializeNtMarta();
86 if (ErrorCode
== ERROR_SUCCESS
)
88 /* try change the NtMarta pointer */
89 if (InterlockedCompareExchangePointer((PVOID
)&NtMarta
,
93 /* another thread initialized ntmarta in the meanwhile, release
94 the reference of the dll loaded. */
95 FreeLibrary(NtMartaStatic
.hDllInstance
);
101 ERR("Failed to initialize ntmarta.dll! Error: 0x%x", ErrorCode
);
107 /* ntmarta was already initialized */
108 ErrorCode
= ERROR_SUCCESS
;
118 if (InterlockedExchangePointer((PVOID
)&NtMarta
,
121 FreeLibrary(NtMartaStatic
.hDllInstance
);
126 /******************************************************************************/
133 AreAllAccessesGranted(DWORD GrantedAccess
,
136 return (BOOL
)RtlAreAllAccessesGranted(GrantedAccess
,
146 AreAnyAccessesGranted(DWORD GrantedAccess
,
149 return (BOOL
)RtlAreAnyAccessesGranted(GrantedAccess
,
154 /************************************************************
155 * ADVAPI_IsLocalComputer
157 * Checks whether the server name indicates local machine.
159 BOOL
ADVAPI_IsLocalComputer(LPCWSTR ServerName
)
161 DWORD dwSize
= MAX_COMPUTERNAME_LENGTH
+ 1;
165 if (!ServerName
|| !ServerName
[0])
168 buf
= HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
169 Result
= GetComputerNameW(buf
, &dwSize
);
170 if (Result
&& (ServerName
[0] == '\\') && (ServerName
[1] == '\\'))
172 Result
= Result
&& !lstrcmpW(ServerName
, buf
);
173 HeapFree(GetProcessHeap(), 0, buf
);
179 /******************************************************************************
180 * GetFileSecurityA [ADVAPI32.@]
182 * Obtains Specified information about the security of a file or directory.
185 * lpFileName [I] Name of the file to get info for
186 * RequestedInformation [I] SE_ flags from "winnt.h"
187 * pSecurityDescriptor [O] Destination for security information
188 * nLength [I] Length of pSecurityDescriptor
189 * lpnLengthNeeded [O] Destination for length of returned security information
192 * Success: TRUE. pSecurityDescriptor contains the requested information.
193 * Failure: FALSE. lpnLengthNeeded contains the required space to return the info.
196 * The information returned is constrained by the callers access rights and
203 GetFileSecurityA(LPCSTR lpFileName
,
204 SECURITY_INFORMATION RequestedInformation
,
205 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
207 LPDWORD lpnLengthNeeded
)
209 UNICODE_STRING FileName
;
213 Status
= RtlCreateUnicodeStringFromAsciiz(&FileName
,
215 if (!NT_SUCCESS(Status
))
217 SetLastError(RtlNtStatusToDosError(Status
));
221 bResult
= GetFileSecurityW(FileName
.Buffer
,
222 RequestedInformation
,
227 RtlFreeUnicodeString(&FileName
);
238 GetFileSecurityW(LPCWSTR lpFileName
,
239 SECURITY_INFORMATION RequestedInformation
,
240 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
242 LPDWORD lpnLengthNeeded
)
244 OBJECT_ATTRIBUTES ObjectAttributes
;
245 IO_STATUS_BLOCK StatusBlock
;
246 UNICODE_STRING FileName
;
247 ULONG AccessMask
= 0;
251 TRACE("GetFileSecurityW() called\n");
253 QuerySecurityAccessMask(RequestedInformation
, &AccessMask
);
255 if (!RtlDosPathNameToNtPathName_U(lpFileName
,
260 ERR("Invalid path\n");
261 SetLastError(ERROR_INVALID_NAME
);
265 InitializeObjectAttributes(&ObjectAttributes
,
267 OBJ_CASE_INSENSITIVE
,
271 Status
= NtOpenFile(&FileHandle
,
275 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
278 RtlFreeHeap(RtlGetProcessHeap(),
282 if (!NT_SUCCESS(Status
))
284 ERR("NtOpenFile() failed (Status %lx)\n", Status
);
285 SetLastError(RtlNtStatusToDosError(Status
));
289 Status
= NtQuerySecurityObject(FileHandle
,
290 RequestedInformation
,
295 if (!NT_SUCCESS(Status
))
297 ERR("NtQuerySecurityObject() failed (Status %lx)\n", Status
);
298 SetLastError(RtlNtStatusToDosError(Status
));
311 GetKernelObjectSecurity(HANDLE Handle
,
312 SECURITY_INFORMATION RequestedInformation
,
313 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
315 LPDWORD lpnLengthNeeded
)
319 Status
= NtQuerySecurityObject(Handle
,
320 RequestedInformation
,
324 if (!NT_SUCCESS(Status
))
326 SetLastError(RtlNtStatusToDosError(Status
));
334 /******************************************************************************
335 * SetFileSecurityA [ADVAPI32.@]
336 * Sets the security of a file or directory
342 SetFileSecurityA(LPCSTR lpFileName
,
343 SECURITY_INFORMATION SecurityInformation
,
344 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
346 UNICODE_STRING FileName
;
350 Status
= RtlCreateUnicodeStringFromAsciiz(&FileName
,
352 if (!NT_SUCCESS(Status
))
354 SetLastError(RtlNtStatusToDosError(Status
));
358 bResult
= SetFileSecurityW(FileName
.Buffer
,
360 pSecurityDescriptor
);
362 RtlFreeUnicodeString(&FileName
);
368 /******************************************************************************
369 * SetFileSecurityW [ADVAPI32.@]
370 * Sets the security of a file or directory
376 SetFileSecurityW(LPCWSTR lpFileName
,
377 SECURITY_INFORMATION SecurityInformation
,
378 PSECURITY_DESCRIPTOR pSecurityDescriptor
)
380 OBJECT_ATTRIBUTES ObjectAttributes
;
381 IO_STATUS_BLOCK StatusBlock
;
382 UNICODE_STRING FileName
;
383 ULONG AccessMask
= 0;
387 TRACE("SetFileSecurityW() called\n");
389 SetSecurityAccessMask(SecurityInformation
, &AccessMask
);
391 if (!RtlDosPathNameToNtPathName_U(lpFileName
,
396 ERR("Invalid path\n");
397 SetLastError(ERROR_INVALID_NAME
);
401 InitializeObjectAttributes(&ObjectAttributes
,
403 OBJ_CASE_INSENSITIVE
,
407 Status
= NtOpenFile(&FileHandle
,
411 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
414 RtlFreeHeap(RtlGetProcessHeap(),
418 if (!NT_SUCCESS(Status
))
420 ERR("NtOpenFile() failed (Status %lx)\n", Status
);
421 SetLastError(RtlNtStatusToDosError(Status
));
425 Status
= NtSetSecurityObject(FileHandle
,
427 pSecurityDescriptor
);
430 if (!NT_SUCCESS(Status
))
432 ERR("NtSetSecurityObject() failed (Status %lx)\n", Status
);
433 SetLastError(RtlNtStatusToDosError(Status
));
446 SetKernelObjectSecurity(HANDLE Handle
,
447 SECURITY_INFORMATION SecurityInformation
,
448 PSECURITY_DESCRIPTOR SecurityDescriptor
)
452 Status
= NtSetSecurityObject(Handle
,
455 if (!NT_SUCCESS(Status
))
457 SetLastError(RtlNtStatusToDosError(Status
));
470 ImpersonateAnonymousToken(IN HANDLE ThreadHandle
)
474 Status
= NtImpersonateAnonymousToken(ThreadHandle
);
475 if (!NT_SUCCESS(Status
))
477 SetLastError(RtlNtStatusToDosError(Status
));
490 ImpersonateLoggedOnUser(HANDLE hToken
)
492 SECURITY_QUALITY_OF_SERVICE Qos
;
493 OBJECT_ATTRIBUTES ObjectAttributes
;
500 /* Get the token type */
501 Status
= NtQueryInformationToken(hToken
,
506 if (!NT_SUCCESS(Status
))
508 SetLastError(RtlNtStatusToDosError(Status
));
512 if (Type
== TokenPrimary
)
514 /* Create a duplicate impersonation token */
515 Qos
.Length
= sizeof(SECURITY_QUALITY_OF_SERVICE
);
516 Qos
.ImpersonationLevel
= SecurityImpersonation
;
517 Qos
.ContextTrackingMode
= SECURITY_DYNAMIC_TRACKING
;
518 Qos
.EffectiveOnly
= FALSE
;
520 ObjectAttributes
.Length
= sizeof(OBJECT_ATTRIBUTES
);
521 ObjectAttributes
.RootDirectory
= NULL
;
522 ObjectAttributes
.ObjectName
= NULL
;
523 ObjectAttributes
.Attributes
= 0;
524 ObjectAttributes
.SecurityDescriptor
= NULL
;
525 ObjectAttributes
.SecurityQualityOfService
= &Qos
;
527 Status
= NtDuplicateToken(hToken
,
528 TOKEN_IMPERSONATE
| TOKEN_QUERY
,
533 if (!NT_SUCCESS(Status
))
535 SetLastError(RtlNtStatusToDosError(Status
));
543 /* User the original impersonation token */
548 /* Impersonate the the current thread */
549 Status
= NtSetInformationThread(NtCurrentThread(),
550 ThreadImpersonationToken
,
554 if (Duplicated
== TRUE
)
559 if (!NT_SUCCESS(Status
))
561 SetLastError(RtlNtStatusToDosError(Status
));
574 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
578 Status
= RtlImpersonateSelf(ImpersonationLevel
);
579 if (!NT_SUCCESS(Status
))
581 SetLastError(RtlNtStatusToDosError(Status
));
599 Status
= NtSetInformationThread(NtCurrentThread(),
600 ThreadImpersonationToken
,
603 if (!NT_SUCCESS(Status
))
605 SetLastError(RtlNtStatusToDosError(Status
));
613 /******************************************************************************
614 * GetUserNameA [ADVAPI32.@]
616 * Get the current user name.
619 * lpszName [O] Destination for the user name.
620 * lpSize [I/O] Size of lpszName.
627 GetUserNameA(LPSTR lpszName
,
630 UNICODE_STRING NameW
;
634 /* apparently Win doesn't check whether lpSize is valid at all! */
636 NameW
.MaximumLength
= (*lpSize
) * sizeof(WCHAR
);
637 NameW
.Buffer
= LocalAlloc(LMEM_FIXED
, NameW
.MaximumLength
);
638 if(NameW
.Buffer
== NULL
)
640 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
645 NameA
.MaximumLength
= ((*lpSize
) < 0xFFFF ? (USHORT
)(*lpSize
) : 0xFFFF);
646 NameA
.Buffer
= lpszName
;
648 Ret
= GetUserNameW(NameW
.Buffer
,
652 NameW
.Length
= (*lpSize
- 1) * sizeof(WCHAR
);
653 RtlUnicodeStringToAnsiString(&NameA
, &NameW
, FALSE
);
655 *lpSize
= NameA
.Length
+ 1;
658 LocalFree(NameW
.Buffer
);
664 /******************************************************************************
665 * GetUserNameW [ADVAPI32.@]
673 GetUserNameW(LPWSTR lpszName
,
676 HANDLE hToken
= INVALID_HANDLE_VALUE
;
679 TOKEN_USER
* token_user
= NULL
;
681 SID_NAME_USE snu
= SidTypeUser
;
682 WCHAR
* domain_name
= NULL
;
685 if (!OpenThreadToken (GetCurrentThread(), TOKEN_QUERY
, FALSE
, &hToken
))
687 DWORD dwLastError
= GetLastError();
688 if (dwLastError
!= ERROR_NO_TOKEN
689 && dwLastError
!= ERROR_NO_IMPERSONATION_TOKEN
)
691 /* don't call SetLastError(),
692 as OpenThreadToken() ought to have set one */
696 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY
, &hToken
))
698 /* don't call SetLastError(),
699 as OpenProcessToken() ought to have set one */
704 tu_buf
= LocalAlloc(LMEM_FIXED
, 36);
707 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
712 if (!GetTokenInformation(hToken
, TokenUser
, tu_buf
, 36, &tu_len
) || tu_len
> 36)
715 tu_buf
= LocalAlloc(LMEM_FIXED
, tu_len
);
718 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
723 if (!GetTokenInformation(hToken
, TokenUser
, tu_buf
, tu_len
, &tu_len
))
725 /* don't call SetLastError(),
726 as GetTokenInformation() ought to have set one */
734 token_user
= (TOKEN_USER
*)tu_buf
;
738 domain_name
= LocalAlloc(LMEM_FIXED
, dn_len
* sizeof(WCHAR
));
742 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
746 if (!LookupAccountSidW(NULL
, token_user
->User
.Sid
, lpszName
, &an_len
, domain_name
, &dn_len
, &snu
)
751 LocalFree(domain_name
);
752 domain_name
= LocalAlloc(LMEM_FIXED
, dn_len
* sizeof(WCHAR
));
756 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
762 if (!LookupAccountSidW(NULL
, token_user
->User
.Sid
, lpszName
, &an_len
, domain_name
, &dn_len
, &snu
))
764 /* don't call SetLastError(),
765 as LookupAccountSid() ought to have set one */
766 LocalFree(domain_name
);
773 LocalFree(domain_name
);
775 *lpSize
= an_len
+ 1;
780 /******************************************************************************
781 * LookupAccountSidA [ADVAPI32.@]
787 LookupAccountSidA(LPCSTR lpSystemName
,
791 LPSTR lpReferencedDomainName
,
792 LPDWORD cchReferencedDomainName
,
795 UNICODE_STRING NameW
, ReferencedDomainNameW
, SystemNameW
;
796 LPWSTR NameBuffer
= NULL
;
797 LPWSTR ReferencedDomainNameBuffer
= NULL
;
798 DWORD dwName
, dwReferencedDomainName
;
802 * save the buffer sizes the caller passed to us, as they may get modified and
803 * we require the original values when converting back to ansi
806 dwReferencedDomainName
= *cchReferencedDomainName
;
808 /* allocate buffers for the unicode strings to receive */
811 NameBuffer
= (PWSTR
)LocalAlloc(LMEM_FIXED
, dwName
);
812 if (NameBuffer
== NULL
)
814 SetLastError(ERROR_OUTOFMEMORY
);
821 if (dwReferencedDomainName
> 0)
823 ReferencedDomainNameBuffer
= (PWSTR
)LocalAlloc(LMEM_FIXED
, dwReferencedDomainName
);
824 if (ReferencedDomainNameBuffer
== NULL
)
828 LocalFree(NameBuffer
);
831 SetLastError(ERROR_OUTOFMEMORY
);
836 ReferencedDomainNameBuffer
= NULL
;
839 /* convert the system name to unicode - if present */
840 if (lpSystemName
!= NULL
)
842 ANSI_STRING SystemNameA
;
844 RtlInitAnsiString(&SystemNameA
, lpSystemName
);
845 RtlAnsiStringToUnicodeString(&SystemNameW
, &SystemNameA
, TRUE
);
848 SystemNameW
.Buffer
= NULL
;
850 /* it's time to call the unicode version */
851 Ret
= LookupAccountSidW(SystemNameW
.Buffer
,
855 ReferencedDomainNameBuffer
,
856 cchReferencedDomainName
,
861 * convert unicode strings back to ansi, don't forget that we can't convert
862 * more than 0xFFFF (USHORT) characters! Also don't forget to explicitly
863 * terminate the converted string, the Rtl functions don't do that!
870 NameA
.MaximumLength
= ((dwName
<= 0xFFFF) ? (USHORT
)dwName
: 0xFFFF);
871 NameA
.Buffer
= lpName
;
873 RtlInitUnicodeString(&NameW
, NameBuffer
);
874 RtlUnicodeStringToAnsiString(&NameA
, &NameW
, FALSE
);
875 NameA
.Buffer
[NameA
.Length
] = '\0';
878 if (lpReferencedDomainName
!= NULL
)
880 ANSI_STRING ReferencedDomainNameA
;
882 ReferencedDomainNameA
.Length
= 0;
883 ReferencedDomainNameA
.MaximumLength
= ((dwReferencedDomainName
<= 0xFFFF) ?
884 (USHORT
)dwReferencedDomainName
: 0xFFFF);
885 ReferencedDomainNameA
.Buffer
= lpReferencedDomainName
;
887 RtlInitUnicodeString(&ReferencedDomainNameW
, ReferencedDomainNameBuffer
);
888 RtlUnicodeStringToAnsiString(&ReferencedDomainNameA
, &ReferencedDomainNameW
, FALSE
);
889 ReferencedDomainNameA
.Buffer
[ReferencedDomainNameA
.Length
] = '\0';
893 /* free previously allocated buffers */
894 if (SystemNameW
.Buffer
!= NULL
)
896 RtlFreeUnicodeString(&SystemNameW
);
899 if (NameBuffer
!= NULL
)
901 LocalFree(NameBuffer
);
904 if (ReferencedDomainNameBuffer
!= NULL
)
906 LocalFree(ReferencedDomainNameBuffer
);
913 /******************************************************************************
914 * LookupAccountSidW [ADVAPI32.@]
919 LookupAccountSidW(LPCWSTR pSystemName
,
922 LPDWORD pdwAccountName
,
924 LPDWORD pdwDomainName
,
927 LSA_UNICODE_STRING SystemName
;
928 LSA_OBJECT_ATTRIBUTES ObjectAttributes
= {0};
929 LSA_HANDLE PolicyHandle
= NULL
;
931 PLSA_REFERENCED_DOMAIN_LIST ReferencedDomain
= NULL
;
932 PLSA_TRANSLATED_NAME TranslatedName
= NULL
;
934 DWORD dwAccountName
, dwDomainName
;
936 RtlInitUnicodeString(&SystemName
, pSystemName
);
937 Status
= LsaOpenPolicy(&SystemName
, &ObjectAttributes
, POLICY_LOOKUP_NAMES
, &PolicyHandle
);
938 if (!NT_SUCCESS(Status
))
940 SetLastError(LsaNtStatusToWinError(Status
));
944 Status
= LsaLookupSids(PolicyHandle
, 1, &pSid
, &ReferencedDomain
, &TranslatedName
);
946 LsaClose(PolicyHandle
);
948 if (!NT_SUCCESS(Status
) || Status
== STATUS_SOME_NOT_MAPPED
)
950 SetLastError(LsaNtStatusToWinError(Status
));
957 dwAccountName
= TranslatedName
->Name
.Length
/ sizeof(WCHAR
);
958 if (ReferencedDomain
&& ReferencedDomain
->Entries
> 0)
959 dwDomainName
= ReferencedDomain
->Domains
[0].Name
.Length
/ sizeof(WCHAR
);
963 if (*pdwAccountName
<= dwAccountName
|| *pdwDomainName
<= dwDomainName
)
965 /* One or two buffers are insufficient, add up a char for NULL termination */
966 *pdwAccountName
= dwAccountName
+ 1;
967 *pdwDomainName
= dwDomainName
+ 1;
972 /* Lengths are sufficient, copy the data */
974 RtlCopyMemory(pAccountName
, TranslatedName
->Name
.Buffer
, dwAccountName
* sizeof(WCHAR
));
975 pAccountName
[dwAccountName
] = L
'\0';
978 RtlCopyMemory(pDomainName
, ReferencedDomain
->Domains
[0].Name
.Buffer
, dwDomainName
* sizeof(WCHAR
));
979 pDomainName
[dwDomainName
] = L
'\0';
981 *pdwAccountName
= dwAccountName
;
982 *pdwDomainName
= dwDomainName
;
985 *peUse
= TranslatedName
->Use
;
989 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
992 if (ReferencedDomain
)
993 LsaFreeMemory(ReferencedDomain
);
996 LsaFreeMemory(TranslatedName
);
1002 /******************************************************************************
1003 * LookupAccountNameA [ADVAPI32.@]
1009 LookupAccountNameA(LPCSTR SystemName
,
1013 LPSTR ReferencedDomainName
,
1014 LPDWORD hReferencedDomainNameLength
,
1015 PSID_NAME_USE SidNameUse
)
1018 UNICODE_STRING lpSystemW
;
1019 UNICODE_STRING lpAccountW
;
1020 LPWSTR lpReferencedDomainNameW
= NULL
;
1022 RtlCreateUnicodeStringFromAsciiz(&lpSystemW
, SystemName
);
1023 RtlCreateUnicodeStringFromAsciiz(&lpAccountW
, AccountName
);
1025 if (ReferencedDomainName
)
1026 lpReferencedDomainNameW
= HeapAlloc(GetProcessHeap(),
1028 *hReferencedDomainNameLength
* sizeof(WCHAR
));
1030 ret
= LookupAccountNameW(lpSystemW
.Buffer
,
1034 lpReferencedDomainNameW
,
1035 hReferencedDomainNameLength
,
1038 if (ret
&& lpReferencedDomainNameW
)
1040 WideCharToMultiByte(CP_ACP
,
1042 lpReferencedDomainNameW
,
1043 *hReferencedDomainNameLength
+ 1,
1044 ReferencedDomainName
,
1045 *hReferencedDomainNameLength
+ 1,
1050 RtlFreeUnicodeString(&lpSystemW
);
1051 RtlFreeUnicodeString(&lpAccountW
);
1052 HeapFree(GetProcessHeap(), 0, lpReferencedDomainNameW
);
1058 /******************************************************************************
1059 * LookupAccountNameW [ADVAPI32.@]
1065 LookupAccountNameW(LPCWSTR lpSystemName
,
1066 LPCWSTR lpAccountName
,
1069 LPWSTR ReferencedDomainName
,
1070 LPDWORD cchReferencedDomainName
,
1071 PSID_NAME_USE peUse
)
1073 OBJECT_ATTRIBUTES ObjectAttributes
= {0};
1074 UNICODE_STRING SystemName
;
1075 UNICODE_STRING AccountName
;
1076 LSA_HANDLE PolicyHandle
= NULL
;
1077 PLSA_REFERENCED_DOMAIN_LIST ReferencedDomains
= NULL
;
1078 PLSA_TRANSLATED_SID TranslatedSid
= NULL
;
1080 DWORD dwDomainNameLength
;
1082 UCHAR nSubAuthorities
;
1086 TRACE("%s %s %p %p %p %p %p\n", lpSystemName
, lpAccountName
,
1087 Sid
, cbSid
, ReferencedDomainName
, cchReferencedDomainName
, peUse
);
1089 RtlInitUnicodeString(&SystemName
,
1092 Status
= LsaOpenPolicy(lpSystemName
? &SystemName
: NULL
,
1094 POLICY_LOOKUP_NAMES
,
1096 if (!NT_SUCCESS(Status
))
1098 SetLastError(LsaNtStatusToWinError(Status
));
1102 RtlInitUnicodeString(&AccountName
,
1105 Status
= LsaLookupNames(PolicyHandle
,
1111 LsaClose(PolicyHandle
);
1113 if (!NT_SUCCESS(Status
) || Status
== STATUS_SOME_NOT_MAPPED
)
1115 SetLastError(LsaNtStatusToWinError(Status
));
1120 pDomainSid
= ReferencedDomains
->Domains
[TranslatedSid
->DomainIndex
].Sid
;
1121 nSubAuthorities
= *GetSidSubAuthorityCount(pDomainSid
);
1122 dwSidLength
= GetSidLengthRequired(nSubAuthorities
+ 1);
1124 dwDomainNameLength
= ReferencedDomains
->Domains
->Name
.Length
/ sizeof(WCHAR
);
1126 if (*cbSid
< dwSidLength
||
1127 *cchReferencedDomainName
< dwDomainNameLength
+ 1)
1129 *cbSid
= dwSidLength
;
1130 *cchReferencedDomainName
= dwDomainNameLength
+ 1;
1136 CopySid(*cbSid
, Sid
, pDomainSid
);
1137 *GetSidSubAuthorityCount(Sid
) = nSubAuthorities
+ 1;
1138 *GetSidSubAuthority(Sid
, (DWORD
)nSubAuthorities
) = TranslatedSid
->RelativeId
;
1140 RtlCopyMemory(ReferencedDomainName
, ReferencedDomains
->Domains
->Name
.Buffer
, dwDomainNameLength
* sizeof(WCHAR
));
1141 ReferencedDomainName
[dwDomainNameLength
] = L
'\0';
1143 *cchReferencedDomainName
= dwDomainNameLength
;
1145 *peUse
= TranslatedSid
->Use
;
1150 if (bResult
== FALSE
)
1151 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1154 if (ReferencedDomains
!= NULL
)
1155 LsaFreeMemory(ReferencedDomains
);
1157 if (TranslatedSid
!= NULL
)
1158 LsaFreeMemory(TranslatedSid
);
1164 /**********************************************************************
1165 * LookupPrivilegeValueA EXPORTED
1171 LookupPrivilegeValueA(LPCSTR lpSystemName
,
1175 UNICODE_STRING SystemName
;
1176 UNICODE_STRING Name
;
1179 /* Remote system? */
1180 if (lpSystemName
!= NULL
)
1182 RtlCreateUnicodeStringFromAsciiz(&SystemName
,
1183 (LPSTR
)lpSystemName
);
1186 SystemName
.Buffer
= NULL
;
1188 /* Check the privilege name is not NULL */
1191 SetLastError(ERROR_NO_SUCH_PRIVILEGE
);
1195 RtlCreateUnicodeStringFromAsciiz(&Name
,
1198 Result
= LookupPrivilegeValueW(SystemName
.Buffer
,
1202 RtlFreeUnicodeString(&Name
);
1204 /* Remote system? */
1205 if (SystemName
.Buffer
!= NULL
)
1207 RtlFreeUnicodeString(&SystemName
);
1214 /**********************************************************************
1215 * LookupPrivilegeValueW
1221 LookupPrivilegeValueW(LPCWSTR lpSystemName
,
1222 LPCWSTR lpPrivilegeName
,
1225 OBJECT_ATTRIBUTES ObjectAttributes
= {0};
1226 UNICODE_STRING SystemName
;
1227 UNICODE_STRING PrivilegeName
;
1228 LSA_HANDLE PolicyHandle
= NULL
;
1231 TRACE("%S,%S,%p\n", lpSystemName
, lpPrivilegeName
, lpLuid
);
1233 RtlInitUnicodeString(&SystemName
,
1236 Status
= LsaOpenPolicy(lpSystemName
? &SystemName
: NULL
,
1238 POLICY_LOOKUP_NAMES
,
1240 if (!NT_SUCCESS(Status
))
1242 SetLastError(LsaNtStatusToWinError(Status
));
1246 RtlInitUnicodeString(&PrivilegeName
,
1249 Status
= LsaLookupPrivilegeValue(PolicyHandle
,
1253 LsaClose(PolicyHandle
);
1255 if (!NT_SUCCESS(Status
))
1257 SetLastError(LsaNtStatusToWinError(Status
));
1265 /**********************************************************************
1266 * LookupPrivilegeDisplayNameA EXPORTED
1272 LookupPrivilegeDisplayNameA(LPCSTR lpSystemName
,
1274 LPSTR lpDisplayName
,
1275 LPDWORD cbDisplayName
,
1276 LPDWORD lpLanguageId
)
1278 FIXME("%s() not implemented!\n", __FUNCTION__
);
1279 SetLastError (ERROR_CALL_NOT_IMPLEMENTED
);
1284 /**********************************************************************
1285 * LookupPrivilegeDisplayNameW EXPORTED
1291 LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName
,
1293 LPWSTR lpDisplayName
,
1294 LPDWORD cbDisplayName
,
1295 LPDWORD lpLanguageId
)
1297 FIXME("%s() not implemented!\n", __FUNCTION__
);
1298 SetLastError (ERROR_CALL_NOT_IMPLEMENTED
);
1303 /**********************************************************************
1304 * LookupPrivilegeNameA EXPORTED
1310 LookupPrivilegeNameA(LPCSTR lpSystemName
,
1315 UNICODE_STRING lpSystemNameW
;
1319 TRACE("%s %p %p %p\n", debugstr_a(lpSystemName
), lpLuid
, lpName
, cchName
);
1321 RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW
, lpSystemName
);
1322 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, NULL
, &wLen
);
1323 if (!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1325 LPWSTR lpNameW
= HeapAlloc(GetProcessHeap(), 0, wLen
* sizeof(WCHAR
));
1327 ret
= LookupPrivilegeNameW(lpSystemNameW
.Buffer
, lpLuid
, lpNameW
,
1331 /* Windows crashes if cchName is NULL, so will I */
1332 unsigned int len
= WideCharToMultiByte(CP_ACP
, 0, lpNameW
, -1, lpName
,
1333 *cchName
, NULL
, NULL
);
1337 /* WideCharToMultiByte failed */
1340 else if (len
> *cchName
)
1343 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1348 /* WideCharToMultiByte succeeded, output length needs to be
1349 * length not including NULL terminator
1354 HeapFree(GetProcessHeap(), 0, lpNameW
);
1356 RtlFreeUnicodeString(&lpSystemNameW
);
1361 /**********************************************************************
1362 * LookupPrivilegeNameW EXPORTED
1368 LookupPrivilegeNameW(LPCWSTR lpSystemName
,
1373 OBJECT_ATTRIBUTES ObjectAttributes
= {0};
1374 UNICODE_STRING SystemName
;
1375 PUNICODE_STRING PrivilegeName
= NULL
;
1376 LSA_HANDLE PolicyHandle
= NULL
;
1379 TRACE("%S,%p,%p,%p\n", lpSystemName
, lpLuid
, lpName
, cchName
);
1381 RtlInitUnicodeString(&SystemName
,
1384 Status
= LsaOpenPolicy(lpSystemName
? &SystemName
: NULL
,
1386 POLICY_LOOKUP_NAMES
,
1388 if (!NT_SUCCESS(Status
))
1390 SetLastError(LsaNtStatusToWinError(Status
));
1394 Status
= LsaLookupPrivilegeName(PolicyHandle
,
1397 if (NT_SUCCESS(Status
))
1399 if (PrivilegeName
->Length
+ sizeof(WCHAR
) > *cchName
* sizeof(WCHAR
))
1401 Status
= STATUS_BUFFER_TOO_SMALL
;
1403 *cchName
= (PrivilegeName
->Length
+ sizeof(WCHAR
)) / sizeof(WCHAR
);
1407 RtlMoveMemory(lpName
,
1408 PrivilegeName
->Buffer
,
1409 PrivilegeName
->Length
);
1410 lpName
[PrivilegeName
->Length
/ sizeof(WCHAR
)] = 0;
1412 *cchName
= PrivilegeName
->Length
/ sizeof(WCHAR
);
1415 LsaFreeMemory(PrivilegeName
->Buffer
);
1416 LsaFreeMemory(PrivilegeName
);
1419 LsaClose(PolicyHandle
);
1421 if (!NT_SUCCESS(Status
))
1423 SetLastError(LsaNtStatusToWinError(Status
));
1432 pGetSecurityInfoCheck(SECURITY_INFORMATION SecurityInfo
,
1437 PSECURITY_DESCRIPTOR
* ppSecurityDescriptor
)
1439 if ((SecurityInfo
& (OWNER_SECURITY_INFORMATION
|
1440 GROUP_SECURITY_INFORMATION
|
1441 DACL_SECURITY_INFORMATION
|
1442 SACL_SECURITY_INFORMATION
)) &&
1443 ppSecurityDescriptor
== NULL
)
1445 /* if one of the SIDs or ACLs are present, the security descriptor
1447 return ERROR_INVALID_PARAMETER
;
1451 /* reset the pointers unless they're ignored */
1452 if ((SecurityInfo
& OWNER_SECURITY_INFORMATION
) &&
1457 if ((SecurityInfo
& GROUP_SECURITY_INFORMATION
) &&
1462 if ((SecurityInfo
& DACL_SECURITY_INFORMATION
) &&
1467 if ((SecurityInfo
& SACL_SECURITY_INFORMATION
) &&
1473 if (SecurityInfo
& (OWNER_SECURITY_INFORMATION
|
1474 GROUP_SECURITY_INFORMATION
|
1475 DACL_SECURITY_INFORMATION
|
1476 SACL_SECURITY_INFORMATION
))
1478 *ppSecurityDescriptor
= NULL
;
1481 return ERROR_SUCCESS
;
1487 pSetSecurityInfoCheck(PSECURITY_DESCRIPTOR pSecurityDescriptor
,
1488 SECURITY_INFORMATION SecurityInfo
,
1494 /* initialize a security descriptor on the stack */
1495 if (!InitializeSecurityDescriptor(pSecurityDescriptor
,
1496 SECURITY_DESCRIPTOR_REVISION
))
1498 return GetLastError();
1501 if (SecurityInfo
& OWNER_SECURITY_INFORMATION
)
1503 if (RtlValidSid(psidOwner
))
1505 if (!SetSecurityDescriptorOwner(pSecurityDescriptor
,
1509 return GetLastError();
1514 return ERROR_INVALID_PARAMETER
;
1518 if (SecurityInfo
& GROUP_SECURITY_INFORMATION
)
1520 if (RtlValidSid(psidGroup
))
1522 if (!SetSecurityDescriptorGroup(pSecurityDescriptor
,
1526 return GetLastError();
1531 return ERROR_INVALID_PARAMETER
;
1535 if (SecurityInfo
& DACL_SECURITY_INFORMATION
)
1539 if (SetSecurityDescriptorDacl(pSecurityDescriptor
,
1544 /* check if the DACL needs to be protected from being
1545 modified by inheritable ACEs */
1546 if (SecurityInfo
& PROTECTED_DACL_SECURITY_INFORMATION
)
1553 return GetLastError();
1559 /* protect the DACL from being modified by inheritable ACEs */
1560 if (!SetSecurityDescriptorControl(pSecurityDescriptor
,
1564 return GetLastError();
1569 if (SecurityInfo
& SACL_SECURITY_INFORMATION
)
1573 if (SetSecurityDescriptorSacl(pSecurityDescriptor
,
1578 /* check if the SACL needs to be protected from being
1579 modified by inheritable ACEs */
1580 if (SecurityInfo
& PROTECTED_SACL_SECURITY_INFORMATION
)
1587 return GetLastError();
1593 /* protect the SACL from being modified by inheritable ACEs */
1594 if (!SetSecurityDescriptorControl(pSecurityDescriptor
,
1598 return GetLastError();
1603 return ERROR_SUCCESS
;
1607 /**********************************************************************
1608 * GetNamedSecurityInfoW EXPORTED
1614 GetNamedSecurityInfoW(LPWSTR pObjectName
,
1615 SE_OBJECT_TYPE ObjectType
,
1616 SECURITY_INFORMATION SecurityInfo
,
1621 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
)
1625 if (pObjectName
!= NULL
)
1627 ErrorCode
= CheckNtMartaPresent();
1628 if (ErrorCode
== ERROR_SUCCESS
)
1630 ErrorCode
= pGetSecurityInfoCheck(SecurityInfo
,
1635 ppSecurityDescriptor
);
1637 if (ErrorCode
== ERROR_SUCCESS
)
1639 /* call the MARTA provider */
1640 ErrorCode
= AccRewriteGetNamedRights(pObjectName
,
1647 ppSecurityDescriptor
);
1652 ErrorCode
= ERROR_INVALID_PARAMETER
;
1658 /**********************************************************************
1659 * GetNamedSecurityInfoA EXPORTED
1665 GetNamedSecurityInfoA(LPSTR pObjectName
,
1666 SE_OBJECT_TYPE ObjectType
,
1667 SECURITY_INFORMATION SecurityInfo
,
1672 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
)
1678 TRACE("%s %d %d %p %p %p %p %p\n", pObjectName
, ObjectType
, SecurityInfo
,
1679 ppsidOwner
, ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
1683 len
= MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, NULL
, 0 );
1684 wstr
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
));
1685 MultiByteToWideChar( CP_ACP
, 0, pObjectName
, -1, wstr
, len
);
1688 r
= GetNamedSecurityInfoW( wstr
, ObjectType
, SecurityInfo
, ppsidOwner
,
1689 ppsidGroup
, ppDacl
, ppSacl
, ppSecurityDescriptor
);
1691 HeapFree( GetProcessHeap(), 0, wstr
);
1697 /**********************************************************************
1698 * SetNamedSecurityInfoW EXPORTED
1704 SetNamedSecurityInfoW(LPWSTR pObjectName
,
1705 SE_OBJECT_TYPE ObjectType
,
1706 SECURITY_INFORMATION SecurityInfo
,
1714 if (pObjectName
!= NULL
)
1716 ErrorCode
= CheckNtMartaPresent();
1717 if (ErrorCode
== ERROR_SUCCESS
)
1719 SECURITY_DESCRIPTOR SecurityDescriptor
;
1721 ErrorCode
= pSetSecurityInfoCheck(&SecurityDescriptor
,
1728 if (ErrorCode
== ERROR_SUCCESS
)
1730 /* call the MARTA provider */
1731 ErrorCode
= AccRewriteSetNamedRights(pObjectName
,
1734 &SecurityDescriptor
);
1739 ErrorCode
= ERROR_INVALID_PARAMETER
;
1745 /**********************************************************************
1746 * SetNamedSecurityInfoA EXPORTED
1752 SetNamedSecurityInfoA(LPSTR pObjectName
,
1753 SE_OBJECT_TYPE ObjectType
,
1754 SECURITY_INFORMATION SecurityInfo
,
1760 UNICODE_STRING ObjectName
;
1764 Status
= RtlCreateUnicodeStringFromAsciiz(&ObjectName
,
1766 if (!NT_SUCCESS(Status
))
1768 return RtlNtStatusToDosError(Status
);
1771 Ret
= SetNamedSecurityInfoW(ObjectName
.Buffer
,
1779 RtlFreeUnicodeString(&ObjectName
);
1785 /**********************************************************************
1786 * GetSecurityInfo EXPORTED
1792 GetSecurityInfo(HANDLE handle
,
1793 SE_OBJECT_TYPE ObjectType
,
1794 SECURITY_INFORMATION SecurityInfo
,
1799 PSECURITY_DESCRIPTOR
*ppSecurityDescriptor
)
1805 ErrorCode
= CheckNtMartaPresent();
1806 if (ErrorCode
== ERROR_SUCCESS
)
1808 ErrorCode
= pGetSecurityInfoCheck(SecurityInfo
,
1813 ppSecurityDescriptor
);
1815 if (ErrorCode
== ERROR_SUCCESS
)
1817 /* call the MARTA provider */
1818 ErrorCode
= AccRewriteGetHandleRights(handle
,
1825 ppSecurityDescriptor
);
1830 ErrorCode
= ERROR_INVALID_HANDLE
;
1836 /**********************************************************************
1837 * SetSecurityInfo EXPORTED
1843 SetSecurityInfo(HANDLE handle
,
1844 SE_OBJECT_TYPE ObjectType
,
1845 SECURITY_INFORMATION SecurityInfo
,
1855 ErrorCode
= CheckNtMartaPresent();
1856 if (ErrorCode
== ERROR_SUCCESS
)
1858 SECURITY_DESCRIPTOR SecurityDescriptor
;
1860 ErrorCode
= pSetSecurityInfoCheck(&SecurityDescriptor
,
1867 if (ErrorCode
== ERROR_SUCCESS
)
1869 /* call the MARTA provider */
1870 ErrorCode
= AccRewriteSetHandleRights(handle
,
1873 &SecurityDescriptor
);
1878 ErrorCode
= ERROR_INVALID_HANDLE
;
1884 /******************************************************************************
1885 * GetSecurityInfoExW EXPORTED
1889 GetSecurityInfoExA(HANDLE hObject
,
1890 SE_OBJECT_TYPE ObjectType
,
1891 SECURITY_INFORMATION SecurityInfo
,
1894 PACTRL_ACCESSA
*ppAccessList
,
1895 PACTRL_AUDITA
*ppAuditList
,
1899 FIXME("%s() not implemented!\n", __FUNCTION__
);
1900 return ERROR_BAD_PROVIDER
;
1904 /******************************************************************************
1905 * GetSecurityInfoExW EXPORTED
1909 GetSecurityInfoExW(HANDLE hObject
,
1910 SE_OBJECT_TYPE ObjectType
,
1911 SECURITY_INFORMATION SecurityInfo
,
1914 PACTRL_ACCESSW
*ppAccessList
,
1915 PACTRL_AUDITW
*ppAuditList
,
1919 FIXME("%s() not implemented!\n", __FUNCTION__
);
1920 return ERROR_BAD_PROVIDER
;
1924 /**********************************************************************
1925 * ImpersonateNamedPipeClient EXPORTED
1931 ImpersonateNamedPipeClient(HANDLE hNamedPipe
)
1933 IO_STATUS_BLOCK StatusBlock
;
1936 TRACE("ImpersonateNamedPipeClient() called\n");
1938 Status
= NtFsControlFile(hNamedPipe
,
1943 FSCTL_PIPE_IMPERSONATE
,
1948 if (!NT_SUCCESS(Status
))
1950 SetLastError(RtlNtStatusToDosError(Status
));
1963 CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR ParentDescriptor
,
1964 PSECURITY_DESCRIPTOR CreatorDescriptor
,
1965 PSECURITY_DESCRIPTOR
*NewDescriptor
,
1966 BOOL IsDirectoryObject
,
1968 PGENERIC_MAPPING GenericMapping
)
1972 Status
= RtlNewSecurityObject(ParentDescriptor
,
1978 if (!NT_SUCCESS(Status
))
1980 SetLastError(RtlNtStatusToDosError(Status
));
1993 CreatePrivateObjectSecurityEx(PSECURITY_DESCRIPTOR ParentDescriptor
,
1994 PSECURITY_DESCRIPTOR CreatorDescriptor
,
1995 PSECURITY_DESCRIPTOR
* NewDescriptor
,
1997 BOOL IsContainerObject
,
1998 ULONG AutoInheritFlags
,
2000 PGENERIC_MAPPING GenericMapping
)
2002 FIXME("%s() not implemented!\n", __FUNCTION__
);
2012 CreatePrivateObjectSecurityWithMultipleInheritance(PSECURITY_DESCRIPTOR ParentDescriptor
,
2013 PSECURITY_DESCRIPTOR CreatorDescriptor
,
2014 PSECURITY_DESCRIPTOR
* NewDescriptor
,
2017 BOOL IsContainerObject
,
2018 ULONG AutoInheritFlags
,
2020 PGENERIC_MAPPING GenericMapping
)
2022 FIXME("%s() not implemented!\n", __FUNCTION__
);
2032 DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR
*ObjectDescriptor
)
2036 Status
= RtlDeleteSecurityObject(ObjectDescriptor
);
2037 if (!NT_SUCCESS(Status
))
2039 SetLastError(RtlNtStatusToDosError(Status
));
2052 GetPrivateObjectSecurity(IN PSECURITY_DESCRIPTOR ObjectDescriptor
,
2053 IN SECURITY_INFORMATION SecurityInformation
,
2054 OUT PSECURITY_DESCRIPTOR ResultantDescriptor OPTIONAL
,
2055 IN DWORD DescriptorLength
,
2056 OUT PDWORD ReturnLength
)
2061 Status
= RtlQuerySecurityObject(ObjectDescriptor
,
2062 SecurityInformation
,
2063 ResultantDescriptor
,
2066 if (!NT_SUCCESS(Status
))
2069 SetLastError(RtlNtStatusToDosError(Status
));
2083 SetPrivateObjectSecurity(SECURITY_INFORMATION SecurityInformation
,
2084 PSECURITY_DESCRIPTOR ModificationDescriptor
,
2085 PSECURITY_DESCRIPTOR
*ObjectsSecurityDescriptor
,
2086 PGENERIC_MAPPING GenericMapping
,
2091 Status
= RtlSetSecurityObject(SecurityInformation
,
2092 ModificationDescriptor
,
2093 ObjectsSecurityDescriptor
,
2096 if (!NT_SUCCESS(Status
))
2098 SetLastError(RtlNtStatusToDosError(Status
));
2111 TreeResetNamedSecurityInfoW(LPWSTR pObjectName
,
2112 SE_OBJECT_TYPE ObjectType
,
2113 SECURITY_INFORMATION SecurityInfo
,
2119 FN_PROGRESSW fnProgress
,
2120 PROG_INVOKE_SETTING ProgressInvokeSetting
,
2125 if (pObjectName
!= NULL
)
2127 ErrorCode
= CheckNtMartaPresent();
2128 if (ErrorCode
== ERROR_SUCCESS
)
2132 case SE_FILE_OBJECT
:
2133 case SE_REGISTRY_KEY
:
2135 /* check the SecurityInfo flags for sanity (both, the protected
2136 and unprotected dacl/sacl flag must not be passed together) */
2137 if (((SecurityInfo
& DACL_SECURITY_INFORMATION
) &&
2138 (SecurityInfo
& (PROTECTED_DACL_SECURITY_INFORMATION
| UNPROTECTED_DACL_SECURITY_INFORMATION
)) ==
2139 (PROTECTED_DACL_SECURITY_INFORMATION
| UNPROTECTED_DACL_SECURITY_INFORMATION
))
2143 ((SecurityInfo
& SACL_SECURITY_INFORMATION
) &&
2144 (SecurityInfo
& (PROTECTED_SACL_SECURITY_INFORMATION
| UNPROTECTED_SACL_SECURITY_INFORMATION
)) ==
2145 (PROTECTED_SACL_SECURITY_INFORMATION
| UNPROTECTED_SACL_SECURITY_INFORMATION
)))
2147 ErrorCode
= ERROR_INVALID_PARAMETER
;
2151 /* call the MARTA provider */
2152 ErrorCode
= AccTreeResetNamedSecurityInfo(pObjectName
,
2161 ProgressInvokeSetting
,
2167 /* object type not supported */
2168 ErrorCode
= ERROR_INVALID_PARAMETER
;
2174 ErrorCode
= ERROR_INVALID_PARAMETER
;
2179 #ifdef HAS_FN_PROGRESSW
2181 typedef struct _INERNAL_FNPROGRESSW_DATA
2183 FN_PROGRESSA fnProgress
;
2185 } INERNAL_FNPROGRESSW_DATA
, *PINERNAL_FNPROGRESSW_DATA
;
2188 InternalfnProgressW(LPWSTR pObjectName
,
2190 PPROG_INVOKE_SETTING pInvokeSetting
,
2194 PINERNAL_FNPROGRESSW_DATA pifnProgressData
= (PINERNAL_FNPROGRESSW_DATA
)Args
;
2198 ObjectNameSize
= WideCharToMultiByte(CP_ACP
,
2207 if (ObjectNameSize
> 0)
2209 pObjectNameA
= RtlAllocateHeap(RtlGetProcessHeap(),
2212 if (pObjectNameA
!= NULL
)
2214 pObjectNameA
[0] = '\0';
2215 WideCharToMultiByte(CP_ACP
,
2224 pifnProgressData
->fnProgress((LPWSTR
)pObjectNameA
, /* FIXME: wrong cast!! */
2227 pifnProgressData
->Args
,
2230 RtlFreeHeap(RtlGetProcessHeap(),
2244 TreeResetNamedSecurityInfoA(LPSTR pObjectName
,
2245 SE_OBJECT_TYPE ObjectType
,
2246 SECURITY_INFORMATION SecurityInfo
,
2252 FN_PROGRESSA fnProgress
,
2253 PROG_INVOKE_SETTING ProgressInvokeSetting
,
2256 #ifndef HAS_FN_PROGRESSW
2257 /* That's all this function does, at least up to w2k3... Even MS was too
2258 lazy to implement it... */
2259 return ERROR_CALL_NOT_IMPLEMENTED
;
2261 INERNAL_FNPROGRESSW_DATA ifnProgressData
;
2262 UNICODE_STRING ObjectName
;
2266 Status
= RtlCreateUnicodeStringFromAsciiz(&ObjectName
,
2268 if (!NT_SUCCESS(Status
))
2270 return RtlNtStatusToDosError(Status
);
2273 ifnProgressData
.fnProgress
= fnProgress
;
2274 ifnProgressData
.Args
= Args
;
2276 Ret
= TreeResetNamedSecurityInfoW(ObjectName
.Buffer
,
2284 (fnProgress
!= NULL
? InternalfnProgressW
: NULL
),
2285 ProgressInvokeSetting
,
2288 RtlFreeUnicodeString(&ObjectName
);
2294 /******************************************************************************
2295 * SaferCreateLevel [ADVAPI32.@]
2297 BOOL WINAPI
SaferCreateLevel(DWORD ScopeId
, DWORD LevelId
, DWORD OpenFlags
,
2298 SAFER_LEVEL_HANDLE
* LevelHandle
, LPVOID lpReserved
)
2300 FIXME("(%u, %x, %u, %p, %p) stub\n", ScopeId
, LevelId
, OpenFlags
, LevelHandle
, lpReserved
);
2304 /******************************************************************************
2305 * SaferGetPolicyInformation [ADVAPI32.@]
2307 BOOL WINAPI
SaferGetPolicyInformation(DWORD scope
, SAFER_POLICY_INFO_CLASS
class, DWORD size
,
2308 PVOID buffer
, PDWORD required
, LPVOID lpReserved
)
2310 FIXME("(%u %u %u %p %p %p) stub\n", scope
, class, size
, buffer
, required
, lpReserved
);
2314 /******************************************************************************
2315 * QueryWindows31FilesMigration [ADVAPI32.@]
2321 QueryWindows31FilesMigration( DWORD x1
)
2323 FIXME("(%d):stub\n",x1
);
2327 /******************************************************************************
2328 * SynchronizeWindows31FilesAndWindowsNTRegistry [ADVAPI32.@]
2337 SynchronizeWindows31FilesAndWindowsNTRegistry( DWORD x1
, DWORD x2
, DWORD x3
,
2340 FIXME("(0x%08x,0x%08x,0x%08x,0x%08x):stub\n",x1
,x2
,x3
,x4
);