USB鼠標(biāo)的上層過(guò)濾型驅(qū)動(dòng)程序
更新時(shí)間: 2007-05-09 09:08:23來(lái)源: 粵嵌教育瀏覽量:1226
AddDevice例程內(nèi)容如下:
NTSTATUS VA_AddDevice
(
IN PDRIVER_OBJECT driverObj,
IN PDEVICE_OBJECT physicalDevObj
)
{
NTSTATUS status;
PDEVICE_OBJECT filterDevObj = NULL;
PAGED_CODE();
DBGOUT(("VA_AddDevice: 驅(qū)動(dòng)對(duì)象=%ph, 物理設(shè)備對(duì)象=%ph", driverObj, physicalDevObj));
status = IoCreateDevice(
driverObj,
sizeof(struct DEVICE_EXTENSION),
NULL, // name for this device
FILE_DEVICE_MOUSE,
0, // device characteristics
FALSE, // not exclusive
&filterDevObj); // our device object
if ( NT_SUCCESS(status) ){
struct DEVICE_EXTENSION *devExt;
ASSERT( filterDevObj );
/*
* Initialize device extension for new device object
*/
devExt = ( struct DEVICE_EXTENSION * )filterDevObj->DeviceExtension;
RtlZeroMemory( devExt, sizeof(struct DEVICE_EXTENSION) );
devExt->signature = DEVICE_EXTENSION_SIGNATURE;
devExt->state = STATE_INITIALIZED;
devExt->filterDevObj = filterDevObj;
devExt->physicalDevObj = physicalDevObj;
devExt->pendingActionCount = 0;
KeInitializeEvent( &devExt->removeEvent, NotificationEvent, FALSE );
#ifdef HANDLE_DEVICE_USAGE
KeInitializeEvent(&devExt->deviceUsageNotificationEvent, SynchronizationEvent, TRUE);
#endif // HANDLE_DEVICE_USAGE
/*
* Attach the new device object to the top of the device stack.
*/
devExt->topDevObj = IoAttachDeviceToDeviceStack(filterDevObj, physicalDevObj);
ASSERT(devExt->topDevObj);
DBGOUT(("創(chuàng)建的過(guò)濾設(shè)備對(duì)象: %ph 掛接到設(shè)備對(duì)象堆棧: %ph.", filterDevObj, devExt->topDevObj));
//
// As a filter driver, we do not want to change the power or I/O
// behavior of the driver stack in any way. Recall that a filter
// driver should "appear" the same (almost) as the underlying device.
// Therefore we must copy some bits from the device object _directly_
// below us in the device stack (notice: DON'T copy from the PDO!)
//
/* Various I/O-related flags which should be maintained */
/* (copy from lower device object) */
filterDevObj->Flags |= DO_BUFFERED_IO;
filterDevObj->Flags |= (devExt->topDevObj->Flags &
(DO_POWER_INRUSH | DO_POWER_PAGABLE ));
#ifdef HANDLE_DEVICE_USAGE
if ((devExt->topDevObj->Flags & DO_POWER_PAGABLE)){
}else{
DBGOUT(( "LOCKing some driver code (non-pageable) (b/c init conditions)" ));
devExt->initUnlockHandle = MmLockPagableCodeSection( VA_Power ); // some func that's inside the code section that we want to lock
ASSERT( NULL != devExt->initUnlockHandle );
}
devExt->initialFlags = filterDevObj->Flags & ~DO_DEVICE_INITIALIZING;
#endif // HANDLE_DEVICE_USAGE
filterDevObj->Flags &= ~DO_DEVICE_INITIALIZING;
RegistryAccessSample(devExt, devExt->physicalDevObj);
}
ASSERT(NT_SUCCESS(status));
return status;
}
用INF內(nèi)容如下:
;***************************************************
;Zt_Usb_Mouse_Filter Driver's Inf file *
;name: ztmouse.inf *
;Date: 4/20/2005 *
;Composer: ting_Zhang *
;version 1.00.0.0 *
;***************************************************
;=========The "[Version]" begin================>>
[Version]
Signature="$Windows NT$"
SignOS=Windows 2000
Provider=%ProviderName%
Class=Mouse
ClassGUID={4D36E96F-E325-11CE-BFC1-08002BE10318}
DriverVer=04/20/2005,1.0.0.0
;<<=========The "[Version]" end==================
[DestinationDirs]
DefaultDestDir = 12
[Manufacturer]
%USBDBE%=USBDBEINS
[USBDBEINS]
%HID.DeviceDesc% = yyz,HID\VID_ba13&PID_b100
;HID\VID_046D&PID_C50B&Mi_01&Col01
;===================================
; Win2000 Installation sections
;===================================
[yyz.NT]
Include = msmouse.inf
Needs = HID_Mouse_Inst.NT
CopyFiles = yyz.CopyFiles
[yyz.CopyFiles]
yyx.sys
[yyz.NT.Services]
Addservice = yyx,0x00000002, yyz_Service_Inst
Include=msmouse.inf
Needs=HID_Mouse_Inst.NT.Services
[yyz.NT.HW]
AddReg = yyz_HW_AddReg
Include=msmouse.inf
Needs=HID_Mouse_Inst.NT.HW
[yyz_Service_Inst]
DisplayName = %HID.DeviceDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
LoadOrderGroup = Pointer Port
ServiceBinary = %12%\yyx.sys
[yyz_HW_AddReg]
;HKR,,"LowerFilters",0x00010000,"yyx"
HKR,,"UpperFilters",0x00010000,"yyx"
[SourceDisksNames]
1 = %DiskId1%
[SourceDisksFiles]
yyx.sys = 1
;=================the "[strings]" begin================>>
[strings]
USBDBE = "YongRui Electronics Co.,Ltd"
HID.ClassName = "Human Input Devices (HID)"
HID.DeviceDesc = "USB Mouse Fliter"
HID.DefaultDevice = "HID Default Device"
REG_SZ = 0x00000000
REG_MULTI_SZ = 0x00010000
REG_EXPAND_SZ = 0x00020000
REG_BINARY = 0x00000001
REG_DWORD = 0x00010001
;SERVICEROOT = "System\CurrentControlSet\Services"
DiskId1 = "Mouse Fliter Installation Disk #1 "
ProviderName = "YongRui Develop Department"
;<<================the "[strings]" end====================
粵嵌動(dòng)態(tài)
推薦閱讀
- ·Linux字符設(shè)備驅(qū)動(dòng)框架解析:file_operations的核心作用與實(shí)現(xiàn)
- ·廣東朝歌數(shù)碼科技股份有限公司專場(chǎng)招聘會(huì)
- ·深化產(chǎn)教融合,共筑技能人才培養(yǎng)新生態(tài) —— 廣州華立學(xué)院到訪粵嵌從化校區(qū)為深化產(chǎn)教
- ·校企合作新突破 | 粵嵌科技與三亞學(xué)院共探產(chǎn)教融合新路徑
- ·粵嵌科技入選國(guó)家級(jí)職業(yè)數(shù)字展館聯(lián)合建設(shè)單位,賦能計(jì)算機(jī)程序設(shè)計(jì)員高技能人才培養(yǎng)
- ·嵌入式實(shí)時(shí)操作系統(tǒng)的性能優(yōu)化與實(shí)現(xiàn)路徑
- ·校企攜手賦能教育!粵嵌科技助力海南科技職業(yè)大學(xué)探索 AGI 時(shí)代教學(xué)新范式
- ·嵌入式系統(tǒng)中的低功耗設(shè)計(jì)策略與實(shí)現(xiàn)路徑
- ·深圳市軒宇軟件開發(fā)有限公司專場(chǎng)招聘會(huì)
- ·嵌入式系統(tǒng)中的代碼空間優(yōu)化:策略與實(shí)踐