130{
134#ifdef _WIN64
136#endif
140 ULONG AbsSDSize, RelSDSize = 0;
148
149
150
154 0,
157 {
158
161 }
162
163
165 'dSeS');
167 {
170 }
171
172
175 RelSD,
179 {
180
181
182
184 }
185
186
188 &OwnerSid,
191 {
193 }
194
200 {
202 }
203
204
206 2,
209 0,
210 0,
211 0,
212 0,
213 0,
214 0,
217 {
219 }
220
221
223 1,
225 0,
226 0,
227 0,
228 0,
229 0,
230 0,
231 0,
234 {
236 }
237
238
239
240 if (OwnerSid !=
NULL &&
244 {
245
247 do
248 {
253 {
255 }
257 {
258
259
262 {
263
264
267 {
271 RelSD);
272 }
273 else
274 {
275
277 }
278
280 }
281 }
283 }
284
286
287
288
290 &AbsSDSize);
291#ifdef _WIN64
293 {
294
295
296
298
300 'dSeS');
302 {
305 }
306
307 AbsSDAllocated =
TRUE;
308
309
311 RelSD,
313
314
316 &AbsSDSize);
317 }
318 else
319#endif
320 {
321 AbsSD = RelSD;
322 }
323
325 {
327 }
328
329
334 {
336 }
337
338
344 {
346 }
347
348
349
352 &RelSDSize);
354 {
356 }
357
358
360 'dSeS');
361 if (NewRelSD ==
NULL)
362 {
365 }
366
367
369 NewRelSD,
370 &RelSDSize);
372 {
374 }
375
376
379 NewRelSD);
380
383 {
385 }
386
388 {
390 }
391
393 {
395 'dSeS');
396 }
397
398 if (NewRelSD !=
NULL)
399 {
401 'dSeS');
402 }
403
404#ifdef _WIN64
405 if (AbsSDAllocated)
406 {
408 'dSeS');
409 }
410#endif
411
413}
static HANDLE DirectoryHandle
static const WCHAR Cleanup[]
NTSYSAPI NTSTATUS WINAPI RtlSetOwnerSecurityDescriptor(PSECURITY_DESCRIPTOR, PSID, BOOLEAN)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
NTSYSAPI NTSTATUS NTAPI RtlGetAce(PACL Acl, ULONG AceIndex, PVOID *Ace)
NTSYSAPI NTSTATUS NTAPI RtlSelfRelativeToAbsoluteSD2(_Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD, _Out_ PULONG BufferSize)
_In_opt_ PSID _In_opt_ BOOLEAN OwnerDefaulted
NTSYSAPI NTSTATUS NTAPI RtlGetDaclSecurityDescriptor(_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _Out_ PBOOLEAN DaclPresent, _Out_ PACL *Dacl, _Out_ PBOOLEAN DaclDefaulted)
NTSYSAPI BOOLEAN NTAPI RtlEqualSid(_In_ PSID Sid1, _In_ PSID Sid2)
_In_ BOOLEAN _In_opt_ PACL _In_opt_ BOOLEAN DaclDefaulted
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
NTSYSAPI NTSTATUS NTAPI RtlGetOwnerSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PSID *Owner, OUT PBOOLEAN OwnerDefaulted)
NTSYSAPI NTSTATUS NTAPI RtlAbsoluteToSelfRelativeSD(IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, IN PULONG BufferLength)
PVOID NTAPI RtlpAllocateMemory(_In_ ULONG Bytes, _In_ ULONG Tag)
#define STATUS_BUFFER_TOO_SMALL
_In_ SIZE_T DescriptorSize
static SID_IDENTIFIER_AUTHORITY LocalSystemAuthority
#define CONTAINER_INHERIT_ACE
#define SECURITY_BUILTIN_DOMAIN_RID
#define DACL_SECURITY_INFORMATION
#define ACCESS_ALLOWED_ACE_TYPE
#define SECURITY_LOCAL_SYSTEM_RID
#define OWNER_SECURITY_INFORMATION
#define OBJECT_INHERIT_ACE
#define DOMAIN_ALIAS_RID_ADMINS