↓ Skip to main content

01 - Introduction to KDAMonitor: Building a Windows Kernel Driver

·932 words·5 mins
Elouan Charbonnier
Author
Elouan Charbonnier
KDAMonitor - This article is part of a series.
Part 1: This Article

Welcome to the first series on my blog! It will serve both as an experiment for my upcoming article series and as a development journal for this project.

The project can be found in this repository: KDAMonitor.


What is KDAMonitor?
#

KDAMonitor stands for Kernel Driver Activity Monitor; the goal of this project is to roughly replicate what Sysmon from Microsoft does. This project will be made up of two components:

  • The driver, which will collect events, log them to a .jsonl file, and send them to the client. Here is the list of events handled by the driver:
    • process creation/termination
    • image loading
    • network connections
    • registry modification/creation/deletion
    • thread creation/termination
  • The client, which will be an interface (a console app at first) for the user to observe events in real time

The choice of these events is partly arbitrary, but it also reflects the basics of what’s typically monitored in malware analysis: which process was launched, which DLLs were loaded, who the process communicates with over the network, etc.


Why this project?
#

There are two main reasons why I decided to build this project rather than something else:

  1. Learning to develop a driver for the Windows kernel
  2. Building a useful tool for malware analysis that I can reuse myself (though nowhere near as capable as Sysmon)

This project stems from a simple desire to learn and discover something new. I figured that to monitor system activity, what better than a kernel driver, which has the ability to see everything?

Note that while writing this article I’m already at version 0.7 of the project, so I already have some hindsight on it.

Without further ado, let’s move on to the architecture I had in mind for this project at the start.


Planned Architecture
#

By the end of this project (at v1.0), the architecture will look like this:

kdamonitor_architecture_final.svg

In summary:

  1. An event occurs (process, image, network connection, etc.).
  2. A sensor (callbacks or callouts) captures the event.
  3. The relevant sensor also adds the event to the queue.
  4. The event is dequeued and dispatched to two destinations:
    • the log writer, which writes it to the .jsonl file
    • the client, for real-time display

Technologies Used
#

LanguageC
IDE / BuildVisual Studio 2026
Driver modelWDM
Test environmentWindows 11 VM (VirtualBox), test signing disabled

The technology choices will be explained throughout the series.


Prerequisites
#

To properly follow this series, I recommend readers have a basic understanding of C and how the Windows kernel works internally. I’m learning right along with you :-), so I’ll do my best to make the articles as clear as possible.


Detailed Development Plan
#

Below is a table outlining a detailed plan for each release of the project:

VersionFile(s) involvedFeature
v0.1driver_entry.cDriver skeleton (load/unload)
v0.2device.c, ioctl.cDevice + IOCTL
v0.3event_queue.cKernel event queue
v0.4log_writer.cLogging
v0.5process_callback.cProcess creation/termination monitoring
v0.6image_callback.cImage/DLL load monitoring
v0.7wfp_session.cWFP session setup
v0.8wfp_callout.cNetwork connection monitoring
v0.9registry_callback.cRegistry activity monitoring
v0.10thread_callback.cThread creation/termination monitoring
v0.11-Codebase structure cleanup
v0.12client/Usermode client
v1.0-Stabilization + release

Upcoming Articles
#

You can skip this section if you’d rather discover the articles as I write them. Also note that this schedule may change as development progresses.

This article serves as an introduction to the series; I’ll now briefly outline the content of the upcoming articles. Below, in order, are the articles to come along with a short description of their content:

ArticleVersion(s)TitleMain content
02v0.1 – v0.2Building the Driver Foundation: DriverEntry, Device Object and IOCTL CommunicationCreating the driver skeleton, DriverEntry/DriverUnload, DEVICE_OBJECT, symbolic link, IOCTL, and a first test usermode client.
03v0.3The Event Queue: Structure and Synchronization in the KernelDesigning the generic event structure, ring buffer, spinlock, queue, FIFO, unique identifiers, and first internal test.
04v0.4Writing Events to Disk: JSONL Logging, Wake Events and the First CrashImplementing the logging thread, creating JSONL files, using KEVENT to remove polling, the first crash (IRQL) and its resolution.
05v0.5The First Sensor: Monitoring Process Creation and TerminationUsing PsSetCreateProcessNotifyRoutineEx, integration into the event pipeline, JSON serialization, and the first real events.
06v0.6The Second Sensor: Tracking Image and DLL LoadsAdding PsSetLoadImageNotifyRoutine, retrieving information about loaded DLLs/EXEs, integration with the existing system.
07v0.7Preparing Network Monitoring: Setting Up the WFP SessionIntroduction to the Windows Filtering Platform, opening the WFP session, creating the provider/sublayer, a second crash encountered and its fix.
08v0.8Monitoring Network Connections with Windows Filtering PlatformDeveloping the WFP callout, intercepting outbound network connections, collecting PIDs, IP addresses, ports, and protocols.
09v0.9Monitoring Registry ActivityImplementing registry callbacks (CmRegisterCallbackEx), monitoring key/value creation, modification, and deletion.
10v0.10Monitoring Thread Creation and TerminationAdding the thread callback (PsSetCreateThreadNotifyRoutine), collecting thread creation and termination events.
11v0.11Refactoring KDAMonitor: Organizing the Codebase for ScalabilityReorganizing the project’s folder structure, separating components, improving maintainability, and preparing for future growth.
12v0.12Building a Usermode Client for Real-Time Event MonitoringDeveloping a console client that communicates with the driver via IOCTL to display events in real time.
13v1.0KDAMonitor v1.0: Stabilization, Validation and Lessons LearnedValidation against real samples in a VM, performance, project limitations, final documentation, development wrap-up, and future prospects.

Thank you in advance to everyone who follows this series. If you have any questions, feedback, or just want to chat about the project, feel free to reach out by email or on LinkedIn.

See you in the next article, where we’ll actually start building the driver!

KDAMonitor - This article is part of a series.
Part 1: This Article