none
relationship between the first argument to CreateFile() and actual device driver file RRS feed

  • Question

  • When we need a device driver handle to be used in subsequent calls to DeviceIoControl(), we specify a path of the form "\\.\".

    What exactly does this name signify? Given this name, can one find out the actual device driver file residing on the system where the driver is installed?

    I've referred to MSDN documentation of both CreateFile() as well as DeviceIoControl(). Both could not state the relationship between the two.

    I also referred to this question and tried using device tree to find the driver file given it's name specified as the first argument to CreateFile() but could not find any entry in the device tree.

    Friday, October 11, 2019 9:26 AM

Answers

  • If the first argument to CreateFile() is "\\.\CCEAPI", then, I understand that there's no physical file for this device but it is registered as a device in the system.

    There is a .sys file that backs the driver, this means that you get a handle to a currently runing .sys file.

    What i want to know is where can I find an entry for this device named "CCEAPI" on the Windows System? In device manager? Also, when the device handle is returned through CreateFile() and then subsequently device is access using DeviceIoControl(), which .sys/.dll/.exe file stored on the disk corresponding to that device is accessed? Is there a way I can find out the above info using only the device name "CCEAPI"?

    The registry, under HKEY_LOCAL_MACHINE\System\CurrentControlSet. Each driver is registered as a service. You could also use WinObj from Sysinternals to look at the currently registered drivers in the system.

    Also, how is the device with name "CCEAPI" registered on the OS in the first place? If the installer does this registeration, how does it do it?

    SetupAPI.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Friday, October 11, 2019 6:17 PM

All replies

  • It's explained here:

    https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#namespaces

    Read the paragraph:  Win32 Device Namespaces.

    Friday, October 11, 2019 12:16 PM
  • Thanks for the reply. I went through the link regarding the device names. I have a further query.

    If the first argument to CreateFile() is "\\.\CCEAPI", then, I understand that there's no physical file for this device but it is registered as a device in the system. 

    What i want to know is where can I find an entry for this device named "CCEAPI" on the Windows System? In device manager? Also, when the device handle is returned through CreateFile() and then subsequently device is access using DeviceIoControl(), which .sys/.dll/.exe file stored on the disk corresponding to that device is accessed?
    Is there a way I can find out the above info using only the device name "CCEAPI"?

    Also, how is the device with name "CCEAPI" registered on the OS in the first place? If the installer does this registeration, how does it do it?

    Thanks,

    --ANURAG.

    Friday, October 11, 2019 5:08 PM
  • If the first argument to CreateFile() is "\\.\CCEAPI", then, I understand that there's no physical file for this device but it is registered as a device in the system.

    There is a .sys file that backs the driver, this means that you get a handle to a currently runing .sys file.

    What i want to know is where can I find an entry for this device named "CCEAPI" on the Windows System? In device manager? Also, when the device handle is returned through CreateFile() and then subsequently device is access using DeviceIoControl(), which .sys/.dll/.exe file stored on the disk corresponding to that device is accessed? Is there a way I can find out the above info using only the device name "CCEAPI"?

    The registry, under HKEY_LOCAL_MACHINE\System\CurrentControlSet. Each driver is registered as a service. You could also use WinObj from Sysinternals to look at the currently registered drivers in the system.

    Also, how is the device with name "CCEAPI" registered on the OS in the first place? If the installer does this registeration, how does it do it?

    SetupAPI.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Friday, October 11, 2019 6:17 PM
  • You can use SetupDi APIs

    For example, for my mouse

    SetupDiGetClassDevs with GUID_DEVINTERFACE_MOUSE
    SetupDiEnumDeviceInfo
    SetupDiEnumDeviceInterfaces
    SetupDiGetDeviceInterfaceDetail

    I get : "\\?\hid#vid_045e&pid_00e1&col02#6&15892b8c&1&0001#{378de44c-56ef-11d1-bc8c-00a0c91405dd}"

    then

    SetupDiGetDeviceProperty with DEVPKEY_Device_Service

    I get : mouhid (mouhid .sys)

    Friday, October 11, 2019 6:22 PM
  • If the first argument to CreateFile() is "\\.\CCEAPI", then, I understand that there's no physical file for this device but it is registered as a device in the system. 
    What i want to know is where can I find an entry for this device named "CCEAPI" on the Windows System?

    This kind of name is a "legacy" name created by API DefineDosDevice  (or its equivalents). Its real device name can be obtained with QueryDosDevice 

    Long complicated names usually are the modern "device interface" names. Getting to their devices is more complicated as well.

    -- pa


    • Edited by Pavel A Saturday, October 12, 2019 4:21 AM
    Saturday, October 12, 2019 4:20 AM