27 static ISecurityInformationVtbl PhSecurityInformation_VTable =
53 aclui = LoadLibrary(L
"aclui.dll");
54 CreateSecurityPage_I = (PVOID)GetProcAddress(aclui,
"CreateSecurityPage");
55 EditSecurity_I = (PVOID)GetProcAddress(aclui,
"EditSecurity");
74 _In_ PWSTR ObjectName,
77 _In_opt_ PVOID Context,
79 _In_ ULONG NumberOfAccessEntries
82 ISecurityInformation *info;
87 if (!CreateSecurityPage_I)
99 page = CreateSecurityPage_I(info);
121 _In_ PWSTR ObjectName,
124 _In_opt_ PVOID Context,
126 _In_ ULONG NumberOfAccessEntries
129 ISecurityInformation *info;
142 NumberOfAccessEntries
145 EditSecurity_I(hWnd, info);
151 _In_ PWSTR ObjectName,
154 _In_opt_ PVOID Context,
156 _In_ ULONG NumberOfAccessEntries
163 info->
VTable = &PhSecurityInformation_VTable;
170 info->
AccessEntries = PhAllocate(
sizeof(SI_ACCESS) * NumberOfAccessEntries);
173 for (i = 0; i < NumberOfAccessEntries; i++)
179 if (AccessEntries[i].General)
181 if (AccessEntries[i].Specific)
185 return (ISecurityInformation *)info;
189 _In_ ISecurityInformation *This,
195 IsEqualIID(Riid, &IID_IUnknown) ||
196 IsEqualIID(Riid, &IID_ISecurityInformation)
205 return E_NOINTERFACE;
209 _In_ ISecurityInformation *This
216 return this->RefCount;
220 _In_ ISecurityInformation *This
227 if (this->RefCount == 0)
230 PhFree(this->AccessEntries);
237 return this->RefCount;
241 _In_ ISecurityInformation *This,
242 _Out_ PSI_OBJECT_INFO ObjectInfo
247 memset(ObjectInfo, 0,
sizeof(SI_OBJECT_INFO));
248 ObjectInfo->dwFlags =
255 ObjectInfo->hInstance = NULL;
256 ObjectInfo->pszObjectName = this->ObjectName->Buffer;
262 _In_ ISecurityInformation *This,
263 _In_ SECURITY_INFORMATION RequestedInformation,
264 _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor,
270 PSECURITY_DESCRIPTOR securityDescriptor;
272 PSECURITY_DESCRIPTOR newSd;
274 status = this->GetObjectSecurity(
276 RequestedInformation,
284 newSd = LocalAlloc(0, sdLength);
285 memcpy(newSd, securityDescriptor, sdLength);
286 PhFree(securityDescriptor);
288 *SecurityDescriptor = newSd;
294 _In_ ISecurityInformation *This,
295 _In_ SECURITY_INFORMATION SecurityInformation,
296 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
302 status = this->SetObjectSecurity(
315 _In_ ISecurityInformation *This,
316 _In_
const GUID *ObjectType,
318 _Out_ PSI_ACCESS *Access,
319 _Out_ PULONG Accesses,
320 _Out_ PULONG DefaultAccess
325 *Access = this->AccessEntries;
326 *Accesses = this->NumberOfAccessEntries;
333 _In_ ISecurityInformation *This,
334 _In_
const GUID *ObjectType,
335 _In_ PUCHAR AceFlags,
336 _Inout_ PACCESS_MASK Mask
343 _In_ ISecurityInformation *This,
344 _Out_ PSI_INHERIT_TYPE *InheritTypes,
345 _Out_ PULONG InheritTypesCount
352 _In_ ISecurityInformation *This,
355 _In_ SI_PAGE_TYPE uPage
363 _In_ SECURITY_INFORMATION SecurityInformation,
364 _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor
372 buffer = PhAllocate(bufferSize);
374 memset(buffer, 0, bufferSize);
384 if (status == STATUS_BUFFER_TOO_SMALL)
387 buffer = PhAllocate(bufferSize);
388 memset(buffer, 0, bufferSize);
405 *SecurityDescriptor = (PSECURITY_DESCRIPTOR)buffer;
424 _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor,
425 _In_ SECURITY_INFORMATION SecurityInformation,
426 _In_opt_ PVOID Context
447 CloseServiceHandle(handle);
476 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
477 _In_ SECURITY_INFORMATION SecurityInformation,
478 _In_opt_ PVOID Context
499 CloseServiceHandle(handle);
512 _In_ ULONG ObjectType,
513 _In_ SECURITY_INFORMATION SecurityInformation,
514 _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor
518 PSECURITY_DESCRIPTOR securityDescriptor;
520 win32Result = GetSecurityInfo(
531 if (win32Result != ERROR_SUCCESS)
532 return NTSTATUS_FROM_WIN32(win32Result);
535 LocalFree(securityDescriptor);
537 return STATUS_SUCCESS;
542 _In_ ULONG ObjectType,
543 _In_ SECURITY_INFORMATION SecurityInformation,
544 _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
548 SECURITY_INFORMATION securityInformation = 0;
556 if (SecurityInformation & OWNER_SECURITY_INFORMATION)
559 securityInformation |= OWNER_SECURITY_INFORMATION;
562 if (SecurityInformation & GROUP_SECURITY_INFORMATION)
565 securityInformation |= GROUP_SECURITY_INFORMATION;
568 if (SecurityInformation & DACL_SECURITY_INFORMATION)
571 securityInformation |= DACL_SECURITY_INFORMATION;
574 if (SecurityInformation & SACL_SECURITY_INFORMATION)
577 securityInformation |= SACL_SECURITY_INFORMATION;
580 win32Result = SetSecurityInfo(
590 if (win32Result != ERROR_SUCCESS)
591 return NTSTATUS_FROM_WIN32(win32Result);
593 return STATUS_SUCCESS;