Hi All !
I have the stupid question. I’m writing the File System Filter driver for NT 2000.
My computer have an FAT32 file system, which was provided by FastFat native Microsoft driver.
At the some time behind i can’t writing of my code as, what it “live” concurrently with Visual C++
(i.e. MSDEV IDE). After driver starting, the system was crashed during building of another project
by MSDEV IDE. My research was complete next manner: i’m define, what the memory crach
was called after first closing of translated file, during MSDEV call NtGetFullAttributesFile native API
call. By this function was generated four file system actions:
- IRP_MJ_CREATE
- FastIoQueryNetworkOpenInfo
- IRP_MJ_CLEANUP
- IRP_MJ_CLOSE
After last from them is arise the bug during ExFreePoolWithTag. It arise during then some object
was released. On stack dump i see the ObpFreeObject, ObpRemoveObjectQueue calls, and other.
During my experiences i’m find, what bug was in my SetFileInformation routine. By this call i set
file position behind to the file begin (after previous non-cached reading). This call was changed
to the native IFS function IoSetInformation(…), but it is causing the trouble of my driver reenter,
and work fine is not forever. At the some routines i was omit my old handler, because during
exit from MSDEV IDE was caused the system stop. May smart guys say to the “novice”, where is my bug ?
I’m include the code of my SetInformation handler to this mail.
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.