I want to use the function GetFileSecurity() to retreive the security descripter of a file in the Master File Table from NTFS..
The function definition is

BOOL WINAPI GetFileSecurity(
  __in       LPCTSTR lpFileName,
  __in       SECURITY_INFORMATION RequestedInformation,
  __out_opt  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  __in       DWORD nLength,
  __out      LPDWORD lpnLengthNeeded

The fifth attibute is the length of the Buffer in which Security descripter attribute for a particular file is stored.. But how can we know the length before extracting the Security descripter ?? Is it fixed or is there any function which can help...

9 Years
Discussion Span
Last Post by Ancient Dragon

Call it twice. The first time pass 0 for pSecurityDescriptor and nLength parameters -- The function will fill in the required length in the pnLengthNeeded parameter. You can then use that value to allocate buffer and call the function again.

Or you can just simply allocate a buffer large enough to hold the description -- no harm done if its larger than needed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.