Getting Started with WDM Driver (3) - Installation Steps

zhaozj2021-02-11  187

DDK is divided into 98 DDK and 2000 DDK, and they work is similar, but some drivers can only be used in 2000 DDK. Since Win98 is destined to be an operating system that is about to be eliminated, I don't plan to describe how to compile in 98 DDK. All the following content is for 2000 DDK.

·Ready to work

1, make sure you have installed Visual C

2, install 2000 DDK

3, after installing 2000 DDK success, "

Start "->"

Program "should have"

Development kits "->"

Project of Windows 2000 DDK.

(

Note Be sure to install the VC first, then install DDK, this order must not be reversed! ! )

4, to ensure that the DDKRoot environment variable is set to the base directory of Windows 2000 DDK. If not, please in the Control Panel "

System "attribute"

Advanced "Label Environment Variable Editor Sets this environment variable.

· Writing required files

When compiling WDM programs, there are two files that must be there, they are:

1,

Makefile

(What is this? You may ask.) For more young programmers, there may not have seen this file. In fact, before VC these IDEs appear, we must use makefile to determine which files need to be recompiled, and now Ide is automatically done. (Well ... is actually like this.)

Our work we have to do is very simple, providing such a file, its content is:

## do not edit ./sources. If you want to add a new source # file to this component. This file melely indirects to the real make file # That Shared by all the driver components of the window NT DDK #! Include $ (Ntmakeenv) /makefile.def

As mentioned, don't edit this file. In fact, the contents of the makefile needed for each WDM program are the same, that is, we only need to simply copy a Makefile to the new project. (Oh, is it very convenient?)

2,

Sources

TARGETNAME = HelloWDMTARGETTYPE = DRIVERDRIVERTYPE = WDMTARGETPATH ​​= OBJINCLUDES = $ (BASEDIR) / inc; / $ (BASEDIR) / inc / ddk; / TARGETLIBS = $ (BASEDIR) / lib / * / free / usbd.lib / SOURCES = HelloWDM.cpp /

This file specifies that the driver target name is Hellowdm.sys, is a WDM driver, generated files stored in the OBJ directory. It is worth noting that there is no space before and after "=", otherwise it will be wrong when compiling.

· Start compilation

Wahaha, in front of Luo Luo said a lot, and now finally focuses. The compilation process of the WDM program is special, it is not compiled in the VC (although you can achieve this by setting), but through a DDK utility build to complete. Let's talk about the specific steps:

1, "Debug" version

First, we assume that your source code is placed in D: / hellowdm. Please follow the following steps: "Start" -> "Programs" -> "Windows 2000 DDK" -> "Checked Build Environment"

