hi,
i am learning how to write a mini filter driver. below is my simple code.
the problem is: on Win7, i can load the driver in (i can verify its
existence in the output of “driverquery” command), but when i start it
with command:
net start mymini
it reports error like: “System error 2 has occurred. The system cannot
find the file specified.”
meanwhile, DbgView reports “ERROR FltRegisterFilter - c0000034”
perhaps my code gets wrong somewhere. please would anybody help me to
fix this problem?
many thanks,
J
#include <ntifs.h>
#include <wdm.h>
#include <fltkernel.h>
#include <ntstrsafe.h>
static NTSTATUS FilterUnload (IN FLT_FILTER_UNLOAD_FLAGS Flags);
static NTSTATUS SetupCallback (IN PCFLT_RELATED_OBJECTS FltObjects,
IN FLT_INSTANCE_SETUP_FLAGS Flags,
IN DEVICE_TYPE VolumeDeviceType,
IN FLT_FILESYSTEM_TYPE VolumeFilesystemType);
static NTSTATUS MessageCallback (
in PVOID ConnectionCookie,
in_bcount_opt(InputBufferSize) PVOID InputBuffer,
in ULONG InputBufferSize,
out_bcount_part_opt(OutputBufferSize,*ReturnOutputBufferLength)
PVOID OutputBuffer,
in ULONG OutputBufferSize,
out PULONG ReturnOutputBufferLength);
static CONST FLT_OPERATION_REGISTRATION Callbacks = {
{ IRP_MJ_OPERATION_END }
};
const FLT_CONTEXT_REGISTRATION Contexts = {
{ FLT_CONTEXT_END }
};
static CONST FLT_REGISTRATION FilterRegistration = {
sizeof(FLT_REGISTRATION),
FLT_REGISTRATION_VERSION,
0,
Contexts,
Callbacks,
FilterUnload,
SetupCallback,
NULL, NULL, NULL, NULL, NULL, NULL
};
static PFLT_FILTER retfilter;
NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
status = FltRegisterFilter(DriverObject, &FilterRegistration, &retfilter);
if (!NT_SUCCESS(status)) {
DbgPrint(“ERROR FltRegisterFilter - %08x\n”, status);
return status;
}
DbgPrint(“Successfully Loaded\n”);
return STATUS_SUCCESS;
}
static NTSTATUS FilterUnload (IN FLT_FILTER_UNLOAD_FLAGS Flags)
{
FltUnregisterFilter(retfilter);
return STATUS_SUCCESS;
}
static NTSTATUS SetupCallback (IN PCFLT_RELATED_OBJECTS FltObjects,
IN FLT_INSTANCE_SETUP_FLAGS Flags,
IN DEVICE_TYPE VolumeDeviceType,
IN FLT_FILESYSTEM_TYPE VolumeFilesystemType)
{
return STATUS_SUCCESS;
}
static NTSTATUS MessageCallback (
in PVOID ConnectionCookie,
in_bcount_opt(InputBufferSize) PVOID InputBuffer,
in ULONG InputBufferSize,
out_bcount_part_opt(OutputBufferSize,*ReturnOutputBufferLength)
PVOID OutputBuffer,
in ULONG OutputBufferSize,
out PULONG ReturnOutputBufferLength)
{
return STATUS_SUCCESS;
}</ntstrsafe.h></fltkernel.h></wdm.h></ntifs.h>