首页 > 学院 > 开发设计 > 正文

驱动框架

2019-11-14 10:39:56
字体:
来源:转载
供稿:网友
#include "ntddk.h"VOID MyDriverUnLoad(PDRIVER_OBJECT pDriverObject) { UNICODE_STRING usSymName; RtlInitUnicodeString(&usSymName,L"//??//FirstDevice"); if(pDriverObject->DeviceObject!=NULL) { IoDeleteSymbolicLink(&usSymName); IoDeleteDevice(pDriverObject->DeviceObject); KdPRint(("delete device success")); } }NTSTATUS CreateDevice(PDRIVER_OBJECT pDriverObject) { NTSTATUS Status; PDEVICE_OBJECT pDevObj; UNICODE_STRING usDevName;//type error bluescreen UNICODE_STRING usSymName; RtlInitUnicodeString(&usDevName,L"//Device//FirstDevice"); Status = IoCreateDevice(pDriverObject,0,&usDevName,FILE_DEVICE_UNKNOWN,0,TRUE,&pDevObj); if(!NT_SUCCESS(Status)) { return Status; } pDevObj->Flags |= DO_BUFFERED_IO; RtlInitUnicodeString(&usSymName,L"//??//FirstDevice"); Status = IoCreateSymbolicLink(&usSymName,&usDevName); if(!NT_SUCCESS(Status)) { IoDeleteDevice(pDevObj); return Status; } return STATUS_SUCCESS; }NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject,PUNICODE_STRING pRegistryPath) { NTSTATUS Status; Status = CreateDevice(pDriverObject); if (!NT_SUCCESS(Status)) { KdPrint(("create device failed")); } else { KdPrint(("create device successed")); KdPrint(("%wZ",pRegistryPath)); } pDriverObject->DriverUnload = MyDriverUnLoad; return STATUS_SUCCESS; }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表