native mode file privileges trouble

Hello all,

I am developing a native mode application (which runs in the same environment as
autochk.exe) and I have some problems reseting a file’s permissions.

To reset the permissions I use this functional call:
status = NtSetSecurityObject(handle, DACL_SECURITY_INFORMATION,&SecurDescript);

The problem I am encountering is when I am trying too obtain a handle to the
file. I get the status value STATUS_ACCESS_DENIED (0xC0000022) after the call:

status = NtOpenFile(&handle, WRITE_DAC, &ObjectAttributes, &IoStatBlock,
FILE_SHARE_VALID_FLAGS, FILE_OPEN_REPARSE_POINT);

The target file has all permissions removed using windows explorer on winxp sp3.
The owner of the file is Administrator. The native application I think it runs
under the user SYSTEM.

If someone has a better idea on what parameters should I use in this case for
NtOpenFile, please feel free to offer your oppinion.

Thank you,
Mihai

You must follow those steps:

  1. Open the file for WRITE_OWNER
  2. Take ownership of the file
  3. Open the file from WRITE_DAC
  4. Set the permissions

L.

Hello all,

I am developing a native mode application (which runs in the same environment as
autochk.exe) and I have some problems reseting a file’s permissions.

To reset the permissions I use this functional call:
status = NtSetSecurityObject(handle,
DACL_SECURITY_INFORMATION,&SecurDescript);

The problem I am encountering is when I am trying too obtain a handle to the
file. I get the status value STATUS_ACCESS_DENIED (0xC0000022) after the call:

status = NtOpenFile(&handle, WRITE_DAC, &ObjectAttributes, &IoStatBlock,
FILE_SHARE_VALID_FLAGS, FILE_OPEN_REPARSE_POINT);

The target file has all permissions removed using windows explorer on winxp sp3.
The owner of the file is Administrator. The native application I think it runs
under the user SYSTEM.

If someone has a better idea on what parameters should I use in this case for
NtOpenFile, please feel free to offer your oppinion.

Thank you,
Mihai


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


S pozdravem,
Ladislav Zezula
mailto:xxxxx@volny.cz

May be this can be of help

http://support.microsoft.com/kb/240184

Regards
Deepak

2010/12/1 Ladislav Zezula

> You must follow those steps:
>
> 1) Open the file for WRITE_OWNER
> 2) Take ownership of the file
> 3) Open the file from WRITE_DAC
> 4) Set the permissions
>
> L.
>
>
> > Hello all,
>
> > I am developing a native mode application (which runs in the same
> environment as
> > autochk.exe) and I have some problems reseting a file’s permissions.
>
> > To reset the permissions I use this functional call:
> > status = NtSetSecurityObject(handle,
> > DACL_SECURITY_INFORMATION,&SecurDescript);
>
> > The problem I am encountering is when I am trying too obtain a handle to
> the
> > file. I get the status value STATUS_ACCESS_DENIED (0xC0000022) after the
> call:
>
> > status = NtOpenFile(&handle, WRITE_DAC, &ObjectAttributes, &IoStatBlock,
> > FILE_SHARE_VALID_FLAGS, FILE_OPEN_REPARSE_POINT);
>
> > The target file has all permissions removed using windows explorer on
> winxp sp3.
> > The owner of the file is Administrator. The native application I think it
> runs
> > under the user SYSTEM.
>
> > If someone has a better idea on what parameters should I use in this case
> for
> > NtOpenFile, please feel free to offer your oppinion.
>
> > Thank you,
> > Mihai
>
> > —
> > NTFSD is sponsored by OSR
>
> > For our schedule of debugging and file system seminars
> > (including our new fs mini-filter seminar) visit:
> > http://www.osr.com/seminars
>
> > To unsubscribe, visit the List Server section of OSR Online at
> > http://www.osronline.com/page.cfm?name=ListServer
>
>
>
>
> –
> S pozdravem,
> Ladislav Zezula
> mailto:xxxxx@volny.cz
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>