[wdmaudiodev] Re: Filter and PortCls node IDs

  • From: Eugene Muzychenko <eugene@xxxxxxxxxxxxxx>
  • To: Matthew van Eerde <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Sat, 17 May 2014 11:39:19 +0700

Hello Matthew,

> Weird.

I'm shocked too. :)

> How confident are you that these are really KSP_NODE requests?

I examine KSPROPERTY.Flags field for KSPROPERTY_TYPE_TOPOLOGY and cast
input buffer pointer to KSP_NODE only if this flag is set.

Initially, I saw node ID differences in XP SP3 x86. Loading the same
driver binary in Win7 SP1 x86, I don't see different node IDs; all
IDs provided by PC in PCPROPERTY_REQUEST are the same as in KSP_NODE
provided in IRP input buffer. Compiling unmodified sources for x64 and
loading in Win7 SP1 x64, see no ID difference too. But in 2003 Server,
I see the same ID differences as in XP (1/8, 3/0, 5/2, 7/6).

So the IDs are different in Win 5.x and identical in Win 6.x.

I have attached screenshoot from KsStudio for topology reference.

Here are code fragments:

From IRP_MJ_DEVICE_IO_CONTROL dispatch routine:

========================================================
    IO_STACK_LOCATION const &SL = *IoGetCurrentIrpStackLocation (Irp);

    FILE_OBJECT const * const FO = SL.FileObject;

    ULONG const CC = SL.Parameters.DeviceIoControl.IoControlCode;

    size_t const InputBufferLength = 
SL.Parameters.DeviceIoControl.InputBufferLength;

    wchar_t Info [128];

    *Info = L'\0';

    PCVOID const InputBuffer = SL.Parameters.DeviceIoControl.Type3InputBuffer;

    switch (CC) {

      case IOCTL_KS_PROPERTY: {

        KSPROPERTY const &Prop = *static_cast <KSPROPERTY const *> 
(InputBuffer);

        if (InputBufferLength >= sizeof (Prop)) {

          wchar_t FlagNames [100];

          DecodeFlagNames (FlagNames, NumArrayElems (FlagNames), Prop.Flags, 
KsPropertyFlags);

          if (TestBits (Prop.Flags, KSPROPERTY_TYPE_TOPOLOGY)) {

            KSP_NODE const &NP = (KSP_NODE const &) (Prop);

            Assert (!memcmp (&NP.Property, &Prop, sizeof (Prop)));

            if (InputBufferLength >= sizeof (NP)) {

              SNPrintf (
                Info, NumArrayElems (Info),
                L"KS_NodeProp,FO=+%06.6p,Prop=%s,F=%s,N=%u,P=%s",
                FO, KsIdText (Prop.Set, Prop.Id), FlagNames,
                NP.NodeId, PidText (GetCurrProcessId ())
              );

              IoCtlProp.Debug (6, L"%s", Info);
========================================================



From KSPROPERTY_AUDIO_VOLUMELEVEL property handler:

========================================================
NTSTATUS MiniTopo::VolumeLevelPropertyHandlerInner (PCPROPERTY_REQUEST &Req) {

  IfDebug (static wchar_t const PropName [] = L"VolLevel");

#if _Debug

  IO_STACK_LOCATION const &SL = *IoGetCurrentIrpStackLocation (Req.Irp);

  KSP_NODE const &OrigNP = *(KSP_NODE 
*)(SL.Parameters.DeviceIoControl.Type3InputBuffer);

#endif

  Debug (
    6,
    L"%s, N=%d, OrigN=%d, IS=%u, VS=%u",
    PropName, Req.Node, OrigNP.NodeId, Req.InstanceSize, Req.ValueSize
  );
========================================================



This inner handler is called via the gate:

========================================================
NTSTATUS MiniTopo::VolumeLevelPropertyHandler (IN PCPROPERTY_REQUEST *Req) {

  MiniTopo &MT = *static_cast <MiniTopo *> (Req->MajorTarget);

  return MT.VolumeLevelPropertyHandlerInner (*Req);

}
========================================================



Output log fragments:

XP SP3 x86:

========================================================
IoCtlProp: KS_NodeProp,FO=+1c1928,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=8,P=4
MT 1: VolLevel, N=1, OrigN=8, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+13db18,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=0,P=4
MT 1: VolLevel, N=3, OrigN=0, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+13db18,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=2,P=4
MT 1: VolLevel, N=5, OrigN=2, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+13db18,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=6,P=4
MT 1: VolLevel, N=7, OrigN=6, IS=8, VS=4
========================================================



2003 Server SP2 x86:

========================================================
IoCtlProp: KS_NodeProp,FO=+3331d0,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=8,P=4
MT 1: VolLevel, N=1, OrigN=8, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+333628,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=0,P=4
MT 1: VolLevel, N=3, OrigN=0, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+333628,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=2,P=4
MT 1: VolLevel, N=5, OrigN=2, IS=8, VS=4

IoCtlProp: KS_NodeProp,FO=+333628,Prop=Audio/VOLUMELEVEL,F=GET|TOPO,N=6,P=4
MT 1: VolLevel, N=7, OrigN=6, IS=8, VS=4
========================================================




Win7 SP1 x86:

========================================================
IoCtlProp: KS_NodeProp,FO=+f919b0,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=1,P=856
MT 1: VolLevel, N=1, OrigN=1, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+f919b0,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=3,P=856
MT 1: VolLevel, N=3, OrigN=3, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+f919b0,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=5,P=856
MT 1: VolLevel, N=5, OrigN=5, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+f919b0,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=7,P=856
MT 1: VolLevel, N=7, OrigN=7, IS=0, VS=40
========================================================



Win7 SP1 x64:

========================================================
IoCtlProp: KS_NodeProp,FO=+adcf20,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=1,P=800
MT 1: VolLevel, N=1, OrigN=1, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+adcf20,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=3,P=800
MT 1: VolLevel, N=3, OrigN=3, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+adcf20,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=5,P=800
MT 1: VolLevel, N=5, OrigN=5, IS=0, VS=40

IoCtlProp: KS_NodeProp,FO=+adcf20,Prop=Audio/VOLUMELEVEL,F=BASSUP|TOPO,N=7,P=800
MT 1: VolLevel, N=7, OrigN=7, IS=0, VS=40
========================================================



> Can you dump the whole structure (including the property set ID and
> the property) for an instance with an out-of-range Node ID?

Attached WinDbg window image from XP SP3 x86.

Regards,
Eugene

Attachment: topo.jpg
Description: JPEG image

Attachment: windbg.jpg
Description: JPEG image

Other related posts: