2000下如何写驱动

I_Love_Soft 2002-08-05 12:02:24
2000下如何写驱动
...全文
33 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
SessionEnum 2002-08-05
  • 打赏
  • 举报
回复
// 驱动入口
NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath )
{
UNICODE_STRING nameString, linkString;
PDEVICE_OBJECT deviceObject;
NTSTATUS status;
WCHAR wBuffer[200];

nameString.Buffer = wBuffer;
nameString.MaximumLength = 200;

//卸载驱动
DriverObject->DriverUnload = DriverUnload;

//建立设备
RtlInitUnicodeString( &nameString, L"\\Device\\DRIVE" );

status = IoCreateDevice( DriverObject,
0,
&nameString,
FILE_DEVICE_UNKNOWN,
0,
TRUE,
&deviceObject
);


if (!NT_SUCCESS( status ))
return status;

RtlInitUnicodeString( &linkString, L"\\??\\MYDRIVE" );

//使WIN32应用程序可见
status = IoCreateSymbolicLink (&linkString, &nameString);

if (!NT_SUCCESS( status ))
{
IoDeleteDevice (DriverObject->DeviceObject);
return status;
}

//初始化功能代码所对应 Dispatch 例程调用

DriverObject->MajorFunction[IRP_MJ_CREATE] = MydrvDispatch; // CreateFile 调用
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MydrvDispatch; // CloseHandle 调用
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = MydrvDispatchIoctl; //DeviceIoControl 调用

return STATUS_SUCCESS;
}

6,849

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