資源簡介
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?ject->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.em
?????文件????????472??2007-05-04?15:15??PCItest1\Test1\NT_Driver\Test\Debug\Test.exe.em
?????文件????????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個文件信息
評論
共有 條評論