Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > symbolic names for multiple instances of devices

Reply
Thread Tools Display Modes

symbolic names for multiple instances of devices

 
 
Mark McDougall
Guest
Posts: n/a

 
      04-19-2010
Hi,

I've got a bus driver that (statically) enumerates a number of child
devices (PDOs) for which I have a corresponding driver. FWIW this is a
*closed* system and devices don't go away.

I want to create ordered Symbolic names for each device - ie. MyDev0,
MyDev1, ... etc, specifically so an application can open them
unambiguously using CreateFile("MyDev0")... (ie I need to absolutely know
which is 0, which is 1) etc...

Right now in AddDevice() I'm calling:

WdfDeviceInitAssignName("\\Device\\MyDev%d")
WdfDeviceCreate()
WdfDeviceCreateSymbolicLink("\\DosDevices\\MyDev%d ")

However, I need the device *number* to insert into the assigned name and
subsequently the symbolic link. How can I get this - especially *before* I
call WdfDeviceCreate() ???

Can I create the SymbolicLink in EvtPrepareHw()? If so, I still have the
problem with the assigned name, since I read that you can't call
CreateSymbolicLink() if you don't call InitAssignName() - although it does
appear to work for me?!?

Or is there a better way?

Regards,

--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
 
Reply With Quote
 
 
 
 
Doron Holan [MSFT]
Guest
Posts: n/a

 
      04-19-2010
RtlUnicodeStringPrintf will format the string for you ala printf style
formatting. you can create a symbolic link name to an unnamed FDO if you
want, KMDF will just create the symlink to the PDO name for you. remember
that the number or even the name itself on the FDO has no relationship with
the symlink name, your dev name could be \Device\FooBar999 and the symlink
could be \DosDevices\BarFoo100.

d
--

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


"Mark McDougall" <> wrote in message
news:#0GT#...
> Hi,
>
> I've got a bus driver that (statically) enumerates a number of child
> devices (PDOs) for which I have a corresponding driver. FWIW this is a
> *closed* system and devices don't go away.
>
> I want to create ordered Symbolic names for each device - ie. MyDev0,
> MyDev1, ... etc, specifically so an application can open them
> unambiguously using CreateFile("MyDev0")... (ie I need to absolutely know
> which is 0, which is 1) etc...
>
> Right now in AddDevice() I'm calling:
>
> WdfDeviceInitAssignName("\\Device\\MyDev%d")
> WdfDeviceCreate()
> WdfDeviceCreateSymbolicLink("\\DosDevices\\MyDev%d ")
>
> However, I need the device *number* to insert into the assigned name and
> subsequently the symbolic link. How can I get this - especially *before* I
> call WdfDeviceCreate() ???
>
> Can I create the SymbolicLink in EvtPrepareHw()? If so, I still have the
> problem with the assigned name, since I read that you can't call
> CreateSymbolicLink() if you don't call InitAssignName() - although it does
> appear to work for me?!?
>
> Or is there a better way?
>
> Regards,
>
> --
> Mark McDougall, Engineer
> Virtual Logic Pty Ltd, <http://www.vl.com.au>
> 21-25 King St, Rockdale, 2216
> Ph: +612-9599-3255 Fax: +612-9599-3266


 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      04-19-2010
> However, I need the device *number* to insert into the assigned name and
> subsequently the symbolic link


Use the global counter and ++ it on each creation.

But it is much better to use device interfaces instead.

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Pavel A.
Guest
Posts: n/a

 
      04-19-2010
"Maxim S. Shatskih" <> wrote in message
news:eA9COU$...
>> However, I need the device *number* to insert into the assigned name and
>> subsequently the symbolic link

>
> Use the global counter and ++ it on each creation.
>
> But it is much better to use device interfaces instead.


Maybe, combination of both: Device interface to detect all the devices, then
query some property
(stored in the registry, or call the driver) to get the numbers assigned to
devices.
-- pa

