SECURITY_ATTRIBUTES Structure

Syntax

typedef struct _SECURITY_ATTRIBUTES {
  DWORD  nLength;
  LPVOID lpSecurityDescriptor;
  BOOL   bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
                    
Members
Member Description
nLength The size of this structure, in bytes. This is required; set it to sizeof(SECURITY_ATTRIBUTES).
lpSecurityDescriptor A pointer to a SECURITY_DESCRIPTOR structure that specifies the security descriptor for the object. If this pointer is NULL, the security attributes of the object being created are set to the default security attributes of the creator.
bInheritHandle A Boolean value that specifies whether a handle returned by a function that takes this structure as a parameter is inherited by the processes that are created by that function. If this member is TRUE, a child process inherits the handle.
Remarks

The SECURITY_ATTRIBUTES structure contains information about the security of an object and whether that security can be inherited by the object's children.

Many system functions that create securable objects, such as files, pipes, or registry keys, take a pointer to a SECURITY_ATTRIBUTES structure as a parameter. This allows you to specify the security descriptor for the new object.

If lpSecurityDescriptor is NULL, the security attributes of the object are set to the default security attributes of the creator. This means the object inherits the security descriptor of its parent object.

The bInheritHandle member is used in conjunction with functions like CreateProcess to control whether handles to securable objects are inherited by child processes.

When you are finished with the SECURITY_ATTRIBUTES structure, it is important to free any allocated memory, especially if you have created a custom security descriptor.

Requirements
Element Description
Header winnt.h (include windows.h)
Library Advapi32.lib
DLL Advapi32.dll