Hi,all.
Most of the article on internet said like this:
if( KeGetCurrentIrql()>PASSIVE_LEVEL)//Must run at Passive_level
{ return 0};
but it not works in my driver,the code as below
//in Routine PostCreate
…
Ret=FileStatus(…);
…
//in function FileStatus
//define some variables
try {
status = FltGetVolumeFromInstance( Instance, &volume );
if (!NT_SUCCESS( status )) {
leave;
}
status = FltGetVolumeProperties( volume,
&volumeProps,
sizeof( volumeProps ),
&length );
if (NT_ERROR( status )) {
DbgPrint(“ERROR on Get Volume Properties\n!”);
leave;
}
length = max( DSS_READ_BUFFER_SIZE, volumeProps.SectorSize );
buffer = FltAllocatePoolAlignedWithTag( Instance,
NonPagedPool,
length,
‘nacS’ );
if (NULL == buffer) {
DbgPrint(“ERROR on allocate buffer\n!”);
status = STATUS_INSUFFICIENT_RESOURCES;
leave;
}
//DbgPrint(“Start Read file Head!\n”);
offset.QuadPart=0;
bytesRead = 0;
if( KeGetCurrentIrql()==PASSIVE_LEVEL)
{leave;}
status = FltReadFile( Instance,
FileObject,
&offset,
length,
buffer,
FLTFL_IO_OPERATION_NON_CACHED |
FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET,
&bytesRead,
NULL,
NULL );
…
…
Mostly it works fine,but sometimes it cause crash when call fltreadfile with
error IRQL_NOT_LESS_OR_EQUAL,current irql = 2,0xFF or other values,the code
" if( KeGetCurrentIrql()==PASSIVE_LEVEL)" looks that not in effect.
Is this question about shared resource access?How to fix it?
Any advise?
Thanks!
Murphy/(A Beginner)