The ZwQuerySecurityObject routine retrieves a copy of an object's security descriptor.
NTSTATUS ZwQuerySecurityObject( _In_ HANDLE Handle, _In_ SECURITY_INFORMATION SecurityInformation, _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Length, _Out_ PULONG LengthNeeded );
Handle for the object whose security descriptor is to be queried. This handle must have the access specified in the Meaning column of the table shown in the description of the SecurityInformation parameter.
Pointer to a SECURITY_INFORMATION value specifying the information to be queried.
Indicates the discretionary access control list (DACL) of the object is being queried. Requires READ_CONTROL access.
Indicates the primary group identifier of the object is being queried. Requires READ_CONTROL access.
Indicates the owner identifier of the object is being queried. Requires READ_CONTROL access.
Indicates the system ACL (SACL) of the object is being queried. Requires ACCESS_SYSTEM_SECURITY access.
Caller-allocated buffer that ZwQuerySecurityObject fills with a copy of the specified security descriptor. The SECURITY_DESCRIPTOR structure is returned in self-relative format.
Size, in bytes, of the buffer pointed to by SecurityDescriptor.
Pointer to a caller-allocated variable that receives the number of bytes required to store the copied security descriptor.
ZwQuerySecurityObject returns STATUS_SUCCESS or an appropriate error status. Possible error status codes include the following:
Handle did not have the required access.
The buffer is too small for the security descriptor. None of the security information was copied to the buffer.
Handle was not a valid handle.
Handle was not a handle of the expected type.
A security descriptor can be in absolute or self-relative form. In self-relative form, all members of the structure are located contiguously in memory. In absolute form, the structure only contains pointers to the members.
The NTFS file system imposes a 64K limit on the size of the security descriptor that is written to disk for a file. (The FAT file system does not support security descriptors for files.) Thus a 64K SecurityDescriptor buffer is guaranteed to be large enough to hold the returned SECURITY_DESCRIPTOR structure.
For more information about security and access control, see the documentation on these topics in the Windows SDK.
Minifilters should call FltQuerySecurityObject instead of ZwQuerySecurityObject.
Note If the call to the ZwQuerySecurityObject function occurs in user mode, you should use the name "NtQuerySecurityObject" instead of "ZwQuerySecurityObject".
For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Available in Windows XP and later versions of Windows.
|Ntifs.h (include Ntifs.h)|
DDI compliance rules