Precautions When Passing Security AttributesLast reviewed: November 2, 1995Article ID: Q94839 |
The information in this article applies to:
SUMMARYAll Win32 APIs that allow security to be specified take a parameter of type LPSECURITY_ATTRIBUTES as the means to attach the security descriptor. However, it is a common error to pass a PSECURITY_DESCRIPTOR type to such functions instead. Because PSECURITY_DESCRIPTOR is of type LPVOID (for opaque data-type reasons), by C Language definition, it is implicitly converted to the correct type. Therefore, the compiler does not generate any warnings; however, unexpected run-time errors will result.
MORE INFORMATIONBelow is a correct example of creating a named pipe with a security descriptor attached.
Sample Code
saSecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); saSecurityAttributes.lpSecurityDescriptor = psdAbsoluteSD; saSecurityAttributes.bInheritHandle = FALSE; hPipe = CreateNamedPipe(TEST_PIPE_NAME, PIPE_ACCESS_DUPLEX, (PIPE_TYPE_BYTE|PIPE_READMODE_BYTE|PIPE_WAIT), 100, // maximum instances 0, // output buffer, sized as needed 0, // input buffer, sized as needed 100, // timeout in milliseconds (LPSECURITY_ATTRIBUTES)&saSecurityAttributes); if( INVALID_HANDLE_VALUE == hPipe ) { // handle error } |
Additional reference words: 3.10 3.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |