Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

Getting STATUS_INVALID_PARAMETER back from pIPort->Init(...)

scott_smithscott_smith Member Posts: 51

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)

    DPF_ENTER(("[%s '%S']", __FUNCTION__, pszMiniportName));


    // 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...

Scott Smith
Windows Developer since 1989


  • scott_smithscott_smith Member Posts: 51
    edited October 2020

    Feh. I was passing pIUnkAdapter into the factory method for the Topology/WaveRT miniport class as UnknownOuter.

    pfnFactoryMethod(&pIMiniport, riidMiniportClass, pIUnkAdapter, NonPagedPoolNx)

    The IPort::Init() call was trying to QI an IID_IMiniportTopology interface from my common adapter class.


    Scott Smith
    Windows Developer since 1989

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE