Windows File System Minifilter

A real-time, kernel-level file system monitoring and malware detection system for Windows. The project intercepts file I/O operations at the kernel level, forwards suspicious executables to a user-mode scanner, and classifies them using PE analysis and entropy-based heuristics.


System Architecture at a Glance

flowchart TB
    subgraph KernelSpace["Kernel Space"]
        FS["File System"]
        FltMgr["Filter Manager\n(FltMgr.sys)"]
        MF["WindowsFileSystemMinifilter.sys\n(Minifilter Driver)"]
    end

    subgraph UserSpace["User Space"]
        MON["FsMinifilterMonitor.exe\n(User-Mode Monitor)"]
        SCAN["Scanner.exe\n(Malware Scanner)"]
        subgraph ScanPipeline["Scan Pipeline"]
            PE["PE Parser"]
            FE["Feature Extractor"]
            ML["ML Classifier"]
            POL["Policy Engine"]
        end
    end

    FS -->|"I/O Request"| FltMgr
    FltMgr -->|"Pre/Post Callbacks"| MF
    MF -->|"FltSendMessage\n(Filter Port)"| MON
    MON -->|"Named Pipe\n(ScannerPipe)"| SCAN
    SCAN --> PE --> FE --> ML --> POL

    style KernelSpace fill:#1a1a2e,color:#fff
    style UserSpace fill:#16213e,color:#fff
    style ScanPipeline fill:#0f3460,color:#fff

Project Components

Component Type Language Description
WindowsFileSystemMinifilter.sys Kernel Driver C (WDK) Intercepts file system I/O via Filter Manager callbacks
FsMinifilterMonitor.exe User-Mode App C++ Receives kernel messages and dispatches scan requests
Scanner.exe User-Mode App C++ PE analysis, feature extraction, ML classification

Documentation Map

Architecture

High-level system design and technology decisions.

Flows

End-to-end data flows and lifecycle diagrams.

  • File Interception Flow โ€” From I/O request to kernel callback to user-mode notification
  • Scan Pipeline Flow โ€” PE parsing โ†’ feature extraction โ†’ classification โ†’ policy enforcement
  • Driver Lifecycle โ€” Install โ†’ load โ†’ attach โ†’ filter โ†’ unload

Modules

Detailed breakdown of every component, class, and subsystem.

API & Contracts

Inter-component interfaces, data types, and communication protocols.

Guides

Step-by-step operational guides.


Task Guide
Build from source Building
Install driver on test machine Installing the Driver
Understand how a file scan works Scan Pipeline Flow
Add a new malware detection rule Adding Detection Rules
Understand kernel โ†” user comms Communication Architecture

Repository Structure

โ”œโ”€โ”€ Windows File System Minifilter/   # Kernel-mode minifilter driver
โ”‚   โ”œโ”€โ”€ main.cpp                      # DriverEntry
โ”‚   โ”œโ”€โ”€ FsMinifilter.cpp              # Callback implementations
โ”‚   โ”œโ”€โ”€ FsMinifilter.h                # Driver declarations & stream context
โ”‚   โ”œโ”€โ”€ FsMinifilterCommon.h          # Shared message types (kernel โ†” user)
โ”‚   โ””โ”€โ”€ WindowsFileSystemMinifilter.inf
โ”œโ”€โ”€ FsMinifilterMonitor/              # User-mode monitor application
โ”‚   โ””โ”€โ”€ main.cpp                      # Port listener, pipe forwarder
โ”œโ”€โ”€ scanner/                          # User-mode malware scanner
โ”‚   โ”œโ”€โ”€ scanner.cpp                   # Entry point, worker thread, pipe server
โ”‚   โ”œโ”€โ”€ pe_parser.cpp/h               # PE file parsing engine
โ”‚   โ”œโ”€โ”€ features.cpp/h                # Feature extraction
โ”‚   โ”œโ”€โ”€ ml.cpp/h                      # ML classification
โ”‚   โ”œโ”€โ”€ policy.cpp/h                  # Policy enforcement
โ”‚   โ”œโ”€โ”€ queue.cpp/h                   # Thread-safe scan queue
โ”‚   โ””โ”€โ”€ scanner_api.h                 # Public API surface
โ”œโ”€โ”€ ScannerShared.h                   # Shared types (monitor โ†” scanner)
โ”œโ”€โ”€ InstallDriver.cmd                 # Driver install/remove script
โ””โ”€โ”€ docs/                             # โ† You are here