I am using ZWCreateFile to open a file on the drive. Code is below. I am
getting error “0xc0000043 (3221225539) - A file cannot be opened because
the share access flags are incompatible.” Any ideas why ?
NTSTATUS status = STATUS_SUCCESS;
UNICODE_STRING ustrOCPDrvPath ;
OBJECT_ATTRIBUTES oAttr;
IO_STATUS_BLOCK oIOstatus;
HANDLE phande;
DbgPrint(“OCPDRV:: Startup() Enter \n”);
RtlInitUnicodeString(&ustrOCPDrvPath,L"\DosDevices\C:\Driver\a.txt")
;
InitializeObjectAttributes (&oAttr,
&ustrOCPDrvPath,
(OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE ),
NULL,
NULL );
DbgPrint(“OCPDRV:: InitializeObjectAttributes Succeeded
\n”);
status = ZwCreateFile(&phande,
(GENERIC_READ|SYNCHRONIZE ),
&oAttr,
&oIOstatus,
0, // allocation size
FILE_ATTRIBUTE_NORMAL, // file attributes
FILE_SHARE_READ, // share access
FILE_SUPERSEDE, // create disposition
FILE_SYNCHRONOUS_IO_NONALERT, // create options
NULL,
// ptr to extended attributes
0);
if(!NT_SUCCESS(status))
{
DbgPrint(“OCPDRV::ZWCreate failed status
= 0x%0x\n”, status);
}
DbgPrint(“OCPDRV:: Startup() Leave \n”);