Hi All !
Sorry for my last mail, but my english is very bad… Perhaps, this letter is written more competently…
I have a stupid question. I’m writing the File System Filter driver for NT 2000.
My computer has FAT32 file system, provided by Microsoft native FastFat driver.
Some time ago i couldn’t write my code, to work properly with Visual C++
(i.e. MSDEV IDE). After driver starts, the system crashes during building of any project
by MSDEV IDE. I’ve found that memory crash occures after closing of thranslated file, when MSDEV calls NtGetFullAttributesFile native API. This function generates four file system actions
- IRP_MJ_CREATE
- FastIoQueryNetworkOpenInfo
- IRP_MJ_CLEANUP
- IRP_MJ_CLOSE
After generating of the last action an error occures during ExFreePoolWithTag execution when some object is being released.
In stack dump i’ve seen the ObpFreeObject, ObpRemoveObjectQueue calls, and others.
During my experiences i found, that error occures in my SetFileInformation routine. By means of this call i set the
file position to the beginning of the file after noncached reading. I’ve changed this call to native IFS function IoSetInformation(…), but it caused the problem of reenterability of my driver. In some functions I needed to set aside my old handler because of system hangover during MSDEV IDE exit. Can any smart guy tell me anything about my bug?
I’ve included the source code in this message.
BOOLEAN SetFileInfo(IN PFILE_OBJECT lpFileObject, IN PDEVICE_OBJECT lpDeviceObject,
IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG dwInfoLen, IN PVOID lpInfo)
{
PIRP Irp;
KEVENT Event;
IO_STATUS_BLOCK IoStatus;
PIO_STACK_LOCATION IrpSp;
Irp = IoAllocateIrp(lpDeviceObject->StackSize,FALSE);
if(!Irp)
return FALSE;
Irp->RequestorMode = KernelMode;
KeInitializeEvent(&Event,SynchronizationEvent,FALSE);
Irp->Flags = IRP_BUFFERED_IO;
Irp->Tail.Overlay.OriginalFileObject = lpFileObject;
Irp->UserIosb = &IoStatus;
if(FileInformationClass != FilePositionInformation)
Irp->UserEvent = &Event;
Irp->AssociatedIrp.SystemBuffer = lpInfo;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->DeviceObject = lpDeviceObject;
IrpSp->FileObject = lpFileObject;
IrpSp->MajorFunction = IRP_MJ_SET_INFORMATION;
IrpSp->Parameters.SetFile.FileInformationClass = FileInformationClass;
IrpSp->Parameters.SetFile.Length = dwInfoLen;
IrpSp->DeviceObject = lpDeviceObject;
Irp->Tail.Overlay.OriginalFileObject = lpFileObject;
IoSetCompletionRoutine(Irp,MyCompleteRequestHandler,((FileInformationClass ==
FilePositionInformation) ? &Event : NULL),TRUE,TRUE,TRUE);
IoCallDriver(lpDeviceObject,Irp);
KeWaitForSingleObject(&Event,Executive,KernelMode,TRUE,0);
return NT_SUCCESS(IoStatus.Status);
}
NTSTATUS MyCompleteRequestHandler(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp,
IN PVOID Context)
{
if( Irp->PendingReturned)
{
IoMarkIrpPending(Irp);
return Irp->IoStatus.Status;
}
*Irp->UserIosb = Irp->IoStatus;
if(Irp->UserEvent)
KeSetEvent(Irp->UserEvent,0,FALSE);
else if(Context)
KeSetEvent((PKEVENT)Context,0,FALSE);
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
}
Best regards.
Always grateful to you
Nikityenko Oleg.