Hi Art, I needed the PDO for the very same reason and didn't find a reliable way to do so. I circumvented the problem by moving most of the registry accesses to the AddDevice routine. In my driver, I wrote an underlying bus driver also. The WDM/KS subdevices query the bottom device stack for a private direct call interface and end up in the child FDO's created by my bus driver. They use this private interface to store/retrieve instance specific settings. Of course, this bus driver thing is a bit complex just for registry access but I needed it anyway for other purposes ;) I guess the more or less documented way is to send an IRP_MJ_PNP/IRP_MN_QUERY_DEVICE_RELATIONS down the stack wo get the "TargetDeviceRelation". The bus driver is supposed to answer with the PDO of your device. Best regards, Dirk > -----Original Message----- > From: Art Edwards [mailto:snowdog0@xxxxxxxxxxxx] > Sent: Wednesday, December 04, 2002 9:47 PM > To: wdmaudiodev@xxxxxxxxxxxxx > Subject: [wdmaudiodev] Re: PcAddAdapterDevice & Device Extensions > > > Dirk, > > Thanks for the advice. > > I'd like to save the PDO pointer passed to AddDevice. I want > to be able to > use it later on in a call to IoOpenDeviceRegistryKey. I know PORTCLS > exports the IRegistryKey interface. I *should* be able to use that > interface to access registry keys related to my device. > > However, there are bugs (I believe) in some of the methods of that > interface. For example, specifying a RegistryKeyType of > HwProfileRegistryKey in a call to PcNewRegistryKey returns an > error. I > posted a message on this about a year ago: > > http://groups.yahoo.com/group/wdmaudiodev/message/1949 > > As I mentioned in that post, PORTCLS saves a pointer to the > PDO in its > portion of the device extension (the long word at byte offset > 8). But, I > don't think it's safe to rely on that. I'd like to keep my own copy. > > Yeah, I was afraid IoGetAttachedDeviceReference would do that. > > At 02:56 PM 12/4/2002 , you wrote: > >Hi Art, > >it looks like the documentation is wrong on this one. > Normally, you would > >create a device in your AddDevice routine given the PDO. > After that you can > >use the Functional Device Object to access your private extension. > >PcAddAdapterDevice creates the necessary device for you but > you have to wait > >until the StartDevice routine is called to access your extension. > > > >Is there any specific reason why you want to use an > extension? You can > >allocate your own object and associate it to the port returned from > >PcNewPort. You can store whatever you need in this object. > > > >IoGetAttachedDeviceReference does not necessarily return > your deviceobject > >because a filter driver could be loaded on top of yours. > > > >Best regards, > >Dirk > > > > > -----Original Message----- > > > From: Art Edwards [mailto:snowdog0@xxxxxxxxxxxx] > > > Sent: Wednesday, December 04, 2002 8:25 PM > > > To: wdmaudiodev@xxxxxxxxxxxxx > > > Subject: [wdmaudiodev] PcAddAdapterDevice & Device Extensions > > > > > > > > > There's a fragment of sample code in the DDK description of > > > PcAddAdapterDevice. The fragment describes how an adapter > > > driver can access its device extension after the call to > > > PcAddAdapterDevice returns. The fragment is: > > > > > > PDEVICE_CONTEXT pDeviceContext = > > > (PDEVICE_CONTEXT)(PhysicalDeviceObject->DeviceExtension); > > > PVOID pMyExtensionData = (PVOID)((PCHAR)pDeviceContext + > > > PORT_CLASS_DEVICE_EXTENSION_SIZE); > > > > > > > > > My understanding of this is that referencing pMyExtensionData > > > will access the PDO's device extension. That extension is > > > owned by the bus driver right ? If so, the above > fragment won't work. > > > > > > To access my device extension, I think it would be more > > > appropriate to call IoGetAttachedDeviceReference and access > > > its device extension pointer. > > > > > > Does anyone out there know about this ? > > > > > Art Edwards > > Art's <http://members.localnet.com/~snowdog0/Resume>resume. > Art's <http://www.soniqboom.net>band (a.k.a. Soniq Boom). > > ****************** > > WDMAUDIODEV addresses: > Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx > Subscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe Unsubscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe Moderator: mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx URL to WDMAUDIODEV page: http://www.wdmaudiodev.de/ ****************** WDMAUDIODEV addresses: Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx Subscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe Unsubscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe Moderator: mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx URL to WDMAUDIODEV page: http://www.wdmaudiodev.de/