阅读:4044回复:5
帮忙阿 CreateFile返回 ERROR_INVALID_FUNCTION(Incorrect function)错误
各位大牛,
我的文件过滤驱动里面使用如下代码创建了设备和连接符,但在应用程序中无法打开这个设备来发送IOCTL阿,我查过说要初实现IRP_MJ_CREATE和IRP_MJ_CLOSE例程,否则就会报这个错。我的都实现了阿,还请牛人指点 #define DRIVER_DEVICE_NAME L"HFsFilter0" #define DRIVER_NAME L"HFsFileMonitor" #define DEVICE_NAME_XP L"\\FileSystem\\Filters\\"##DRIVER_DEVICE_NAME #define DEVICE_NAME_2K L"\\FileSystem\\"##DRIVER_DEVICE_NAME #define DOS_DEV_NAME L"\\DosDevices\\"##DRIVER_NAME 结果在调用CreateFile准备过滤驱动设备时就返回了 ERROR_INVALID_FUNCTION(Incorrect function)错误。 |
|
沙发#
发布于:2009-09-17 03:15
Where is your MJ_CREATE dispatch routine?
|
|
板凳#
发布于:2009-09-17 14:49
Thanks!
我的Create派发例程代码如下: 有不对之处还请指出阿 NTSTATUS HFsCreate( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { PSFILTER_DEVICE_EXTENSION DevExt = (PSFILTER_DEVICE_EXTENSION) DeviceObject->DeviceExtension; PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PFILE_OBJECT FileObject = IrpSp->FileObject; PWSTR FileName = NULL; PFILE_CONTEXT FileCtxPtr = NULL; BOOLEAN DeleteOnClose = (BOOLEAN) (IrpSp->Parameters.Create.Options & FILE_DELETE_ON_CLOSE); NTSTATUS Status = STATUS_SUCCESS; NTSTATUS LocalStatus = STATUS_SUCCESS; ULONG ulBusType = BusTypeUnknown; PAGED_CODE(); .................... } |
|
地板#
发布于:2009-09-17 23:52
Your MJ_CREATE routine is a mess. You'd better rewrite it.
For your own control device, you should complete it with STATUS_SUCCESS. |
|
地下室#
发布于:2009-09-18 09:48
回 3楼(michaelgz) 的帖子
谢谢michaelgz 指点,我验证了,问题确实是Create例程所致。不胜感激! |
|
5楼#
发布于:2009-09-18 09:50
我直接用了SFilter源码的例程来做的,结果他的Create里面本来就有问题。
|
|