Author: gedmurphy
Date: Tue Sep 6 16:47:43 2016
New Revision: 72594
URL:
http://svn.reactos.org/svn/reactos?rev=72594&view=rev
Log:
[FLTMGR]
- Implement FltLoadFilter and stub FltUnloadFilter
- Register contexts if the caller requests (coming later)
- Stubpliment FltStartFiltering
Added:
trunk/reactos/drivers/filters/fltmgr/Filter.c
- copied, changed from r72588, trunk/reactos/drivers/filters/fltmgr/Registration.c
Copied: trunk/reactos/drivers/filters/fltmgr/Filter.c (from r72588,
trunk/reactos/drivers/filters/fltmgr/Registration.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/fltmgr/Fil…
==============================================================================
--- trunk/reactos/drivers/filters/fltmgr/Registration.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/fltmgr/Filter.c [iso-8859-1] Tue Sep 6 16:47:43 2016
@@ -1,7 +1,7 @@
/*
* PROJECT: Filesystem Filter Manager
* LICENSE: GPL - See COPYING in the top level directory
-* FILE: drivers/fs_minifilter/fltmgr/Registration.c
+* FILE: drivers/filters/fltmgr/Filter.c
* PURPOSE: Handles registration of mini filters
* PROGRAMMERS: Ged Murphy (gedmurphy(a)reactos.org)
*/
@@ -9,6 +9,7 @@
/* INCLUDES ******************************************************************/
#include "fltmgr.h"
+#include "fltmgrint.h"
#define NDEBUG
#include <debug.h>
@@ -16,6 +17,8 @@
/* DATA *********************************************************************/
+#define SERVICES_KEY
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"
+#define MAX_KEY_LENGTH 0x200
NTSTATUS
FltpStartingToDrainObject(
@@ -24,6 +27,38 @@
/* EXPORTED FUNCTIONS ******************************************************/
+
+NTSTATUS
+NTAPI
+FltLoadFilter(_In_ PCUNICODE_STRING FilterName)
+{
+ UNICODE_STRING DriverServiceName;
+ UNICODE_STRING ServicesKey;
+ CHAR Buffer[MAX_KEY_LENGTH];
+
+ /* Setup the base services key */
+ RtlInitUnicodeString(&ServicesKey, SERVICES_KEY);
+
+ /* Initialize the string data */
+ DriverServiceName.Length = 0;
+ DriverServiceName.Buffer = (PWCH)Buffer;
+ DriverServiceName.MaximumLength = MAX_KEY_LENGTH;
+
+ /* Create the full service key for this filter */
+ RtlCopyUnicodeString(&DriverServiceName, &ServicesKey);
+ RtlAppendUnicodeStringToString(&DriverServiceName, FilterName);
+
+ /* Ask the kernel to load it for us */
+ return ZwLoadDriver(&DriverServiceName);
+}
+
+NTSTATUS
+NTAPI
+FltUnloadFilter(_In_ PCUNICODE_STRING FilterName)
+{
+ UNREFERENCED_PARAMETER(FilterName);
+ return STATUS_NOT_IMPLEMENTED;
+}
NTSTATUS
NTAPI
@@ -39,8 +74,6 @@
PCHAR Ptr;
NTSTATUS Status;
- Status = 0; //remove me
-
/* Make sure we're targeting the correct major revision */
if ((Registration->Version & 0xFF00) != FLT_MAJOR_VERSION)
{
@@ -70,7 +103,8 @@
/* Calculate the buffer sizes */
CallbackBufferSize = Count * sizeof(FLT_OPERATION_REGISTRATION);
- FilterBufferSize = sizeof(FLT_FILTER) + CallbackBufferSize +
+ FilterBufferSize = sizeof(FLT_FILTER) +
+ CallbackBufferSize +
DriverObject->DriverExtension->ServiceKeyName.Length;
/* Allocate a buffer to hold our filter data */
@@ -116,12 +150,21 @@
InitializeListHead(&Filter->PortList.mList);
Filter->PortList.mCount = 0;
+ /* We got this far, assume success from here */
+ Status = STATUS_SUCCESS;
+
/* Check if the caller requested any context data */
if (Registration->ContextRegistration)
{
- // register the context information
- }
-
+ /* Register the contexts for this filter */
+ Status = FltpRegisterContexts(Filter, Registration->ContextRegistration);
+ if (NT_SUCCESS(Status))
+ {
+ goto Quit;
+ }
+ }
+
+ /* Check if the caller is registering any callbacks */
if (Registration->OperationRegistration)
{
/* The callback data comes after the fixed struct */
@@ -162,7 +205,7 @@
// - More stuff??
//
-//Quit:
+Quit:
if (!NT_SUCCESS(Status))
{
// Add cleanup for context resources
@@ -230,6 +273,32 @@
/* Hand the memory back */
ExFreePoolWithTag(Filter, FM_TAG_FILTER);
+}
+
+NTSTATUS
+NTAPI
+FltStartFiltering(_In_ PFLT_FILTER Filter)
+{
+ NTSTATUS Status;
+
+ /* Grab a ref to the filter */
+ Status = FltObjectReference(&Filter->Base);
+ if (NT_SUCCESS(Status))
+ {
+ /* Make sure we aren't already starting up */
+ if (!(Filter->Flags & FLTFL_FILTERING_INITIATED))
+ {
+ // Startup
+ }
+ else
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ }
+
+ FltObjectDereference(&Filter->Base);
+ }
+
+ return Status;
}