Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Just a minor KMDF concern

Just a minor KMDF concern

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingarchitecturehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mattzimmerer
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • M Mattzimmerer

      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

      J Offline
      J Offline
      JudyL_MD
      wrote on last edited by
      #2

      You might try asking this in the "Hardware and Devices" forum. What type of driver have you declared yourself to be? A good thing to do is to get the tools from OSR Online, especially the IRP viewer. Very good!! Judy

      Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups