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)
InitializeObjectAttributes(&obFileAttrib, FilePath, (OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE),
// Open the file for reading
status = ZwOpenFile(hFileHandle, GENERIC_READ | SYNCHRONIZE,
&obFileAttrib, &ioStatus, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, 0);
DPRINT("Could not open file for reading:\n\t Information: %X\nNT Status: %X\n", ioStatus.Information, status);
bReleaseHandle = TRUE;
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.