Trying to deploy driver and cannot create directories on target.

Hi.
I am new to writing Windows drivers (I betcha have heard that before) however I have several years of Linux out-of-tree driver development for proprietary PCI express based hardware.
We are looking to develop a driver for Windows 10 64 bit so we can avoid GPL issues.

So I installed Visual Studio Community 2017.
WDK for Windows 10, version 1809.

Anyhow before I get to PCIe I simply want to get a Hello World driver operational so I have been following the steps on this.

https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/writing-a-very-small-kmdf--driver

However after trying to deploy the driver I get this error.

Deploying driver files for project “C:\Drivers\HelloWorld\KmdfHelloWorld\KmdfHelloWorld\KmdfHelloWorld.vcxproj”. Deployment may take a few minutes…
[15:12:46:162]: Remove Existing Remote Package
[15:12:46:180]: Task “Remove Existing Remote Package” completed successfully
[15:12:46:192]: Copy Driver Package
[15:12:46:229]: Task “Copy Driver Package” was aborted because an error occured on the target machine during execution.

An error occurred on the target machine while copying a file from the host machine.
Error code: 2
Error message: Unable to create directory: C:\DriverTest\DriversNew.
[15:12:46:239]: Driver Removal
[15:12:46:239]: Removing any existing files from test execution folder.
[15:12:46:260]: Copying required files for “Driver Removal”.
[15:12:46:310]: An error occured while deploying files to the target machine for test “Driver Removal”: An error occurred on the target machine while copying a file from the host machine.
Error code: 2
Error message: Unable to create directory: C:\DriverTest\Run…

From this link

https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer

I do this

Deployment fails due to Error code: 2
Add the following registry key:
HKLM\Software\Microsoft\DriverTest\Service
Under this key, create a DWORD value DebugSession, and set it to 0.

And I still get the same error.

I looked here.

https://www.osr.com/getting-started-writing-windows-drivers/

And it suggests that debugging on a remote machine from a host is the way to go.

While other “old schoolers” suggest installing the driver on the test machine and just updating the binary.

I made the mistake of thinking I would easily be able to do the latter.

So my questions are:

  1. Why can’t the host machine create directories on the target? Is there something I can do to alleviate this?
  2. Is there an in depth tutorial on reverting to the “old school” method?

I am rather suck ATM.

Why can’t the host machine create directories on the target?

Because “deploy” and debugging from within Visual Studio is very often broken, and when it is it is impossible to determine the root cause

Is there an in depth tutorial on reverting to the “old school” method?

Well, you don’t need a tutorial. Just:

  1. Copy your driver package to a dedicated directory on your target machine
  2. Install your driver
  3. Thereafter, JUST copy your .SYS file to \windows\system32\drivers, overwriting the old version. If you’re using Windows 10, you will have to rename the original driver (fred.sys to fred.old, for example) before you can copy the new version. Disable and Enable the device in Device Manager.

In terms of debugging… Setup and Run Windbg. All the steps are here: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/setting-up-a-network-debugging-connection – The only hint I can give you is to setup the target machine (do the bcdedit stuff), THEN run WinDbg on your device box, THEN reboot the target machine. Restarting the target machine while you have WinDbg running is the easiest/surest way to get the two in synch.

Hope that helps… feel free to post back here with questions/comments.

Peter

Thank you for your help.

Yeah I reread OSR’s intro to writing and it told me to ditch the Visual Studio tools and just use WinDbg. I am now making some progress.

My advice, coming from Linux driver where the “Hello World” is de facto first driver, is to avoid the Microsoft Hello World driver tutorial.

I also got lost on the how I actually install Windows’ drivers (being used to compiling in-tree or loading out-of-tree kernel modules in Linux).

Therefore I was thankful to find the following two tutorials, which are way better than the Hello World example (and also explain how to install a Windows driver for an absolute beginner)

https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debug-universal-drivers–kernel-mode-#connectto

https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debug-universal-drivers—step-by-step-lab–echo-kernel-mode-