Add SetEntriesInAcl()

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
2022-10-17 14:43:06 +02:00
parent ad2d67e680
commit 0fea2d1ed7
2 changed files with 35 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
#pragma once
#include "Common.h"
#include <AclAPI.h>
#include <tlhelp32.h>
#include <string>
#include <vector>
@@ -2444,6 +2445,30 @@ static BOOL AllocateAndInitializeSid(_In_ PSID_IDENTIFIER_AUTHORITY pIdentifierA
return FALSE;
}
/// @copydoc SetEntriesInAclW()
static DWORD SetEntriesInAclA(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_A pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
{
PACL h;
DWORD dwResult = SetEntriesInAclA(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
if (dwResult == ERROR_SUCCESS)
Acl.reset(h);
return ERROR_SUCCESS;
}
///
/// Creates a new access control list (ACL) by merging new access control or audit control information into an existing ACL structure.
///
/// \sa [SetEntriesInAclW function](https://learn.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-setentriesinaclw)
///
static DWORD SetEntriesInAclW(_In_ ULONG cCountOfExplicitEntries, _In_reads_opt_(cCountOfExplicitEntries) PEXPLICIT_ACCESS_W pListOfExplicitEntries, _In_opt_ PACL OldAcl, _Inout_ std::unique_ptr<ACL, winstd::LocalFree_delete<ACL>>& Acl)
{
PACL h;
DWORD dwResult = SetEntriesInAclW(cCountOfExplicitEntries, pListOfExplicitEntries, OldAcl, &h);
if (dwResult == ERROR_SUCCESS)
Acl.reset(h);
return ERROR_SUCCESS;
}
#pragma warning(pop)
/// @}