Compilation and installation of WDM driver design

zhaozj2021-02-08  197

Compilation and installation of WDM driver design

(Author: Su Jinguo, 2000 at 13:26 on November 9)

After designing its own WDM driver, in order to run the driver, we must compile and install them.

■ After the compilation device driver is installed, after the DDK, there are two compilers in the DDK program group, and the check environment is used to compile the driver with debugging information. Free is the environment that compiles formally released. Normally, the compilation of the device driver uses the way the command line is used. You can compile in a VC integrated environment through a certain setting. In general, successfully compiling a basic device driver requires four files, the first is the driver, the C language source program file (eg vdisk.c, Note All of the following examples are illustrated); The second is the RC file (for example, vdisk.rc); the third is a Sources file; the fourth file is a makefile.rc file. Sources files and make files are similar to specify files that need to be compiled and the library that needs to be connected. These three auxiliary documents are simple. There are three such files in each routine of DDK Samples, and they can understand their structure and significance. 1. In the following Examples vdisk analysis program, for example, set vdisk.rc code: /vdisk.rc/ #include #include #define VER_FILETYPE VFT_DRV #define VER_FILESUBTYPE VFT2_DRV_SYSTEM #define VER_FILEDESCRIPTION_STR "SCSI VDisk Driver" #define VER_INTERNALNAME_STR "vdisk .sys "#define ver_originalFileName_STR" vdisk.sys "#include" common.ver "/ enD of vdisk.rc / device driver Generally uses the build utility, Build is just an outer packager outside NMAKE. Build itself is actually quite simple, most of the work is actually passed to NMAKE by Build. / Sources = vdisk targettype = driver targetpath = $ (basedir) / lib targetlibs = $ (basedir) / lib /  / $ (ddkbuildenv) /scsiport.lib incrudes = .. /. / Incnources = vdisk .c vdisk.rc / END OF SOURCES  / Note Sources' file name has no extension. # Makefile # # do not edit this file !!! Edit ./sources. If you want to add a new source # file to this component. this file merely indirects to the real make file # That Shared by All the Driver Components of File The Windows NT DDK #! INCLUDE $ (NTMAKEENV) /makefile.def # End of makefile is the same for all drivers, Microsoft also warns not to edit this file, if necessary, edit the Sources file to achieve the same Effect. For device drivers, the C compiler used is basically selected by VC . 2. Basic steps in compilation (1) First enter the Check or Free Compilation Environment, initialize the DDK compilation environment.

(2) Run the vcvars32.bat under the bin directory in the VC installation directory, initialize the VC compilation environment. (3) Run Build.exe for compilation. ■ Installation and start of the device driver 1. Add key values ​​in the registry to construct the driver list by scanning the registry when booting. This list includes both start-up drivers, including drivers that require manual startup. This list is actually all the devices listed in the device applet in the control panel. All device drivers should have corresponding key values ​​on the hkey_local_machine / system / currentcontrol-set / service / currentcontrol- set / service / currentcontrol- set / service / system / currentcontrol- set / service. The following is to explain how to add a key value as an example: First add a child vdisk to HKEY_LOCAL_MACHINE / SYSTEM / CURRENT ControlSet / Services / Note The name here should be consistent with your driver name. For example, the driver name is vdisk.sys, then the child name here is VDisk. Then add the following key values ​​under VDISK:

Name Type Description Data driver start the start time of another species StartREG_DWORD ErrorControlREG_DWORD driver TypeREG_DWORD Driver loading error handling GroupREG_SZ driver failed group name DependOnGroupREG_MULTI_SZ depend TagREG_BINARY driver into the same group order Parameters (key The driver-specific parameter key TYPE value is 1 represents the kernel mode driver; 2 represents the file system driver. ERRORCONTROL value is 0 indicates logging errors and ignores; the value indicates logging error and display a dialog; value 2 indicates logging error, and reboots with the last correct configuration; value 3 indicates logging errors, if already Use the correct configuration to return to fail. In any device driver, the top three parameters in the above table are required. 2. Controlling the order of the driver Sometimes the order in which the plurality of drivers are controlled is necessary. For example, a set of drivers include three drivers, respectively, JBChanger.sys, ChangerDisk.sys, and VDisk.sys. JBCHANGER and CHANGERDISK are two SCSI class drivers that rely on SCSI small ports (MINI PORT drivers), while ChangerDisk must start after JBCHANGER startup. Vdisk is a virtual disk driver that must be successful after JBCHANGER and CHANGERDISK are started. 3. The START value of the driver's START value above the registry's START value control driver starts at the system. Currently, Start can take a lower value, in addition to this value to apply to new requirements: (L) 0x0 (service_boot_start): This value specifies that the driver should be started by the operating system loader. The general driver does not adopt this value because the system is almost not started at this time, and most of the system is not available. (2) 0x1 (Service_System_Start): This value indicates that the driver is started when the operating system is loaded but initializes itself. (3) 0x2 (Service_AUTO_START): This value indicates that the service control manager is loaded after the entire system is started and run. (4) 0x3 (service_demand_start): This value indicates that the driver must be started manually. You can start with the device applet of the control panel or use Win32 API programming. (5) 0x4 (service_disabled): Indicates that the driver is disabled. Note When the driver is commissioned, it is best to set the start value to 3 to manually start, because if it is set to automatically start, the driver has an exception error in the start-up process, it may cause the system to not start. If there is no emergency recovery disk, you can first try to start the system with a known configuration while starting, see if it can start successfully. If fails, you can use DOS to start to /% systemroot% / system32 / drivers to delete the driver, and then the system can start. However, if the NT is installed in the NTFS partition, this partition will not be seen after the DOS starts so that the hard disk must be hung on another NT system to delete this file. You can control the driver at different times by setting START. But if you want to resolve dependency issues, you need to use Group and DependongRouP values.

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

New Post(0)