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.
- System Overview โ Component topology, tech stack, deployment model
- Driver Architecture โ Kernel minifilter internals, callback registration, stream contexts
- Communication Architecture โ Filter ports, named pipes, message protocols
- Design Decisions โ Why minifilter? Why entropy? Rationale for every major choice
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.
- Kernel Driver Module โ
FsMinifilter.cpp, callback implementations, context management - Monitor Module โ
FsMinifilterMonitor, port connection, deduplication, pipe forwarding - Scanner Module โ Worker thread, queue, pipe server, scan modes
- PE Parser Module โ DOS/NT header validation, section parsing, import counting
- ML Classifier Module โ Entropy-based heuristic classification model
- Policy Engine Module โ Verdict handling and enforcement actions
API & Contracts
Inter-component interfaces, data types, and communication protocols.
- Kernel โ User Interface โ Filter communication port protocol and message format
- Scanner API โ Public scanner interface, scan results, scan modes
- Data Types Reference โ All shared structures, enums, and constants
Guides
Step-by-step operational guides.
- Getting Started โ Prerequisites, first build, first run
- Building the Project โ Visual Studio configuration, WDK setup, multi-arch builds
- Installing the Driver โ Test signing, service creation,
fltmccommands - Adding Detection Rules โ How to extend the ML classifier and policy engine
Quick Links
| 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