Sometimes ZwCreateFile returned C0000022

Hi,

The following is my code. Sometimes it works OK, but sometimes ZwCreateFile failed with
status code 0xC0000022(STATUS_ACCESS_DENIED) returned.

ntStatus = ZwCreateFile(&hFileHandle,
SYNCHRONIZE|GENERIC_READ,
&objAttributes,
&isbCreateReadStatus,
NULL,
0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,
NULL,
0);

I don’t know what’s the problem.

Thanks.

ZM Chen

That looks correct. Are you opening a file on a network? And the obvious
question… are any other applications opening the file for any purpose?

Zm Chen wrote:

Hi,

The following is my code. Sometimes it works OK, but sometimes ZwCreateFile failed with
status code 0xC0000022(STATUS_ACCESS_DENIED) returned.

ntStatus = ZwCreateFile(&hFileHandle,
SYNCHRONIZE|GENERIC_READ,
&objAttributes,
&isbCreateReadStatus,
NULL,
0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,
NULL,
0);

I don’t know what’s the problem.

Thanks.

ZM Chen


You are currently subscribed to ntdev as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  • Nick Ryan (MVP for DDK)

ZwCreateFile is called at boot time in my driver.

ZM Chen

Ooops. This API isn’t available for use in DriverEntry if your driver is
loading at SERVICE_BOOT_START.

Zm Chen wrote:

ZwCreateFile is called at boot time in my driver.

ZM Chen


You are currently subscribed to ntdev as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  • Nick Ryan (MVP for DDK)