"Reprint" vs2010+vmware8+visualddk1.5.6 Create and debug drivers-Full tutorial

Source: Internet
Author: User
Tags visual studio 2010

Original Posts: http://techird.blog.163.com/blog/static/1215640362011112385241568/

This article describes how to use visual STUDIO+VMMARE+VISUALDDK to create, compile, and debug your first driver. This article provides detailed operational steps in the context of developing and debugging tools without having to worry too much about what's going on behind these environments.

In this tutorial we will create the following driver sequencing and test it on the virtual machine:

· A super simple driver that prints a piece of information when loading

If you have another physical machine, you don't have to install a virtual machine. However, you may need a COM connection or a FireWire connection to two machines.

Software Prerequisites

Before you start writing a drive, you need to prepare some software (click the hyperlink to download it directly).

VMWare: Virtual machine software for running virtual machines for debugging.

A Windows installation image used to install a system to a virtual machine. It is recommended to use XP or Windows7 (if you have a larger memory, suggest Windows7). If not, you can get a copy or download it to msdn.itellyou.cn.

Visual Studio: Used to write code

Windows Driver Kit (WDK) 7.1.0: A Toolkit for Windows driver development

VISUALDDK: A visual vs plug-in that configures WDK and vs together

Preparatory work

· The first step -Install the virtual machine software. This process is very simple, just follow the steps step by step.

· Then create a virtual machine with VMware Workstation 8 as an example.

o Click file-new Virtual Machine

O Select Custom (Advanced)

o Hardware compatibility does not matter, if you use the latest VMware, choose Workstation 8.0

o Select the operating system: Select your operating system image here

O then fill in the virtual machine operating system profile (Windows7 key can not be filled)

O then the CPU and memory are set, the default is yes.

o Select network settings, either Bridge or NAT

o IO settings default, disk create new disk File

o Last click Finish, the operating system will be installed automatically, waiting for it to be loaded (too Win7 for 10 minutes).

Step Two -install the support software on the virtual machine and create a snapshot.

o When the system is installed, the support tool will be installed automatically if the system is installed automatically

o manual installation is done by clicking on the menu Vm-install VMware Tools, install Step by step follow the wizard.

o Create a snapshot of the clean system. Click the menu Vm-snapshot-take Snapshot, the snapshot name is Clean system and so on. Then take Snapshot.

Step three -install Visual Studio 2010 and Skip if you've installed it. Note, however, that your vs will include at least two modules for C + + and C #, and if not all, reinstall.

· Install VAX (optional). VAX is just to make it easier for you to write C + + code.

Fourth Step -Install the 32-bit Windows Debugging tool (DDK).

o Locate H:\Debuggers\setup_x86.exe under the WDK's ISO directory to start the installation. Fully installed. (Visual Studio is a 32-bit software, so you cannot use the 64-bit debugging tools.)

Fifth Step -Install and configure VISUALDDK

o Double-click "Visualddk-1.5.6.exe" to start the installation DDK

o after loading (soon), a configuration wizard appears. If you follow the above steps to install, then the WDK location and DDK location will be recognized automatically, directly point to the next step.

O will then let you choose the version of VS, if you already have VS, it will also be automatically recognized.

o Click Finish to start the physical machine configuration (may automatically start VS, do not move it, will automatically shut down).

Sixth Step --Configuring the virtual machine

o Network configuration. Select Menu Vm-settings to open the configuration page. Select Network Adapter to change the configuration to bridge or NAT.

Then test your network connection, host ping virtual machine, virtual machine ping host should be able to interoperate.

