Debugging driver locally - windows

Is there anyway I can test/debug Window drivers locally? That way I don't need a separate computer or to install a VM.
I followed these instructions: http://msdn.microsoft.com/en-us/library/windows/hardware/ff553382(v=vs.85).aspx
But I can't get past the welcome screen with bcdedit /debug on enabled. My computer just hangs there.
I am using Visual Studio 2013 and the Windows 8.1 Driver Kit

In my opinion, local kernel debugging is next to worthless.
Even if it wasn't worthless, targeting a separate machine (virtual or physical) is the way to go, as kernel mode drivers under development can (and most likely will) destabilize the target machine until they're complete - something that you likely don't want happening on your development machine.

Related

Test Windows driver in Visual Studio (local)

I'm developing a Windows driver using Visual Studio + WDK, but i'm not able to test it.
There's a article about it, that says:
A test computer (or computers). The test computer must be on the same
network as the computer that you are using for development.
But I don't have another computer.
Does anyone knows a way to test using the same computer that i'm using to develop (local debuggin)?
I'm using:
Microsoft Visual Studio Community 2017
Version 15.5.2
VisualStudio.15.Release/15.5.2+27130.2010
Microsoft .NET Framework
Version 4.7.02558
Windows Driver Kit 10.0.16292.1001
Thank you!
You can use a Virtual Machine, I do this frequently but sometimes I prefer to use a physical machine. The Virtual Machine method will use a named pipe for Inter-Process Communication (IPC) between Visual Studio (the WinDbg engine is used) and the Virtual Machine environment; you'll preferably want to use VMWare but I have not used VirtualBox for this before.
See the following article please:
https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/attaching-to-a-virtual-machine--kernel-mode-
You cannot however debug your kernel-mode software while it is active on your actual Host environment; testing kernel-mode software on your Host environment until you are certain it will go well is a bad idea anyway because data corruption is caused by BSOD crashes so if a BSOD crash occurs, you can lose sensitive and important data unexpectedly.

Can't debug correctly Windows drivers with Visual Studio

I've written a Windows driver sample (WDM) with Visual Studio but I'm encountering issues when trying to debug it. The target is running in a Virtual Machine (VMware)
I've followed the documentation (http://msdn.microsoft.com/en-us/library/windows/hardware/hh698272(v=vs.85).aspx) to configure everything.
It's compiling fine but there are problems when debugging.
I have tried various configurations and have different problems on each.
Visual Studio 2013 Preview on Win7 (host) / Win8.1 Preview (target) - VMware
It seems the debugger isn't working properly. Indeed it's like if nothing was loaded, the Modules Window is empty, when I click on "Break all" nothing is happening. As you can see in the logs, the debugger session isn't created.
Screenshot:
Logs: http://pastebin.com/DfVzGR4Z
Visual Studio 2012 on Win7 (host) / Win8 (target) - VMware
It's working correctly at the first try but if I stop the debugger to modify the driver, it'll freeze the VM. I'll then have to restart the VM, Visual Studio and kill the process ntkd.exe because otherwise I have these errors:
Failure to create process instance prevents debugging
Unable to start (null), Error 80004005. (Unspecified error)
Followed by a crash of VS (Event Name: CLR20r3)
I've tried with other samples downloaded from the MSDN but it's the same problem.
I've been stuck on these issues for weeks and I'm starting to desperate, so any help would be appreciate. I haven't tried WinDDK but since VS has everything needed, I don't see why I couldn't use it normally.
I recommend to forget using Visual Studio for driver development/debugging because, on my opinion, is not solid enough.
But targetting the debugging process, it is better to install VisualDDK and then launch vmmon/vmmon64.
In the installed application you will find a folder named "target" with an application named DDKLaunchMonitor.exe, install it in the virtual machine (it will create a boot menu option to activate kernel debugging)
When you want to debug your driver, launch vmmon, activate the option to launch windbg at vm startup, start your vm and when windows boots it will load windbg and attach to the vm.
The install your driver as desired and learn windbg.
I know this answer does not solve you problem with VS but using windbg directly is faster and better.
I was having a similar problem with: Visual Studio 2015 Community Edition, Windows 10 host, Windows 10 target, VirtualBox with host only network.
Provisioning and remote driver deployment worked, but the debugger would not connect.
Edit: In the last step of provisioning in VS2015 the Host IP can be selected. The manual method below is an alternative.
The manual setup guide for kernel mode debugging says to run the following:
bcdedit /debug on
bcdedit /dbgsettings net hostip:w.x.y.z port:n
Visual Studio automatically runs these during the provisioning process. Notice the hostip parameter - this has to be the address of the connecting machine (the one with the debugger) on the interface it uses to connect to the target. Visual Studio may set this incorrectly if you have multiple network interfaces. In my case the VirtualBox host only network created the extra network interface.
Provision the target machine in VS, if you haven't already. Then run the two bcdedit commands above and reboot the target machine. After this, the debugger should connect properly.
I came across the same problem. The windbg connection is hang. I found there is something wrong in my configuration for Kernel mode debugger settings( Visual studio 2012 Driver->test->Configuration). I set the port simply com1. Actually, it should be \.\pipe\com_1.Then it works
In your case, there maybe other configuration problems. You can check through the points on webpage http://www.codeproject.com/Tips/545835/Kernel-Mode-Debugging-in-a-VM-using-Visual-Studio.

