My audio driver’s StartDevice
callback calls a function twice to instantiate both the topology and wave subdevices:
NTSTATUS InstallSubdevice(IPort **ppIPort, IMiniport **ppIMiniport, DEVICE_OBJECT *pDeviceObject, IRP *pIrp,
PCWSTR pszMiniportName, REFGUID riidPortClass, REFGUID riidMiniportClass, PFN_FACTORY_METHOD pfnFactoryMethod,
IUnknown *pIUnkAdapter, IResourceList *pIResourceList)
{
ASSERT(pszMiniportName);
DPF_ENTER(("[%s '%S']", __FUNCTION__, pszMiniportName));
ASSERT(pDeviceObject);
// Create the PortCls driver object and return an IPort interface
IPort *pIPort = nullptr;
auto ntStatus = ::PcNewPort(&pIPort, riidPortClass);
// Create the specified miniport (CMiniportTopology or CMiniportWaveRt) object and return an IMiniport interface
IMiniport *pIMiniport = nullptr;
if (NT_SUCCESS(ntStatus))
{
ntStatus = pfnFactoryMethod
? pfnFactoryMethod(&pIMiniport, riidMiniportClass, pIUnkAdapter, NonPagedPoolNx) // (CreateInstance call)
: ::PcNewMiniport(&pIMiniport, riidMiniportClass);
}
// Initialize the audio port driver (calls IMiniportXXX::Init on the miniport)
if (NT_SUCCESS(ntStatus))
ntStatus = pIPort->Init(pDeviceObject, pIrp, pIMiniport, pIUnkAdapter, pIResourceList);
I’m getting STATUS_INVALID_PARAMETER back from the pIPort->Init(…) call at the bottom. I’ve been over each of the parameters in WinDbg multiple times, and I can’t find anything wrong with them. I’ve even tried passing nullptr
for pIrp, pIUnkAdapter, and pIResourceList (based upon differences in some of the sample code), but I get the same result.
Could this be due to something else, like a mistake somewhere in my INF file?
SIDE QUESTION: Since the “common adapter” class doesn’t seem to need to implement any well-known interfaces other than IUnknown (docs do mention IAdapterObject, but I couldn’t find any references to that in docs or examples), why does this API include it? I can’t see what PortCls could do with it, other than AddRef/Release it…