阅读:2947回复:0
关于驱动的制作安装包问题
先说下需求,小弟现在有SYS文件和INF文件以及一些DLL。
现在想做成安装包。 安装包的使用流程如下,在不插入KEY的情况下直接安装,安装后插入KEY就可以直接使用。 其中就涉及到安装后插入KEY不再弹出欢迎找到新硬件向导等对话框。也就是coinstaller,小弟根据DDK提供的coinstaller代码进行了修改,修改如下(请看代码1); 这个coinstaller的DLL只要INF里面注册上就可以吗?是不是还要在别的地方调用?(INF文件请看代码2) 其中还涉及到installdriver.exe(这个原先是别人直接在网上找的EXE,但是我用着不行)或者devcon.exe(问下大家这个东西是不是要自己写,或者根据DDK给的代码修改,还是直接找个exe就能直接用?) 为了减少走弯路,并小弟原先没接触过驱动,所以希望高人帮忙说下具体的流程,不胜感激。 (如果我做成功愿意把经验分给后来人,为中国的驱动开发事业做点贡献,呵呵) 代码一: case DIF_SELECTBESTCOMPATDRV: DbgOut("DIF_SELECTBESTCOMPATDRV"); if (DeviceInfoData) { SP_DRVINFO_DATA sDrvInfoData; DWORD MemberIndex = 0; BOOL bRet = FALSE; memset((void*)&sDrvInfoData, 0, sizeof(SP_DRVINFO_DATA)); sDrvInfoData.cbSize = sizeof(SP_DRVINFO_DATA); DbgOut("DIF_SELECTBESTCOMPATDRV"); //遍历驱动程序列表,获得每个驱动程序的信息 bRet = SetupDiEnumDriverInfo(DeviceInfoSet, DeviceInfoData, SPDIT_COMPATDRIVER, MemberIndex++, &sDrvInfoData); if (bRet) { SP_DRVINSTALL_PARAMS sDrvInstallParams; memset((void*)&sDrvInstallParams, 0, sizeof(SP_DRVINSTALL_PARAMS)); sDrvInstallParams.cbSize = sizeof(SP_DRVINSTALL_PARAMS); OutputDebugString(sDrvInfoData.Description); DbgOut("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"); //获得驱动程序安装参数――一个SP_DRVINSTALL_PARAMS结构,其中我们想要修改的Rank赫然在列 SetupDiGetDriverInstallParams(DeviceInfoSet, DeviceInfoData, &sDrvInfoData, &sDrvInstallParams); //把RANK修改为0 sDrvInstallParams.Rank = 0; //把修改后的SP_DRVINSTALL_PARAMS结构作为输入 SetupDiSetDriverInstallParams(DeviceInfoSet, DeviceInfoData, &sDrvInfoData, &sDrvInstallParams); DbgOut("ssssssssssssssssssssssssssssssssssssss"); } } else DbgOut("DeviceInfoData is null!"); break; —————————————————————————————————— 代码 2:(inf文件) ; TSIMUSBCCID.inf [Version] Signature="$Windows NT$" Class=SmartCardReader ClassGuid={50DD5230-BA8A-11D1-BF5D-0000F805F530} Provider=%MS% DriverVer=08/01/2006,5.2.3790.2724 CatalogFile=usbccid.cat [SourceDisksNames] 1=%Distribution%,usbccid.sys,, [SourceDisksFiles] usbccid.sys = 1 KoalKey_Coinst.dll = 1 [ClassInstall32] Addreg=SmartCardReaderClassReg [ClassInstall] Addreg=SmartCardReaderClassReg [SmartCardReaderClassReg] HKR,,,0,%ClassName% HKR,,Icon,,-25 HKR,,NoInstallClass,,1 HKR,,Installer32,,"winscard.dll,ClassInstall32" [Manufacturer] %CCID%=CCID ; ============ Add reg for all readers =============== [Reader.Install.AddReg] HKLM, Software\Microsoft\Cryptography\Calais\Readers,,, HKLM, System\CurrentControlSet\Services\SCardSvr,Start,0x00010001,2 HKLM, System\CurrentControlSet\Services\CertPropSvc,Start,0x00010001,2 ; ************************** ; USB CCID Compliant Readers ; ************************** [CCID] %USBCCID.DeviceDesc% = USBCCID.Install,USB\Class_0B&SubClass_00 [USBCCID.Install.NT] AddReg = Reader.Install.AddReg CopyFiles = USBCCID.Install.CopyFiles [USBCCID.Install.NT.CoInstallers] CopyFiles = USBCCID.Install.CoInstallers.CopyFiles AddReg = USBCCID.Install.CoInstallers.AddReg [USBCCID.Install.CoInstallers.CopyFiles] KoalKey_Coinst.dll [USBCCID.Install.CoInstallers.AddReg] HKR,,CoInstallers32,0x00010000,"KoalKey_Coinst.dll,KoalKey_CoInstaller" [USBCCID.Install.NT.HW] AddReg = USBCCID.Install.AddReg.HW [USBCCID.Install.AddReg.HW] HKR,,"VendorName",,"Generic" HKR,,"IfdType",,"USB Smartcard" [USBCCID.Install.CopyFiles] usbccid.sys,,,2 [USBCCID.Install.NT.Services] AddService = USBCCID, 2, USBCCID.Service [USBCCID.Service] DisplayName = %USBCCID.DeviceDesc% ServiceType = 1 ;%SERVICE_KERNEL_DRIVER% StartType = 3 ;%SERVICE_AUTO_START% ErrorControl = 1 ;%SERVICE_ERROR_NORMAL% ServiceBinary = %12%\usbccid.sys [DestinationDirs] USBCCID.Install.CopyFiles = 12 USBCCID.Install.CoInstallers.CopyFiles = 11 [Strings] MS = "KOAL" Distribution = "Windows USB CCID Driver Disk" ClassName = "Smart card readers" CCID = "USB CCID Compliant" USBCCID.DeviceDesc = "Smart Card" --------对帮助的人们将不胜感激!!! |
|