A few issues
- the path should by be L"\systemroot\system32\myfile.dat"
- you are allocating 4K for a small string (which you already have the size in fileNameSize)
- you are making a copy of a const string with no purpose, you can just pass the constant string to RtlInitUnicodeString
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, July 15, 2008 7:34 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] ZwCreateFile error in filter driver at boot time
Following is snippet from my code
NTSTATUS file_status;
HANDLE dataFileHandle;
OBJECT_ATTRIBUTES initAttrib;
IO_STATUS_BLOCK fileIoStatusBlock;
UNICODE_STRING uStr;
PWCHAR fileName;
ULONG fileNameSize;
PWCHAR pFullPath;
char * myFileBuffer;
fileName = L"System32\myfile.dat";
fileNameSize = sizeof(L"System32\myfile.dat");
pFullPath = (PWCHAR) ExAllocatePoolWithTag(NonPagedPool, 4096, ‘0PWA’);
myFileBuffer = ExAllocatePoolWithTag(NonPagedPool,1024,‘XgaT’);
if(!myFileBuffer)
{
ExFreePool (pFullPath);
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlCopyMemory(pFullPath, fileName, fileNameSize);
RtlInitUnicodeString(&uStr, pFullPath);
InitializeObjectAttributes(&initAttrib, &uStr, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL,NULL);
file_status = ZwCreateFile( &dataFileHandle,
SYNCHRONIZE|FILE_READ_DATA,
&initAttrib,
&fileIoStatusBlock,
NULL,
0,
0,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,
NULL,
0);
the file_status value is not STATUS_SUCCESS
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer