hlz2014
驱动牛犊
驱动牛犊
  • 注册日期2013-04-17
  • 最后登录2013-09-10
  • 粉丝0
  • 关注0
  • 积分12分
  • 威望91点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1913回复:1

wdk中elotouch例子win7下为何安装不成功?

楼主#
更多 发布于:2013-05-24 10:14

NTSTATUS
DriverEntry (
    __in PDRIVER_OBJECT  DriverObject,
    __in PUNICODE_STRING RegistryPath
    )
/*++
Routine Description:
    Installable driver initialization entry point.
    This entry point is called directly by the I/O system.
Arguments:
    DriverObject - pointer to the driver object
    RegistryPath - pointer to a unicode string representing the path,
                   to driver-specific key in the registry.
Return Value:
    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise.
--*/
{
    NTSTATUS               status = STATUS_SUCCESS;
    WDF_DRIVER_CONFIG      config = {0};
    WDF_OBJECT_ATTRIBUTES  attributes = {0};
    
    KdPrint(("ELO MT driver entry!\n"));
    WDF_DRIVER_CONFIG_INIT(&config, NInputDeviceAdd);
    //
    // Register a cleanup callback so that we can call WPP_CLEANUP when
    // the framework driver object is deleted during driver unload.
    //
    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    //
    // Create a framework driver object to represent our driver.
    //
    status = WdfDriverCreate(DriverObject,
                             RegistryPath,
                             &attributes, // Driver Attributes
                             &config,          // Driver Config Info
                             WDF_NO_HANDLE
                             );
    if (NT_SUCCESS(status)) {
    }
    else{
        KdPrint(("failed to create driver object status=%x", status));
    }
    return status;
}
NTSTATUS
NInputDeviceAdd(
    IN WDFDRIVER       Driver,
    IN PWDFDEVICE_INIT DeviceInit
    )
/*++
Routine Description:
    EloTouchDeviceAdd is called by the framework in response to AddDevice
    call from the PnP manager. We create and initialize a WDF device object to
    represent a new instance of toaster device.
Arguments:
    Driver - Handle to a framework driver object created in DriverEntry
    DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure.
Return Value:
    STATUS_SUCCESS if successful,
    NTSTATUS of failure otherwise.
--*/
{
    NTSTATUS                      status = STATUS_SUCCESS;
    WDF_IO_QUEUE_CONFIG           queueConfig = {0};
    WDF_OBJECT_ATTRIBUTES         attributes = {0};
    WDFDEVICE                     hDevice = {0};
    PDEVICE_EXTENSION             devContext = NULL;
    WDFQUEUE                      queue = {0};
    
    UNREFERENCED_PARAMETER(Driver);
    PAGED_CODE();
    KdPrint(("ELO PMT add device!\n"));
    //
    // Relinquish power policy ownership because HIDCLASS acts a power
    // policy owner for ther HID stack.
    //
    //WdfDeviceInitSetPowerPolicyOwnership(DeviceInit, FALSE);

  
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_EXTENSION);
    //
    // Create a framework device object.This call will in turn create
    // a WDM device object, attach to the lower stack, and set the
    // appropriate flags and attributes.
    //
    status = WdfDeviceCreate(&DeviceInit, &attributes, &hDevice);
    if (!NT_SUCCESS(status)) {
        TErr(("WdfDeviceCreate failed status:0x%x",status));
        return status;
    }
    devContext = GetDeviceContext(hDevice);
    devContext->Device = hDevice;
    devContext->InputMode = MODE_MULTI_TOUCH;
    //initialize spinlock
    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    attributes.ParentObject = hDevice;
    status = WdfSpinLockCreate(
                           &attributes,
                           &devContext->SpinLock
                           );
    if(!NT_SUCCESS(status))
    {
        KdPrint(("Spink lock creation failed\n"));
        return status;
    }
    
    //get the lower device.
    devContext->IoTarget = WdfDeviceGetIoTarget(hDevice);
#ifdef PRIORITY_UPDATE
    devContext->LastState = TOUCH_NONE;
