problems with calling IoCreateDevice in a dispatch routine

Discussion in 'Windows Vista Drivers' started by troymclure__, Jan 23, 2007.

  1. troymclure__

    troymclure__ Guest

    I have to create a new device inside a DispatchWrite routine. I know ,
    correct me if im wrong, that i just have to create the device just like
    i do in the DriverEntry function,but i just have to take care of the
    IO_DEVICE_INITIALIZING bit flag. I do this, but very strange things
    happen to me. at run time IoCreateDevice returns STATUS_SUCCESS, and
    IoCreateSymbolicLink returns STATUS_SUCCESS too. But when i go to see
    what Device name and what symbolic name exists in the system, i find
    out there is just the device name, and not the symbolic name. very
    strange, couse infact IoCreateSymbolicLink returns success.
    I copy and paste my code here... I would really appreciate if someone
    can take a look and find the way to help a poor student with a teacher
    who thinks developing device drivers is easy :)

    //this code is inside a myDispatchWrite routine

    NTSTATUS status;

    // Form the internal Device Name
    CUString devName("\\Device\\MyDevice");//this is just a class of W2000
    device drivers books, is a class 4 unicode with overloaded operators

    status =
    IoCreateDevice( pDriverObject,//someone gives u pDriverObject
    &(UNICODE_STRING)devName, //another overloaded operator of CUString,
    the unicode class of W2000 DD book
    0, TRUE,
    &pDevObj );
    if (!NT_SUCCESS(status))
    return status;

    // Initialize the Device Extension code dont do much and is missing

    pDevObj->Flags |= DO_BUFFERED_IO ; //i wanna do buffered io
    // i dont set up the DEVICE_OBJECT::Stack field, is it correct?

    // Form the symbolic link name
    CUString symLinkName("\\??\\MyDEV");

    // Now create the link name
    status =
    IoCreateSymbolicLink( &(UNICODE_STRING)symLinkName,
    &(UNICODE_STRING)devName );
    if (!NT_SUCCESS(status)) {
    // if it fails now, must delete Device object
    IoDeleteDevice( pDevObj );
    return status;

    pDevObj->Flags &= ~DO_DEVICE_INITIALIZING;// i tell to Io Manger i
    finished with the device initialization

    return STATUS_SUCCESS;


    the code is this... It executes... IoCreateDevice and
    IoCreateSymbolicLink return STATUS_PERFECT_WONDELFUL_SUCCESS , but when
    i launch my WinObj to c if there are the device name and the symbolic
    name, the device name there is, the symbolic no... I dont think the
    problem is in WinObj....
    troymclure__, Jan 23, 2007
    1. Advertisements

  2. troymclure__

    Don Burn Guest

    Well you might want to try a symlink name of "\\DosDevices\\MyDev" since
    that is the convention for in the kernel. If that doesn't work dump the
    C++ crap, since it is likely something in there.
    Don Burn, Jan 23, 2007
    1. Advertisements

  3. Is it possible that the symlink gets created in the wrong namespace, i.e. in
    the namespace of the current session, instead of the global namespace?

    I would probably check with winobj (or similar tool) to see if the symlink
    has been created under \\sessions\SOMETHING instead of \\global\.

    Hope it helps
    Gianluca Varenni, Jan 23, 2007
  4. Since the dispatch routine is running in the context of the user process,
    the symbolic link you are creating ends up in the local session space of the
    process. If you want the symbolic link to be visible to all the users then
    you should create it in the global name by using \GLOBAL??\ prefix instead
    of \??\.

    So change your code from:

    CUString symLinkName("\\??\\MyDEV");

    to this and you will be set:

    CUString symLinkName("\\GLOBAL??\\MyDEV");

    Eliyas Yakub [MSFT], Jan 23, 2007
  5. troymclure__

    troymclure__ Guest

    Thanks a lot Aliyas (and Gianluca too) ... the problem was exactly

    4 Gianluca... im italian too... but u do drivers 4 fun , or 4 job?...
    and if it is for job, how do u c the career of drivers developer in
    Italy? couse i (relatively) like developing device drivers , but im not
    sure in Italy i can find such a job...
    troymclure__, Jan 24, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.