order of calling IoCreateDevice and IoRegisterDeviceInterface?

Discussion in 'Windows Vista Drivers' started by M Taha Masood, Feb 5, 2005.

  1. Hi ,
    The MSDN topic at
    http://msdn.microsoft.com/library/d..._f439d4d3-234f-4952-ab5a-a14899fbe5f3.xml.asp

    suggests that first IoCreateDevice should be called and then a driver
    should register any device interfaces with IoRegisterDeviceInterface.

    Does thos order matter?
    what could possibly go wrong if i call IoRegisterDeviceInterface first
    and then IoCreateDevice?

    Note that this is a WDM driver and hence i would call IoCreateDevice
    with DeviceName parameter as NULL


    thanks and regards
    Taha
     
    M Taha Masood, Feb 5, 2005
    #1
    1. Advertisements

  2. what could possibly go wrong if i call IoRegisterDeviceInterface first
    IoRegisterDeviceInterface requires a PDO, and can be called exactly when you
    see the PDO for the first time - i.e. in AddDevice.

    But you also need IoSetDeviceInterfaceState, which you must call in
    MN_START_DEVICE path after everything is ready to accept MJ_CREATE IRPs to your
    device.
     
    Maxim S. Shatskih, Feb 5, 2005
    #2
    1. Advertisements

  3. thanks for the answer but i'm afraid it does not quite satisfy my
    question.
    right , that i understand fine , but what i am not clear about it that
    why does the DDK help topic mentioned in original post say that
    IoCreateDevice should always be called first and
    IoRegisterDeviceInterface later in sequence. In my driver i had the
    order reversed ( ofcourse still inside AddDevice ) and they were
    apparently working fine
    right that i have no doubt about at all.


    thanks in advance
    Taha
     
    M Taha Masood, Feb 11, 2005
    #3
  4. If you call before IoCreateDevice, where do you store the symbolic link name
    returned by IoRegisterDeviceInterface. You need that to enable and disable
    interface state. Technically there is nothing wrong in calling
    IoRegisterDeviceInterface because the registration happens on the PDO and
    the symbolic link to the PDO isn't created until you enable it later in the
    Start-device. By creating after IoCreateDevice, it makes it easier to store
    the string in the device context and manage it.

    --
     
    Eliyas Yakub [MSFT], Feb 12, 2005
    #4
    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.