From: Mark McDougall on
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
From: Doron Holan [MSFT] on
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" <markm(a)vl.com.au> wrote in message
news:#0GT#683KHA.1624(a)TK2MSFTNGP06.phx.gbl...
> 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

From: Maxim S. Shatskih on
> 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
maxim(a)storagecraft.com
http://www.storagecraft.com

From: Pavel A. on
"Maxim S. Shatskih" <maxim(a)storagecraft.com.no.spam> wrote in message
news:eA9COU$3KHA.5588(a)TK2MSFTNGP06.phx.gbl...
>> 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
> maxim(a)storagecraft.com
> http://www.storagecraft.com
>
From: Mark McDougall on
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