驱动程序测试问题
作者:网络转载 发布时间:[ 2014/1/24 9:12:35 ] 推荐标签:驱动程序 测试
为什么我的测试程序测试不成功?
测试程序的CreateFile的返回值-1, GetLastError 错误码是123(文件名、目录名或卷标语法不正确。)
我的驱动程序加载后用winObj是可以查看到FirstDevice的 ,测试程序运行时是失败 ???
代码:
驱动程序:
#include "ntddk.h"
NTSTATUS CreateDevice(PDRIVER_OBJECT pDriverObject);
NTSTATUS CreateComplateRoutine(PDEVICE_OBJECT pDeviceObj, PIRP pIrp);
NTSTATUS ReadComplateRoutine(PDEVICE_OBJECT pDeviceObj, PIRP pIrp);
NTSTATUS WriteComplateRoutine(PDEVICE_OBJECT pDeviceObj, PIRP pIrp);
NTSTATUS CloseComplateRoutine(PDEVICE_OBJECT pDeviceObj, PIRP pIrp);
VOID MyDriverUnoad(PDRIVER_OBJECT pDriverObject);
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject,PUNICODE_STRING pRegistryPath)
{
NTSTATUS status;
status = CreateDevice(pDriverObject);
KdPrint(("CreateDevice."));
if (!NT_SUCCESS(status))
{
KdPrint(("Create device faild."));
}
else
{
KdPrint(("Create device success."));
KdPrint(("%wZ", pRegistryPath));
}
pDriverObject->MajorFunction[IRP_MJ_CREATE] = CreateComplateRoutine;
pDriverObject->MajorFunction[IRP_MJ_READ] = ReadComplateRoutine;
pDriverObject->MajorFunction[IRP_MJ_WRITE] = WriteComplateRoutine;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = CloseComplateRoutine;
pDriverObject->DriverUnload = MyDriverUnoad;
return STATUS_SUCCESS;
}
NTSTATUS CreateDevice(PDRIVER_OBJECT pDriverObject)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
UNICODE_STRING usDevName;
UNICODE_STRING usSymName;
RtlInitUnicodeString(&usDevName, L"\Device\FirstDevice");
RtlInitUnicodeString(&usSymName, L"\??\FirstDevice");;
status = IoCreateDevice(pDriverObject,
0,
&usDevName,
FILE_DEVICE_UNKNOWN,
0,
TRUE,
&pDevObj);
pDevObj->Flags |= DO_BUFFERED_IO;
if (!NT_SUCCESS(status))
{
KdPrint(("IoCreateDevice faild."));
return status;
}
status = IoCreateSymbolicLink(&usSymName, &usDevName);
if (!NT_SUCCESS(status))
{
KdPrint(("IoCreateSymbolicLink faild."));
IoDeleteDevice(pDevObj);
return status;
}
return STATUS_SUCCESS;
}
NTSTATUS CreateComplateRoutine (PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status;
status = STATUS_SUCCESS;
KdPrint(("Create"));
pIrp->IoStatus.Status = status;
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return status;
}
NTSTATUS ReadComplateRoutine (PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status;
status = STATUS_SUCCESS;
return status;
}
NTSTATUS WriteComplateRoutine (PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status;
status = STATUS_SUCCESS;
return status;
}
NTSTATUS CloseComplateRoutine (PDEVICE_OBJECT pDeviceObj, PIRP pIrp)
{
NTSTATUS status;
status = STATUS_SUCCESS;
return status;
}
VOID MyDriverUnoad(PDRIVER_OBJECT pDriverObject)
{
UNICODE_STRING usSymName;
RtlInitUnicodeString(&usSymName, L"\??\FirstDevice");
if (pDriverObject->DeviceObject != NULL)
{
IoDeleteSymbolicLink(&usSymName);
IoDeleteDevice(pDriverObject->DeviceObject);
KdPrint(("Delete device success!"));
}
}
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11