> --
> Maxim S. Shatskih
> Windows DDK MVP
>
> http://www.storagecraft.com
>

 
Reply With Quote
 
Mark McDougall
Guest
Posts: n/a

 
      04-20-2010
Maxim S. Shatskih wrote:

> Use the global counter and ++ it on each creation.


I have subsequently discovered that this is how the serial driver does it.
In this case, IIUC there's no guaranteed correlation between the first PDO
enumerated and the first AddDevice() call - ie. a PDO enumerated as MyPdo2
could conceivably get its AddDevice() called first, and the
Assigned/Symbolic name could be "MyDev0" - right?

FTR I think I can live with this anyway, since I can store the port number
(global counter) in the FDO device extension in AddDevice() and then
assign the physical resources in EvtPrepareHw() based on this port number.

> But it is much better to use device interfaces instead.


Ugghh!! No thanks. These are actually custom communications ports and they
will never need to do detection. It's a closed system and each port has a
predetermined connection to the outside world.

Regards,

--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
 
Reply With Quote
 
Tim Roberts
Guest
Posts: n/a

 
      04-20-2010
Mark McDougall <> wrote:
>
>> But it is much better to use device interfaces instead.

>
>Ugghh!! No thanks. These are actually custom communications ports and they
>will never need to do detection. It's a closed system and each port has a
>predetermined connection to the outside world.


Your response indicates that you do not know what device interfaces are.
--
Tim Roberts,
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      04-21-2010
> In this case, IIUC there's no guaranteed correlation between the first PDO
> enumerated


Enumeration order of the PDOs is not defined at all.

> FTR I think I can live with this anyway, since I can store the port number
> (global counter) in the FDO device extension in AddDevice() and then
> assign the physical resources in EvtPrepareHw() based on this port number.


Correct.

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Doron Holan [MSFT]
Guest
Posts: n/a

 
      04-21-2010
> I do not like device interfaces - correct me if I'm wrong - because
> they require a nonstandard API in the user side.


what is non standard about using SetupAPI to enumerate the device interface?

--

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


"alberto" <> wrote in message
news:01938386-bc6e-4d7a-ba45-...
>
> I don't know if I quite understand your need, but maybe you can
> preallocate your own array of device structure areas in the nonpaged
> pool, have an atomic counter that increments for every device you
> create, and store a pointer to its Device Object in the corresponding
> slot. When the Open request comes your driver gets control anyway, and
> from there you can quickly figure out which device you're talking
> about.
>
> In other words, devices are primarily identified by your own
> structure, not by the Device Object - you just use the Device Object
> to keep Windows quiet. Instead of embedding your device-unique storage
> in the Device Object as a device extension, you just maintain your
> own array of device structures, and do not include a device extension
> in your device object.
>
> I use a variation of this technique in my driver, and I have
> successfully run production volume through up to 6-board
> configurations.
>
> I do not like device interfaces - correct me if I'm wrong - because
> they require a nonstandard API in the user side.
>
>
> Hope this helps,
>
>
> Alberto.
>
>
>
>
> On Apr 19, 8:35 pm, Mark McDougall <ma...@vl.com.au> wrote:
>> Maxim S. Shatskih wrote:
>> > Use the global counter and ++ it on each creation.

>>
>> I have subsequently discovered that this is how the serial driver does
>> it.
>> In this case, IIUC there's no guaranteed correlation between the first
>> PDO
>> enumerated and the first AddDevice() call - ie. a PDO enumerated as
>> MyPdo2
>> could conceivably get its AddDevice() called first, and the
>> Assigned/Symbolic name could be "MyDev0" - right?
>>
>> FTR I think I can live with this anyway, since I can store the port
>> number
>> (global counter) in the FDO device extension in AddDevice() and then
>> assign the physical resources in EvtPrepareHw() based on this port
>> number.
>>
>> > But it is much better to use device interfaces instead.

