I'm using
CreateFile
Win32 API to get a handle to a file to add ACE to its DACL. The problem is, when the file has no permissions, I get access denied error when I call the function
CreateFile
, I'm the OWNER of the file and Admin. If I'm using windows explorer I can add permissions.
I'm not interested in other functions such as OpenFile or Set security descriptor directly, I'm interested in the right combination of permissions and flags to open such files with the
CreateFile
function.
I've read in MSDN that I have to use specific access right, I've tried:
CreateFile(lpFileName, READ_CONTROL | WRITE_DAC, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS);
CreateFile(lpFileName, READ_CONTROL | WRITE_DAC, 0, NULL, OPEN_EXISTING, ACCESS_SYSTEM_SEURITY);
With these combinations I get the access denied. Any ideas?
Thanks, Gabi