Filter driver

On this page 7

A filter driver is an optional kernel driver that inserts itself into an existing driver stack to observe, modify or block I/O requests passing between other drivers, without replacing the driver that actually controls the device. In operating systems, filter drivers belong to the topic of drivers & devices and are the standard way to add encryption, monitoring, compression or compatibility fixes to hardware and file systems that already work.

The concept is most formalized in Microsoft Windows, where the Windows Driver Model and its successors define upper and lower filters, file system minifilters and network filters. Comparable layering exists in other systems, for example stacked block devices in Linux, but the term filter driver is used most precisely in the Windows architecture.

How a filter driver sits in the driver stack

A filter driver works by attaching a device object to the stack of an existing device. When the I/O manager sends an I/O request packet, or IRP, to the top of the stack, each driver in turn may process it, pass it down with IoCallDriver, or complete it immediately.

The stack for a typical device contains a bus driver, a function driver and any number of filters. The table below shows how these roles differ.

Driver roleDevice objectResponsibilityRequired
Bus driverPhysical device object (PDO)Enumerates the device and controls bus accessYes
Function driverFunctional device object (FDO)Implements the main device behaviorYes
Upper filterFilter device object above the FDOAdjusts requests before the function driver sees themNo
Lower filterFilter device object below the FDOAdjusts requests sent toward the hardwareNo
Roles in a device stack

Because a filter registers completion routines, it can also act on the way back up the stack, for example by decrypting data that the lower drivers have just read. A well-behaved filter passes through every request it does not understand unchanged.

Types of filter drivers

Filter drivers are classified by where they attach and by which subsystem they serve. Each subsystem in Windows has its own filtering framework with different rules.

TypeAttaches toTypical uses
Device upper filterAbove a function driverKeyboard remapping, input logging, class-wide policy
Device lower filterBelow a function driverHardware workarounds, bus-level monitoring
Bus filterAbove a bus driverChanging enumeration or device properties
File system minifilterFilter Manager frameworkAntivirus scanning, encryption, backup, quotas
Network filterWindows Filtering Platform or NDISFirewalls, traffic shaping, VPN clients
Main filter driver categories

File system minifilters replaced the older legacy file system filters. They register callbacks with the Filter Manager, which handles attachment, ordering and request routing, so developers write far less fragile code. Each minifilter receives an altitude, a numeric position that determines its order relative to other filters.

Installing and ordering filter drivers

Device filters are installed through INF files that add the driver name to the UpperFilters or LowerFilters registry value of either one device or an entire device setup class. A class filter applies to every device of that class, such as all disk drives or all keyboards.

Load order determines behavior, because a filter only sees what the drivers above it have passed down. Microsoft assigns minifilter altitudes in load order groups, and the following ranges illustrate the principle.

Load order groupApproximate altitude rangePurpose
Activity monitor360000 to 389999Observes file activity
Anti-virus320000 to 329999Scans content before access
Replication300000 to 309999Copies changes to other storage
Encryption140000 to 149999Encrypts and decrypts file data
Example minifilter altitude groups

Higher altitudes sit closer to the application, so an antivirus scanner above an encryption filter sees plaintext data. Choosing the wrong position can make a product inspect encrypted bytes or miss operations entirely.

A filter driver is not the only way to influence device behavior. It differs from a function driver, which owns the device, and from user-mode hooks, which operate in a single process rather than for the whole system.

MechanismScopePrivilegeRisk
Filter driverAll I/O for a device or volumeKernel modeCrash affects the whole system
Function driverComplete control of a deviceKernel modeReplaces vendor behavior
User-mode driverOne device, isolated host processUser modeLower performance, safer failure
API hookingOne applicationUser modeFragile, easily bypassed
Filter drivers versus alternatives

Risks and common mistakes

Because filter drivers run in kernel mode on every request, a single defect affects the stability of the entire operating system. Faulty filters are a leading cause of system crashes, boot failures and performance loss on otherwise healthy machines.

  • Leaving a filter registered after its driver file is removed, which can prevent the device or the whole system from starting.
  • Blocking in the I/O path with slow operations such as network calls, which stalls every application using the device.
  • Mishandling unknown requests instead of passing them through, which breaks new features added by later system versions.
  • Stacking several security products with overlapping filters, which multiplies latency and creates conflicts.
  • Ignoring IRQL rules and paged memory constraints, which leads to bug checks under load.

Microsoft requires driver signing for kernel filters on modern Windows versions, and tools such as fltmc list loaded minifilters with their altitudes. Checking that list is a sensible first diagnostic step when file access slows down unexpectedly.

In everyday language

Picture a mail room between a company and its post office. Normally letters go straight through. Now the company adds an extra checkpoint. One clerk scans each letter for danger. Another seals private letters in locked envelopes. The original mail room still does its job.

A filter driver is that extra checkpoint inside the computer. It stands between programs and a device, such as a disk or keyboard. It can check, change or stop what passes by. If the checkpoint works badly, though, all the mail slows down.

Seen in the real world

An IT department rolls out full-disk encryption and endpoint antivirus to 2,000 corporate laptops running Windows. Both products install filter drivers: the encryption product adds a lower filter on the disk stack, and the antivirus product adds a file system minifilter at an altitude in the anti-virus group.

After the rollout, users report that opening large spreadsheets takes several seconds longer. A technician runs fltmc and finds that a retired backup agent left an orphaned minifilter still scanning every file. Removing it and excluding the spreadsheet cache folder from real-time scanning restores normal file performance while keeping encryption and malware protection in place.