文件系统过滤器驱动程序 [英] File System Filter driver
问题描述
大家好,
我使用了属于"Sergey Podobry"的文件系统过滤器驱动程序示例,
并且我想使用"DeviceIoControl"将一些数据从驱动程序发送到我的应用程序.
实际上,我以正确的方式处理了设备对象,但是当我调用"DeviceIoControl"时,我得到了蓝屏.
这是我所做的.
Hi all,
i used File System Filter driver example which belong''s to "Sergey Podobry"
and i want to send some data from driver to my application using "DeviceIoControl".
Actually i got handle to the device object in right way ,but when i call "DeviceIoControl" i got blue screen .
Here what i have done.
//g_PDeviceObject global pointer to Device object
NTSTATUS FsFilterDispatchControl(
__in PDEVICE_OBJECT DeviceObject,
__in PIRP Irp
)
{
PIO_STACK_LOCATION ioStack = IoGetCurrentIrpStackLocation(Irp);
ULONG operation;
NTSTATUS status=STATUS_SUCCESS;
if(DeviceObject==g_PDeviceObject)
{
operation = ioStack->Parameters.DeviceIoControl.IoControlCode;
switch (operation)
{
case IOCTL_OPEN_EVENT:
DbgPrint("IOCTL_OPEN_EVENT \n");
break;
default:
status=STATUS_INVALID_DEVICE_REQUEST;
break;
}
Irp->IoStatus.Status = status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return status;
}
else
{
return FsFilterDispatchPassThrough(DeviceObject, Irp);
}
}
在用户模式下应用程序:
In user mode Application :
DeviceDriver = CreateFile(
\\\\.\\example, // lpFileName
GENERIC_READ | GENERIC_WRITE, // dwDesiredAccess
FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
NULL, // lpSecurityAttributes
OPEN_EXISTING, // dwCreationDistribution
0, // dwFlagsAndAttributes
NULL // hTemplateFile
);
if (DeviceDriver == INVALID_HANDLE_VALUE) {
printf("Unable to open handle to the device driver\n");
return 1;
}
//
// Send an IOCTL to the driver to signal that the named event
// has been created and that it can now open a handle to it
//
if (!DeviceIoControl(DeviceDriver,
IOCTL_OPEN_EVENT,
NULL,0,
NULL,0 ,
&bytesReturned,
NULL)) {
printf("The driver failed to open the named event!\n");
return 1;
}
printf("you have successfully called the device !\n");
CloseHandle(DeviceDriver);
在驱动程序条目中:
In Driver Entry :
RtlInitUnicodeString(&usDriverName, L"\\Device\\example");
RtlInitUnicodeString(&usDosDeviceName, L"\\DosDevices\\example");
//Create device object
NtStatus = IoCreateDevice (
DriverObject,
0,
&usDriverName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&g_PDeviceObject
);
//create symbolic link
NtStatus=IoCreateSymbolicLink(&usDosDeviceName, &usDriverName);
if(!NT_SUCCESS(NtStatus))
{
return NtStatus;
}
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = FsFilterDispatchControl;
VOID FsFilterUnload(
__in PDRIVER_OBJECT DriverObject
)
{
UNICODE_STRING usDosDeviceName;
RtlInitUnicodeString(&usDosDeviceName, L"\\DosDevices\\example");
IoDeleteSymbolicLink(&usDosDeviceName);
IoDeleteDevice(g_PDeviceObject);
}
最后,我发布的只是我对文件系统筛选器驱动程序所做的更改.
请帮我,我不知道为什么我在调用"DeviceIoControl"时会出现蓝屏.
finally,what i posted is only the changes i have made on the file system filter driver .
please , help me i don''t know why i got blue screen during calling "DeviceIoControl".
推荐答案
请提供故障转储分析,以便我们为您解决您的问题可以通过获取故障转储并使用win调试进行分析来解决.
please provide a crash dump analysis so we can help you solve your problem this can be done by getting a crash dump and analyzing it with win debug.
这篇关于文件系统过滤器驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!