//创建设备对象
status = IoCreateDevice(pDriver,0,&DeviceName,FILE_DEVICE_UNKNOWN,FILE_DEVICE_SECURE_OPEN,FALSE,&pDeviceObj);
if (status != STATUS_SUCCESS)
{
DbgPrint("创建设备对象失败\r\n");
//If a driver's call to IoCreateDevice returns an error, the driver should release any resources that it allocated for that device.
IoDeleteDevice(pDeviceObj);
return status;
}
//设置交互方式
pDeviceObj->Flags |= DO_BUFFERED_IO;
//创建符号链接
status = IoCreateSymbolicLink(&SymbolLinkName,&DeviceName);
if (status != STATUS_SUCCESS)
{
DbgPrint("创建符号链接失败\r\n");
return STATUS_UNSUCCESSFUL;
}
//删除设备
//This member is automatically updated when the driver calls IoCreateDevice successfully.
//A driver can use this member and the NextDevice member of DEVICE_OBJECT to step through a list of all the device objects that the driver created.
IoDeleteDevice(pDriver->DeviceObject);
DbgPrint("驱动已停止\r\n");
}
//派遣函数:Create
NTSTATUS DispatchCreateFunc(PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status = STATUS_SUCCESS;
DbgPrint("Create Dispatch Function Success\r\n");
//创建设备对象
status = IoCreateDevice(pDriver,0,&DeviceName,FILE_DEVICE_UNKNOWN,FILE_DEVICE_SECURE_OPEN,FALSE,&pDeviceObj);
if (status != STATUS_SUCCESS)
{
DbgPrint("创建设备对象失败\r\n");
//If a driver's call to IoCreateDevice returns an error, the driver should release any resources that it allocated for that device.
IoDeleteDevice(pDeviceObj);
return status;
}
//设置交互方式
pDeviceObj->Flags |= DO_BUFFERED_IO;
//创建符号链接
status = IoCreateSymbolicLink(&SymbolLinkName,&DeviceName);
if (status != STATUS_SUCCESS)
{
DbgPrint("创建符号链接失败\r\n");
return STATUS_UNSUCCESSFUL;
}
//删除设备
//This member is automatically updated when the driver calls IoCreateDevice successfully.
//A driver can use this member and the NextDevice member of DEVICE_OBJECT to step through a list of all the device objects that the driver created.
IoDeleteDevice(pDriver->DeviceObject);
DbgPrint("驱动已停止\r\n");
}
//派遣函数:Create
NTSTATUS DispatchCreateFunc(PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status = STATUS_SUCCESS;
DbgPrint("Create Dispatch Function Success\r\n");