Configure the driver development environment for Windows 7 (WDK)

Source: Internet
Author: User

Configure the driver development environment for Windows 7 (WDK)

1. Install VS2010. Download WDK from the official website (that is, the early DDK), decompress and install it (GRMWDK_EN_7600_1 );

2. Create an empty project in VS2010. The project can be named "driver ";

3. Configure the solution and add a configuration scheme called driver;

4. Configure project properties;

In this case, you need to enter the installation path of your own WDK. My installation path is as follows:

Executable File directory: G: \ WinDDK \ 7600.16385.1 \ bin \ x86

Contains 3 files: G: \ WinDDK \ 7600.16385.1 \ inc \ api

G: \ WinDDK \ 7600.16385.1 \ inc \ crt

G: \ WinDDK \ 7600.16385.1 \ inc \ ddk

Library Directory: G: \ WinDDK \ 7600.16385.1 \ lib \ win7 \ i386

5. Create a new C ++ file;

6. Set project properties;

GENERAL: target file extension. sys

C/c ++ drop-down menu:

Pre-processor
Pre-processor definition: WIN32 = 100; _ X86 _ = 1; WINVER = 0x501; DBG = 1 // required

Advanced
Call Convention _ stdcall (/Gz) // required

General Tab
1. debug information format (C7 compatible (/Z7) // optional
2 warning level (level 2 (/W2) // optional
3. view the warning as an error (Yes (/wx) // optional

Optimization Tab
Optimized (disabled/Od) // optional

Code Generation
Enable minimum regenerate: No // optional

Basic runtime check: Default Value // optional
Runtime Library: multi-thread debugging (/MTd) or multi-thread (/MT) // recommended <I chose multi-thread debugging (/MTd)>
Buffer security check: No // optional
(LINK: error LNK2001: the external symbol _ security_cookie cannot be parsed)

In the linker:

General
Enable INCREMENTAL link: NO (/INCREMENTAL: NO) // It is recommended that you select
Ignore import/export: Yes // optional
(When this value is set, you must add G: \ WinDDK \ 7600.16385.1 \ lib \ win7 \ i386 to the directory of the additional library so that the project will not depend on the setting of the IDE environment)

If no (when this value is set, it depends on the relevant settings of the IDE environment)

Input
Additional Dependencies
Ntoskrnl. lib; Hal. lib; wdm. lib; wdmsec. lib; wmilib. lib; ndis. lib; MSVCRT. LIB; LIBCMT. LIB // required

// Ntoskrnl. lib WDM driver ntoskrnl. lib
(HalXXX function in Hal. lib, WmiXXX function in wmilib. lib, NdisXXX function in ndis. lib)
(If necessary, add Microsoft's standard library MSVCRT. lib msvcrtd. LIB (debugging Library) LIBCMT. LIBIBCMTD. LIB (debugging Library ))
(If the source file exists in the source code, the TARGETLIBS field of the file lists the required libraries for this project)

Ignore all default libraries: Yes (/nodefalib Lib) // required

Configuration file:
Enable User Account Control (UAC) No // required

Otherwise,> LINK: fatal error LNK1295: "/MANIFESTUAC" is incompatible with the "/DRIVER" Specification. "/MANIFESTUAC" is not used for LINK"

Debugging:
The generated debugging information is (/DEBUG) // optional
Generate an image file: Yes (/MAP) // optional
Image File Name: $ (TargetDir) $ (TargetName). map // optional

System)
SUBSYSTEM: CONSOLE (/SUBSYSTEM: CONSOLE) // required
Stack retention size: 4194304 // optional
Stack submission size: 4096 // optional
DRIVER: DRIVER (/DRIVER) // required

Advanced:
Entry Point: DriverEntry // required
Random base address: Clear // Delete the data in the box. (Yes is neither no nor a clean text box) // required
Otherwise, e: \ xxx. sys: fatal error LNK1295: "/DYNAMICBASE" is not compatible with the "/DRIVER" Specification. "/DYNAMICBASE" is not used for linking"

Data Execution Protection (DEP): Clear // required
Otherwise, e: \ xxx. sys: fatal error LNK1295: "/NXCOMPAT: NO" is incompatible with the "/DRIVER" Specification. "/NXCOMPAT: NO" is not used for links"

Set Effect and: Yes (/RELEASE) // optional

Base Address: 0x10000 // recommended

Command line:

/SECTION: INIT, D/IGNORE: 4078 (it is recommended that you do not enter it. An error will be reported !)

Test code:

# Include "ntddk. h"

NTSTATUS
DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
Return STATUS_UNSUCCESSFUL;
}

References:

Http://www.cnblogs.com/xlhblog/archive/2011/03/22/1991785.html

Http://www.cppblog.com/guojingjia2006/archive/2011/03/19/142211.html

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.