Get FileName used in CreateFile

we have a driver that was written using a product called WinDK by a company that is no longer around. WinDk does work on Win7.

the driver supports multiple cards, and the cards can have multiple channels.

the driver creates symbolic links in the form of \\.\TstSmPci0_0, where in this case the first zero indicates the device number, and the second zero indicates the channel number. i.e. each channel is treated like a device.

we’re looking to rewrite the driver in KMDF. in my EvtIoDeviceControl function, there are some IOCTL’s where i need to know what channel the IOCTL came from.

I was wondering if there is any way to get the FileName used when applications called CreateFile() to get a handle to the driver. i figured that if i had the string, i could determine which channel.

i’m trying to mimic what the old driver did because i don’t want to have to modify a lot of user mode applications. thanks.

Take a look at WdfDeviceInitSetFileObjectConfig this will allow you to
get the filename on the create and store it in a file context for later
use.

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

xxxxx@ddc-web.com” wrote in message
news:xxxxx@ntdev:

> we have a driver that was written using a product called WinDK by a company that is no longer around. WinDk does work on Win7.
>
> the driver supports multiple cards, and the cards can have multiple channels.
>
> the driver creates symbolic links in the form of \\.\TstSmPci0_0, where in this case the first zero indicates the device number, and the second zero indicates the channel number. i.e. each channel is treated like a device.
>
> we’re looking to rewrite the driver in KMDF. in my EvtIoDeviceControl function, there are some IOCTL’s where i need to know what channel the IOCTL came from.
>
> I was wondering if there is any way to get the FileName used when applications called CreateFile() to get a handle to the driver. i figured that if i had the string, i could determine which channel.
>
> i’m trying to mimic what the old driver did because i don’t want to have to modify a lot of user mode applications. thanks.

Please read

How do I know which symbolic link was opened? http://blogs.msdn.com/b/doronh/archive/2006/08/23/715612.aspx

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ddc-web.com
Sent: Thursday, October 27, 2011 1:35 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Get FileName used in CreateFile

we have a driver that was written using a product called WinDK by a company that is no longer around. WinDk does work on Win7.

the driver supports multiple cards, and the cards can have multiple channels.

the driver creates symbolic links in the form of \\.\TstSmPci0_0, where in this case the first zero indicates the device number, and the second zero indicates the channel number. i.e. each channel is treated like a device.

we’re looking to rewrite the driver in KMDF. in my EvtIoDeviceControl function, there are some IOCTL’s where i need to know what channel the IOCTL came from.

I was wondering if there is any way to get the FileName used when applications called CreateFile() to get a handle to the driver. i figured that if i had the string, i could determine which channel.

i’m trying to mimic what the old driver did because i don’t want to have to modify a lot of user mode applications. thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

> the driver creates symbolic links in the form of \\.\TstSmPci0_0, where in this case the first zero

indicates the device number, and the second zero indicates the channel number

I would create a device object per channel.

Well, you can also go the way the AVStream/KS stuff goes and create a device object per device, with a reference string (kinda “wave0”, “wave1” and so on) for channel. Reference string is trivially visible in create path.

To do so, create a DO per device, and then create many instances of the same device interface GUID on this device, each with its own reference string.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com