能力值:
( LV2,RANK:10 )
|
-
-
2 楼
1、INITCODE的问题?卸载的时候Unload函数不在内存了把?
2、学驱动我用VS2010+WDK7.6,虚拟机用XP
3、先学32位的,64位是一样的,甚至代码都不用改就能编译成64位驱动。学习和开发64位驱动不用证书,测试模式就行了。
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
解答你后面的问题
网上的免费32位驱动教程多如牛毛,不懂用GOOGLE就去亚马逊买书看
64位免费的驱动教程,目前就这一个http://bbs.pediy.com/showthread.php?t=187348
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
派遣例程都没有正确设置,不蓝屏才怪。
DriverEntry一个重要的工作就是设置
DriverObject->MajorFunction[IRP_MJ_XXXXX]。
|
能力值:
( LV3,RANK:20 )
|
-
-
5 楼
[QUOTE=aait;1287135]派遣例程都没有正确设置,不蓝屏才怪。
DriverEntry一个重要的工作就是设置
DriverObject->MajorFunction[IRP_MJ_XXXXX]。[/QUOTE]
系统有默认的派遣函数,如果不处理的话是可以不设置的。
|
能力值:
( LV5,RANK:75 )
|
-
-
6 楼
有现成的驱动开发的书,比如《寒江独钓》
|
能力值:
( LV5,RANK:70 )
|
-
-
7 楼
平时大家学习驱动的时候用的什么环境呢?
我是VS2012+WDK8
虚拟机是win_X86的还是64的呢? 还是XP的?
我的是WIN7 64位
如果是64位的话,那么证书要怎么解决呢?
破解PG:http://bbs.pediy.com/showthread.php?t=187348 看这个帖子
如果不是64位的,那学完之后是不是没用了? 我的意思是你做的驱动只能在win7_X86或XP上运行,要做64位和win8还要重写代码?
不是学完就没用了,而是之间有少许不同。学习的只是总会有用的。
HelloNTDriver代码(我用的C++写的,微软官方推荐用C写驱动):
#ifdef __cplusplus
extern "C"
{
#endif
#include <ntddk.h>
#ifdef __cplusplus
}
#endif
NTSTATUS HelloNTDDKDispatch (PDRIVER_OBJECT pDeivceObject, PIRP pIrp);
VOID DriverUnload(PDRIVER_OBJECT pDriverObject);
NTSTATUS CreateDevice(PDRIVER_OBJECT pDriverObject);
NTSTATUS CreateDevice2(PDRIVER_OBJECT pDriverObject);
typedef struct _DEVICE_EXTENSION
{
PDEVICE_OBJECT pDevice;
UNICODE_STRING ustrDeviceName;
UNICODE_STRING ustrSymLinkName;
}DEIVCE_EXTENSION, *PDEVICE_ENTENSION;
VOID DumpInformation(PDRIVER_OBJECT pDriverObject)
{
DbgPrint("---------------------------------------------------\n");
DbgPrint("Begin Dump.....\n");
DbgPrint("Driver Address:0X%08X\n",pDriverObject);
DbgPrint("Driver name:%wZ\n",&pDriverObject->DriverName);
DbgPrint("Driver HardwareDatabase:%wZ\n",&pDriverObject->HardwareDatabase);
DbgPrint("Driver first device:0X%08X\n",&pDriverObject->DeviceObject);
PDEVICE_OBJECT pDevice = pDriverObject->DeviceObject;
int i =1;
for (;pDevice!=NULL;pDevice =pDevice->NextDevice)
{
DbgPrint("The %d Device\n",i++);
DbgPrint("Device AttachedDevice:0X%08X\n",pDevice->AttachedDevice);
DbgPrint("Device NextDevice:0X%08X\n",pDevice->NextDevice);
DbgPrint("Device StackSize:%d\n",pDevice->StackSize);
DbgPrint("Device's DriverObject:0X%08X\n",pDevice->DriverObject);
}
DbgPrint("Dump END.....\n");
DbgPrint("---------------------------------------------------\n");
}
extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
{
NTSTATUS status;
__asm int 3;
DbgPrint("DirverEntry...\n");
pDriverObject->DriverUnload = DriverUnload;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = (PDRIVER_DISPATCH)HelloNTDDKDispatch;
pDriverObject->MajorFunction[IRP_MJ_CREATE] = (PDRIVER_DISPATCH)HelloNTDDKDispatch;
pDriverObject->MajorFunction[IRP_MJ_READ] = (PDRIVER_DISPATCH)HelloNTDDKDispatch;
pDriverObject->MajorFunction[IRP_MJ_WRITE] = (PDRIVER_DISPATCH)HelloNTDDKDispatch;
status = CreateDevice(pDriverObject);
status = CreateDevice2(pDriverObject);
DumpInformation(pDriverObject);
DbgPrint("DirverEntry leave...\n");
return status;
}
VOID DriverUnload(PDRIVER_OBJECT pDriverObject)
{
PDEVICE_OBJECT pNextObj;
DbgPrint("Enter DriverUnload\n");
pNextObj = pDriverObject->DeviceObject;
while (pNextObj != NULL)
{
PDEVICE_ENTENSION pDevExt = (PDEVICE_ENTENSION)pNextObj->DeviceExtension;
UNICODE_STRING pLinkName = pDevExt->ustrSymLinkName;
IoDeleteSymbolicLink(&pLinkName);
pNextObj = pNextObj->NextDevice;
IoDeleteDevice(pDevExt->pDevice);
}
}
NTSTATUS HelloNTDDKDispatch (PDRIVER_OBJECT pDeivceObject, PIRP pIrp)
{
DbgPrint("Enter HelloNTDDKDispatch\n");
NTSTATUS status = STATUS_SUCCESS;
pIrp->IoStatus.Status = status;
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp,IO_NO_INCREMENT);
DbgPrint("Leave HelloNTDDKDispatch\n");
return status;
}
NTSTATUS CreateDevice(PDRIVER_OBJECT pDriverObject)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
PDEVICE_ENTENSION pDevExt;
UNICODE_STRING devName;
RtlInitUnicodeString(&devName,L"\\Device\\HelloNTDDK");
status = IoCreateDevice(pDriverObject,sizeof(DEIVCE_EXTENSION),&devName,FILE_DEVICE_UNKNOWN,0,TRUE,&pDevObj);
if (!NT_SUCCESS(status))
{
return status;
}
pDevObj->Flags |= DO_BUFFERED_IO;
pDevExt = (PDEVICE_ENTENSION)pDevObj->DeviceExtension;
pDevExt->pDevice = pDevObj;
pDevExt->ustrDeviceName = devName;
UNICODE_STRING symLinkName;
RtlInitUnicodeString(&symLinkName,L"\\??\\HelloNTDDK");
pDevExt->ustrSymLinkName = symLinkName;
status = IoCreateSymbolicLink(&symLinkName,&devName);
if (!NT_SUCCESS(status))
{
IoDeleteDevice(pDevObj);
return status;
}
return STATUS_SUCCESS;
}
NTSTATUS CreateDevice2(PDRIVER_OBJECT pDriverObject)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
PDEVICE_ENTENSION pDevExt;
UNICODE_STRING devName;
RtlInitUnicodeString(&devName,L"\\Device\\HelloNTDDK2");
status = IoCreateDevice(pDriverObject,sizeof(DEIVCE_EXTENSION),&devName,FILE_DEVICE_UNKNOWN,0,TRUE,&pDevObj);
if (!NT_SUCCESS(status))
{
return status;
}
pDevObj->Flags |= DO_BUFFERED_IO;
pDevExt = (PDEVICE_ENTENSION)pDevObj->DeviceExtension;
pDevExt->pDevice = pDevObj;
pDevExt->ustrDeviceName = devName;
UNICODE_STRING symLinkName;
RtlInitUnicodeString(&symLinkName,L"\\??\\HelloNTDDK2");
pDevExt->ustrSymLinkName = symLinkName;
status = IoCreateSymbolicLink(&symLinkName,&devName);
if (!NT_SUCCESS(status))
{
IoDeleteDevice(pDevObj);
return status;
}
return STATUS_SUCCESS;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
8 楼
我也来看看各大牛的答案
|