代码改变世界

随笔分类 -  Windows设备驱动

DeviceIoControl与驱动交互

2012-05-02 11:11 by java20130722, 540 阅读, 收藏,
摘要: 与驱动程序通信的函数,除了ReadFile和WriteFile函数还有DeviceIoControl函数,而且DeviceIoControl函数那是相当的彪悍。因为它可以自定义控制码,你只要在IRP_MJ_DEVICE_CONTROL对应的派遣函数中读取控制码,然后针对控制码,你就可以实现自定义的功能了。函数原型:BOOL WINAPI DeviceIoControl(__inHANDLEhDevice,__inDWORDdwIoControlCode,__in_optLPVOID lpInBuffer,__inDWORDnInBufferSize,__out_optLPVOID lpOutB 阅读全文

设备驱动开发之缓冲区读写操作

2012-05-01 08:48 by java20130722, 207 阅读, 收藏,
摘要: 在驱动程序创建设备对象时,就需要为设备指定何种读写方式。设备对象共有三种读写方式,分别是缓冲区方式读写/直接方式读写/其他方式读写其对应的Flags设置为:DO_BUFFERED_IO/DO_DIRECT_IO/0(零值)。缓冲区读取代码示例: //创建设备 status = IoCreateDevice( pDriverObject, sizeof(DEVICE_EXTENSION), &(UNICODE_STRING)devName, FILE_DEVICE_UNKNOWN, 0, TRUE, &pDevObj ); if (... 阅读全文

INF DestinationDirs Section

2012-04-30 09:05 by java20130722, 421 阅读, 收藏,
摘要: INFDestinationDirsSectionINFDestinationDirsSection格式如下:[DestinationDirs][DefaultDestDir=dirid[,subdir]][file-list-section=dirid[,subdir]]...描述:该域记录了在INF文件的其他域中引用的需要复、删除、重命名的文所在的目录。DefaultDestDir=dirid[,subdir]指定所有需要进行操作的文件默认目录,并且这些目录没有出现的file-list-section域中。file-list-section=dirid[,subdir]]...如果所有的I 阅读全文

INF Manufacturer Section

