mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 20:18:22 +00:00
[FLTMGR]
- Add stubs for context registration - Add dispatch and device control handlers - Implement the load IOCTL. We can now load minifilters with 'fltmc load <myfilter>' svn path=/trunk/; revision=72595
This commit is contained in:
parent
2c3c2095fb
commit
abe4dbbca0
2 changed files with 208 additions and 0 deletions
79
reactos/drivers/filters/fltmgr/Context.c
Normal file
79
reactos/drivers/filters/fltmgr/Context.c
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* PROJECT: Filesystem Filter Manager
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/filters/fltmgr/Context.c
|
||||
* PURPOSE: Contains context routines
|
||||
* PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include "fltmgr.h"
|
||||
#include "fltmgrint.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
IsContextTypeValid(
|
||||
_In_ FLT_CONTEXT_TYPE ContextType
|
||||
);
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
SetupContextHeader(
|
||||
_In_ PFLT_FILTER Filter,
|
||||
_In_ PFLT_CONTEXT_REGISTRATION ContextPtr,
|
||||
_Out_ PALLOCATE_CONTEXT_HEADER ContextHeader
|
||||
);
|
||||
|
||||
/* EXPORTED FUNCTIONS ******************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/* INTERNAL FUNCTIONS ******************************************************/
|
||||
|
||||
|
||||
NTSTATUS
|
||||
FltpRegisterContexts(_In_ PFLT_FILTER Filter,
|
||||
_In_ const FLT_CONTEXT_REGISTRATION *Context)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Filter);
|
||||
UNREFERENCED_PARAMETER(Context);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS ******************************************************/
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
IsContextTypeValid(_In_ FLT_CONTEXT_TYPE ContextType)
|
||||
{
|
||||
switch (ContextType)
|
||||
{
|
||||
case FLT_VOLUME_CONTEXT:
|
||||
case FLT_INSTANCE_CONTEXT:
|
||||
case FLT_FILE_CONTEXT:
|
||||
case FLT_STREAM_CONTEXT:
|
||||
case FLT_STREAMHANDLE_CONTEXT:
|
||||
case FLT_TRANSACTION_CONTEXT:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
SetupContextHeader(_In_ PFLT_FILTER Filter,
|
||||
_In_ PFLT_CONTEXT_REGISTRATION ContextPtr,
|
||||
_Out_ PALLOCATE_CONTEXT_HEADER ContextHeader)
|
||||
{
|
||||
return 0;
|
||||
}
|
129
reactos/drivers/filters/fltmgr/Dispatch.c
Normal file
129
reactos/drivers/filters/fltmgr/Dispatch.c
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* PROJECT: Filesystem Filter Manager
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: drivers/filters/fltmgr/Dispatch.c
|
||||
* PURPOSE: Contains dispatch handler routines
|
||||
* PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include "fltmgr.h"
|
||||
#include "fltmgrint.h"
|
||||
#include "fltmgr_shared.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* DATA *********************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
HandleLoadUnloadIoctl(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
HandleFindFirstIoctl(
|
||||
_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp
|
||||
);
|
||||
|
||||
|
||||
/* sdsfds *******************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
FltpDeviceControlHandler(_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
ULONG ControlCode;
|
||||
NTSTATUS Status;
|
||||
|
||||
StackPtr = IoGetCurrentIrpStackLocation(Irp);
|
||||
FLT_ASSERT(StackPtr->MajorFunction == IRP_MJ_DEVICE_CONTROL);
|
||||
|
||||
ControlCode = StackPtr->Parameters.DeviceIoControl.IoControlCode;
|
||||
switch (ControlCode)
|
||||
{
|
||||
case IOCTL_LOAD_FILTER:
|
||||
Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
|
||||
break;
|
||||
|
||||
case IOCTL_UNLOAD_FILTER:
|
||||
Status = HandleLoadUnloadIoctl(DeviceObject, Irp);
|
||||
break;
|
||||
|
||||
case IOCTL_FIND_FIRST_FILTER:
|
||||
Status = HandleFindFirstIoctl(DeviceObject, Irp);
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
FltpDispatchHandler(_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
StackPtr = IoGetCurrentIrpStackLocation(Irp);
|
||||
UNREFERENCED_PARAMETER(StackPtr);
|
||||
|
||||
// implement me
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* INTERNAL FUNCTIONS ******************************************************/
|
||||
|
||||
NTSTATUS
|
||||
HandleLoadUnloadIoctl(_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
UNICODE_STRING Name;
|
||||
PFILTER_NAME FilterName;
|
||||
ULONG BufferLength;
|
||||
ULONG ControlCode;
|
||||
|
||||
/* Get the IOCTL data from the stack pointer */
|
||||
StackPtr = IoGetCurrentIrpStackLocation(Irp);
|
||||
BufferLength = StackPtr->Parameters.DeviceIoControl.InputBufferLength;
|
||||
ControlCode = StackPtr->Parameters.DeviceIoControl.IoControlCode;
|
||||
|
||||
FLT_ASSERT(ControlCode == IOCTL_LOAD_FILTER || ControlCode == IOCTL_UNLOAD_FILTER);
|
||||
|
||||
/* Make sure the buffer is valid */
|
||||
if (BufferLength < sizeof(FILTER_NAME))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* Convert the file name buffer into a string */
|
||||
FilterName = (PFILTER_NAME)Irp->AssociatedIrp.SystemBuffer;
|
||||
Name.Length = FilterName->Length;
|
||||
Name.MaximumLength = FilterName->Length;
|
||||
Name.Buffer = (PWCH)((PCHAR)FilterName + FIELD_OFFSET(FILTER_NAME, FilterName[0]));
|
||||
|
||||
/* Forward the request to our Flt routines */
|
||||
if (ControlCode == IOCTL_LOAD_FILTER)
|
||||
{
|
||||
return FltLoadFilter(&Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FltUnloadFilter(&Name);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
HandleFindFirstIoctl(_In_ PDEVICE_OBJECT DeviceObject,
|
||||
_Inout_ PIRP Irp)
|
||||
{
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
Loading…
Reference in a new issue