Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars

Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 4  
08 Mar 18 09:09
Greg Lindor
Join Date: 15 Aug 2017
Posts To This List: 3
ZwOpenFile failing with C0000043

Hello, I'm attempting to read a file (and determine its size) from my Driver, however Im getting the strange error code of C0000043, which seems to indicate my parameters might be wrong. I've tried almost every combination that makes sense to my goals, but ZwOpenFile just fails. I am sure the path to the file is correct ( and in correct form) a snippet is shown below: if (FilePath == NULL) return STATUS_INVALID_PARAMETER; InitializeObjectAttributes(&obFileAttrib, FilePath, (OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE), NULL, NULL); // Open the file for reading status = ZwOpenFile(hFileHandle, GENERIC_READ | SYNCHRONIZE, &obFileAttrib, &ioStatus, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, 0); if(!NT_SUCCESS(status)) { DPRINT("Could not open file for reading:\n\t Information: %X\nNT Status: %X\n", ioStatus.Information, status); bReleaseHandle = TRUE; goto done; } I've tried with FILE_GENERIC_READ, and in SharedAccess I've tried 0, FILE_SYNCHRONOUS_IO_NONALERT alone. But nothing seems to be working. The FilePath is a global: UNICODE_STRING g_FileToMap = RTL_CONSTANT_STRING(L"\\??\\C:\\Users\\x\\Desktop\\SimpleFile.dll"); Passed in like: status = GetFileSize(&g_FileToMap, &szSizeToMap, &hCapturedFileHandle); The host and target test systems are both Windows 10. Any help appreciated.
  Message 2 of 4  
08 Mar 18 10:12
Greg Lindor
Join Date: 15 Aug 2017
Posts To This List: 3
ZwOpenFile failing with C0000043

Small correction to the snippet: status = ZwOpenFile(hFileHandle, GENERIC_READ | SYNCHRONIZE, &obFileAttrib, &ioStatus, FILE_SHARE_READ, FILE_NON_DIRECTORY_FILE); IS what Im using and getting the same error.
  Message 3 of 4  
08 Mar 18 10:44
Scott Noone
Join Date:
Posts To This List: 1377
List Moderator
ZwOpenFile failing with C0000043

// // 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
  Message 4 of 4  
08 Mar 18 23:12
Greg Lindor
Join Date: 15 Aug 2017
Posts To This List: 3
ZwOpenFile failing with C0000043

Thanks, IoCreateFileEx worked for me Scott
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 04:10.

Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license