Вот приложил код.
NTSTATUS
SfPassThrough (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
UNICODE_STRING uu;
UNICODE_STRING uu3;
PUNICODE_STRING uu2=&uu;
PIO_STACK_LOCATION irpSp;
PSFILTER_DEVICE_EXTENSION devExtS = DeviceObject->DeviceExtension;
PIRP MiMi;
PVOID BufferName;
PIO_STACK_LOCATION MiMiSp;
KEVENT Ev;
IO_STATUS_BLOCK io_Block;
VALIDATE_IRQL(Irp);
if (IS_MY_CONTROL_DEVICE_OBJECT(DeviceObject)) {
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
Irp->IoStatus.Information = 0;
IoCompleteRequest( Irp, IO_NO_INCREMENT );
return STATUS_INVALID_DEVICE_REQUEST;
}
irpSp = IoGetCurrentIrpStackLocation( Irp );
if ((irpSp->MajorFunction!=IRP_MJ_SET_INFORMATION) && (irpSp->MajorFunction!=IRP_MJ_WRITE) && (irpSp->MajorFunction!=IRP_MJ_READ)){
IoSkipCurrentIrpStackLocation( Irp );
return IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, Irp );
}
DbgPrint ("SW11_BETA037\n");
BufferName = ExAllocatePoolWithTag( NonPagedPool, 2000, SFLT_POOL_TAG);
if (BufferName == NULL){
IoSkipCurrentIrpStackLocation( Irp );
return IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, Irp );
}
KeInitializeEvent(&Ev, SynchronizationEvent,FALSE);
MiMi = IoAllocateIrp(((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject->StackSize,FALSE);
if (MiMi == NULL){
ExFreePool(BufferName);
IoSkipCurrentIrpStackLocation( Irp );
return IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, Irp );
}
MiMi->AssociatedIrp.SystemBuffer = BufferName;
MiMi->UserEvent = &Ev;
MiMi->UserIosb = &io_Block;
MiMi->Tail.Overlay.Thread = PsGetCurrentThread();
MiMi->Tail.Overlay.OriginalFileObject = irpSp->FileObject;
MiMi->RequestorMode = KernelMode;
MiMi->Flags = 0;
MiMiSp = IoGetNextIrpStackLocation(MiMi);
MiMiSp->MajorFunction = IRP_MJ_QUERY_INFORMATION;
MiMiSp->DeviceObject = ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject;
MiMiSp->FileObject = irpSp->FileObject;
MiMiSp->Parameters.QueryFile.Length = 2000;
MiMiSp->Parameters.QueryFile.FileInformationClass = FileNameInformation;
IoSetCompletionRoutine(MiMi, DeleteIrpRoutine, NULL, TRUE, TRUE, TRUE);
IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, MiMi);
KeWaitForSingleObject(&Ev,Executive, KernelMode, FALSE, 0);
DbgPrint ("SW8_BETA038\n");
if (!NT_SUCCESS(io_Block.Status)){
ExFreePool(BufferName);
IoSkipCurrentIrpStackLocation( Irp );
return IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, Irp );
DbgPrint ("SW8_NO\n");
}
uu3.MaximumLength = (USHORT)((PFILE_NAME_INFORMATION)BufferName)->FileNameLength;
uu3.Length = uu3.MaximumLength;
uu3.Buffer = ((PFILE_NAME_INFORMATION)BufferName)->FileName;
ExFreePool(BufferName);
IoSkipCurrentIrpStackLocation( Irp );
return IoCallDriver( ((PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension)->AttachedToDeviceObject, Irp );
}
NTSTATUS
DeleteIrpRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
{
UNREFERENCED_PARAMETER( DeviceObject );
UNREFERENCED_PARAMETER( Context );
*Irp->UserIosb = Irp->IoStatus;
KeSetEvent(Irp->UserEvent,0,FALSE);
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}