在進行驅動開發時,調用ZwCreateFile報錯0xC0000043,STATUS_SHARING_VIOLATION,經過搜尋得知參數ShareAccess,指定“共享所有”的正确方法是FILE_SHARE_VALID_FLAGS,而不是0 。下面是幫助網頁
https://community.osr.com/discussion/288138
關鍵回答
//
// MessageId: STATUS_SHARING_VIOLATION
//
// MessageText:
//
// A file cannot be opened because the share access flags are incompatible.
//
#define STATUS_SHARING_VIOLATION ((NTSTATUS)0xC0000043L)
If the file is local, you can call IoCreateFileEx and specify
IO_IGNORE_SHARE_ACCESS_CHECK. Note that this doesn't do anything for a file
on a network share.
Also, the proper way to specify "share all" is FILE_SHARE_VALID_FLAGS, not 0
(which means "share none").
-scott
OSR
@OSRDrivers