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
<PackageReference Include="Driver.NET.DeviceIoControl" Version="2.4.0" />
<PackageVersion Include="Driver.NET.DeviceIoControl" Version="2.4.0" />
<PackageReference Include="Driver.NET.DeviceIoControl" />
paket add Driver.NET.DeviceIoControl --version 2.4.0
#r "nuget: Driver.NET.DeviceIoControl, 2.4.0"
#:package Driver.NET.DeviceIoControl@2.4.0
#addin nuget:?package=Driver.NET.DeviceIoControl&version=2.4.0
#tool nuget:?package=Driver.NET.DeviceIoControl&version=2.4.0
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 | Versions 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. |
-
.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.
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.