 
        #ifndef _NTOBAPI_H
// Objects, handles
#if (PHNT_MODE != PHNT_MODE_KERNEL)
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetSecurityObject(
    _In_ HANDLE Handle,
    _In_ SECURITY_INFORMATION SecurityInformation,
    _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
    );
View code on GitHub#ifndef _NTZWAPI_H
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetSecurityObject(
    _In_ HANDLE Handle,
    _In_ SECURITY_INFORMATION SecurityInformation,
    _In_ PSECURITY_DESCRIPTOR SecurityDescriptor
    );
View code on GitHubThis function is documented in Windows Driver Kit here and here.
Function NtSetSecurityDescriptor writes object's Security Descriptor.
HANDLE to object of any type. Must be opened with WRITE_DAC or WRITE_OWNER access depending on SecurityInformationClass parameter.
See NtQuerySecurityObject for possible values.
Pointer to user's allocated SECURITY_DESCRIPTOR to set.
NtQuerySecurityObjectSECURITY_DESCRIPTOR