Добрый день!
есть код
NTSTATUS FileSysmetFilterDriverRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
UNICODE_STRING DeviceName,Win32Device;
PDEVICE_OBJECT DeviceObject = NULL;
NTSTATUS status;
unsigned i;
DbgPrint("DriverEntry\n");
RtlInitUnicodeString(&DeviceName,L"\\Device\\FileSysmetFilterDriver0");
RtlInitUnicodeString(&Win32Device,L"\\DosDevices\\FileSysmetFilterDriver0");
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
DriverObject->MajorFunction[i] = FileSysmetFilterDriverDefaultHandler;
DriverObject->MajorFunction[IRP_MJ_CREATE] = FileSysmetFilterDriverCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = FileSysmetFilterDriverCreateClose;
DriverObject->MajorFunction[IRP_MJ_READ] = FileSysmetFilterDriverRead;
DriverObject->DriverUnload = FileSysmetFilterDriverUnload;
status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(status))
return status;
if (!DeviceObject)
return STATUS_UNEXPECTED_IO_ERROR;
DeviceObject->Flags |= DO_DIRECT_IO;
DeviceObject->AlignmentRequirement = FILE_WORD_ALIGNMENT;
status = IoCreateSymbolicLink(&Win32Device, &DeviceName);
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
DbgPrint("DbgPrint: Hello, world!\n");
DbgPrintEx(DPFLTR_IHVVIDEO_ID, DPFLTR_INFO_LEVEL, "DbgPrintEx: Hello, world!\n");
return STATUS_SUCCESS;
}
...
NTSTATUS FileSysmetFilterDriverRead(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
PFSFILTER_DEVICE_EXTENSION pDevExt = (PFSFILTER_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
DbgPrint("Read callback\n");
DbgPrintEx(DPFLTR_IHVVIDEO_ID, DPFLTR_INFO_LEVEL, "DbgPrintEx: Read\n");
return IoCallDriver(pDevExt->AttachedToDeviceObject, Irp);
}
я вижу трэйсы DriverEntry, но не вижу "Read callback".
что не так?
в другом примере — все нормально отрабатывает
NTSTATUS DriverEntry(
__inout PDRIVER_OBJECT DriverObject, //объект драйвера, содержит указатели на все необходимые операционной системе функции, которые мы должны будем инициализировать.
__in PUNICODE_STRING RegistryPath //имя раздела в реестре, где хранится информация о данном драйвере.
)
{
NTSTATUS status = STATUS_SUCCESS;
ULONG i = 0;
DbgPrint("FsFilter file driver loaded successfully\n");
DbgPrint("RegistryPath = %s\n", RegistryPath);
//ASSERT(FALSE); // This will break to debugger
//
// Store our driver object.
//
g_fsFilterDriverObject = DriverObject;
//
// Initialize the driver object dispatch table.
//
for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; ++i)
{
DriverObject->MajorFunction[i] = FsFilterDispatchPassThrough;
}
DbgPrint("IRP_MJ_MAXIMUM_FUNCTION = %d\n", IRP_MJ_MAXIMUM_FUNCTION);
DriverObject->MajorFunction[IRP_MJ_CREATE] = FsFilterDispatchCreate;
DriverObject->MajorFunction[IRP_MJ_READ] = DispatchRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = DispatchWrite;
DbgPrint("IRP_MJ_READ method override\n");
//
// Set fast-io dispatch table.
//
DriverObject->FastIoDispatch = &g_fastIoDispatch;
//
// Registered callback routine for file system changes.
//
status = IoRegisterFsRegistrationChange(DriverObject, FsFilterNotificationCallback);
if (!NT_SUCCESS(status))
{
return status;
}
//
// Set driver unload routine (debug purpose only).
//
DriverObject->DriverUnload = FsFilterUnload;
return STATUS_SUCCESS;
}
...
NTSTATUS DispatchRead//(IN PDEVICE_OBJECT pDeviceObject, IN PIRP theIrp)
(
__in PDEVICE_OBJECT DeviceObject,
__in PIRP Irp
)
{
PFSFILTER_DEVICE_EXTENSION pDevExt = (PFSFILTER_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
//DbgPrint("DispatchRead. pFileObject->Parameters.Read.Length = %d\n", BufLen);
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(pDevExt->AttachedToDeviceObject, Irp);
}
и я вижу "DispatchRead. pFileObject->Parameters.Read.Length = "
Что я не так указываю в первом DriverEntry?
Спасибо!