资源简介

PCI配置寄存器读写Winows驱动及测试用应用程序,参见博客http://blog.csdn.net/li171049/article/details/17655065

资源截图

代码片段和文件信息

/************************************************************************
* 文件名称:Driver.cpp                                                 
* 作    者:张帆
* 完成日期:2007-11-1
*************************************************************************/

#include “Driver.h“

/************************************************************************
* 函数名称:DriverEntry
* 功能描述:初始化驱动程序,定位和申请硬件资源,创建内核对象
* 参数列表:
      pDriverobject:从I/O管理器中传进来的驱动对象
      pRegistryPath:驱动程序在注册表的中的路径
* 返回 值:返回初始化驱动状态
*************************************************************************/
#pragma INITCODE
extern “C“ NTSTATUS DriverEntry (
IN PDRIVER_object pDriverobject
IN PUNICODE_STRING pRegistryPath ) 
{
NTSTATUS status;
KdPrint((“Enter DriverEntry\n“));

//设置卸载函数
pDriverobject->DriverUnload = HelloDDKUnload;

//设置派遣函数
for (int i = 0; i < arraysize(pDriverobject->MajorFunction); ++i)
pDriverobject->MajorFunction[i] = HelloDDKDispatchRoutin;

pDriverobject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HelloDDKDeviceIOControl;

//创建驱动设备对象
status = CreateDevice(pDriverobject);

KdPrint((“Leave DriverEntry\n“));
return status;
}

/************************************************************************
* 函数名称:CreateDevice
* 功能描述:初始化设备对象
* 参数列表:
      pDriverobject:从I/O管理器中传进来的驱动对象
* 返回 值:返回初始化状态
*************************************************************************/
#pragma INITCODE
NTSTATUS CreateDevice (
IN PDRIVER_object pDriverobject) 
{
NTSTATUS status;
PDEVICE_object pDevObj;
PDEVICE_EXTENSION pDevExt;

//创建设备名称
UNICODE_STRING devName;
RtlInitUnicodeString(&devNameL“\\Device\\MyDDKDevice“);

//创建设备
status = IoCreateDevice( pDriverobject
sizeof(DEVICE_EXTENSION)
&(UNICODE_STRING)devName
FILE_DEVICE_UNKNOWN
0 TRUE
&pDevObj );
if (!NT_SUCCESS(status))
return status;

pDevObj->Flags |= DO_DIRECT_IO;
pDevExt = (PDEVICE_EXTENSION)pDevObj->DeviceExtension;
pDevExt->pDevice = pDevObj;
pDevExt->ustrDeviceName = devName;

//申请模拟文件的缓冲区
pDevExt->buffer = (PUCHAR)ExAllocatePool(PagedPoolMAX_FILE_LENGTH);
//设置模拟文件大小
pDevExt->file_length = 0;

//创建符号链接
UNICODE_STRING symlinkName;
RtlInitUnicodeString(&symlinkNameL“\\??\\HelloDDK“);
pDevExt->ustrSymlinkName = symlinkName;
status = IoCreateSymboliclink( &symlinkName&devName );
if (!NT_SUCCESS(status)) 
{
IoDeleteDevice( pDevObj );
return status;
}
return STATUS_SUCCESS;
}

/************************************************************************
* 函数名称:HelloDDKUnload
* 功能描述:负责驱动程序的卸载操作
* 参数列表:
      pDriverobject:驱动对象
* 返回 值:返回状态
*************************************************************************/
#pragma PAGEDCODE
VOID HelloDDKUnload (IN PDRIVER_object pDriverobject) 
{
PDEVICE_object pNextObj;
KdPrint((“Enter DriverUnload\n“));
pNextObj = pDriverobject->Deviceobject;
while (pNextObj != NULL) 
{
PDEVICE_EXTENSION pDevExt = (PDEVI

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    4820330  2007-05-06 15:13  PCItest1\i-o-controller-hub-7-datasheet.pdf

     文件       7838  2008-03-12 10:38  PCItest1\Test1\NT_Driver\NT_Driver\Driver.cpp

     文件       1272  2008-01-23 16:02  PCItest1\Test1\NT_Driver\NT_Driver\Driver.h

     文件       2874  2013-05-07 21:43  PCItest1\Test1\NT_Driver\NT_Driver\DriverDev.dsp

     文件       1728  2013-05-07 21:20  PCItest1\Test1\NT_Driver\NT_Driver\DriverDev.plg

     文件       3706  2007-05-04 15:14  PCItest1\Test1\NT_Driver\NT_Driver\DriverDev.vcproj

     文件        826  2007-05-06 18:31  PCItest1\Test1\NT_Driver\NT_Driver\DriverDev.vcproj.Z6WIAPNOV98W4WH.Administrator.user

     文件        499  2008-03-06 13:54  PCItest1\Test1\NT_Driver\NT_Driver\Ioctls.h

     文件       4686  2007-05-05 19:46  PCItest1\Test1\NT_Driver\NT_Driver\MyDriver_Check\BuildLog.htm

     文件      25600  2013-05-07 21:20  PCItest1\Test1\NT_Driver\NT_Driver\MyDriver_Check\vc60.idb

     文件      11264  2007-05-05 19:46  PCItest1\Test1\NT_Driver\NT_Driver\MyDriver_Check\vc90.idb

     文件        833  2008-01-23 15:37  PCItest1\Test1\NT_Driver\NT_Driver.dsw

     文件      58368  2013-12-27 15:59  PCItest1\Test1\NT_Driver\NT_Driver.ncb

     文件          0  2007-05-06 18:31  PCItest1\Test1\NT_Driver\NT_Driver.ncb (Can‘t open)

     文件      54784  2013-12-27 15:59  PCItest1\Test1\NT_Driver\NT_Driver.opt

     文件       1999  2007-05-04 15:14  PCItest1\Test1\NT_Driver\NT_Driver.sln

     文件      60928  2007-05-06 18:31  PCItest1\Test1\NT_Driver\NT_Driver.suo

     文件       6906  2007-05-06 18:15  PCItest1\Test1\NT_Driver\Test\Debug\BuildLog.htm

     文件      10021  2013-05-07 21:07  PCItest1\Test1\NT_Driver\Test\Debug\function.obj

     文件      19826  2013-05-07 21:42  PCItest1\Test1\NT_Driver\Test\Debug\main.obj

     文件         69  2007-05-06 18:15  PCItest1\Test1\NT_Driver\Test\Debug\mt.dep

     文件        406  2007-05-04 15:15  PCItest1\Test1\NT_Driver\Test\Debug\Test.exe.embed.manifest

     文件        472  2007-05-04 15:15  PCItest1\Test1\NT_Driver\Test\Debug\Test.exe.embed.manifest.res

     文件        381  2007-05-06 18:15  PCItest1\Test1\NT_Driver\Test\Debug\Test.exe.intermediate.manifest

     文件     188920  2013-05-07 21:42  PCItest1\Test1\NT_Driver\Test\Debug\Test.ilk

     文件    3658444  2013-05-07 21:07  PCItest1\Test1\NT_Driver\Test\Debug\Test.pch

     文件     435200  2013-05-07 21:42  PCItest1\Test1\NT_Driver\Test\Debug\Test.pdb

     文件     140288  2013-05-07 21:42  PCItest1\Test1\NT_Driver\Test\Debug\vc60.idb

     文件      86016  2013-05-07 21:42  PCItest1\Test1\NT_Driver\Test\Debug\vc60.pdb

     文件     453632  2007-05-06 18:15  PCItest1\Test1\NT_Driver\Test\Debug\vc90.idb

............此处省略54个文件信息

评论

共有 条评论