>>
>> Ugghh!! No thanks. These are actually custom communications ports and
>> they
>> will never need to do detection. It's a closed system and each port has a
>> predetermined connection to the outside world.
>>
>> Regards,
>>
>> --
>> Mark McDougall, Engineer
>> Virtual Logic Pty Ltd, <http://www.vl.com.au>
>> 21-25 King St, Rockdale, 2216
>> Ph: +612-9599-3255 Fax: +612-9599-3266

>

 
Reply With Quote
 
Pavel A.
Guest
Posts: n/a

 
      04-21-2010
"Doron Holan [MSFT]" <> wrote in message
news:...
>> I do not like device interfaces - correct me if I'm wrong - because
>> they require a nonstandard API in the user side.

>
> what is non standard about using SetupAPI to enumerate the device
> interface?


No such thing in posix :-)

-- pa

> "alberto" <> wrote in message
> news:01938386-bc6e-4d7a-ba45-...
>>
>> I don't know if I quite understand your need, but maybe you can
>> preallocate your own array of device structure areas in the nonpaged
>> pool, have an atomic counter that increments for every device you
>> create, and store a pointer to its Device Object in the corresponding
>> slot. When the Open request comes your driver gets control anyway, and
>> from there you can quickly figure out which device you're talking
>> about.
>>
>> In other words, devices are primarily identified by your own
>> structure, not by the Device Object - you just use the Device Object
>> to keep Windows quiet. Instead of embedding your device-unique storage
>> in the Device Object as a device extension, you just maintain your
>> own array of device structures, and do not include a device extension
>> in your device object.
>>
>> I use a variation of this technique in my driver, and I have
>> successfully run production volume through up to 6-board
>> configurations.
>>
>> I do not like device interfaces - correct me if I'm wrong - because
>> they require a nonstandard API in the user side.
>>
>>
>> Hope this helps,
>>
>>
>> Alberto.
>>
>>
>>
>>
>> On Apr 19, 8:35 pm, Mark McDougall <ma...@vl.com.au> wrote:
>>> Maxim S. Shatskih wrote:
>>> > Use the global counter and ++ it on each creation.
>>>
>>> I have subsequently discovered that this is how the serial driver does
>>> it.
>>> In this case, IIUC there's no guaranteed correlation between the first
>>> PDO
>>> enumerated and the first AddDevice() call - ie. a PDO enumerated as
>>> MyPdo2
>>> could conceivably get its AddDevice() called first, and the
>>> Assigned/Symbolic name could be "MyDev0" - right?
>>>
>>> FTR I think I can live with this anyway, since I can store the port
>>> number
>>> (global counter) in the FDO device extension in AddDevice() and then
>>> assign the physical resources in EvtPrepareHw() based on this port
>>> number.
>>>
>>> > But it is much better to use device interfaces instead.
>>>
>>> Ugghh!! No thanks. These are actually custom communications ports and
>>> they
>>> will never need to do detection. It's a closed system and each port has
>>> a
>>> predetermined connection to the outside world.
>>>
>>> Regards,
>>>
>>> --
>>> Mark McDougall, Engineer
>>> Virtual Logic Pty Ltd, <http://www.vl.com.au>
>>> 21-25 King St, Rockdale, 2216
>>> Ph: +612-9599-3255 Fax: +612-9599-3266

>>

 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      04-22-2010
> No such thing in posix :-)

POSIX is non-standard, it violates the Microsoft's tradition :-)

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Mass Storage Devices Unrecognized (Vista) Jason Windows Vista Hardware 9 06-01-2007 03:04 PM
previously working USB devices now showing as "Unknown Device" A L Windows Vista Hardware 4 02-27-2007 01:18 PM
bluetooth devices mtgb Windows Vista Hardware 0 12-16-2006 01:19 PM
Stop 0x0000007b at end of Install BobMiller Windows Vista Installation 2 08-03-2006 06:52 PM
ANN: Upcoming Windows Embedded Chats and Webcasts Nick White [MSFT] ActiveSync 0 08-25-2004 06:50 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59