The screen will be displayed: (with "Enter", you need a reader, you are in person.

. New or updated MSVC detected Updating DDK environment ... .Setting environment for using Microsoft Visual C tools.Starting dirs creation ... Completed.D: / NTDDK> cd / HelloWDM (Enter) D: / HelloWDM> build (Enter)

If the source code is not wrong, the generated hellowdm.sys will be stored in the Objchk / i386 directory.

2, "Release" version

Please follow the steps:

"Start" -> "Program" -> "Windows 2000 DDK" -> "Free Build Environment"

The subsequent steps are the same as the "Debug" version, and the difference is that the generated hellowdm.sys will be stored in the Objfre / i386 directory.

·installation

If the previous compilation process is not wrong, we should have got a hellowdm.sys file, assume it in D: / HellowDM / ObjFre / I386.

What should we do? ............ right, just install it! Otherwise, what is the use of hard compilation?

The WDM driver can be installed in two ways, one is to use the registry, and another is to use the INF file. We generally use INF files (this is recommended by Microsoft). INF files can be found in the WinNT / INF directory. In order to install, I will give the helpdm.inf file required for Hellowdm here.

;; The win2k ddk documentation,;; --------- Version Section -------------------------------------------------------------------------------------------------------------------- ------------------------- [Version] Signature = "$ Chicago $" provider = lc_devicedriver = 8/21/2002, 3.0.0.3; if device fits one of the standard classes, use the name and GUID here ,; otherwise create your own device class and GUID as this example shows.Class = UnknownClassGUID = {ff646f80-8def-11d2-9449-00105a075f6b}; ----- ---- SourceDiskNames and SourcediskFiles Section -----------------------; These section Identify Source Disks and Files for Installation. They is; shown here as an example But commented out. [SOURCEDISKSNAMES] 1 = "HellowdM", Disk1, [SourceDisksfiles] hellowdm.sys = 1, objfre / i386,; -------- ClassInstall / ClassInstall32 Section ------------ -------------------------; Not Necessary if Using A Standard Class; 9x Style [ClassInstall] addreg = class_addreg; Nt Style [ClassInstall32] AddReg = Class_addreg [class_addreg] HKR, ,,,% DeviceClassName% HKR, ICON, "- 5"; --------- DestinationDirs S Ection ------------------------------------------- [destinationDirs] Youmark_files_driver = 10 SYSTEM32 / Drivers; --------- Manufacturer and Models Sections -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [Manufacturer]% MfgName% = Mfg0 [Mfg0]; PCI hardware Ids use the form; PCI / VEN_aaaa & DEV_bbbb & SUBSYS_cccccccc & REV_dd;% DeviceDesc% change your own ID = YouMark_DDI, PCI / VEN_9999 & DEV_9999; --------- - DdInstall Sections ------------------------------------------------------------------------------- ; --------- Windows 9x -----------------; Experimentation Has Shown That DdInstall Root Names Greater Than 19 Characters; Cause Problems in Windows 98 [Youmark_DDI] CopyFiles = youmark_files_driveradddreg =

YOUMARK_9X_ADDREG [YOUMARK_9X_ADDREG] HKR, DEVLOADER, * NTKERNHKR, NTMPDRIVER, HELLOWDM.SYSHKR, "Parameters", "BreakONENTRY", 0x00010001, 0; --------- Windows NT --------------- Windows NT ------ ----------- [YouMark_DDI.NT] CopyFiles = YouMark_Files_DriverAddReg = YouMark_NT_AddReg [YouMark_DDI.NT.Services] addservice = HelloWDM, 0x00000002, YouMark_AddService [YouMark_AddService] DisplayName =% SvcDesc% ServiceType = 1; SERVICE_KERNEL_DRIVERStartType = 3 ; SERVICE_DEMAND_STARTErrorControl = 1; SERVICE_ERROR_NORMALServiceBinary =% 10% / System32 / Drivers / HelloWDM.sys [YouMark_NT_AddReg] HKLM, "System / CurrentControlSet / Services / HelloWDM / Parameters", / "BreakOnEntry", 0x00010001, 0; ------ --- Files (Common) ------------- [Youmark_files_driver] hellowdm.sys; -------- Strings Section -------------- --------------------------------------- [Strings] providername = "flying l Co., Ltd. "mfgname =" LC Soft "DeviceDesc =" Hello World WDM! "DeviceClassName =" lc_device "svcdesc ="? "Note It can be used in Win98 or Win2000 (the system will pass the field name inside this INF file) Automatically select the installation method for the current system. Due to the complexity of all fields of the INF file, it is limited to the space, I will not explain it here, please read the readers to refer to the article or books. After you get this hellowdm.inf file, let us open the control panel, double-click Add / Remove Hardware, and Select "Add / Exclude" -> "Add New Device" -> "No, I want to select hardware from the list." -> "Other Equipment" -> "From Disk Install", select the path where hellowdm.inf is located, and then install. When the installation is complete, the system will add a driver you write. (You can check it in "Device Manager"). Then restart the computer, this driver is put into use. Call ~~~~~~ Finally, do you understand the official? If you still don't understand, welcome letter, lcother @ 163.net, we discuss together! ! (It's so tired! Write an article is still hard than writing ... ZZZZ ...)

(Source: http://laoluoc.yeah.net)

转载请注明原文地址:https://www.9cbs.com/read-4885.html

New Post(0)