随笔分类 -  Windows Driver Dev

摘要:对于Windows驱动来说,有三种选择。 1. AVStream ,依赖于ks.sys 2. Stream ,依赖于stream.sys(而它本身又依赖于ks.sys),该方法已被淘汰。 3. Port 一般来说需要使用AVStream小端口驱动。 阅读全文
posted @ 2011-06-09 11:33 Fan Zhang 阅读(330) 评论(0) 推荐(0)
摘要:在64位模拟32位程序时候,会对C:\Windows\System32进行重定位,重定位到C:\Windows\SysWOW64。说起来真想骂人,搞了一下午才弄明白。 阅读全文
posted @ 2011-05-07 19:42 Fan Zhang 阅读(395) 评论(0) 推荐(0)
摘要:DbgBreakPoint 在64位下只能用这个,__asm int 3 用不了 阅读全文
posted @ 2011-05-07 11:43 Fan Zhang 阅读(167) 评论(0) 推荐(0)
摘要:Alt+F7 => C++ => Code Generation => Enable C++ Exception,选择”Yes with SHE Exceptions” 另外,用VS2005编译驱动的时候,如果使用SEH,可能会把kernel32.dll link到驱动里。这样讲导致驱动不能正常加载。 简单的办法是: Alt+F7 => Linker => Input => Additional ... 阅读全文
posted @ 2011-05-06 17:26 Fan Zhang 阅读(291) 评论(0) 推荐(0)
摘要:DMA分为两大类,总线主DMA驱动(利用PCI卡上的DMA控制器),从属DMA驱动(利用主板上的DMA控制器,例如软盘控制器,这类基本被淘汰)。这两类驱动每种又可以分为基于包的DMA驱动和通用缓冲区DMA驱动。 基于包的DMA驱动是,由用户程序进程发起读写请求。由于读写请求是虚拟内存连续,但物理内存不连续的,所以需要调用MapTransfer来完成这些转换。 另外一种是通用缓冲区DMA驱动,是在驱... 阅读全文
posted @ 2011-05-04 16:10 Fan Zhang 阅读(450) 评论(0) 推荐(0)
摘要:LONG InterlockedExchange( IN OUT PLONG Target, IN LONG Value ); 这个就是相当于赋值用,例如 InterlockedExchange ( &m_PinsWithResources, 0 ); LONG InterlockedCompareExchange( IN OUT PLONG Destination, IN ... 阅读全文
posted @ 2011-04-29 16:13 Fan Zhang 阅读(213) 评论(0) 推荐(0)
摘要:列出所有设备Node !devnode 0 1 列出设备堆栈 !devstack xxxxx 查看IRP !irp xxxxx 查看设备对象 !devobj 查看文件对象 !fileobj 阅读全文
posted @ 2011-04-28 11:16 Fan Zhang 阅读(384) 评论(0) 推荐(0)
摘要:早期的Windows驱动为了给设备程序暴露一个名字,使用符号链接。 在Win2000以后使用Device Interface Classes,它其实就是一个GUID。用设备的硬件ID加上这个GUID,构成一个符号链接。这样避免了使用命名冲突,同时一眼就可以从这个符号链接里知道这个设备是什么类型的设备。 它的信心存储在HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\C... 阅读全文
posted @ 2011-04-19 15:59 Fan Zhang 阅读(287) 评论(0) 推荐(0)
摘要:Trap Frame是指中断、自陷、异常进入内核后,在堆栈上形成的一种数据结构。对于Windows操作系统,是 kd> dt nt!_KTRAP_FRAME +0x000 DbgEbp : Uint4B +0x004 DbgEip : Uint4B +0x008 DbgArgMark : Uint4B +0x00c DbgArgPointer : Uint4B +0x010 TempSe... 阅读全文
posted @ 2011-04-07 17:17 Fan Zhang 阅读(1729) 评论(0) 推荐(0)
摘要:.load wmitrace .load Traceprt !wmitrace.searchpath C:\MFLD\I2C_SPB\Debug 阅读全文
posted @ 2011-03-23 17:42 Fan Zhang 阅读(339) 评论(0) 推荐(0)
摘要:bcdedit/set testsigning on 阅读全文
posted @ 2011-03-19 12:00 Fan Zhang 阅读(282) 评论(0) 推荐(0)
摘要:NTSTATUS CompleteRoutine( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context ){ PIO_STACK_LOCATION IrpSp; PKEYBOARD_INPUT_DATA KeyData; int numKeys, i; IrpSp = IoGetCurrentIrpStackLocation(... 阅读全文
posted @ 2011-03-14 16:35 Fan Zhang 阅读(398) 评论(0) 推荐(0)
摘要:ObReferenceObjectByName 可以返回任意对象地址。它的本质是使用ObpLookupObjectName对 “\A\B\C”逐级解析。 IoGetDeviceObjectPointer 只能返回设备对象地址。它的本质是调用ZwOpenFile得到设备句柄,然后调用ObReferenceObjectByHandle得到设备对象指针。 阅读全文
posted @ 2011-03-12 12:36 Fan Zhang 阅读(410) 评论(0) 推荐(0)
摘要:例如,如果使用 DEFINE_GUID( GUID_DEVINTERFACE_KEYBOARD, 0x884b96c3, 0x56ef, 0x11d1, \ 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd); 必须引用initguid.h 例如: #include <initguid.h> #include <ntddkbd.h> 阅读全文
posted @ 2011-02-27 15:41 Fan Zhang 阅读(434) 评论(0) 推荐(0)
摘要:在source文件中加入KERNEL_ALIGNMENT = 0x1000DRIVER_ALIGNMENT = 0x1000HAL_ALIGNMENT = 0x1000 阅读全文
posted @ 2011-02-13 22:25 Fan Zhang 阅读(312) 评论(0) 推荐(0)
摘要:C:\Windows\inf\setupapi.dev.log 阅读全文
posted @ 2011-02-09 17:45 Fan Zhang 阅读(552) 评论(0) 推荐(0)
摘要:psexec -s "cmd.exe" 阅读全文
posted @ 2011-02-09 11:27 Fan Zhang 阅读(368) 评论(0) 推荐(0)
摘要:1. CriticalSection不需要进入内核就可以使用,速度比Mutex快100倍。2. CriticalSection只能用于同一个进程,而Mutex可以被不同进程使用CriticalSection的伪代码 阅读全文
posted @ 2011-02-08 18:48 Fan Zhang 阅读(294) 评论(0) 推荐(0)
摘要:NTSTATUSAcpiGetInteger( IN PDEVICE_OBJECT pAcpiPdo, IN ULONG MethodName, IN ULONG * pValue )/*++Routine Description: This routine sends a request to ACPI, the parent driver, to get a value from the DSDT entry for the device. The ACPI driver executes the specified method and this routine returns the 阅读全文
posted @ 2011-01-31 16:41 Fan Zhang 阅读(541) 评论(0) 推荐(0)
摘要:typedef enum _DEVICE_PNP_STATE { NotStarted = 0, // Not started yet Started, // Device has received the START_DEVICE IRP StopPending, // Device has received the QUERY_STOP IRP Stopped, // Device has received the STOP_DEVICE IRP RemovePending, // Device has received the QUERY_REMOVE IRP SurpriseRemov 阅读全文
posted @ 2011-01-31 11:07 Fan Zhang 阅读(287) 评论(0) 推荐(0)