阅读:1147回复:3
DeviceIoControl问题
驱动:
RtlInitUnicodeString(&FilDevName,L"\\Device\\TdiFilter"); RtlInitUnicodeString(&FilDevLink,L"\\DosDevices\\TdiFilter"); //Create Device status = IoCreateDevice(pDriObj,0,NULL,FILE_DEVICE_UNKNOWN,0,TRUE,&g_DevObj); //Create SymbolicLink status = IoCreateSymbolicLink(&FilDevLink,&FilDevName); 应用程序: hFile = CreateFile("\\\\.\\TdiFilter",GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); 怎么hFIle总是INVALID_HANDLE_VALUE |
|
沙发#
发布于:2007-08-30 11:25
你在驱动里面要处理CDO的CREATE,CLOSE,CLEANUP函数
|
|
板凳#
发布于:2007-08-30 11:27
DriverEntry
{ 。。。 DriverObject->MajorFunction[IRP_MJ_CREATE] = FsDeviceCreate; DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsDeviceClose; DriverObject->MajorFunction[IRP_MJ_CLEANUP] = FsDeviceClose; } NTSTATUS FsDeviceCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation (Irp); if (g_CDO == DeviceObject) { KdPrint(("CDO Created!\n")); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } return SfPassThrough(DeviceObject, Irp); } NTSTATUS FsDeviceClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { if (g_CDO == DeviceObject) { KdPrint(("CDO Closed!\n")); Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } return SfPassThrough(DeviceObject, Irp); } NTSTATUS SfPassThrough(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation(Irp); //不处理 //ASSERT(IS_MY_DEVICE_OBJECT(DeviceObject)); if (g_CDO == DeviceObject) { KdPrint((("ERROR CDO:[%08x]\n"), irpSp->MajorFunction, irpSp->MinorFunction)); //_asm int 3; Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_INVALID_DEVICE_REQUEST; } IoSkipCurrentIrpStackLocation(Irp); return IoCallDriver(((PDEVICE_EXTENSION)DeviceObject->DeviceExtension)->AttachedToDevice, Irp); } |
|
地板#
发布于:2007-08-30 17:23
RtlInitUnicodeString(&FilDevLink,L"\\DosDevices\\TdiFilter");这句改成RtlInitUnicodeString(&FilDevLink,L"\\??\\TdiFilter"); 再试试
|
|