Driver.NET.DeviceIoControl 2.4.0

dotnet add package Driver.NET.DeviceIoControl --version 2.4.0
                    
NuGet\Install-Package Driver.NET.DeviceIoControl -Version 2.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Driver.NET.DeviceIoControl" Version="2.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Driver.NET.DeviceIoControl" Version="2.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Driver.NET.DeviceIoControl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Driver.NET.DeviceIoControl --version 2.4.0
                    
#r "nuget: Driver.NET.DeviceIoControl, 2.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Driver.NET.DeviceIoControl@2.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Driver.NET.DeviceIoControl&version=2.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Driver.NET.DeviceIoControl&version=2.4.0
                    
Install as a Cake Tool

Driver.NET Driver.NET Driver.NET

Driver.NET is a powerful, simple and lightweight library used to create services and load/communicate with kernel drivers on Windows.

The solution is split in two libraries:

Library Purpose
Driver.NET Create and configure a service in the registry, then load/unload it as a kernel driver (NtLoadDriver / NtUnloadDriver).
Driver.NET.DeviceIoControl Open the symbolic link of a device and send I/O control requests (IOCTL) to the driver behind it.

Supported frameworks

  • .NET 10
  • .NET Framework 4.8

Both libraries are Windows-only. Loading and unloading drivers requires an elevated process holding SeLoadDriverPrivilege.

Usage

Send an IOCTL to a device

using Driver.NET.DeviceIoControl;

using var Device = new DeviceIoControl("\\\\.\\MyDevice");
Device.Connect();

if (Device.IsValid)
{
    var Request = new MY_REQUEST { Value = 42 };

    if (Device.TryIoControl(IOCTL_MY_REQUEST, Request, out MY_RESPONSE Response))
    {
        // Use the response.
    }
}

Create, load and unload a kernel driver service

using Driver.NET.Services;

var Service = WindowsService.FromServiceName("mydriver");
Service.CreateRegistryKey();
Service.WriteRegistryValue("ImagePath", "System32\\drivers\\mydriver.sys");
Service.WriteRegistryValue("Type", 1);
Service.WriteRegistryValue("ErrorControl", 1);
Service.WriteRegistryValue("Start", 1);
Service.WriteRegistryValue("Parameters\\MyCustomParameter", 69);

var KernelService = WindowsServiceKernel.FromService(Service);
var Status = KernelService.TryStartDriver(); // NTSTATUS, 0 on success.

KernelService.TryStopDriver();
Service.DeleteRegistryKey();

A complete example that retrieves the serial number of a disk by talking to the disk.sys driver through \\.\PhysicalDrive0 is available in the repository, in the Driver.NET.Example project.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.0 76 9/16/2026
2.3.4 433 9/7/2025
2.3.3 414 5/11/2025
2.3.2 850 3/27/2024
2.3.1 918 2/21/2023
2.3.0 1,211 2/15/2022

Targets .NET 10 and .NET Framework 4.8. The assembly is now marked as Windows-only. DeviceIoControl implements IDisposable, buffer sizes use the unmanaged size of the structure, and a TryIoControl overload exposes the number of returned bytes.