2012-04-30 09:04 by java20130722, 406 阅读, 收藏,
摘要: INFManufacturerSection[Manufacturer]manufacturer-identifier[manufacturer-identifier][manufacturer-identifier]...描述:ManufacturerSection指定了INF文件安装的设备制造商信息。manufacturer-identifier指定一个设备模型制造商和包含设备模型制造商信息的INF域(INFSection)其格式如下:manufacturer-name|%strkey%=models-section-name|%strkey%=models-section-name[,T 阅读全文

INF Models Section

2012-04-30 09:01 by java20130722, 268 阅读, 收藏,
摘要: INFModelsSection形如:[models-section-name]|[models-section-name.TargetOSVersion](WindowsXPandlaterversionsofWindows)device-description=install-section-name[,hw-id][,compatible-id...][device-description=install-section-name[,hw-id][,compatible-id]...]...Device-description标识要安装的设备。形如:"quotedstring& 阅读全文

INF DDInstall Section

2012-04-30 08:59 by java20130722, 382 阅读, 收藏,
摘要: INFDDInstallSection形如:[install-section-name]|[install-section-name.nt]|[install-section-name.ntx86]|[install-section-name.ntia64]|(WindowsXPandlaterversionsofWindows)[install-section-name.ntamd64](WindowsXPandlaterversionsofWindows)[DriverVer=mm/dd/yyyy[,x.y.v.z]][CopyFiles=@filename|file-list-secti 阅读全文

INF DDInstall.Services Section

2012-04-30 08:58 by java20130722, 290 阅读, 收藏,
摘要: INFDDInstall.ServicesSection[install-section-name.Services]|[install-section-name.nt.Services]|[install-section-name.ntx86.Services]|[install-section-name.ntia64.Services]|(WindowsXPandlaterversionsofWindows)[install-section-name.ntamd64.Services](WindowsXPandlaterversionsofWindows)AddService=Servic 阅读全文

IRP(I/O Request Package)详解

2012-04-28 20:42 by java20130722, 1072 阅读, 收藏,
摘要: 简介:IRP(I/O Request Package)在windows内核中,有一种系统组件——IRP,即输入输出请求包。当上层应用程序需要访问底层输入输出设备时,发出I/O请求,系统会把这些请求转化为IRP数据,不同的IRP会启动I/O设备驱动中对应的派遣函数。IRP类型由于IRP是响应上层应用程序的。可想而知,IRP类型是与上层对底层设备的访问类型相对应。文件相关的I/O函数如:CreateFile/ReadFile/WriteFile/CloseHandle等,操作系统就会将其转为IRP_MJ_CREATE/IRP_MJ_READ/IRP_MJ_WRITE/IRP_MJ_CLOSE等IR 阅读全文

sys文件--查看DbgPrint函数打印的信息

2012-04-28 16:51 by java20130722, 635 阅读, 收藏,
摘要: 环境:XP + VS2008 + WDK工具:DebugView+DriverMonitor查看DbgPrint函数打印的信息只需两步。step1:成功编译出sys文件。step2:打开DriverMonitor和DebugView软件。step3:用DriverMonitor加载对应的sys文件,在DebugView软件就可以查看到对应的DbgPrint 函数打印的信息。PS: 网上一些文章指出要在win7、vista下打印信息要用DbgPrintEx函数。 阅读全文

INF ClassInstall32.Services Section详解

2012-04-27 10:31 by java20130722, 466 阅读, 收藏,
摘要: 原文链接:http://msdn.microsoft.com/en-us/library/windows/hardware/ff546339(v=vs.85).aspx'ClassInstall32.Services Section形如:[ClassInstall32.Services] | [ClassInstall32.nt.Services] | [ClassInstall32.ntx86.Services] | [ClassInstall32.ntia64.Services] | (Windows XP and later versions of Windows) [Class 阅读全文

INF ClassInstall32 Section详解

2012-04-26 22:40 by java20130722, 567 阅读, 收藏,
摘要: 原文链接:http://msdn.microsoft.com/en-us/library/windows/hardware/ff546335(v=vs.85).aspxINF ClassInstall32 Section的形式如下:[ClassInstall32] | [ClassInstall32.nt] | [ClassInstall32.ntx86] | [ClassInstall32.ntia64] | (Windows XP and later versions of Windows) [ClassInstall32.ntamd64] (Windows XP and later .. 阅读全文

INF SourceDisksNames Section 和 SourceDisksFiles Section详解

2012-04-26 17:47 by java20130722, 906 阅读, 收藏,
摘要: INF SourceDisksNames Section[SourceDisksNames] | [SourceDisksNames.x86] | [SourceDisksNames.ia64] | (Windows XP and later versions of Windows) [SourceDisksNames.amd64] (Windows XP and later versions of Windows) diskid = disk-description[,tag-or-cab-file] | diskid = disk-description[,[tag-or-cab-fi.. 阅读全文

INF Version Section详解

2012-04-26 15:37 by java20130722, 593 阅读, 收藏,
摘要: 最近在学习设备驱动程序方面,了解到安装sys文件需要INF文件,边学习边做笔记原文链接:http://msdn.microsoft.com/en-us/library/windows/hardware/ff547502(v=vs.85).aspx[Version] Signature="signature-name" [Class=class-name] [ClassGuid={nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}] [Provider=%INF-creator%] [LayoutFile=filename.inf [,filename 阅读全文

INF文件中的HKR

2012-04-26 09:53 by java20130722, 434 阅读, 收藏,
摘要: 原文链接地址:http://blog.csdn.net/weiwei22844/article/details/6088889最近在学习驱动编程的INF文件格式时,在AddReg等directive中有很多与注册表相关的内容,现总结如下:HKCR代表HKEY_CLASSES_ROOT;HKCU代表HKEY_CURRENT_USER;HKLM代表HKEY_LOCAL_MACHINEHKU代表HKEY_USERS比较麻烦的是HKR,该缩写代表那个注册表键值的缩写呢?通过查询帮助文档可以发现如下解释:(1)在DDInstall section中,HKR缩写表示的是设备的software key(软件 阅读全文

vs2008+WDK环境配置

2012-04-24 10:47 by java20130722, 282 阅读, 收藏,
摘要: 环境:WDK (7600.16385.1版默认安装目录) +WindowsXP + VS2008 其他VS或者Vista/Win7应该都是大同小异的。参考网站:http://www.cnblogs.com/Jesses/articles/1636331.html http://blog.csdn.net/hellward/article/details/5374539需要工具:ddkwizard+ddkbuild_bat+ddkbuild_cmd下面开始具体的步骤:step1:用默认目录安装WDK和ddkwizard,同时把ddkbuild.cmd和ddkbuild... 阅读全文