KMDF driver building using VisualDDK and Visual studio 2008

To build my driver i used VisualDDK in visual studio 2008. In the beginning i start debugging using my computer and virtualBox machine but when i launch the debugging process in visual studio, my virtual machine did not show me the external ip address(normally should show me 192.168.1.102 and 10.0.1.15 in DDKLauncherMonitor but it show me only 10.0.1.15 ).
I stopped using virtual machine and i decide to use real computer. In the second computer i launched DDKLauncherMonitor. And i start debugging from my first computer. I received Udp package in my second machine and also the driver.sys. But when i tried to load the driver from visual studio(First computer) nothing work. Plus this, in the second machine tell me "Windows required digitally signed driver".
There is same one meet this kind of problem and he/she can help.
Can you go into more details when you say "nothing works"? It's possible that your debugger is not set up properly.
This is kind of a pseudo-answer since I'm not overly aware of VisualDDK, but have you considered trying the standard Microsoft debugging tools like WinDbg? If you can acquire Visual Studio 2012 or 2013 Preview, all of the build and debug tools are integrated into the IDE and you will get full support from Microsoft with any problems you may encounter.
As for your second issue, it sounds like you're building a driver and not signing it. Is your target PC 64-bit? What operating system is it? The 64-bit Windows platform requires signed drivers for installation, but this can be disabled.
You can disable the driver signing requirement using the F8 menu when booting your PC; this should fix your "digitally signed driver required" problem, but needs to be done for each reboot.
Another option would be to add a post-build step or some sort of scripted execution of the Microsoft signing tools (Inf2cat, SignTool) to sign your driver with your company's certificate.

Remote debugging in visual studio: remote debugger does not support this edition of windows

