Hi all!
Following is my source code which im calling only once
from the dispatch read routine.Im getting a success
msg in the ZwCreateFile but not so in the ZwreadFile.
Please,can anybody tell what’ wrong…
…This is an upper disk filter driver attaching to
some specific partition.
ReadDispatch(…)
{
My read sector routine…
if ( ObtainKey == 0 )
{
InterlockedIncrement( & ObtainKey );
if( KeGetCurrentIrql() == PASSIVE_LEVEL )
{
RtlInitUnicodeString(
&fileName,
L"\Device\Harddisk0\Partition0");
InitializeObjectAttributes(
&initializedAttributes,
&fileName ,
OBJ_CASE_INSENSITIVE,
NULL,
NULL );
Status =
ZwCreateFile
(
&fileHandle,
SYNCHRONIZE|GENERIC_READ,
&initializedAttributes,
&IoStatusBlock,
0,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT |
FILE_NON_DIRECTORY_FILE,
NULL,
0
);
if( NT_SUCCESS( Status ))
{
DbgPrint( “Zw Create file was successful\n” );
}
else
{
DbgPrint( “Zw Create file was NOT
successful\n” );
}
KeyBufTemp = ExAllocatePoolWithTag(
NonPagedPool,35,‘cnED’);
RtlZeroMemory( KeyBufTemp , 35);
BufLen = 35;
Status =
ZwReadFile
(
fileHandle,
NULL,
NULL,
NULL,
&IoStatusBlock,
KeyBufTemp,
BufLen,
NULL,
NULL
);
if( NT_SUCCESS( Status ))
{
DbgPrint(“ZwRead file was successful\n”);
for( Cnt = 0 ; Cnt < 35 ; Cnt++ )
DbgPrint(" %c",KeyBufTemp[Cnt]);
DbgPrint(“\n”);
}
else
{
DbgPrint(“ZwRead file was NOT successful\n”);
}
ExFreePool( KeyBufTemp );
Status = ZwClose( fileHandle );
}
}
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo