none
createfile is failing with error 2(ERROR_PATH_NOT_FOUND) RRS feed

  • Question

  • Dear All,

    I am trying to access the WPF isnpect sample driver from application but create file is failing with error 3.

    In Driver:

       RtlInitUnicodeString(
          &deviceName,
          L"\\Device\\StreamEitor"
          );
       status = IoCreateDevice(
                   driverObject,
                   0,
                   &deviceName,
                   FILE_DEVICE_NETWORK,
                   0,
                   FALSE,
                   &gDeviceObject
                   );

    In Application:

        WCHAR        pDeviceName[255]={0};
        size_t        i,j;
        HANDLE      hDeviceHandle;
        const char *prefix="\\Device\\StreamEitor";
        j=19; //length for Device Name
      
        for(i=0;i<j;i++)
            pDeviceName[i]=(WCHAR)prefix[i];

        pDeviceName[i]=L'\0';
        hDeviceHandle = CreateFile(pDeviceName,
                                     GENERIC_READ | GENERIC_WRITE,
                                     FILE_SHARE_READ | FILE_SHARE_WRITE,
                                     NULL,
                                     OPEN_EXISTING,
                                     0,
                                     NULL);


    A.David Preetham

    Tuesday, April 23, 2013 9:25 AM

Answers

  • In the driver you must create a symbolic link for the application to be able to access the driver.  So after the create of the device issue a IoCreateSymbolicLink (many of the examples in the WDK will show how).


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, April 23, 2013 11:12 AM

All replies

  • In the driver you must create a symbolic link for the application to be able to access the driver.  So after the create of the device issue a IoCreateSymbolicLink (many of the examples in the WDK will show how).


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, April 23, 2013 11:12 AM
  • Hi Burn,

    Thank you very much for your reply.

    I created symbolic link name but i am getting object name collision.

       RtlInitUnicodeString(
          &deviceName,
          L"\\Device\\StreamEitor"
          );
       RtlInitUnicodeString(
          &symbolicLinkName,
          L"\\DosDevices\\StreamEitor"
          );

    I called after creating device object using IoCreateDevice

    IoCreateSymbolicLink( &symbolicLinkName, &deviceName );

    I am starting service using net start. failing with IoCreateSymbolicLink failed c0000035(STATUS_OBJECT_NAME_COLLISION).


    A.David Preetham

    Tuesday, April 23, 2013 1:06 PM
  • Dear Burn,

    I am able to create symbolic name and able to start service using net start.

    When i try to open createfile from application still i am getting ERROR_PATH_NOT_FOUND.


    A.David Preetham

    Tuesday, April 23, 2013 1:52 PM
  • Sorry, missed the bug in the application.  The name on CreateFile should be \\\\.\\StreamEitor


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, April 23, 2013 2:10 PM
  • You can easily declare a Unicode string constant instead of that crazy loop, L"\\.\Foo"

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

    Tuesday, April 23, 2013 2:14 PM
  • Hi Don,

    Thanks for the reply.

    Still i am not able to communicate with driver after creating symbolic name also. i am getting error code 3 for create file.

    i tried with
          L"\\Device\\StreamEitor3"
          L"\\DosDevices\\StreamEitor3" and also tried  L"\\DosDevices\\Global\\StreamEitor3"

    and created symbolic name.

    in my application

    CreateFile(L"\\\\.\\StreamEitor3",
                                     GENERIC_READ,
                                     0,
                                     NULL,
                                     OPEN_EXISTING,
                                     0,
                                     NULL);

    This driver is an msdn wfp driver and i am starting with net start inspect. I am wondering any arguments in createfile causing issue?

    like access and share memory?


    A.David Preetham

    Wednesday, April 24, 2013 1:39 PM
  • I suspect your problem is the way you are starting the driver.  The samples have an INX file which should create an INF file, which you should use to install the driver with.   Take a look at the samples they some I believe have an install script.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Wednesday, April 24, 2013 3:02 PM
  • Hi Don,

    i am installing right click inf file and clicking install to driver to install. it is specified in help like and then start using net start.

    but in driver code they only created device object not symbolic name with your help i am able to create symbolic name but not able to open handle from application.


    A.David Preetham

    Thursday, April 25, 2013 7:37 AM
  • Don't right click, instead use DeviceManager and "Add legacy device" to do this.  Or use Difx tools.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Thursday, April 25, 2013 11:00 AM
  • Thanks Don,

    I will try that..


    A.David Preetham

    Thursday, April 25, 2013 1:04 PM