Akshdeep Singh
Akshdeep Singh

Reputation: 1437

Can the windows sandbox feature be used for driver testing?

Doing windows driver development for first time, I want to deploy my first driver. But I don't have a second computer.

Microsoft docs:

Typically when you test and debug a driver, the debugger and driver run on separate computers. The computer that runs the debugger is called the host computer, and the computer that runs the driver is called the target computer. The target computer is also called the test computer.

I am starting with vhidmini2 as my project base (the UMDF2 version). I want to know if the Windows Sandbox feature can be used in place of test computer? My driver will not be interacting with any hardware.

Upvotes: 4

Views: 2965

Answers (2)

mrexodia
mrexodia

Reputation: 705

You can set up Windows Sandbox for kernel debugging with CmDiag (undocumented, but mentioned by Jonas L):

First you need to enable development mode (everything needs to be run from an Administrator command prompt):

CmDiag DevelopmentMode -On

Then enable network debugging (you can see additional options with CmDiag Debug):

CmDiag Debug -On -Net

This should give you the connection string:

Debugging successfully enabled.

Connection string: -k net:port=50100,key=cl.ea.rt.ext,target=<ContainerHostIp> -v

Now start WinDbg and connect to 127.0.0.1:

windbg.exe -k net:port=50100,key=cl.ea.rt.ext,target=127.0.0.1 -v

Then you start Windows Sandbox and it should connect:

Microsoft (R) Windows Debugger Version 10.0.22621.1 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

Using NET for debugging
Opened WinSock 2.0
Using IPv4 only.
Waiting to reconnect...
Connected to target 127.0.0.1 on port 50100 on local IP <xxx.xxx.xxx.xxx>.
You can get the target MAC address by running .kdtargetmac command.
Connected to Windows 10 19041 x64 target at (Sun Aug  7 10:32:11.311 2022 (UTC + 2:00)), ptr64 TRUE
Kernel Debugger connection established.

(When I set this up initially I was getting some error when starting Windows Sandbox and I had to reboot, but this might not be necessary)

A few times I got error 0x80070020, this seems to be because the port isn't available (perhaps reserved by Hyper-V?). Switching to port 12345 fixed it for me.

Upvotes: 5

Tey&#39;
Tey&#39;

Reputation: 990

The Windows Sandbox is basically a virtual machine, so you can load drivers into it as long as they do not need to interact with hardware.

But there is also one extra limitation: there does not seem to exist a way to disable the drivers signature check in the Windows Sandbox, as this requires a restart which is not possible for the sandbox. Thus, your driver has be signed to be loaded and tested.

EDIT: the Sandbox supports rebooting since Windows 11 Build 2250, so it should be possible to disable the drivers signature and install custom drivers now (cannot test though, still on W10).

Upvotes: 3

Related Questions