o Copy C:\Program Files (x86) \visualddk\target\vminstall.exe to run on the virtual machine (if Vmtools is properly installed, you can copy and paste directly, if not, Reinstall Vmtools or copy the file using VMware's network capabilities.

o Click Install, prompt to restart (virtual machine), point is on it. After rebooting, turn off the virtual machine (yes, turn it off).

Create a driver using the wizard

1. Run visual Studio with Administrator privileges (right-click-run with Administrator privileges)

2. Click File-New-project, open the New Project Wizard, select VISUALDDK under C + +,

Note: Project location can not contain spaces, can not contain Chinese, otherwise you will be very tragic (unable to build solution)

3. Select a PNP driver, other configuration default

1. Now open your source code, see should be the following effect

2. Build a solution. Choose Menu Build-Build Solution.

If there are no errors, prove that the build was successful. After the build is successful, you can right-click on the project and click "Open folder in Windows Explorer" to enter the build directory (such as objchk_win7_x86\i386) to see the successfully generated SYS driver file.

3. If you do not need to debug, run the SYS file to use the driver (installation method you have to study). Here's how to debug (debugging will automatically install the driver for you).

Debug your drive

1. Run Vmmon.exe or Vmmon64.exe under the VISUALDDK installation directory (if you are a 64-bit system). Of course, you can also search for both programs from the Start menu.

2. Start the virtual machine at this time, do not enter the system, stop on the operating System selection menu! At this point your vmmonitor and virtual machine screen should look like this:

Note that this step is crucial if you see that the icon on the PID field is not green, or that pipe name is not established, you will not be able to debug the kernel. This step I got a solution for n long. If you have such a problem, you can do this:

· Go to directory "%USERPROFILE%\APPDATA\ROAMING\VIRTUALKD"

· Delete the *.vmpatch file inside

· Retry the above steps

1. VS Select Menu Debug-driver Launch Settings ...

· For the first time debugging, you will be prompted to configure Visual DDK (this action you can also-VISUALDDK Settings by the menu tool ... For

Choose your Debug tool's directory (above, requires 32-bit debugging tools) and symbol directory (debug symbols, will be automatically downloaded to the directory)

· After setting the VISUALDDK, the Debug Settings dialog box should pop up.

Choose the debug mode of virtual machine, at which point you should be able to select the virtual machines that have already loaded the pipeline. The other uses the default configuration (if you manually specify the IP of the virtual machine, it is best to fill it out again), after configuration, point launch.

1. After clicking on launch, you should be able to see a connection dialog box, at which point detail can see the following information. It waits for the virtual machine to start.

2. Start the virtual machine at this time (choose VIRTUALKD Debugging), when you start the symbol will be loaded for you. The first load symbol is downloaded from the symbol server, please wait patiently.

If there are symbols that cannot be loaded, VISUALDDK will pop up a reminder (not on the server) and ask if you want to skip the symbols next time, just click OK.

3. If the virtual machine version is more than Vista, a dialog will pop up asking if you want to print debugging information.

4. Then, VS, this will enter an interrupt. Click Debug-Continue to allow kernel and driver to continue loading

5. The startup process can be quite slow, and the VISUALDDK console will output some error messages, which is normal, please wait patiently

6. If your virtual machine starts successfully, congratulations, you have basically succeeded! After successful startup, start the Ddklaunchmonitor on the virtual machine (default in the C packing directory). After booting, you can see that the IP of the virtual machine is 192.168.3.105

7. Now click the load-driven command on the VISUALDDK console (if the console is missing, you can choose menu Debug-window-VISUALDDK console)

After you click, you can see the following dialog box. Because you just fill in the Debug configuration when the IP is not filled out, now need to re-fill to communicate with the virtual machine.

Click menu Debug-Stop Debugging, re-select menu Debug-driver Launch Settings ..., fill in the IP of the virtual machine.

This time again click on Launch, you can successfully connect.

8. Now a driver-installed configuration Wizard pops up, using the default settings and clicking "Install"

9. Now look at the virtual machine, will pop up let you install the driver dialog box, select "Always install this driver"

10. When the driver installation succeeds, you can see that the output of the debug message "Hello from Pnpdriver", the output statement you can find in the DriverEntry function of your source code.

11. To end the debugging, remember to click "Debug"-"End debugging".

12. The next time you continue debugging without restarting the virtual machine, you can use the built-in pipeline directly. Hit a breakpoint below to try.

13. Commissioning situation:

Problem Collection

1. There are no VISUALDDK related menu items under the Debug menu.

At this point you can try to open my document, delete the AddIns folder under the Visual Studio 2010 directory and Reload VISUALDDK. If not, you can try to delete the entire visual Studio 2010 directory (note back up your previous project)

2. Unable to connect to my VMware virtual machine

The correct step is to leave the interface in OS select here when VMware starts, then click Driver Launch Settings, set it up, then click Launch, then enter the system in VMware. After such a step, the driver in the virtual machine system can be debugged normally.

If the "indication icon" You see in Vmmon is not green, you need to delete the *.vmpatch file under%USERPROFILE%\APPDATA\ROAMING\VIRTUALKD

3. Refer to Address:

· http://articles.sysprogs.org/visualddk/firstdriver/(Making your first driver-complete walkthrough)

· HTTP://DEBUGMAN.COM/THREAD/5729/1/1 (VS. + visualddk + VMware Debug Drive Essentials)

· http://forum.sysprogs.org/viewtopic.php?f=4&t=587 (VS Engineering Directory contains spaces that cannot generate problems)

"Reprint" vs2010+vmware8+visualddk1.5.6 Create and debug drivers-Full tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.