ZwCreateFile problem

G

Guest

Guest
Archived from groups: microsoft.public.development.device.drivers,microsoft.public.windowsxp.device_driver.dev (More info?)

Hi All,
My ZwCreateFile does not succeed at all. I had this problem initially and i
got this suddenly again.
I am calling this function from my first ReadWrite.(IRP_MJ_READ)




RtlInitUnicodeString(&fileNameUnicodeString,L\\??\\C:\\Windows\\System32\\So
meFile.xml);

InitializeObjectAttributes(&objectAttributes,
&fileNameUnicodeString,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );

rc = ZwCreateFile( &hFileHandle, SYNCHRONIZE|FILE_ANY_ACCESS,
&objectAttributes, &IoStatus, NULL, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_CREATE,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,
NULL, 0 );

if(!NT_SUCCESS(rc))
KdPrint((DRIVERNAME "Error Creating the File\n"));

I always get the error code as -1073741766(ERROR_PATH_NOT_FOUND)
I get the same error code even if i change my file name to
\\SystemRoot\\System32\\Somefile.xml ..

Any ideas guys?
Regards
Shal
 
Archived from groups: microsoft.public.development.device.drivers,microsoft.public.windowsxp.device_driver.dev (More info?)

hi,

The problem in your code might be the file name u have
mention, try with this, suppose the file u wish to access
is c:\file.txt,then

RtlInitUnicodeString(&fileNameUnicodeString,L"\\DosDevices\\c:\\file.txt");

I hope the rest of ur coding is correct

Bye

"Shalini" <kandukondein@NOSPAMyahoo.com> wrote in message news:<eNegnFDZEHA.3168@TK2MSFTNGP10.phx.gbl>...
> Hi All,
> My ZwCreateFile does not succeed at all. I had this problem initially and i
> got this suddenly again.
> I am calling this function from my first ReadWrite.(IRP_MJ_READ)
>
>
>
>
> RtlInitUnicodeString(&fileNameUnicodeString,L\\??\\C:\\Windows\\System32\\So
> meFile.xml);
>
> InitializeObjectAttributes(&objectAttributes,
> &fileNameUnicodeString,
> OBJ_CASE_INSENSITIVE,
> NULL,
> NULL );
>
> rc = ZwCreateFile( &hFileHandle, SYNCHRONIZE|FILE_ANY_ACCESS,
> &objectAttributes, &IoStatus, NULL, 0,
> FILE_SHARE_READ|FILE_SHARE_WRITE,
> FILE_CREATE,
> FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE,
> NULL, 0 );
>
> if(!NT_SUCCESS(rc))
> KdPrint((DRIVERNAME "Error Creating the File\n"));
>
> I always get the error code as -1073741766(ERROR_PATH_NOT_FOUND)
> I get the same error code even if i change my file name to
> \\SystemRoot\\System32\\Somefile.xml ..
>
> Any ideas guys?
> Regards
> Shal
 

TRENDING THREADS