mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[FLTMGR]
- Properly handle requests that were sent directly to the fltmgr instead of sending them down the stack - Add a separate callback for IRP_MJ_DEVICE_CONTROL and forward them on to an internal handler - We can now open a handle to the fltmgr and send IOCTLs down to it. svn path=/trunk/; revision=72593
This commit is contained in:
parent
4e466b10df
commit
72ae4c113e
1 changed files with 94 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* PROJECT: Filesystem Filter Manager
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/fs_minifilter/fltmgr/interface.c
|
||||
* FILE: drivers/filters/fltmgr/interface.c
|
||||
* PURPOSE: Implements the driver interface
|
||||
* PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@
|
|||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include "fltmgr.h"
|
||||
#include "fltmgrint.h"
|
||||
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -99,6 +100,13 @@ FltpFsControl(
|
|||
_Inout_ PIRP Irp
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
FltpDeviceControl(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
FltpFastIoCheckIfPossible(
|
||||
|
@ -344,6 +352,7 @@ FltpFastIoQueryOpen(
|
|||
#pragma alloc_text(PAGE, FltpFsNotification)
|
||||
#pragma alloc_text(PAGE, FltpCreate)
|
||||
#pragma alloc_text(PAGE, FltpFsControl)
|
||||
#pragma alloc_text(PAGE, FltpDeviceControl)
|
||||
#pragma alloc_text(PAGE, FltpFastIoRead)
|
||||
#pragma alloc_text(PAGE, FltpFastIoWrite)
|
||||
#pragma alloc_text(PAGE, FltpFastIoQueryBasicInfo)
|
||||
|
@ -366,26 +375,11 @@ FltpFastIoQueryOpen(
|
|||
#pragma alloc_text(PAGE, FltpFastIoQueryOpen)
|
||||
#endif
|
||||
|
||||
#define MAX_DEVNAME_LENGTH 64
|
||||
|
||||
|
||||
DRIVER_DATA DriverData;
|
||||
|
||||
|
||||
typedef struct _FLTMGR_DEVICE_EXTENSION
|
||||
{
|
||||
/* The file system we're attached to */
|
||||
PDEVICE_OBJECT AttachedToDeviceObject;
|
||||
|
||||
/* The storage stack(disk) accociated with the file system device object we're attached to */
|
||||
PDEVICE_OBJECT StorageStackDeviceObject;
|
||||
|
||||
/* Either physical drive for volume device objects otherwise
|
||||
* it's the name of the control device we're attached to */
|
||||
UNICODE_STRING DeviceName;
|
||||
WCHAR DeviceNameBuffer[MAX_DEVNAME_LENGTH];
|
||||
|
||||
} FLTMGR_DEVICE_EXTENSION, *PFLTMGR_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct _DETACH_DEVICE_WORK_ITEM
|
||||
{
|
||||
WORK_QUEUE_ITEM WorkItem;
|
||||
|
@ -427,18 +421,38 @@ FltpDispatch(_In_ PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
NTSTATUS Status;
|
||||
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
__debugbreak();
|
||||
|
||||
/* Check if this is a request for us */
|
||||
if (DeviceObject == DriverData.DeviceObject)
|
||||
{
|
||||
FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
|
||||
FLT_ASSERT(DeviceExtension == NULL);
|
||||
|
||||
/* Hand it off to our internal handler */
|
||||
Status = FltpDispatchHandler(DeviceObject, Irp);
|
||||
if (Status != STATUS_REPARSE)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, 0);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
FLT_ASSERT(DeviceExtension &&
|
||||
DeviceExtension->AttachedToDeviceObject);
|
||||
|
||||
StackPtr = IoGetCurrentIrpStackLocation(Irp);
|
||||
if (StackPtr->MajorFunction == IRP_MJ_SHUTDOWN)
|
||||
{
|
||||
//FltpProcessShutdownRequest(DeviceObject);
|
||||
// handle shutdown request
|
||||
}
|
||||
|
||||
DPRINT1("Received %X from %wZ\n", StackPtr->MajorFunction, &DeviceExtension->DeviceName);
|
||||
|
||||
/* Just pass the IRP down the stack */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
|
||||
|
@ -454,10 +468,25 @@ FltpCreate(_In_ PDEVICE_OBJECT DeviceObject,
|
|||
PAGED_CODE();
|
||||
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
__debugbreak();
|
||||
|
||||
/* Check if this is a request for us */
|
||||
if (DeviceObject == DriverData.DeviceObject)
|
||||
{
|
||||
FLT_ASSERT(DeviceObject->DriverObject == DriverData.DriverObject);
|
||||
FLT_ASSERT(DeviceExtension == NULL);
|
||||
|
||||
/* Someone wants a handle to the fltmgr, allow it */
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IofCompleteRequest(Irp, 0);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
FLT_ASSERT(DeviceExtension &&
|
||||
DeviceExtension->AttachedToDeviceObject);
|
||||
|
||||
DPRINT1("Received create from %wZ (%lu)\n", &DeviceExtension->DeviceName, PsGetCurrentProcessId());
|
||||
|
||||
/* Just pass the IRP down the stack */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
|
||||
|
@ -472,10 +501,53 @@ FltpFsControl(_In_ PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
PAGED_CODE();
|
||||
|
||||
/* Check if this is a request for us */
|
||||
if (DeviceObject == DriverData.DeviceObject)
|
||||
{
|
||||
/* We don't handle this request */
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||
IofCompleteRequest(Irp, 0);
|
||||
return STATUS_INVALID_DEVICE_REQUEST;
|
||||
}
|
||||
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
__debugbreak();
|
||||
|
||||
FLT_ASSERT(DeviceExtension &&
|
||||
DeviceExtension->AttachedToDeviceObject);
|
||||
|
||||
/* Just pass the IRP down the stack */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
FltpDeviceControl(_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp)
|
||||
{
|
||||
PFLTMGR_DEVICE_EXTENSION DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Check if the request was meant for us */
|
||||
if (DeviceObject == DriverData.DeviceObject)
|
||||
{
|
||||
Status = FltpDeviceControlHandler(DeviceObject, Irp);
|
||||
if (Status != STATUS_REPARSE)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, 0);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
FLT_ASSERT(DeviceExtension &&
|
||||
DeviceExtension->AttachedToDeviceObject);
|
||||
|
||||
/* Just pass the IRP down the stack */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->AttachedToDeviceObject, Irp);
|
||||
|
@ -1890,7 +1962,6 @@ FltpDetachFromFileSystemDevice(_In_ PDEVICE_OBJECT DeviceObject)
|
|||
LONG_PTR Count;
|
||||
|
||||
PAGED_CODE();
|
||||
__debugbreak();
|
||||
|
||||
/* Get the top device in the chain and increment the ref count on it */
|
||||
AttachedDevice = IoGetAttachedDeviceReference(DeviceObject);
|
||||
|
@ -2099,6 +2170,7 @@ SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject)
|
|||
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = FltpCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = FltpCreate;
|
||||
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FltpFsControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FltpDeviceControl;
|
||||
|
||||
/* The FastIo diapatch table is stored in the pool along with a tag */
|
||||
FastIoDispatch = ExAllocatePoolWithTag(NonPagedPool, sizeof(FAST_IO_DISPATCH), FM_TAG_DISPATCH_TABLE);
|
||||
|
|
Loading…
Reference in a new issue