zoukankan      html  css  js  c++  java
  • [转]驱动开程序发—安装(6)

    作为一个完整的例子,你开发出来驱动还必须要能安装。所以下面我讲一下安装。

    如果前面的编译过程没有错误的话,现在我们应该已经得到了一个HelloWDM.sys文件,假设它是放在D:\HelloWDM\objfre\i386中。

    安装WDM驱动程序可以用两种方法,一种是利用注册表,还有一种是利用INF文件。我们一般是采用INF文件(这是微软推荐的)。INF文件可以在 WINNT\INF 目录中找到很多。为了顺利安装,我在这里先给出 HelloWDM 所需要的 HelloWDM.INF 文件:

    ;; The Win2K DDK documentation contains an excellent INF reference.

    ;--------- Version Section ---------------------------------------------------

    [Version]
    Signature="$CHICAGO$"
    Provider=LC_Device
    DriverVer=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=Unknown
    ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}

    ;--------- SourceDiskNames and SourceDiskFiles Section -----------------------

    ; These sections identify source disks and files for installation. They are
    ; 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 Section -------------------------------------------

    [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
    ;改成你自己的ID
    %DeviceDesc%=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_Driver
    AddReg=YouMark_9X_AddReg

    [YouMark_9X_AddReg]
    HKR,,DevLoader,,*ntkern
    HKR,,NTMPDriver,,HelloWDM.sys
    HKR, "Parameters", "BreakOnEntry", 0x00010001, 0

    ; --------- Windows NT -----------------

    [YouMark_DDI.NT]
    CopyFiles=YouMark_Files_Driver
    AddReg=YouMark_NT_AddReg

    [YouMark_DDI.NT.Services]
    Addservice = HelloWDM, 0x00000002, YouMark_AddService

    [YouMark_AddService]
    DisplayName = %SvcDesc%
    ServiceType = 1 ; SERVICE_KERNEL_DRIVER
    StartType = 3 ; SERVICE_DEMAND_START
    ErrorControl = 1 ; SERVICE_ERROR_NORMAL
    ServiceBinary = %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="???"



    注意它可以同时在Win98或者Win2000中使用(系统会通过这个INF文件里面的字段名称,自动选择适合当前系统的安装方法的)。关于INF文件的各个字段含义现在我也不知道,所以也没有办法说清楚,如果谁看到这篇文章,而又知道的话,不妨为我一份。

    准备好这个 HelloWDM.INF 文件后,让我们打开控制面板,双击“添加/删除硬件”,选择“添加/排除设备故障”->“添加新设备”->“否,我想从列表选择硬件”->“其它设备”->“从磁盘安装”,选择 HelloWDM.INF 所在的路径,然后安装。

    当安装完成后,系统就会添加上你写好的驱动程序了。(可以在“设备管理器”中查看到)。然后重启电脑,这个驱动程序就投入使用啦。

    关于安装,我也只知道这么多,到底安装驱动程序时,操作系统都作了些什么,我也不是很清楚,等我弄明白了我再贴上。

  • 相关阅读:
    ②.kubernetes service
    c2p
    ⑤.docker dockerfile
    ④.docker volume
    ②.docker image
    ③.docker container
    ①.docker介绍
    三剑客之grep
    ⑦.shell 数组
    shell 正则
  • 原文地址:https://www.cnblogs.com/4kapple/p/959426.html
Copyright © 2011-2022 走看看