Hello, Sorry for the basic question. I need to create a file for write access in kernel mode and and allow other thread to read it, this can happen simultaneously. so This what I do when creating the file.
status = ZwCreateFile(&hfile,
GENERIC_WRITE,
&oa,
&iostatus,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0);
}
works well, the file is created for write and later when I try to create another handle to read it I always get "STATUS_SHARING_VIOLATION"
here is how I do it.
ntstatus = ZwCreateFile(&OriFileHandle,
FILE_READ_DATA,
&objOriAttr,
&ioOriStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE,
NULL,
0);
Can anybody tell me what is it that I am doing wrong?
What I have tried:
I already read about ZwCreatefile and how to share a file for access by other thread but I am still getting that error.