Group: Security - Library: advapi32
The GetNamedSecurityInfo function retrieves a copy of the security descriptor for an object specified by name.
GetFileOwner - Get the owner of an NTFS file
DWORD GetNamedSecurityInfo(
LPTSTR pObjectName,
SE_OBJECT_TYPE ObjectType,
SECURITY_INFORMATION SecurityInfo,
PSID* ppsidOwner,
PSID* ppsidGroup,
PACL* ppDacl,
PACL* ppSacl,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor
);
DECLARE INTEGER GetNamedSecurityInfo IN advapi32;
STRING pObjectName,;
INTEGER ObjectType,;
INTEGER SecurityInfo,;
INTEGER ppsidOwner,;
INTEGER ppsidGroup,;
INTEGER ppDacl,;
INTEGER ppSacl,;
INTEGER @ ppSecurityDescriptor
pObjectName [in] Pointer to a null-terminated string that specifies the name of the object from which to retrieve security information.
ObjectType [in] Specifies a value from the SE_OBJECT_TYPE enumeration that indicates the type of object named by the pObjectName parameter.
SecurityInfo [in] A set of SECURITY_INFORMATION bit flags that indicate the type of security information to retrieve.
ppsidOwner [out] Pointer to a variable that receives a pointer to the owner SID in the security descriptor returned in ppSecurityDescriptor.
ppsidGroup [out] Pointer to a variable that receives a pointer to the primary group SID in the returned security descriptor.
ppDacl [out] Pointer to a variable that receives a pointer to the DACL in the returned security descriptor.
ppSacl [out] Pointer to a variable that receives a pointer to the SACL in the returned security descriptor.
ppSecurityDescriptor [out] Pointer to a variable that receives a pointer to the security descriptor of the object.
If the function succeeds, the return value is ERROR_SUCCESS (0).
When you have finished using the ppSecurityDescriptor pointer, free the returned buffer by calling the LocalFree function.
If the ppsidOwner, ppsidGroup, ppDacl, and ppSacl parameters are non-NULL, and the SecurityInfo parameter specifies that they be retrieved from the object, those parameters will point to the corresponding parameters in the security descriptor returned in ppSecurityDescriptor.