#endif
        
    WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel);
    queueConfig.EvtIoInternalDeviceControl = NInputInternalDeviceControl;
    
    queueConfig.PowerManaged = WdfFalse;
    status = WdfIoQueueCreate(hDevice,
                              &queueConfig,
                              WDF_NO_OBJECT_ATTRIBUTES,
                              &queue
                              );
    if (!NT_SUCCESS (status)) {
        TErr(("WdfIoQueueCreate failed status:0x%x",status));
        return status;
    }
    //
    // Register a manual I/O queue for Read Requests.
    // This queue will be used for storing Requests that need to wait for data
    //  from the serial driver before they can be completed.
    //
    WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchManual);
    //
    // This queue is used for requests that dont directly access the device. The
    // requests in this queue are serviced only when the device is in a fully
    // powered state and sends an interrupt. So we can use a non-power managed
    // queue to park the requests since we dont care whether the device is idle
    // or fully powered up.
    //
     queueConfig.PowerManaged = WdfFalse;
    status = WdfIoQueueCreate(hDevice,
                              &queueConfig,
                              WDF_NO_OBJECT_ATTRIBUTES,
                              &devContext->PingPongQueue
                              );
    if (!NT_SUCCESS(status)) {
        KdPrint(("failed to create queue\n"));      
    }
    TExit(Func, ("=%x", status));
    return status;
}
上面是入口函数和设备添加函数,inf文件如下:

; EloMT.INF
; Copyright (c) 2000,2002 Microsoft Corporation
 
[SourceDisksNames]
3426=windows cd
[SourceDisksFiles]
EloTouch.sys   = 3426
hidkmdf.sys             = 3426
;;--
[version]
signature="$WINDOWS NT$"
Class=HIDClass
ClassGuid={745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Provider=%MS%
DriverVer=05/23/2013,6.1.7600.16385
[ControlFlags]
ExcludeFromSelect=*
[DestinationDirs]
DefaultDestDir              =11     ;LDID_SYS
EloTouchInst.NT.Copy        =12     ;LDID_DRIVERS
EloTouchInst.Win7.NT.Copy  =12     ;LDID_DRIVERS
; Drivers
;----------------------------------------------------------
[Manufacturer]
%Elo%=Elo, NTx86, NTx86.6.1
 
;For XP and Vista
[Elo.NTx86]
%EloTouch\COM1.DeviceDesc%   =EloTouchInst, ACPI\PNP0501
%MTCollection.DeviceDesc%   =MTCollectionInst, HID\PNP0501&Col01
;For Windows 7
[Elo.NTx86.6.1]
%EloTouch\COM1.DeviceDesc%   =EloTouchInst.Win7, ACPI\PNP0501
%MTCollection.DeviceDesc%   =MTCollectionInst, HID\PNP0501&Col01
[MTCollectionInst.NT]
Include=input.inf
Needs=HID_Raw_Inst.NT
[MTCollectionInst.NT.HW]
AddReg                     =MTCollectionInst.NT.HW.AddReg
[MTCollectionInst.NT.HW.AddReg]
HKR,,"LinearityData",0x00000001,40,00,00,00,02,00,00,00,00,00,00,00,00,00,00,00,00,80,00,00,00,80,00,00,00,00,00,00,02,00,02,00,e0,04,80,06,28,04,d8,05,e0,7a,80,06,38,7b,00,04,e0,04,2a,79,40,04,f0,79,e0,7a,2a,79,38,7b,40,79

;===============================================================
;  EloTouch for XP and Vista
;===============================================================
[EloTouchInst.NT]
CopyFiles                   =EloTouchInst.NT.Copy
[EloTouchInst.NT.Copy]
EloTouch.sys
hidkmdf.sys

[EloTouchInst.NT.HW]
AddReg                      =SerialInst.NT.HW.AddReg
[EloTouchInst.NT.Services]
AddService                  =serial,,SerialServiceInst, SerialEventLogInst
AddService                  =EloTouch,0x00000002,EloTouchServiceInst,EloEventLogInst
AddService                  =serenum,,SerenumServiceInst, SerenumEventLogInst
AddService                  =hidkmdf,, hidkmdf_Service_Inst

[hidkmdf_Service_Inst]
DisplayName    = %hidkmdf.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ; SERVICE_DEMAND_START
ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
ServiceBinary  = %12%\hidkmdf.sys
LoadOrderGroup = PNP Filter
[SerialInst.NT.HW.AddReg]
HKR,,"UpperFilters",0x00010000,hidkmdf
HKR,,"LowerFilters",0x00010000,serial,serenum
HKR,,"MultiportDevice",0x00010001,0
HKR,,"SerialRelinquishPowerPolicy",0x00010001,1
;===============================================================
;  EloTouch for Win7
;===============================================================
[EloTouchInst.Win7.NT]
CopyFiles                   =EloTouchInst.Win7.NT.Copy
[EloTouchInst.Win7.NT.Copy]
EloTouch.sys
 
[EloTouchInst.Win7.NT.HW]
AddReg                      =SerialInst.Win7.NT.HW.AddReg
[EloTouchInst.Win7.NT.Services]
AddService                  =serial,,SerialServiceInst, SerialEventLogInst
AddService                  =EloTouch,0x00000002,EloTouchServiceInst,EloEventLogInst
AddService                  =serenum,,SerenumServiceInst, SerenumEventLogInst
[SerialInst.Win7.NT.HW.AddReg]
HKR,,"UpperFilters",0x00010000,mshidkmdf
HKR,,"LowerFilters",0x00010000,serial,serenum
HKR,,"MultiportDevice",0x00010001,0
HKR,,"SerialRelinquishPowerPolicy",0x00010001,1
;===============================================================
;   Sections common to all OS versions
;===============================================================

[EloEventLogInst]
AddReg                      =EloEventLogAddReg
[EloEventLogAddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\elotouch.sys"
HKR,,TypesSupported,0x00010001,7
; -------------- Elo Touch Driver install section
[EloTouchServiceInst]
DisplayName    = %EloTouch.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ;
ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
ServiceBinary  = %12%\EloTouch.sys
LoadOrderGroup = Extended Base
 

[SerialEventLogInst]
AddReg         = SerialEventLogAddReg
[SerialEventLogAddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\serial.sys"
HKR,,TypesSupported,0x00010001,7
[SerenumEventLogInst]
AddReg         = SerenumEventLogAddReg
[SerenumEventLogAddReg]
HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\serenum.sys"
HKR,,TypesSupported,0x00010001,7
; -------------- Serenum Port Driver install sections
[SerenumServiceInst]
DisplayName    = %Serenum.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ; SERVICE_DEMAND_START
ErrorControl   = 0               ; SERVICE_ERROR_IGNORE
ServiceBinary  = %12%\serenum.sys
LoadOrderGroup = Extended base
; -------------- Serial Port Driver install sections
[SerialServiceInst]
DisplayName    = %Serial.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ; SERVICE_DEMAND_START
ErrorControl   = 0               ; SERVICE_ERROR_IGNORE
ServiceBinary  = %12%\serial.sys
LoadOrderGroup = Extended base

;================================================================
;--- WDF Coinstaller installation ------
;
[DestinationDirs]
EloTouchInst_CoInstaller_CopyFiles = 11
[EloTouchInst.NT.CoInstallers]
AddReg=EloTouchInst_CoInstaller_AddReg
CopyFiles=EloTouchInst_CoInstaller_CopyFiles
[EloTouchInst_CoInstaller_AddReg]
HKR,,CoInstallers32,0x00010000, "wdfcoinstaller01009.dll,WdfCoInstaller"
[EloTouchInst_CoInstaller_CopyFiles]
wdfcoinstaller01009.dll
[SourceDisksFiles]
wdfcoinstaller01009.dll=3426 ; make sure the number matches with SourceDisksNames
[EloTouchInst.NT.Wdf]
KmdfService = EloTouch, EloTouch_wdfsect
[EloTouch_wdfsect]
KmdfLibraryVersion = 1.9

[Strings]
MS="Microsoft"
Elo="Elo"
EloTouch\COM1.DeviceDesc="Elo Multi-Touch Display Digitizer"
EloTouch.SVCDESC="Elo Serial Multi-touch Driver"
Serenum.SVCDESC="Serenum Port Driver"
Serial.SVCDESC="Serial Port Driver"
hidkmdf.SVCDESC="HID Class Shim for KMDF"
MTCollection.DeviceDesc="Elo HID MT"
另外用
   echo off
devcon_x32 install EloMT.inf  "ACPI\PNP0501"
安装后,设备管理器中的驱动一直有感叹号,安装不成功,求大神们指教
hlz2014
驱动牛犊
驱动牛犊
  • 注册日期2013-04-17
  • 最后登录2013-09-10
  • 粉丝0
  • 关注0
  • 积分12分
  • 威望91点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2013-05-24 10:19
大牛们顶起来啊
游客

返回顶部