Windows Driver WDF driver development series (1)

Source: Internet
Author: User

No driver development has been done before, and everything starts from. I have read some books and WDF development for Windows Device Drivers. But it is always in the fog. So I want to accumulate driver knowledge at 1.1 points.

First, I will record how to build a debugging environment? The premise is that wmware has been installed and there are two guest OS. (XP and win7 ). The following describes the debugging of the two types of systems.

  • Settings for XP driver debugging (refer to: http://joeyliu.blog.51cto.com/3647812/937476)
It is best to use the vmwarevm for driver development. First, set the vmwarevm to ensure that the VM is shut down)

1. Set the serial port for communication between Vm and windbg

OpenVirtual
Machine setting option, add new hardware in hardware: 1) Select serial
Port; 2) Serial
Select "output to named pipe" for port type; 3) specify
Socket option 1; 4) The final configuration result 2 is shown. Start the target system of the VM.

Note: Generally the serial port 2 is Serial Port 2, because the default VM installation virtual printer occupies Serial Port 1.

 

Figure 1

Figure 2

2. Set the startup Item of guest OS

Enter the WINXP virtual machine operating system, open the system disk (C: \), and open all the folder viewing options. There is a boot under the C root directory. INI startup Item file, first remove the read-only attribute, open it as a text file, copy the original startup item, and make the following changes:

Multi (0) disk (0) RDISK (0) Partition (1) \ Windows = "Microsoft Windows XP Professional"/noexecute = optin/fastdetect/debug/debugport =Com2
/Baudrate = 115200

NOTE: If Serial Port 1 is selected in step 1, com1. if Serial Port 2 is selected, com2.

3. Configure the windbg shortcut

Find the windbg.exe executable program in the installation directory (C: \ winddk \ 7600.16385.0 \ debuggers.pdf) of winddk. Create a shortcut on the desktop and modify the attributes as follows:

"C: \ winddk \ 7600.16385.0 \ debuggers \ windbg.exe"-B-K COM: Port =\\. \ PIPE \ com_1, baud = 115200, pipe

Note: The Host OS uses the corresponding windbg.exebecause windbg.exe contains 32 and 64 bits.

  • Settings for win7 driver debugging
1. Communication serial port settings for WM and windbg (same as those for XP in guest OS) 2. Set the guest OS startup Item First, run msconfig To Go To The Boot tab, click Advanced options, and select debugging. Note that the debugging port must be consistent with the settings of the Communication serial port, and restart Guest OS. Second, Method 1: Start dbgview.exe with the Authority after starting guest OS2. Method 2: Modify the registry if you want to debug kdprint. [HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/Session Manager/debug print filter] default = DWORD: 0000000f
3. Configure the windbg shortcut(Same as setting Guest OS as XP)

  •  Single-step debugging

1.Load symbol files

On windbg, type:. Reload

Type: LD charsample

Type: LM L

2.Set breakpoints

Choose "file"> "opensource file ...", Select the source file queue. cpp in the driver directory and open it. Move the cursor to a certain command position and use F9 to set the breakpoint. The code is displayed in red, indicating that the breakpoint has been set.

3. Use F11 for single-step debugging

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.