المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Just a minor KMDF concern



C++ Programming
12-31-2009, 07:41 PM
I' m trying to get a solid grasp on the whole KMDF. The reason for the following doesn't jump out at me immediately, can anyone explain?

When my input program sends the writefile IRP through WriteFile, my driver seems to receive 4 different IRP, 3 of which are unused. Should I be concerned about this? What exactly is happening?

Ohh and while im here, what should I do about the __drv_dispatchType(IRP_MJ_UNUSED) line before my mem_Unused declaration? I just made up IRP_MJ_UNUSED...


DRIVER SRC: (snippet)

DRIVER_INITIALIZE DriverEntry;
DRIVER_UNLOAD DriverUnload;
__drv_dispatchType(IRP_MJ_UNUSED) DRIVER_DISPATCH mem_Unused;
__drv_dispatchType(IRP_MJ_WRITE) DRIVER_DISPATCH mem_Write;


NTSTATUS mem_Write(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
DbgPrint("Write IRP Received\n");
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT );
return STATUS_SUCCESS;
}

NTSTATUS mem_Unused(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp )
{
DbgPrint("Un-used IRP Received\n");
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT );
return STATUS_NOT_SUPPORTED;
}


INTERFACE INPUT: (snippet)

hFile = CreateFile(L"\\\\.\\Meminterface", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

if ( hFile == INVALID_HANDLE_VALUE )
{
printf("FAILED, last error:%i\n",GetLastError());
}
else
{
WriteFile(hFile, "Hello from user mode!", sizeof("Hello from user mode!"), &dwReturn, NULL);

DEBUG OUTPUT:

Un-used IRP Received
Write IRP Received
Un-used IRP Received
Un-used IRP Received