tags:

views:

40

answers:

1

Hi, how can I get the driver's name of a device to use with CreateFile?

handle = CreateFile( DRIVER_NAME_HERE,  
                     GENERIC_READ | GENERIC_WRITE,
                     FILE_SHARE_READ | FILE_SHARE_WRITE,
                     NULL, OPEN_EXISTING, 0, NULL);

thanks!

A: 

It's depend on what you want. A typical examples are

\\.\C:
\\.\Tcp
\\.\PhysicalDrive0
\\?\usbstor#disk&ven_sandisk&prod_cruzer&rev_8.01#1740030578903736&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
\\.\CON

(see http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx). I recommend you to also to use WinObj (see http://technet.microsoft.com/en-us/sysinternals/bb896657.aspx) to understand more about which devices you can use. If you start WinObj.exe and choose GLOBAL?? namespace you will see different names which can you use after \\.\ prefix. The function QueryDosDevice can be also helpful.

You can use DefineDosDevice function to create additional Symbolic link from \Device\Blabla to a name which you can use in CreateFile with the syntax \\.\MyLogicalDevicName (see http://msdn.microsoft.com/en-us/library/aa364014(VS.85).aspx).

If you want to send IOCTL codes with respect of DeviceIoControl function to a device, you should use 0 instead of GENERIC_READ | GENERIC_WRITE as the second parameter of CreateFile (see http://msdn.microsoft.com/en-us/library/aa363147(v=VS.85).aspx)

Oleg