Unable to open device driver. How can I verify the name I should use in the CreateFile call? RRS feed

  • Question

  • Hello.

    I am developing a KMDF driver for a custom PCI board. I have the driver to the point where it is installed on my target computer and it passes the tests during provisioning. I can debug it, etc.

    I want to write a test program to open the device driver and send Ioctl commands to the driver.

    On the device driver side, I am using a reference string:

    DECLARE_CONST_UNICODE_STRING(RefStr1, L"dts9080_1"); 

    that I pass to the call to WdfDeviceCreateDeviceInterface.

            status = WdfDeviceCreateDeviceInterface(
            &RefStr1  // ReferenceString

    On the target machine, I am simply trying to open the device driver and I get an invalid handle return code with an extended error code of 2 (ERROR_FILE_NOT_FOUND).

    Here is my basic test code:

    HANDLE hDevice;

    hDevice =  CreateFile( _T("\\\\.\\dts9080_1"),

                   GENERIC READ,






    if (hDevice == INVALID_HANDLE_VALUE)


    I have tried not using UNICODE, etc. I figure the OS is looking up the driver name in a table and the CreateFile call is failing due a mismatch.

    Is there a way to find what the driver name is in the target machine? 

    One other piece of information... I tried a call to WdfDeviceRetrieveDeviceInterfaceString to read back the reference string right after calling WdfDeviceCreateDeviceInterface and I get a status of 0xC0000034 which is STATUS_OBJECT_NAME_NOT_FOUND.

    Am I missing a call in the driver that finishes this process? 



    Wednesday, October 2, 2013 5:21 PM


  • the reference string passed in to WdfDeviceCreateDeviceInterface is not the symbolic link name an app sees, it is a filename appended to the device interface symbolic link name that allows you to differentiate between different device interface registrations, see .  If you want a fixed file name, use WdfDeviceCreateSymbolicLink instead, use L"\\DosDevices\\dts9080_1"as the string constant. OR keep the device interface and then use SetupDiXxx calls to enumerate the device interface instances to find the symbolic link name, see the enum.exe part of the toaster sample for how these calls work.  The benefit of the device interface is that you can be notified of dynamic arrival of the device (if that matters)

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, October 2, 2013 5:41 PM