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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. cmd.exe bug / GetFileType from kernel mode

cmd.exe bug / GetFileType from kernel mode

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++sysadminhelptutorial
1 Posts 1 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
    Mike_V
    wrote on last edited by
    #1

    Okay... this question feels out of place in this forum, but it doesn't fit in OS/SysAdmin as that is more of the usage side - not the programming side. Given my driver is in C++, I figure this is as good a place as any. That out of the way, I found a bug (handle leak) in cmd.exe: I'm writing a device driver that I want to be able to write stuff to via the command prompt redirection. For example, typing

    echo Hello there > \\.\MyDevice

    Should send the string "Hello there" to the MyDevice device. Unfortunately it does not work. Cmd opens the handle to my device, but never writes to it or closes it! So until I exit cmd, my driver cannot be unloaded. Some debugging indicates that cmd opens my device with CreateFile, which succeeds, then calls GetFileType, and since it is not a file or network file, it cancels the redirection operation, forgetting to close the original handle. So now for the real question: Does anybody happen to know how GetFileType is implemented in kernel mode (ie. if there's a field of the FILE_OBJECT I can set to get GetFileType to work properly? Or is there any way to register something like lpt1 which is a device that cmd can write to? Thanks, Mike

    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