I am trying to remote debug my application in VMware workstation 7 and Visual studio 2010 ultimate. I habe several images (win 7 ultimate,vista,etc).
I am following this tutorial: http://kristofmattei.be/2010/01/20/debugging-applications-in-virtual-machines-with-vmware-workstation-7-and-visual-studio-2008-sp1-2/
Whenever I try to start msvsmon.exe on the remote computer it will say :
"The visual studio remote debugger does not support this edition of windows"
tried it with win 7 ultimate, vista premium and xp home, same situation.
Could someone help me out here?
Thanks!
The error message "The visual studio remote debugger does not support this edition of windows" appears because the remote debugger tries to use Windows Authentication by default, and this is only supported in the "Pro" versions of Windows, and up.
However, the remote debugger does work with the "Home" versions of Windows, you just have to tell it not to use authentication via the command line.
(Why it doesn't let you do this after launching it without any arguments, why the error message is so misleading (and contradicts the official list of supported OS), and why there is so little info about this on the web, I don't know. :))
To launch it, run this:
msvsmon.exe /noauth /nosecuritywarn
Of course, this launches it in the lowest security mode, so you'd only want to do this on a secure network. (But that's usually the mode one ends up using msvcmon in anyway, as the other mode is an even bigger PITA to set up than it is normally. Very useful tool, but really could use some streamlining.)
No need to use VMWare features.
Inside the guest VM run the version of msvsmon that came with your copy of visual studio 2010 (A setup package for just the remote deubgging stuff can be found on the disc/image) (use x86 if debugging a 32-bit process or x64 if debugging 64-bit one ,Itanium if you need to laugh).
through the msvsmon GUI disable authentication and select allow any user to connect.
disable the firewall in the VM.
on the host machine you should be running visual studio 2010, under the debug dropdown select "attach to process..." and then on the window that pops up select remote from the dropdown that should say local or something initially, enter the IP address (should be private network IP i.e. 10.1.?.?) of the guest VM, alternatively use the server name displayed by the msvsmon GUI. You should get the process list for the guest and should only attach to any process that matches the version of msvsmon you ran (x86 or 64 ...or Itanium laugh).
NOTE: These are basic instructions to show you it definitely works but these instructions will only work for native code since managed requires a secure connection.
If you are debugging a .NET app using the VMWare VS Plugin and are getting a "file not found" type of error...make sure you have the .NET runtime installed! :)
Like a moron, I set up a fresh XP VM and forgot to install the .NET runtime and wasted a good day trying to get the VMWare VS Plug-In to work!
VSID is not supported by visual studio2010 http://communities.vmware.com/thread/282407

How is your Development Environment Set up?

Curious to know how people set up their personal and/or work development environment, in terms of:
Do you just have all of your developer tools (for example Visual Studio, SSMS, etc.) installed on your main operating system;
Do you use Virtual Machines to have a separate "clean" dev environment that consists only of the OS and one compiler you're working with;
Do you have multiple OS's in a multi-boot system;
Do you remote connect to a separate machine with your developer tools installed on there
It all depends on the type of the job i guess. Here is how my setup is:
The main PC. The one on my desk. Has everything on it.
The secondary machine. Runs Vista.
A bunch of "Clean" VMs for testing. Typically 2 machines of each OS we support.
A build machine. VM with no installed product. Just source code and some compilers.
A dedicated "Server" to host the server app and the DB. [Our product is a client-server thingy]
[On top of that, my primary and sec machines have the server and DB running too.]
EDIT: By "clean" i mean that they only have a freshly installed OS on them, nothing else. These are non-persistent and go back to clean state on shutdown.
I am running what I think is a fairly standard Agile C# development environment. Vista SP1, Visual Studio 2008 with Resharper 4.1, SQL Express 2008, Subversion server, command line svn client and Cruise Enterprise (unbelievable product) with 1 server and 1 agent for continuous integration.
I am running on a Dell XPS core 2 duo 2.4Ghz laptop with 4GB of RAM and 1 external 22" widescreen monitor.
I have tried and tried and persisted with VMWare Workstation (mostly but also Virtual PC) but I again and again resort back after tiring with the performance and annoying delays in Visual Studio. And I have tried every performance trick and tweak in the book available to me. It apparently just needs either more hardware than I have or far more patience.
I have also tried running 64bit Ubuntu with VMWare Worstation server running Vista (vlite'ed) and also windows XP (lite), but I found it just as annoying.
If you have similar specs to what I described then I can simply recommend not going down the VM path, unless it is ABSOLUTELY necessary.
I have a VMWare network replication of the main servers in my environment including SQLservers, Web-Servers, a copy of my dev box, and AD Servers. I also use VS on my dev box for simple things that don't need as much testing.
We use Virtual PC's for our development. As well as a VP for our build environment. The reason for this is so that we can switch between different projects without losing time. (for Support)
At our current client, we have an ESX server with virtual machines running on it. We access the virtual machines through Remote Desktop.
For my style in VS 2008, I use VibrantInk by Rob Conery.
We have Reflector and all Sysinternal tools available on all virtual machines.
I'm planning to have ReSharper on every machine also.
Firefox/Firebug combo is installed on every machine.
Web Developer for IE7 is also installed on every machine.
Cheers!
I really enjoyed using a single VM for each IDE I worked with, but that requires a beefy machine. However, my company has taken recently to the idea that the developers can do "just fine" with sub $500 machines. Thus, my current setup is everything on my only machine.
All of my tools are on my local machine. I generally work within the MVC mindset.
VMWare is set up on my machine, but it's only used on rare occasion for things beyond the control of my machine.
My work is primarily done on a windows machine, with Visual Studio.
I have Visual Studio 2005 and 2008 running on my main machine (Vista :p), and everything I can develop here without cluttering the machine, I do. Feels so much more responsive than in a VM. I have a VM for Linux-based development and several VMs for testing purposes. I never tested VMWare's debugging feature (run the debugger on the host and the debuggee on the guest), though I can imagine that that would be a good reason to have Visual Studio on the host, even if you don't care about responsiveness.
I have a number of IDEs and server products running on my main workstation. I also have a remote access laptop that has all the same critical software on it so I can develop locally (and not depend on Citrix and Remote Desktop to work on code fixes outside the office).
My main work system
Linux x64 dual core
Dual monitor
Redhat based OS
Vim, Kdevelop, Eclipse(with Epic, and Subclipse).
My system is similar(arch, and OS) to our servers, which is what I implement code for. Since I work for a small company with many hats, I tend to have a ssh'd mysql connection open in one window, with a vim screen open on the other side. Throughout the day I use SSH, VIM, SVN, firefox, and e-mail daily.
I put all toolchains and other apps needed to build my code into revision control, and write makefiles for all projects such that the version of the tools from the repository is used, not whatever may be in the $PATH. So when I do a label for a release, it includes everything needed to do the build, and depends on build machine setup as little as possible. All I need to do is sync to revision control, and type 'make'. Unfortunately this does require having cygwin installed on Windows, but personally, I consider a Windows machine just about unusable for development without cygwin, regardless of the prerequisites of the build system.
I have simple makefiles to build projects that include platform-specific .mk files. I don't manually create IDE project files. In a couple cases (Rowley Crossworks for embedded ARM development, Visual Studio for self-hosted windows PC development), I auto-generate project files based on my makefiles, as part of the "make debug" target, and then launch the IDE with the generated project. This makes debugging convenient, without requiring parallel maintenance of a IDE-specific project file in addition to my makefile.
I am about to set up a new development environment for a new department.
Build environment (support both Java development and .Net) will be on to separate VMware machines running on the same physical computer. Both images will use 2008 server.
Developer machines will be desktop computers, most likely qith 6 gig ram, big harddrives, 1 or 2 cpu's with dual or quad core, 24" screens * 2, etc., and with 2008 server installed. This to ensure that the developer code is compiled on the OS. Desktops because I want the developers to be able to use VMware to test, etc., without spending to much time complaining about lack of performance with 2 VMwares running at the same time :)
I am trying to figure out the build environment now. Considering Team City, ++. Difficult to find the right one when you want to support multi-platform environment without to much fuss :)
Every developper setup includes a MacBookPro 17" with a 22" lcd screen.
Eclipse is our IDE, and we use VMWare to host our developpement database (oracle) under winXP.
Obviously a lot of your answers are going to depend heavily on what kind of development each person does. Maybe we should be categorizing these? :)
Web Development
I use a VM to run a Linux guest with a development webserver. I use Notepad++ on my host for editing (recent convert from jEdit), and with drive mapping in the VM software (Sun's VirtualBox), my dev webserver guest machine has no problem serving up the ever-changing source files. I also use the Windows XP IE6 VPC image in another VM to test the page in IE6. I use this setup even if I'm not developing a complicated web-app and am simply working on a static HTML page; there are still some quirky differences in behavior between a locally opened file and a served webpage in a number of browsers that make this worthwhile.

Resources