Home | History | Annotate | Download | only in ddk
      1 /*
      2     ReactOS Kernel Streaming
      3     Port Class
      4 
      5     This file is in the public domain.
      6 
      7     Andrew Greenwood
      8 
      9     NOTES:
     10     Does not support PC_OLD_NAMES (which is required for backwards-compatibility
     11     with older code)
     12 
     13     Obsolete macros are not implemented. For more info:
     14     http://www.osronline.com/ddkx/stream/audpc-struct_167n.htm
     15 
     16 
     17     == EXPORTS ==
     18     DRM (new in XP):
     19     * PcAddContentHandlers
     20     * PcCreateContentMixed
     21     * PcDestroyContent
     22     * PcForwardContentToDeviceObject
     23     * PcForwardContentToFileObject
     24     * PcForwardContentToInterface
     25     * PcGetContentRights
     26 
     27     IRP HANDLING:
     28     * PcCompleteIrp
     29     * PcDispatchIrp
     30     * PcForwardIrpSynchronous
     31 
     32     ADAPTER:
     33     * PcAddAdapterDevice
     34     * PcInitializeAdapterDriver
     35 
     36     FACTORIES:
     37     * PcNewDmaChannel
     38     * PcNewInterruptSync
     39     * PcNewMiniport
     40     * PcNewPort
     41     * PcNewRegistryKey
     42     * PcNewResourceList
     43     * PcNewResourceSublist
     44     * PcNewServiceGroup
     45 
     46     POWER MANAGEMENT:
     47     * PcRegisterAdapterPowerManagement
     48     * PcRequestNewPowerState
     49 
     50     PROPERTIES:
     51     * PcCompletePendingPropertyRequest
     52     * PcGetDeviceProperty
     53 
     54     IO TIMEOUTS:
     55     * PcRegisterIoTimeout
     56     * PcUnregisterIoTimeout
     57 
     58     PHYSICAL CONNECTIONS:
     59     * PcRegisterPhysicalConnection
     60     * PcRegisterPhysicalConnectionFromExternal
     61     * PcRegisterPhysicalConnectionToExternal
     62 
     63     MISC:
     64     * PcGetTimeInterval
     65     * PcRegisterSubdevice
     66 
     67 
     68     == AUDIO HELPER OBJECT INTERFACES ==
     69     IDmaChannel
     70     IDmaChannelSlave
     71     IDmaOperations
     72     IDrmPort                        (XP)
     73     IDrmPort2                       (XP)
     74     IInterruptSync
     75     IMasterClock
     76     IPortClsVersion                 (XP)
     77     IPortEvents
     78     IPreFetchOffset                 (XP)
     79     IRegistryKey
     80     IResourceList
     81     IServiceGroup
     82     IServiceSink
     83     IUnregisterPhysicalConnection   (Vista)
     84     IUnregisterSubdevice            (Vista)
     85 
     86     == AUDIO PORT OBJECT INTERFACES ==
     87     IPort
     88     IPortDMus
     89     IPortMidi
     90     IPortTopology
     91     IPortWaveCyclic
     92     IPortWavePci
     93 
     94     == AUDIO MINIPORT OBJECT INTERFACES ==
     95     IMiniport
     96     IMiniportDMus
     97     IMiniportMidi
     98     IMiniportTopology
     99     IMiniportWaveCyclic
    100     IMiniportWavePci
    101 
    102     == AUDIO MINIPORT AUXILIARY INTERFACES ==
    103     IMusicTechnology                (XP)
    104     IPinCount                       (XP)
    105 
    106     == AUDIO STREAM OBJECT INTERFACES ==
    107     IAllocatorMXF
    108     IDrmAudioStream                 (XP)
    109     IMiniportMidiStream
    110     IMiniportWaveCyclicStream
    111     IMiniportWavePciStream
    112     IMXF
    113     IPortWavePciStream
    114     ISynthSinkDMus
    115 
    116     == DIRECTMUSIC USERMODE SYNTH AND SYNTH SINK INTERFACES ==
    117     IDirectMusicSynth
    118     IDirectMusicSynthSink
    119 
    120     == AUDIO POWER MANAGEMENT INTERFACES ==
    121     IAdapterPowerManagement
    122     IPowerNotify
    123 */
    124 
    125 #ifndef PORTCLS_H
    126 #define PORTCLS_H
    127 
    128 #ifdef __cplusplus
    129 extern "C"
    130 {
    131 # include <wdm.h>
    132 }
    133 #else
    134 # include <wdm.h>
    135 #endif
    136 
    137 #include <windef.h>
    138 
    139 #define NOBITMAP
    140 #include <mmreg.h>
    141 #undef NOBITMAP
    142 
    143 #include <punknown.h>
    144 #include <ks.h>
    145 #include <ksmedia.h>
    146 #include <drmk.h>
    147 
    148 #ifdef __cplusplus
    149 extern "C"
    150 {
    151 # include <wdm.h>
    152 }
    153 #else
    154 # include <wdm.h>
    155 #endif
    156 
    157 #ifndef PC_NO_IMPORTS
    158 #define PORTCLASSAPI EXTERN_C __declspec(dllimport)
    159 #else
    160 #define PORTCLASSAPI EXTERN_C
    161 #endif
    162 
    163 /* TODO */
    164 #define PCFILTER_NODE ((ULONG) -1)
    165 
    166 /* HACK */
    167 /* typedef PVOID CM_RESOURCE_TYPE; */
    168 
    169 #define _100NS_UNITS_PER_SECOND 10000000L
    170 #define PORT_CLASS_DEVICE_EXTENSION_SIZE ( 64 * sizeof(ULONG_PTR) )
    171 
    172 
    173 DEFINE_GUID(CLSID_MiniportDriverFmSynth, 0xb4c90ae0L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
    174 DEFINE_GUID(CLSID_MiniportDriverFmSynthWithVol, 0xe5a3c139L, 0xf0f2, 0x11d1, 0x81, 0xaf, 0x00, 0x60, 0x08, 0x33, 0x16, 0xc1);
    175 
    176 /* ===============================================================
    177     Event Item Flags - TODO
    178 */
    179 #define PCEVENT_ITEM_FLAG_ENABLE            KSEVENT_TYPE_ENABLE
    180 #define PCEVENT_ITEM_FLAG_ONESHOT           KSEVENT_TYPE_ONESHOT
    181 #define PCEVENT_ITEM_FLAG_BASICSUPPORT      KSEVENT_TYPE_BASICSUPPORT
    182 
    183 
    184 /* ===============================================================
    185     Event Verbs - TODO
    186 */
    187 #define PCEVENT_VERB_NONE       0
    188 #define PCEVENT_VERB_ADD        1
    189 #define PCEVENT_VERB_REMOVE     2
    190 #define PCEVENT_VERB_SUPPORT    4
    191 
    192 
    193 /* ===============================================================
    194     Method Item Flags - TODO
    195 */
    196 #define PCMETHOD_ITEM_FLAG_NONE             KSMETHOD_TYPE_NONE
    197 #define PCMETHOD_ITEM_FLAG_READ             KSMETHOD_TYPE_READ
    198 #define PCMETHOD_ITEM_FLAG_WRITE            KSMETHOD_TYPE_WRITE
    199 #define PCMETHOD_ITEM_FLAG_MODIFY           KSMETHOD_TYPE_MODIFY
    200 #define PCMETHOD_ITEM_FLAG_SOURCE           KSMETHOD_TYPE_SOURCE
    201 
    202 
    203 /* ===============================================================
    204     Method Verbs - TODO
    205 */
    206 #define PCMETHOD_ITEM_FLAG_BASICSUPPORT     KSMETHOD_TYPE_BASICSUPPORT
    207 #define PCMETHOD_ITEM_FLAG_SEND
    208 #define PCMETHOD_ITEM_FLAG_SETSUPPORT
    209 
    210 
    211 /* ===============================================================
    212     Versions
    213     IoIsWdmVersionAvailable may also be used by older drivers.
    214 */
    215 
    216 enum
    217 {
    218     kVersionInvalid = -1,
    219 
    220     kVersionWin98,
    221     kVersionWin98SE,
    222     kVersionWin2K,
    223     kVersionWin98SE_QFE2,
    224     kVersionWin2K_SP2,
    225     kVersionWinME,
    226     kVersionWin98SE_QFE3,
    227     kVersionWinME_QFE1,
    228     kVersionWinXP,
    229     kVersionWinXPSP1,
    230     kVersionWinServer2003,
    231     kVersionWin2K_UAAQFE,           /* These support IUnregister* interface */
    232     kVersionWinXP_UAAQFE,
    233     kVersionWinServer2003_UAAQFE
    234 };
    235 
    236 /* ===============================================================
    237     Properties
    238 */
    239 
    240 struct _PCPROPERTY_REQUEST;
    241 
    242 typedef struct _PCPROPERTY_REQUEST PCPROPERTY_REQUEST, *PPCPROPERTY_REQUEST;
    243 
    244 typedef NTSTATUS (NTAPI *PCPFNPROPERTY_HANDLER)(
    245     IN  PPCPROPERTY_REQUEST PropertyRequest);
    246 
    247 typedef struct
    248 {
    249     const GUID *            Set;
    250     ULONG                   Id;
    251     ULONG                   Flags;
    252 #define PCPROPERTY_ITEM_FLAG_GET            KSPROPERTY_TYPE_GET
    253 #define PCPROPERTY_ITEM_FLAG_SET            KSPROPERTY_TYPE_SET
    254 #define PCPROPERTY_ITEM_FLAG_BASICSUPPORT   KSPROPERTY_TYPE_BASICSUPPORT
    255 //not supported #define PCPROPERTY_ITEM_FLAG_RELATIONS      KSPROPERTY_TYPE_RELATIONS
    256 #define PCPROPERTY_ITEM_FLAG_SERIALIZERAW   KSPROPERTY_TYPE_SERIALIZERAW
    257 #define PCPROPERTY_ITEM_FLAG_UNSERIALIZERAW KSPROPERTY_TYPE_UNSERIALIZERAW
    258 #define PCPROPERTY_ITEM_FLAG_SERIALIZESIZE  KSPROPERTY_TYPE_SERIALIZESIZE
    259 #define PCPROPERTY_ITEM_FLAG_SERIALIZE\
    260         (PCPROPERTY_ITEM_FLAG_SERIALIZERAW\
    261         |PCPROPERTY_ITEM_FLAG_UNSERIALIZERAW\
    262         |PCPROPERTY_ITEM_FLAG_SERIALIZESIZE\
    263         )
    264 #define PCPROPERTY_ITEM_FLAG_DEFAULTVALUES  KSPROPERTY_TYPE_DEFAULTVALUES
    265     PCPFNPROPERTY_HANDLER   Handler;
    266 }
    267 PCPROPERTY_ITEM, *PPCPROPERTY_ITEM;
    268 
    269 
    270 struct _PCPROPERTY_REQUEST
    271 {
    272     PUNKNOWN                MajorTarget;
    273     PUNKNOWN                MinorTarget;
    274     ULONG                   Node;
    275     const PCPROPERTY_ITEM * PropertyItem;
    276     ULONG                   Verb;
    277     ULONG                   InstanceSize;
    278     PVOID                   Instance;
    279     ULONG                   ValueSize;
    280     PVOID                   Value;
    281     PIRP                    Irp;
    282 };
    283 
    284 struct _PCEVENT_REQUEST;
    285 
    286 typedef NTSTATUS (NTAPI *PCPFNEVENT_HANDLER)(
    287     IN  struct _PCEVENT_REQUEST* EventRequest);
    288 
    289 typedef struct _PCEVENT_ITEM
    290 {
    291     const GUID* Set;
    292     ULONG Id;
    293     ULONG Flags;
    294     PCPFNEVENT_HANDLER Handler;
    295 } PCEVENT_ITEM, *PPCEVENT_ITEM;
    296 
    297 typedef struct _PCEVENT_REQUEST
    298 {
    299     PUNKNOWN MajorTarget;
    300     PUNKNOWN MinorTarget;
    301     ULONG Node;
    302     const PCEVENT_ITEM* EventItem;
    303     PKSEVENT_ENTRY EventEntry;
    304     ULONG Verb;
    305     PIRP Irp;
    306 } PCEVENT_REQUEST, *PPCEVENT_REQUEST;
    307 
    308 
    309 
    310 struct _PCMETHOD_REQUEST;
    311 
    312 typedef NTSTATUS (NTAPI *PCPFNMETHOD_HANDLER)(
    313     IN  struct _PCMETHOD_REQUEST* MethodRequest);
    314 
    315 typedef struct _PCMETHOD_ITEM
    316 {
    317     const GUID* Set;
    318     ULONG Id;
    319     ULONG Flags;
    320     PCPFNMETHOD_HANDLER Handler;
    321 } PCMETHOD_ITEM, *PPCMETHOD_ITEM;
    322 
    323 typedef struct _PCMETHOD_REQUEST
    324 {
    325     PUNKNOWN MajorTarget;
    326     PUNKNOWN MinorTarget;
    327     ULONG Node;
    328     const PCMETHOD_ITEM* MethodItem;
    329     ULONG Verb;
    330 } PCMETHOD_REQUEST, *PPCMETHOD_REQUEST;
    331 
    332 
    333 /* ===============================================================
    334     Structures (unsorted)
    335 */
    336 
    337 typedef struct
    338 {
    339     ULONG PropertyItemSize;
    340     ULONG PropertyCount;
    341     const PCPROPERTY_ITEM* Properties;
    342     ULONG MethodItemSize;
    343     ULONG MethodCount;
    344     const PCMETHOD_ITEM* Methods;
    345     ULONG EventItemSize;
    346     ULONG EventCount;
    347     const PCEVENT_ITEM* Events;
    348     ULONG Reserved;
    349 } PCAUTOMATION_TABLE, *PPCAUTOMATION_TABLE;
    350 
    351 typedef struct
    352 {
    353     ULONG FromNode;
    354     ULONG FromNodePin;
    355     ULONG ToNode;
    356     ULONG ToNodePin;
    357 } PCCONNECTION_DESCRIPTOR, *PPCCONNECTIONDESCRIPTOR;
    358 
    359 typedef struct
    360 {
    361     ULONG MaxGlobalInstanceCount;
    362     ULONG MaxFilterInstanceCount;
    363     ULONG MinFilterInstanceCount;
    364     const PCAUTOMATION_TABLE* AutomationTable;
    365     KSPIN_DESCRIPTOR KsPinDescriptor;
    366 } PCPIN_DESCRIPTOR, *PPCPIN_DESCRIPTOR;
    367 
    368 typedef struct
    369 {
    370     ULONG Flags;
    371     const PCAUTOMATION_TABLE* AutomationTable;
    372     const GUID* Type;
    373     const GUID* Name;
    374 } PCNODE_DESCRIPTOR, *PPCNODE_DESCRIPTOR;
    375 
    376 typedef struct
    377 {
    378     ULONG Version;
    379     const PCAUTOMATION_TABLE* AutomationTable;
    380     ULONG PinSize;
    381     ULONG PinCount;
    382     const PCPIN_DESCRIPTOR* Pins;
    383     ULONG NodeSize;
    384     ULONG NodeCount;
    385     const PCNODE_DESCRIPTOR* Nodes;
    386     ULONG ConnectionCount;
    387     const PCCONNECTION_DESCRIPTOR* Connections;
    388     ULONG CategoryCount;
    389     const GUID* Categories;
    390 } PCFILTER_DESCRIPTOR, *PPCFILTER_DESCRIPTOR;
    391 
    392 #define DEFINE_PCAUTOMATION_TABLE_PROP(AutomationTable,PropertyTable)\
    393 const PCAUTOMATION_TABLE AutomationTable =\
    394 {\
    395     sizeof(PropertyTable[0]),\
    396     SIZEOF_ARRAY(PropertyTable),\
    397     (const PCPROPERTY_ITEM *) PropertyTable,\
    398     0,0,NULL,\
    399     0,0,NULL,\
    400     0\
    401 }
    402 
    403 /* ===============================================================
    404     IResourceList Interface
    405 */
    406 
    407 #undef INTERFACE
    408 #define INTERFACE IResourceList
    409 
    410 DEFINE_GUID(IID_IResourceList, 0x22C6AC60L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    411 
    412 DECLARE_INTERFACE_(IResourceList, IUnknown)
    413 {
    414     DEFINE_ABSTRACT_UNKNOWN()
    415 
    416     STDMETHOD_(ULONG, NumberOfEntries)( THIS ) PURE;
    417 
    418     STDMETHOD_(ULONG, NumberOfEntriesOfType)( THIS_
    419         IN  CM_RESOURCE_TYPE Type) PURE;
    420 
    421     STDMETHOD_(PCM_PARTIAL_RESOURCE_DESCRIPTOR, FindTranslatedEntry)( THIS_
    422         IN  CM_RESOURCE_TYPE Type,
    423         IN  ULONG Index) PURE;
    424 
    425     STDMETHOD_(PCM_PARTIAL_RESOURCE_DESCRIPTOR, FindUntranslatedEntry)( THIS_
    426         IN  CM_RESOURCE_TYPE Type,
    427         IN  ULONG Index) PURE;
    428 
    429     STDMETHOD_(NTSTATUS, AddEntry)( THIS_
    430         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated,
    431         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated) PURE;
    432 
    433     STDMETHOD_(NTSTATUS, AddEntryFromParent)( THIS_
    434         IN  IResourceList* Parent,
    435         IN  CM_RESOURCE_TYPE Type,
    436         IN  ULONG Index) PURE;
    437 
    438     STDMETHOD_(PCM_RESOURCE_LIST, TranslatedList)( THIS ) PURE;
    439     STDMETHOD_(PCM_RESOURCE_LIST, UntranslatedList)( THIS ) PURE;
    440 };
    441 
    442 #define IMP_IResourceList \
    443     STDMETHODIMP_(ULONG) NumberOfEntries(void); \
    444 \
    445     STDMETHODIMP_(ULONG) NumberOfEntriesOfType( \
    446         IN  CM_RESOURCE_TYPE Type); \
    447 \
    448     STDMETHODIMP_(PCM_PARTIAL_RESOURCE_DESCRIPTOR) FindTranslatedEntry( \
    449         IN  CM_RESOURCE_TYPE Type, \
    450         IN  ULONG Index); \
    451 \
    452     STDMETHODIMP_(PCM_PARTIAL_RESOURCE_DESCRIPTOR) FindUntranslatedEntry( \
    453         IN  CM_RESOURCE_TYPE Type, \
    454         IN  ULONG Index); \
    455 \
    456     STDMETHODIMP_(NTSTATUS) AddEntry( \
    457         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated, \
    458         IN  PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated); \
    459 \
    460     STDMETHODIMP_(NTSTATUS) AddEntryFromParent( \
    461         IN  IResourceList* Parent, \
    462         IN  CM_RESOURCE_TYPE Type, \
    463         IN  ULONG Index); \
    464 \
    465     STDMETHODIMP_(PCM_RESOURCE_LIST) TranslatedList(void); \
    466     STDMETHODIMP_(PCM_RESOURCE_LIST) UntranslatedList(void);
    467 
    468 typedef IResourceList *PRESOURCELIST;
    469 
    470 #define NumberOfPorts() \
    471     NumberOfEntriesOfType(CmResourceTypePort)
    472 
    473 #define FindTranslatedPort(n) \
    474     FindTranslatedEntry(CmResourceTypePort, (n))
    475 
    476 #define FindUntranslatedPort(n) \
    477     FindUntranslatedEntry(CmResourceTypePort, (n))
    478 
    479 #define AddPortFromParent(p, n) \
    480     AddEntryFromParent((p), CmResourceTypePort, (n))
    481 
    482 #define NumberOfInterrupts() \
    483     NumberOfEntriesOfType(CmResourceTypeInterrupt)
    484 
    485 #define FindTranslatedInterrupt(n) \
    486     FindTranslatedEntry(CmResourceTypeInterrupt, (n))
    487 
    488 #define FindUntranslatedInterrupt(n) \
    489     FindUntranslatedEntry(CmResourceTypeInterrupt, (n))
    490 
    491 #define AddInterruptFromParent(p, n) \
    492     AddEntryFromParent((p), CmResourceTypeInterrupt, (n))
    493 
    494 #define NumberOfMemories() \
    495     NumberOfEntriesOfType(CmResourceTypeMemory)
    496 
    497 #define FindTranslatedMemory(n) \
    498     FindTranslatedEntry(CmResourceTypeMemory, (n))
    499 
    500 #define FindUntranslatedMemory(n) \
    501     FindUntranslatedEntry(CmResourceTypeMemory, (n))
    502 
    503 #define AddMemoryFromParent(p, n) \
    504     AddEntryFromParent((p), CmResourceTypeMemory, (n))
    505 
    506 #define NumberOfDmas() \
    507     NumberOfEntriesOfType(CmResourceTypeDma)
    508 
    509 #define FindTranslatedDma(n) \
    510     FindTranslatedEntry(CmResourceTypeDma, (n))
    511 
    512 #define FindUntranslatedDma(n) \
    513     FindUntranslatedEntry(CmResourceTypeDma, (n))
    514 
    515 #define AddDmaFromParent(p, n) \
    516     AddEntryFromParent((p), CmResourceTypeInterrupt, (n))
    517 
    518 #define NumberOfDeviceSpecifics() \
    519     NumberOfEntriesOfType(CmResourceTypeDeviceSpecific)
    520 
    521 #define FindTranslatedDeviceSpecific(n) \
    522     FindTranslatedEntry(CmResourceTypeDeviceSpecific, (n))
    523 
    524 #define FindUntranslatedDeviceSpecific(n) \
    525     FindUntranslatedEntry(CmResourceTypeDeviceSpecific, (n))
    526 
    527 #define AddDeviceSpecificFromParent(p, n) \
    528     AddEntryFromParent((p), CmResourceTypeDeviceSpecific, (n))
    529 
    530 #define NumberOfBusNumbers() \
    531     NumberOfEntriesOfType(CmResourceTypeBusNumber)
    532 
    533 #define FindTranslatedBusNumber(n) \
    534     FindTranslatedEntry(CmResourceTypeBusNumber, (n))
    535 
    536 #define FindUntranslatedBusNumber(n) \
    537     FindUntranslatedEntry(CmResourceTypeBusNumber, (n))
    538 
    539 #define AddBusNumberFromParent(p, n) \
    540     AddEntryFromParent((p), CmResourceTypeBusNumber, (n))
    541 
    542 #define NumberOfDevicePrivates() \
    543     NumberOfEntriesOfType(CmResourceTypeDevicePrivate)
    544 
    545 #define FindTranslatedDevicePrivate(n) \
    546     FindTranslatedEntry(CmResourceTypeDevicePrivate, (n))
    547 
    548 #define FindUntranslatedDevicePrivate(n) \
    549     FindUntranslatedEntry(CmResourceTypeDevicePrivate, (n))
    550 
    551 #define AddDevicePrivateFromParent(p, n) \
    552     AddEntryFromParent((p), CmResourceTypeDevicePrivate, (n))
    553 
    554 #define NumberOfAssignedResources() \
    555     NumberOfEntriesOfType(CmResourceTypeAssignedResource)
    556 
    557 #define FindTranslatedAssignedResource(n) \
    558     FindTranslatedEntry(CmResourceTypeAssignedResource, (n))
    559 
    560 #define FindUntranslatedAssignedResource(n) \
    561     FindUntranslatedEntry(CmResourceTypeAssignedResource, (n))
    562 
    563 #define AddAssignedResourceFromParent(p, n) \
    564     AddEntryFromParent((p), CmResourceTypeAssignedResource, (n))
    565 
    566 #define NumberOfSubAllocateFroms() \
    567     NumberOfEntriesOfType(CmResourceTypeSubAllocateFrom)
    568 
    569 #define FindTranslatedSubAllocateFrom(n) \
    570     FindTranslatedEntry(CmResourceTypeSubAllocateFrom, (n))
    571 
    572 #define FindUntranslatedSubAllocateFrom(n) \
    573     FindUntranslatedEntry(CmResourceTypeSubAllocateFrom, (n))
    574 
    575 #define AddSubAllocateFromFromParent(p, n) \
    576     AddEntryFromParent((p), CmResourceTypeSubAllocateFrom, (n))
    577 
    578 #undef INTERFACE
    579 
    580 
    581 /* ===============================================================
    582     IServiceSink Interface
    583 */
    584 #define INTERFACE IServiceSink
    585 
    586 DEFINE_GUID(IID_IServiceSink, 0x22C6AC64L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    587 
    588 DECLARE_INTERFACE_(IServiceSink, IUnknown)
    589 {
    590     DEFINE_ABSTRACT_UNKNOWN()
    591     STDMETHOD_(void, RequestService)( THIS ) PURE;
    592 };
    593 
    594 #define IMP_IServiceSink \
    595     STDMETHODIMP_(void) RequestService(void);
    596 
    597 typedef IServiceSink *PSERVICESINK;
    598 
    599 
    600 /* ===============================================================
    601     IServiceGroup Interface
    602 */
    603 #undef INTERFACE
    604 #define INTERFACE IServiceGroup
    605 
    606 DEFINE_GUID(IID_IServiceGroup, 0x22C6AC65L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    607 
    608 DECLARE_INTERFACE_(IServiceGroup, IServiceSink)
    609 {
    610     DEFINE_ABSTRACT_UNKNOWN()
    611 
    612     STDMETHOD_(void, RequestService)( THIS ) PURE;  /* IServiceSink */
    613 
    614     STDMETHOD_(NTSTATUS, AddMember)( THIS_
    615         IN  PSERVICESINK pServiceSink) PURE;
    616 
    617     STDMETHOD_(void, RemoveMember)( THIS_
    618         IN  PSERVICESINK pServiceSink) PURE;
    619 
    620     STDMETHOD_(void, SupportDelayedService)( THIS ) PURE;
    621 
    622     STDMETHOD_(void, RequestDelayedService)( THIS_
    623         IN  ULONGLONG ullDelay) PURE;
    624 
    625     STDMETHOD_(void, CancelDelayedService)( THIS ) PURE;
    626 };
    627 
    628 #define IMP_IServiceGroup \
    629     IMP_IServiceSink; \
    630 \
    631     STDMETHODIMP_(NTSTATUS) AddMember( \
    632         IN  PSERVICESINK pServiceSink); \
    633 \
    634     STDMETHODIMP_(void) RemoveMember( \
    635         IN  PSERVICESINK pServiceSink); \
    636 \
    637     STDMETHODIMP_(void) SupportDelayedService(void); \
    638 \
    639     STDMETHODIMP_(void) RequestDelayedService( \
    640         IN  ULONGLONG ullDelay); \
    641 \
    642     STDMETHODIMP_(void) CancelDelayedService(void);
    643 
    644 typedef IServiceGroup *PSERVICEGROUP;
    645 
    646 
    647 #if (NTDDI_VERSION >= NTDDI_WS03)
    648 /* ===============================================================
    649     IUnregisterSubdevice Interface
    650 */
    651 
    652 DEFINE_GUID(IID_IUnregisterSubdevice, 0x16738177L, 0xe199, 0x41f9, 0x9a, 0x87, 0xab, 0xb2, 0xa5, 0x43, 0x2f, 0x21);
    653 
    654 #undef INTERFACE
    655 #define INTERFACE IUnregisterSubdevice
    656 
    657 DECLARE_INTERFACE_(IUnregisterSubdevice,IUnknown)
    658 {
    659     DEFINE_ABSTRACT_UNKNOWN()
    660 
    661     STDMETHOD_(NTSTATUS,UnregisterSubdevice)(THIS_
    662         IN  PDEVICE_OBJECT  DeviceObject,
    663         IN  PUNKNOWN        Unknown)PURE;
    664 };
    665 
    666 typedef IUnregisterSubdevice *PUNREGISTERSUBDEVICE;
    667 
    668 #define IMP_IUnregisterSubdevice                        \
    669     STDMETHODIMP_(NTSTATUS) UnregisterSubdevice(THIS_   \
    670         IN  PDEVICE_OBJECT  DeviceObject,               \
    671         IN  PUNKNOWN        Unknown)
    672 
    673 /* ===============================================================
    674     IUnregisterPhysicalConnection Interface
    675 */
    676 
    677 #undef INTERFACE
    678 #define INTERFACE IUnregisterPhysicalConnection
    679 
    680 DEFINE_GUID(IID_IUnregisterPhysicalConnection, 0x6c38e231L, 0x2a0d, 0x428d, 0x81, 0xf8, 0x07, 0xcc, 0x42, 0x8b, 0xb9, 0xa4);
    681 
    682 DECLARE_INTERFACE_(IUnregisterPhysicalConnection,IUnknown)
    683 {
    684     DEFINE_ABSTRACT_UNKNOWN()
    685 
    686     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnection)(THIS_
    687         IN  PDEVICE_OBJECT  DeviceObject,
    688         IN  PUNKNOWN        FromUnknown,
    689         IN  ULONG           FromPin,
    690         IN  PUNKNOWN        ToUnknown,
    691         IN  ULONG           ToPin)PURE;
    692 
    693     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnectionToExternal)(THIS_
    694         IN  PDEVICE_OBJECT  DeviceObject,
    695         IN  PUNKNOWN        FromUnknown,
    696         IN  ULONG           FromPin,
    697         IN  PUNICODE_STRING ToString,
    698         IN  ULONG           ToPin)PURE;
    699 
    700     STDMETHOD_(NTSTATUS,UnregisterPhysicalConnectionFromExternal)(THIS_
    701         IN  PDEVICE_OBJECT  DeviceObject,
    702         IN  PUNICODE_STRING FromString,
    703         IN  ULONG           FromPin,
    704         IN  PUNKNOWN        ToUnknown,
    705         IN  ULONG           ToPin)PURE;
    706 };
    707 
    708 typedef IUnregisterPhysicalConnection *PUNREGISTERPHYSICALCONNECTION;
    709 #endif
    710 
    711 #define IMP_IUnregisterPhysicalConnection                                    \
    712     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnection(                    \
    713         IN  PDEVICE_OBJECT  DeviceObject,                                    \
    714         IN  PUNKNOWN        FromUnknown,                                     \
    715         IN  ULONG           FromPin,                                         \
    716         IN  PUNKNOWN        ToUnknown,                                       \
    717         IN  ULONG           ToPin);                                          \
    718                                                                              \
    719     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnectionToExternal(          \
    720         IN  PDEVICE_OBJECT  DeviceObject,                                    \
    721         IN  PUNKNOWN        FromUnknown,                                     \
    722         IN  ULONG           FromPin,                                         \
    723         IN  PUNICODE_STRING ToString,                                        \
    724         IN  ULONG           ToPin);                                          \
    725                                                                              \
    726     STDMETHODIMP_(NTSTATUS) UnregisterPhysicalConnectionFromExternal(        \
    727         IN  PDEVICE_OBJECT  DeviceObject,                                    \
    728         IN  PUNICODE_STRING FromString,                                      \
    729         IN  ULONG           FromPin,                                         \
    730         IN  PUNKNOWN        ToUnknown,                                       \
    731         IN  ULONG           ToPin)
    732 
    733 
    734 /* ===============================================================
    735     IDmaChannel Interface
    736 */
    737 
    738 #define DEFINE_ABSTRACT_DMACHANNEL() \
    739     STDMETHOD_(NTSTATUS, AllocateBuffer)( THIS_ \
    740         IN  ULONG BufferSize, \
    741         IN  PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL) PURE; \
    742 \
    743     STDMETHOD_(void, FreeBuffer)( THIS ) PURE; \
    744     STDMETHOD_(ULONG, TransferCount)( THIS ) PURE; \
    745     STDMETHOD_(ULONG, MaximumBufferSize)( THIS ) PURE; \
    746     STDMETHOD_(ULONG, AllocatedBufferSize)( THIS ) PURE; \
    747     STDMETHOD_(ULONG, BufferSize)( THIS ) PURE; \
    748 \
    749     STDMETHOD_(void, SetBufferSize)( THIS_ \
    750         IN  ULONG BufferSize) PURE; \
    751 \
    752     STDMETHOD_(PVOID, SystemAddress)( THIS ) PURE; \
    753     STDMETHOD_(PHYSICAL_ADDRESS, PhysicalAddress)( THIS ) PURE; \
    754     STDMETHOD_(PADAPTER_OBJECT, GetAdapterObject)( THIS ) PURE; \
    755 \
    756     STDMETHOD_(void, CopyTo)( THIS_ \
    757         IN  PVOID Destination, \
    758         IN  PVOID Source, \
    759         IN  ULONG ByteCount) PURE; \
    760 \
    761     STDMETHOD_(void, CopyFrom)( THIS_ \
    762         IN  PVOID Destination, \
    763         IN  PVOID Source, \
    764         IN  ULONG ByteCount) PURE;
    765 
    766 #define IMP_IDmaChannel                                                   \
    767     STDMETHODIMP_(NTSTATUS) AllocateBuffer(                               \
    768         IN  ULONG BufferSize,                                             \
    769         IN  PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL);        \
    770                                                                           \
    771     STDMETHODIMP_(void) FreeBuffer(void);                                 \
    772     STDMETHODIMP_(ULONG) TransferCount(void);                             \
    773     STDMETHODIMP_(ULONG) MaximumBufferSize(void);                         \
    774     STDMETHODIMP_(ULONG) AllocatedBufferSize(void);                       \
    775     STDMETHODIMP_(ULONG) BufferSize(void);                                \
    776                                                                           \
    777     STDMETHODIMP_(void) SetBufferSize(                                    \
    778         IN  ULONG BufferSize);                                            \
    779                                                                           \
    780     STDMETHODIMP_(PVOID) SystemAddress(void);                             \
    781     STDMETHODIMP_(PHYSICAL_ADDRESS) PhysicalAddress(void);                \
    782     STDMETHODIMP_(PADAPTER_OBJECT) GetAdapterObject(void);                \
    783                                                                           \
    784     STDMETHODIMP_(void) CopyTo(                                           \
    785         IN  PVOID Destination,                                            \
    786         IN  PVOID Source,                                                 \
    787         IN  ULONG ByteCount);                                             \
    788                                                                           \
    789     STDMETHODIMP_(void) CopyFrom(                                         \
    790         IN  PVOID Destination,                                            \
    791         IN  PVOID Source,                                                 \
    792         IN  ULONG ByteCount)
    793 
    794 #undef INTERFACE
    795 #define INTERFACE IDmaChannel
    796 
    797 DEFINE_GUID(IID_IDmaChannel, 0x22C6AC61L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    798 
    799 DECLARE_INTERFACE_(IDmaChannel, IUnknown)
    800 {
    801     DEFINE_ABSTRACT_UNKNOWN()
    802     DEFINE_ABSTRACT_DMACHANNEL()
    803 };
    804 
    805 typedef IDmaChannel *PDMACHANNEL;
    806 
    807 
    808 /* ===============================================================
    809     IDmaChannelSlave Interface
    810 */
    811 
    812 #define DEFINE_ABSTRACT_DMACHANNELSLAVE() \
    813     STDMETHOD_(NTSTATUS, Start)( THIS_ \
    814         IN  ULONG MapSize, \
    815         IN  BOOLEAN WriteToDevice) PURE; \
    816 \
    817     STDMETHOD_(NTSTATUS, Stop)( THIS ) PURE; \
    818     STDMETHOD_(ULONG, ReadCounter)( THIS ) PURE; \
    819 \
    820     STDMETHOD_(NTSTATUS, WaitForTC)( THIS_ \
    821         ULONG Timeout) PURE;
    822 
    823 #define IMP_IDmaChannelSlave                   \
    824     IMP_IDmaChannel;                           \
    825     STDMETHODIMP_(NTSTATUS) Start(             \
    826         IN  ULONG MapSize,                     \
    827         IN  BOOLEAN WriteToDevice);            \
    828                                                \
    829     STDMETHODIMP_(NTSTATUS) Stop(void);        \
    830     STDMETHODIMP_(ULONG) ReadCounter(void);    \
    831                                                \
    832     STDMETHODIMP_(NTSTATUS) WaitForTC(         \
    833         ULONG Timeout)
    834 
    835 #undef INTERFACE
    836 #define INTERFACE IDmaChannelSlave
    837 
    838 #if (NTDDI_VERSION < NTDDI_LONGHORN)
    839 DEFINE_GUID(IID_IDmaChannelSlave, 0x22C6AC62L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    840 #endif
    841 
    842 #undef INTERFACE
    843 #define INTERFACE IDmaChannelSlave
    844 
    845 DECLARE_INTERFACE_(IDmaChannelSlave, IDmaChannel)
    846 {
    847     DEFINE_ABSTRACT_UNKNOWN()
    848     DEFINE_ABSTRACT_DMACHANNEL()
    849     DEFINE_ABSTRACT_DMACHANNELSLAVE()
    850 };
    851 
    852 typedef IDmaChannelSlave *PDMACHANNELSLAVE;
    853 
    854 
    855 /* ===============================================================
    856     IInterruptSync Interface
    857 */
    858 
    859 typedef enum
    860 {
    861     InterruptSyncModeNormal = 1,
    862     InterruptSyncModeAll,
    863     InterruptSyncModeRepeat
    864 } INTERRUPTSYNCMODE;
    865 
    866 struct IInterruptSync;
    867 
    868 typedef NTSTATUS (NTAPI *PINTERRUPTSYNCROUTINE)(
    869     IN  struct IInterruptSync* InterruptSync,
    870     IN  PVOID DynamicContext);
    871 
    872 #undef INTERFACE
    873 #define INTERFACE IInterruptSync
    874 
    875 DECLARE_INTERFACE_(IInterruptSync, IUnknown)
    876 {
    877     DEFINE_ABSTRACT_UNKNOWN()
    878 
    879     STDMETHOD_(NTSTATUS, CallSynchronizedRoutine)( THIS_
    880         IN  PINTERRUPTSYNCROUTINE Routine,
    881         IN  PVOID DynamicContext) PURE;
    882 
    883     STDMETHOD_(PKINTERRUPT, GetKInterrupt)( THIS ) PURE;
    884     STDMETHOD_(NTSTATUS, Connect)( THIS ) PURE;
    885     STDMETHOD_(void, Disconnect)( THIS ) PURE;
    886 
    887     STDMETHOD_(NTSTATUS, RegisterServiceRoutine)( THIS_
    888         IN  PINTERRUPTSYNCROUTINE Routine,
    889         IN  PVOID DynamicContext,
    890         IN  BOOLEAN First) PURE;
    891 };
    892 
    893 DEFINE_GUID(IID_IInterruptSync, 0x22C6AC63L, 0x851B, 0x11D0, 0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE);
    894 
    895 #define IMP_IInterruptSync                           \
    896     STDMETHODIMP_(NTSTATUS) CallSynchronizedRoutine( \
    897         IN  PINTERRUPTSYNCROUTINE Routine,           \
    898         IN  PVOID DynamicContext);                   \
    899                                                      \
    900     STDMETHODIMP_(PKINTERRUPT) GetKInterrupt(void);  \
    901     STDMETHODIMP_(NTSTATUS) Connect(void);           \
    902     STDMETHODIMP_(void) Disconnect(void);            \
    903                                                      \
    904     STDMETHODIMP_(NTSTATUS) RegisterServiceRoutine(  \
    905         IN  PINTERRUPTSYNCROUTINE Routine,           \
    906         IN  PVOID DynamicContext,                    \
    907         IN  BOOLEAN First)
    908 
    909 typedef IInterruptSync *PINTERRUPTSYNC;
    910 
    911 
    912 /* ===============================================================
    913     IRegistryKey Interface
    914 */
    915 
    916 #undef INTERFACE
    917 #define INTERFACE IRegistryKey
    918 
    919 enum
    920 {
    921     GeneralRegistryKey,
    922     DeviceRegistryKey,
    923     DriverRegistryKey,
    924     HwProfileRegistryKey,
    925     DeviceInterfaceRegistryKey
    926 };
    927 
    928 DEFINE_GUID(IID_IRegistryKey, 0xE8DA4302l, 0xF304, 0x11D0, 0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
    929 
    930 DECLARE_INTERFACE_(IRegistryKey, IUnknown)
    931 {
    932     DEFINE_ABSTRACT_UNKNOWN()
    933 
    934     STDMETHOD_(NTSTATUS, QueryKey)( THIS_
    935         IN  KEY_INFORMATION_CLASS KeyInformationClass,
    936         OUT PVOID KeyInformation,
    937         IN  ULONG Length,
    938         OUT PULONG ResultLength) PURE;
    939 
    940     STDMETHOD_(NTSTATUS, EnumerateKey)( THIS_
    941         IN  ULONG Index,
    942         IN  KEY_INFORMATION_CLASS KeyInformationClass,
    943         OUT PVOID KeyInformation,
    944         IN  ULONG Length,
    945         OUT PULONG ResultLength) PURE;
    946 
    947     STDMETHOD_(NTSTATUS, QueryValueKey)( THIS_
    948         IN  PUNICODE_STRING ValueName,
    949         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
    950         OUT PVOID KeyValueInformation,
    951         IN  ULONG Length,
    952         OUT PULONG ResultLength) PURE;
    953 
    954     STDMETHOD_(NTSTATUS, EnumerateValueKey)( THIS_
    955         IN  ULONG Index,
    956         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
    957         OUT PVOID KeyValueInformation,
    958         IN  ULONG Length,
    959         OUT PULONG ResultLength) PURE;
    960 
    961     STDMETHOD_(NTSTATUS, SetValueKey)( THIS_
    962         IN  PUNICODE_STRING ValueName OPTIONAL,
    963         IN  ULONG Type,
    964         IN  PVOID Data,
    965         IN  ULONG DataSize) PURE;
    966 
    967     STDMETHOD_(NTSTATUS, QueryRegistryValues)( THIS_
    968         IN  PRTL_QUERY_REGISTRY_TABLE QueryTable,
    969         IN  PVOID Context OPTIONAL) PURE;
    970 
    971     STDMETHOD_(NTSTATUS, NewSubKey)( THIS_
    972         OUT IRegistryKey** RegistrySubKey,
    973         IN  PUNKNOWN OuterUnknown,
    974         IN  ACCESS_MASK DesiredAccess,
    975         IN  PUNICODE_STRING SubKeyName,
    976         IN  ULONG CreateOptions,
    977         OUT PULONG Disposition OPTIONAL) PURE;
    978 
    979     STDMETHOD_(NTSTATUS, DeleteKey)( THIS ) PURE;
    980 };
    981 
    982 #define IMP_IRegistryKey \
    983     STDMETHODIMP_(NTSTATUS) QueryKey( \
    984         IN  KEY_INFORMATION_CLASS KeyInformationClass, \
    985         OUT PVOID KeyInformation, \
    986         IN  ULONG Length, \
    987         OUT PULONG ResultLength); \
    988 \
    989     STDMETHODIMP_(NTSTATUS) EnumerateKey( \
    990         IN  ULONG Index, \
    991         IN  KEY_INFORMATION_CLASS KeyInformationClass, \
    992         OUT PVOID KeyInformation, \
    993         IN  ULONG Length, \
    994         OUT PULONG ResultLength); \
    995 \
    996     STDMETHODIMP_(NTSTATUS) QueryValueKey( \
    997         IN  PUNICODE_STRING ValueName, \
    998         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, \
    999         OUT PVOID KeyValueInformation, \
   1000         IN  ULONG Length, \
   1001         OUT PULONG ResultLength); \
   1002 \
   1003     STDMETHODIMP_(NTSTATUS) EnumerateValueKey( \
   1004         IN  ULONG Index, \
   1005         IN  KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, \
   1006         OUT PVOID KeyValueInformation, \
   1007         IN  ULONG Length, \
   1008         OUT PULONG ResultLength); \
   1009 \
   1010     STDMETHODIMP_(NTSTATUS) SetValueKey( \
   1011         IN  PUNICODE_STRING ValueName OPTIONAL, \
   1012         IN  ULONG Type, \
   1013         IN  PVOID Data, \
   1014         IN  ULONG DataSize); \
   1015 \
   1016     STDMETHODIMP_(NTSTATUS) QueryRegistryValues( \
   1017         IN  PRTL_QUERY_REGISTRY_TABLE QueryTable, \
   1018         IN  PVOID Context OPTIONAL); \
   1019 \
   1020     STDMETHODIMP_(NTSTATUS) NewSubKey( \
   1021         OUT IRegistryKey** RegistrySubKey, \
   1022         IN  PUNKNOWN OuterUnknown, \
   1023         IN  ACCESS_MASK DesiredAccess, \
   1024         IN  PUNICODE_STRING SubKeyName, \
   1025         IN  ULONG CreateOptions, \
   1026         OUT PULONG Disposition OPTIONAL); \
   1027 \
   1028     STDMETHODIMP_(NTSTATUS) DeleteKey(void);
   1029 
   1030 typedef IRegistryKey *PREGISTRYKEY;
   1031 
   1032 
   1033 /* ===============================================================
   1034     IMusicTechnology Interface
   1035 */
   1036 
   1037 DECLARE_INTERFACE_(IMusicTechnology, IUnknown)
   1038 {
   1039     DEFINE_ABSTRACT_UNKNOWN()
   1040 
   1041     STDMETHOD_(NTSTATUS, SetTechnology)( THIS_
   1042         IN  const GUID* Technology) PURE;
   1043 };
   1044 
   1045 #define IMP_IMusicTechnology \
   1046     STDMETHODIMP_(NTSTATUS) SetTechnology( \
   1047         IN  const GUID* Technology);
   1048 
   1049 typedef IMusicTechnology *PMUSICTECHNOLOGY;
   1050 
   1051 
   1052 /* ===============================================================
   1053     IPort Interface
   1054 */
   1055 
   1056 #if 0
   1057 #define STATIC_IPort 0xb4c90a25L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44
   1058 DEFINE_GUIDSTRUCT("0xB4C90A25-5791-11d0-86f9-00a0c911b544", IID_IPort);
   1059 #define IID_IPort DEFINE_GUIDNAMED(IID_IPort)
   1060 #endif
   1061 
   1062 DEFINE_GUID(IID_IMiniport,
   1063     0xb4c90a24L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1064 
   1065 DEFINE_GUID(IID_IPort,
   1066     0xb4c90a25L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1067 
   1068 #define DEFINE_ABSTRACT_PORT() \
   1069     STDMETHOD_(NTSTATUS, Init)( THIS_ \
   1070         IN  PDEVICE_OBJECT DeviceObject, \
   1071         IN  PIRP Irp, \
   1072         IN  PUNKNOWN UnknownMiniport, \
   1073         IN  PUNKNOWN UnknownAdapter OPTIONAL, \
   1074         IN  PRESOURCELIST ResourceList) PURE; \
   1075 \
   1076     STDMETHOD_(NTSTATUS, GetDeviceProperty)( THIS_ \
   1077         IN  DEVICE_REGISTRY_PROPERTY DeviceProperty, \
   1078         IN  ULONG BufferLength, \
   1079         OUT PVOID PropertyBuffer, \
   1080         OUT PULONG ResultLength) PURE; \
   1081 \
   1082     STDMETHOD_(NTSTATUS, NewRegistryKey)( THIS_ \
   1083         OUT PREGISTRYKEY* OutRegistryKey, \
   1084         IN  PUNKNOWN OuterUnknown OPTIONAL, \
   1085         IN  ULONG RegistryKeyType, \
   1086         IN  ACCESS_MASK DesiredAccess, \
   1087         IN  POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, \
   1088         IN  ULONG CreateOptiona OPTIONAL, \
   1089         OUT PULONG Disposition OPTIONAL) PURE;
   1090 
   1091 #ifdef PC_IMPLEMENTATION
   1092 #define IMP_IPort\
   1093     STDMETHODIMP_(NTSTATUS) Init\
   1094     (   IN      PDEVICE_OBJECT  DeviceObject,\
   1095         IN      PIRP            Irp,\
   1096         IN      PUNKNOWN        UnknownMiniport,\
   1097         IN      PUNKNOWN        UnknownAdapter      OPTIONAL,\
   1098         IN      PRESOURCELIST   ResourceList\
   1099     );\
   1100     STDMETHODIMP_(NTSTATUS) GetDeviceProperty\
   1101     (   IN      DEVICE_REGISTRY_PROPERTY    DeviceProperty,\
   1102         IN      ULONG                       BufferLength,\
   1103         OUT     PVOID                       PropertyBuffer,\
   1104         OUT     PULONG                      ResultLength\
   1105     );\
   1106     STDMETHODIMP_(NTSTATUS) NewRegistryKey\
   1107     (   OUT     PREGISTRYKEY *      OutRegistryKey,\
   1108         IN      PUNKNOWN            OuterUnknown        OPTIONAL,\
   1109         IN      ULONG               RegistryKeyType,\
   1110         IN      ACCESS_MASK         DesiredAccess,\
   1111         IN      POBJECT_ATTRIBUTES  ObjectAttributes    OPTIONAL,\
   1112         IN      ULONG               CreateOptions       OPTIONAL,\
   1113         OUT     PULONG              Disposition         OPTIONAL\
   1114     )
   1115 #endif
   1116 
   1117 #undef INTERFACE
   1118 #define INTERFACE IPort
   1119 
   1120 DECLARE_INTERFACE_(IPort, IUnknown)
   1121 {
   1122     DEFINE_ABSTRACT_UNKNOWN()
   1123     DEFINE_ABSTRACT_PORT()
   1124 };
   1125 
   1126 typedef IPort *PPORT;
   1127 
   1128 
   1129 /* ===============================================================
   1130     IPortMidi Interface
   1131 */
   1132 
   1133 DEFINE_GUID(IID_IPortMidi,
   1134     0xb4c90a40L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1135 DEFINE_GUID(CLSID_PortMidi,
   1136     0xb4c90a43L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1137 
   1138 #undef INTERFACE
   1139 #define INTERFACE IPortMidi
   1140 
   1141 DECLARE_INTERFACE_(IPortMidi, IPort)
   1142 {
   1143     DEFINE_ABSTRACT_UNKNOWN()
   1144     DEFINE_ABSTRACT_PORT()
   1145 
   1146     STDMETHOD_(VOID, Notify)(THIS_
   1147         IN  PSERVICEGROUP ServiceGroup OPTIONAL) PURE;
   1148 
   1149     STDMETHOD_(NTSTATUS, RegisterServiceGroup)(THIS_
   1150         IN  PSERVICEGROUP ServiceGroup) PURE;
   1151 };
   1152 
   1153 typedef IPortMidi *PPORTMIDI;
   1154 
   1155 #define IMP_IPortMidi() \
   1156     STDMETHODIMP_(VOID) Notify( \
   1157         IN  PSERVICEGROUP ServiceGroup OPTIONAL); \
   1158 \
   1159     STDMETHODIMP_(NTSTATUS) RegisterServiceGroup( \
   1160         IN  PSERVICEGROUP ServiceGroup);
   1161 
   1162 #undef INTERFACE
   1163 
   1164 /* ===============================================================
   1165     IPortWaveCyclic Interface
   1166 */
   1167 
   1168 DEFINE_GUID(IID_IPortWaveCyclic,
   1169     0xb4c90a26L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1170 DEFINE_GUID(CLSID_PortWaveCyclic,
   1171     0xb4c90a2aL, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1172 
   1173 #define INTERFACE IPortWaveCyclic
   1174 
   1175 DECLARE_INTERFACE_(IPortWaveCyclic, IPort)
   1176 {
   1177     DEFINE_ABSTRACT_UNKNOWN()
   1178 
   1179     DEFINE_ABSTRACT_PORT()
   1180 
   1181     STDMETHOD_(VOID, Notify)(THIS_
   1182         IN  PSERVICEGROUP ServiceGroup) PURE;
   1183 
   1184     STDMETHOD_(NTSTATUS, NewSlaveDmaChannel)(THIS_
   1185         OUT PDMACHANNELSLAVE* DmaChannel,
   1186         IN  PUNKNOWN OuterUnknown,
   1187         IN  PRESOURCELIST ResourceList OPTIONAL,
   1188         IN  ULONG DmaIndex,
   1189         IN  ULONG MaximumLength,
   1190         IN  BOOLEAN DemandMode,
   1191         IN  DMA_SPEED DmaSpeed) PURE;
   1192 
   1193     STDMETHOD_(NTSTATUS, NewMasterDmaChannel)(THIS_
   1194         OUT PDMACHANNEL* DmaChannel,
   1195         IN  PUNKNOWN OuterUnknown,
   1196         IN  PRESOURCELIST ResourceList OPTIONAL,
   1197         IN  ULONG MaximumLength,
   1198         IN  BOOLEAN Dma32BitAddresses,
   1199         IN  BOOLEAN Dma64BitAddresses,
   1200         IN  DMA_WIDTH DmaWidth,
   1201         IN  DMA_SPEED DmaSpeed) PURE;
   1202 
   1203 };
   1204 
   1205 typedef IPortWaveCyclic *PPORTWAVECYCLIC;
   1206 
   1207 #ifdef PC_IMPLEMENTATION
   1208 #define IMP_IPortWaveCyclic                           \
   1209     IMP_IPort;                                        \
   1210     STDMETHODIMP_(VOID) Notify(                       \
   1211         IN  PSERVICEGROUP ServiceGroup);              \
   1212                                                       \
   1213     STDMETHODIMP_(NTSTATUS) NewSlaveDmaChannel(       \
   1214         OUT PDMACHANNELSLAVE* DmaChannel,             \
   1215         IN  PUNKNOWN OuterUnknown,                    \
   1216         IN  PRESOURCELIST ResourceList OPTIONAL,      \
   1217         IN  ULONG DmaIndex,                           \
   1218         IN  ULONG MaximumLength,                      \
   1219         IN  BOOLEAN DemandMode,                       \
   1220         IN  DMA_SPEED DmaSpeed);                      \
   1221                                                       \
   1222     STDMETHODIMP_(NTSTATUS) NewMasterDmaChannel(      \
   1223         OUT PDMACHANNEL* DmaChannel,                  \
   1224         IN  PUNKNOWN OuterUnknown,                    \
   1225         IN  PRESOURCELIST ResourceList OPTIONAL,      \
   1226         IN  ULONG MaximumLength,                      \
   1227         IN  BOOLEAN Dma32BitAddresses,                \
   1228         IN  BOOLEAN Dma64BitAddresses,                \
   1229         IN  DMA_WIDTH DmaWidth,                       \
   1230         IN  DMA_SPEED DmaSpeed)
   1231 #endif
   1232 
   1233 
   1234 #undef INTERFACE
   1235 /* ===============================================================
   1236     IPortWavePci Interface
   1237 */
   1238 #undef INTERFACE
   1239 #define INTERFACE IPortWavePci
   1240 
   1241 DEFINE_GUID(IID_IPortWavePci,
   1242     0xb4c90a50L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1243 DEFINE_GUID(CLSID_PortWavePci,
   1244     0xb4c90a54L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1245 
   1246 DECLARE_INTERFACE_(IPortWavePci, IPort)
   1247 {
   1248     DEFINE_ABSTRACT_UNKNOWN()
   1249     DEFINE_ABSTRACT_PORT()
   1250 
   1251     STDMETHOD_(VOID, Notify)(THIS_
   1252         IN  PSERVICEGROUP ServiceGroup) PURE;
   1253 
   1254     STDMETHOD_(NTSTATUS, NewMasterDmaChannel)(THIS_
   1255         OUT PDMACHANNEL* DmaChannel,
   1256         IN  PUNKNOWN OuterUnknown,
   1257         IN  POOL_TYPE PoolType,
   1258         IN  PRESOURCELIST ResourceList OPTIONAL,
   1259         IN  BOOLEAN ScatterGather,
   1260         IN  BOOLEAN Dma32BitAddresses,
   1261         IN  BOOLEAN Dma64BitAddresses,
   1262         IN  BOOLEAN IgnoreCount,
   1263         IN  DMA_WIDTH DmaWidth,
   1264         IN  DMA_SPEED DmaSpeed,
   1265         IN  ULONG MaximumLength,
   1266         IN  ULONG DmaPort) PURE;
   1267 };
   1268 
   1269 typedef IPortWavePci *PPORTWAVEPCI;
   1270 #undef INTERFACE
   1271 
   1272 #ifdef PC_IMPLEMENTATION
   1273 #define IMP_IPortWavePci                                     \
   1274     IMP_IPort;                                               \
   1275     STDMETHODIMP_(VOID) Notify(                              \
   1276         IN  PSERVICEGROUP ServiceGroup);                     \
   1277                                                              \
   1278     STDMETHODIMP_(NTSTATUS) NewMasterDmaChannel(             \
   1279         OUT PDMACHANNEL* DmaChannel,                         \
   1280         IN  PUNKNOWN OuterUnknown,                           \
   1281         IN  POOL_TYPE PoolType,                              \
   1282         IN  PRESOURCELIST ResourceList OPTIONAL,             \
   1283         IN  BOOLEAN ScatterGather,                           \
   1284         IN  BOOLEAN Dma32BitAddresses,                       \
   1285         IN  BOOLEAN Dma64BitAddresses,                       \
   1286         IN  BOOLEAN IgnoreCount,                             \
   1287         IN  DMA_WIDTH DmaWidth,                              \
   1288         IN  DMA_SPEED DmaSpeed,                              \
   1289         IN  ULONG MaximumLength,                             \
   1290         IN  ULONG DmaPort);
   1291 #endif
   1292 
   1293 /* ===============================================================
   1294     IMiniPort Interface
   1295 */
   1296 
   1297 DEFINE_GUID(IID_IMiniPort,
   1298     0xb4c90a24L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1299 
   1300 #define DEFINE_ABSTRACT_MINIPORT() \
   1301     STDMETHOD_(NTSTATUS, GetDescription)( THIS_ \
   1302         OUT  PPCFILTER_DESCRIPTOR* Description) PURE; \
   1303 \
   1304     STDMETHOD_(NTSTATUS, DataRangeIntersection)( THIS_ \
   1305         IN  ULONG PinId, \
   1306         IN  PKSDATARANGE DataRange, \
   1307         IN  PKSDATARANGE MatchingDataRange, \
   1308         IN  ULONG OutputBufferLength, \
   1309         OUT PVOID ResultantFormat OPTIONAL, \
   1310         OUT PULONG ResultantFormatLength) PURE;
   1311 
   1312 #define IMP_IMiniport                                        \
   1313     STDMETHODIMP_(NTSTATUS) GetDescription(                  \
   1314         OUT  PPCFILTER_DESCRIPTOR* Description);             \
   1315                                                              \
   1316     STDMETHODIMP_(NTSTATUS) DataRangeIntersection(           \
   1317         IN  ULONG PinId,                                     \
   1318         IN  PKSDATARANGE DataRange,                          \
   1319         IN  PKSDATARANGE MatchingDataRange,                  \
   1320         IN  ULONG OutputBufferLength,                        \
   1321         OUT PVOID ResultantFormat OPTIONAL,                  \
   1322         OUT PULONG ResultantFormatLength)
   1323 
   1324 DECLARE_INTERFACE_(IMiniport, IUnknown)
   1325 {
   1326     DEFINE_ABSTRACT_UNKNOWN()
   1327     DEFINE_ABSTRACT_MINIPORT()
   1328 };
   1329 
   1330 typedef IMiniport *PMINIPORT;
   1331 
   1332 
   1333 /* ===============================================================
   1334     IMiniportMidiStream Interface
   1335 */
   1336 #undef INTERFACE
   1337 #define INTERFACE IMiniportMidiStream
   1338 
   1339 DEFINE_GUID(IID_IMiniportMidiStream,
   1340     0xb4c90a42L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1341 
   1342 DECLARE_INTERFACE_(IMiniportMidiStream, IUnknown)
   1343 {
   1344     DEFINE_ABSTRACT_UNKNOWN()
   1345 
   1346     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
   1347         IN PKSDATAFORMAT DataFormat)PURE;
   1348 
   1349     STDMETHOD_(NTSTATUS,SetState)(THIS_
   1350         IN KSSTATE State)PURE;
   1351 
   1352     STDMETHOD_(NTSTATUS,Read)(THIS_
   1353         IN PVOID BufferAddress,
   1354         IN ULONG BufferLength,
   1355         OUT PULONG BytesRead)PURE;
   1356 
   1357     STDMETHOD_(NTSTATUS,Write)(THIS_
   1358         IN PVOID BufferAddress,
   1359         IN ULONG BytesToWrite,
   1360         OUT PULONG BytesWritten)PURE;
   1361 };
   1362 
   1363 typedef IMiniportMidiStream* PMINIPORTMIDISTREAM;
   1364 #undef INTERFACE
   1365 
   1366 /* ===============================================================
   1367     IMiniportMidi Interface
   1368 */
   1369 #undef INTERFACE
   1370 #define INTERFACE IMiniportMidi
   1371 
   1372 DEFINE_GUID(IID_IMiniportMidi,
   1373     0xb4c90a41L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1374 
   1375 DECLARE_INTERFACE_(IMiniportMidi, IMiniport)
   1376 {
   1377     DEFINE_ABSTRACT_UNKNOWN()
   1378     DEFINE_ABSTRACT_MINIPORT()
   1379 
   1380     STDMETHOD_(NTSTATUS, Init)(THIS_
   1381     IN  PUNKNOWN UnknownAdapter,
   1382     IN  PRESOURCELIST ResourceList,
   1383     IN  PPORTMIDI Port,
   1384     OUT PSERVICEGROUP* ServiceGroup) PURE;
   1385 
   1386     STDMETHOD_(void, Service)(THIS) PURE;
   1387 
   1388     STDMETHOD_(NTSTATUS, NewStream)(THIS_
   1389         OUT PMINIPORTMIDISTREAM *Stream,
   1390         IN  PUNKNOWN OuterUnknown OPTIONAL,
   1391         IN  POOL_TYPE PoolType,
   1392         IN  ULONG Pin,
   1393         IN  BOOLEAN Capture,
   1394         IN  PKSDATAFORMAT DataFormat,
   1395         OUT PSERVICEGROUP* ServiceGroup) PURE;
   1396 
   1397 };
   1398 
   1399 typedef IMiniportMidi *PMINIPORTMIDI;
   1400 #undef INTERFACE
   1401 
   1402 /* ===============================================================
   1403     IMiniportDriverUart Interface
   1404 */
   1405 
   1406 DEFINE_GUID(IID_MiniportDriverUart,
   1407     0xb4c90ae1L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1408 DEFINE_GUID(CLSID_MiniportDriverUart,
   1409     0xb4c90ae1L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1410 
   1411 /* ===============================================================
   1412     IPortTopology Interface
   1413 */
   1414 #if 0
   1415 #define STATIC_IPortTopology \
   1416     0xb4c90a30L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44
   1417 DEFINE_GUIDSTRUCT("0xB4C90A30-5791-11d0-86f9-00a0c911b544", IID_IPortTopology);
   1418 #define IID_IPortTopology DEFINE_GUIDNAMED(IID_IPortTopology)
   1419 #endif
   1420 
   1421 #undef INTERFACE
   1422 #define INTERFACE IPortTopology
   1423 
   1424 DEFINE_GUID(IID_IPortTopology, 0xb4c90a30L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1425 DEFINE_GUID(CLSID_PortTopology, 0xb4c90a32L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1426 
   1427 #undef INTERFACE
   1428 #define INTERFACE IPortTopology
   1429 
   1430 DECLARE_INTERFACE_(IPortTopology, IPort)
   1431 {
   1432     DEFINE_ABSTRACT_UNKNOWN()
   1433     DEFINE_ABSTRACT_PORT()
   1434 };
   1435 
   1436 typedef IPortTopology *PPORTTOPOLOGY;
   1437 
   1438 #define IMP_IPortTopology IMP_IPort
   1439 
   1440 
   1441 /* ===============================================================
   1442     IMiniportTopology Interface
   1443 */
   1444 
   1445 #undef INTERFACE
   1446 #define INTERFACE IMiniportTopology
   1447 
   1448 DEFINE_GUID(IID_IMiniportTopology, 0xb4c90a31L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1449 
   1450 #undef INTERFACE
   1451 #define INTERFACE IMiniportTopology
   1452 
   1453 DECLARE_INTERFACE_(IMiniportTopology,IMiniport)
   1454 {
   1455     DEFINE_ABSTRACT_UNKNOWN()
   1456     DEFINE_ABSTRACT_MINIPORT()
   1457 
   1458     STDMETHOD_(NTSTATUS,Init)(THIS_
   1459         IN PUNKNOWN UnknownAdapter,
   1460         IN PRESOURCELIST ResourceList,
   1461         IN PPORTTOPOLOGY Port)PURE;
   1462 };
   1463 
   1464 typedef IMiniportTopology *PMINIPORTTOPOLOGY;
   1465 
   1466 /* ===============================================================
   1467     IMiniportWaveCyclicStream Interface
   1468 */
   1469 
   1470 #undef INTERFACE
   1471 #define INTERFACE IMiniportWaveCyclicStream
   1472 
   1473 DEFINE_GUID(IID_IMiniportWaveCyclicStream,
   1474 0xb4c90a28L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1475 
   1476 DECLARE_INTERFACE_(IMiniportWaveCyclicStream,IUnknown)
   1477 {
   1478     DEFINE_ABSTRACT_UNKNOWN()
   1479 
   1480     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
   1481         IN PKSDATAFORMAT DataFormat)PURE;
   1482 
   1483     STDMETHOD_(ULONG,SetNotificationFreq)(THIS_
   1484         IN ULONG Interval,
   1485         OUT PULONG FrameSize) PURE;
   1486 
   1487     STDMETHOD_(NTSTATUS,SetState)(THIS_
   1488         IN KSSTATE State) PURE;
   1489 
   1490     STDMETHOD_(NTSTATUS,GetPosition)( THIS_
   1491         OUT PULONG Position) PURE;
   1492 
   1493     STDMETHOD_(NTSTATUS,NormalizePhysicalPosition)(THIS_
   1494         IN OUT PLONGLONG PhysicalPosition) PURE;
   1495 
   1496     STDMETHOD_(void, Silence)( THIS_
   1497         IN PVOID Buffer,
   1498         IN ULONG ByteCount) PURE;
   1499 };
   1500 
   1501 typedef IMiniportWaveCyclicStream *PMINIPORTWAVECYCLICSTREAM;
   1502 
   1503 #define IMP_IMiniportWaveCyclicStream\
   1504     STDMETHODIMP_(NTSTATUS) SetFormat\
   1505     (   IN      PKSDATAFORMAT   DataFormat\
   1506     );\
   1507     STDMETHODIMP_(ULONG) SetNotificationFreq\
   1508     (   IN      ULONG           Interval,\
   1509         OUT     PULONG          FrameSize\
   1510     );\
   1511     STDMETHODIMP_(NTSTATUS) SetState\
   1512     (   IN      KSSTATE         State\
   1513     );\
   1514     STDMETHODIMP_(NTSTATUS) GetPosition\
   1515     (   OUT     PULONG          Position\
   1516     );\
   1517     STDMETHODIMP_(NTSTATUS) NormalizePhysicalPosition\
   1518     (   IN OUT PLONGLONG        PhysicalPosition\
   1519     );\
   1520     STDMETHODIMP_(void) Silence\
   1521     (   IN      PVOID           Buffer,\
   1522         IN      ULONG           ByteCount\
   1523     )
   1524 
   1525 
   1526 /* ===============================================================
   1527     IMiniportWaveCyclic Interface
   1528 */
   1529 #undef INTERFACE
   1530 
   1531 DEFINE_GUID(IID_IMiniportWaveCyclic,
   1532     0xb4c90a27L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1533 
   1534 #define INTERFACE IMiniportWaveCyclic
   1535 
   1536 DECLARE_INTERFACE_(IMiniportWaveCyclic, IMiniport)
   1537 {
   1538     DEFINE_ABSTRACT_UNKNOWN()
   1539     DEFINE_ABSTRACT_MINIPORT()
   1540 
   1541     STDMETHOD_(NTSTATUS, Init)(THIS_
   1542         IN PUNKNOWN  UnknownAdapter,
   1543         IN PRESOURCELIST  ResourceList,
   1544         IN PPORTWAVECYCLIC  Port) PURE;
   1545 
   1546     STDMETHOD_(NTSTATUS, NewStream)(THIS_
   1547         OUT PMINIPORTWAVECYCLICSTREAM  *Stream,
   1548         IN PUNKNOWN  OuterUnknown  OPTIONAL,
   1549         IN POOL_TYPE  PoolType,
   1550         IN ULONG  Pin,
   1551         IN BOOLEAN  Capture,
   1552         IN PKSDATAFORMAT  DataFormat,
   1553         OUT PDMACHANNEL  *DmaChannel,
   1554         OUT PSERVICEGROUP  *ServiceGroup) PURE;
   1555 };
   1556 
   1557 typedef IMiniportWaveCyclic *PMINIPORTWAVECYCLIC;
   1558 #undef INTERFACE
   1559 
   1560 #define IMP_IMiniportWaveCyclic\
   1561     IMP_IMiniport;\
   1562     STDMETHODIMP_(NTSTATUS) Init\
   1563     (   IN      PUNKNOWN        UnknownAdapter,\
   1564         IN      PRESOURCELIST   ResourceList,\
   1565         IN      PPORTWAVECYCLIC Port\
   1566     );\
   1567     STDMETHODIMP_(NTSTATUS) NewStream\
   1568     (   OUT     PMINIPORTWAVECYCLICSTREAM * Stream,\
   1569         IN      PUNKNOWN                    OuterUnknown    OPTIONAL,\
   1570         IN      POOL_TYPE                   PoolType,\
   1571         IN      ULONG                       Pin,\
   1572         IN      BOOLEAN                     Capture,\
   1573         IN      PKSDATAFORMAT               DataFormat,\
   1574         OUT     PDMACHANNEL *               DmaChannel,\
   1575         OUT     PSERVICEGROUP *             ServiceGroup\
   1576     )
   1577 
   1578 
   1579 /* ===============================================================
   1580     IPortWavePciStream Interface
   1581 */
   1582 #undef INTERFACE
   1583 #define INTERFACE IPortWavePciStream
   1584 
   1585 DEFINE_GUID(IID_IPortWavePciStream, 0xb4c90a51L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1586 
   1587 DECLARE_INTERFACE_(IPortWavePciStream,IUnknown)
   1588 {
   1589     DEFINE_ABSTRACT_UNKNOWN()   //  For IUnknown
   1590 
   1591     STDMETHOD_(NTSTATUS,GetMapping)(THIS_
   1592         IN PVOID Tag,
   1593         OUT PPHYSICAL_ADDRESS PhysicalAddress,
   1594         OUT PVOID * VirtualAddress,
   1595         OUT PULONG ByteCount,
   1596         OUT PULONG Flags)PURE;
   1597 
   1598     STDMETHOD_(NTSTATUS,ReleaseMapping)(THIS_
   1599         IN PVOID Tag)PURE;
   1600 
   1601     STDMETHOD_(NTSTATUS,TerminatePacket)(THIS)PURE;
   1602 };
   1603 
   1604 typedef IPortWavePciStream *PPORTWAVEPCISTREAM;
   1605 
   1606 #define IMP_IPortWavePciStream                             \
   1607     STDMETHODIMP_(NTSTATUS) GetMapping(                    \
   1608         IN PVOID Tag,                                      \
   1609         OUT PPHYSICAL_ADDRESS PhysicalAddress,             \
   1610         OUT PVOID * VirtualAddress,                        \
   1611         OUT PULONG ByteCount,                              \
   1612         OUT PULONG Flags);                                 \
   1613                                                            \
   1614     STDMETHODIMP_(NTSTATUS) ReleaseMapping(                \
   1615         IN PVOID Tag);                                     \
   1616                                                            \
   1617     STDMETHODIMP_(NTSTATUS) TerminatePacket(THIS)
   1618 
   1619 
   1620 /* ===============================================================
   1621     IMiniportWavePciStream Interface
   1622 */
   1623 #undef INTERFACE
   1624 #define INTERFACE IMiniportWavePciStream
   1625 
   1626 DEFINE_GUID(IID_IMiniportWavePciStream, 0xb4c90a53L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1627 
   1628 DECLARE_INTERFACE_(IMiniportWavePciStream,IUnknown)
   1629 {
   1630     DEFINE_ABSTRACT_UNKNOWN()
   1631 
   1632     STDMETHOD_(NTSTATUS,SetFormat)(THIS_
   1633         IN PKSDATAFORMAT DataFormat)PURE;
   1634 
   1635     STDMETHOD_(NTSTATUS,SetState)(THIS_
   1636         IN KSSTATE State)PURE;
   1637 
   1638     STDMETHOD_(NTSTATUS,GetPosition)(THIS_
   1639         OUT PULONGLONG Position)PURE;
   1640 
   1641     STDMETHOD_(NTSTATUS,NormalizePhysicalPosition)(THIS_
   1642         IN OUT PLONGLONG PhysicalPosition)PURE;
   1643 
   1644     STDMETHOD_(NTSTATUS,GetAllocatorFraming)(THIS_
   1645         OUT PKSALLOCATOR_FRAMING AllocatorFraming) PURE;
   1646 
   1647     STDMETHOD_(NTSTATUS,RevokeMappings)(THIS_
   1648         IN PVOID FirstTag,
   1649         IN PVOID LastTag,
   1650         OUT PULONG MappingsRevoked)PURE;
   1651 
   1652     STDMETHOD_(void,MappingAvailable)(THIS)PURE;
   1653 
   1654     STDMETHOD_(void,Service)(THIS)PURE;
   1655 };
   1656 
   1657 typedef IMiniportWavePciStream *PMINIPORTWAVEPCISTREAM;
   1658 
   1659 /* ===============================================================
   1660     IMiniportWavePci Interface
   1661 */
   1662 #undef INTERFACE
   1663 #define INTERFACE IMiniportWavePci
   1664 
   1665 DEFINE_GUID(IID_IMiniportWavePci, 0xb4c90a52L, 0x5791, 0x11d0, 0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
   1666 
   1667 DECLARE_INTERFACE_(IMiniportWavePci,IMiniport)
   1668 {
   1669     DEFINE_ABSTRACT_UNKNOWN()
   1670 
   1671     DEFINE_ABSTRACT_MINIPORT()
   1672 
   1673     STDMETHOD_(NTSTATUS,Init)(THIS_
   1674         IN PUNKNOWN UnknownAdapter,
   1675         IN PRESOURCELIST ResourceList,
   1676         IN PPORTWAVEPCI Port,
   1677         OUT PSERVICEGROUP * ServiceGroup)PURE;
   1678 
   1679     STDMETHOD_(NTSTATUS,NewStream)(THIS_
   1680         OUT PMINIPORTWAVEPCISTREAM *    Stream,
   1681         IN PUNKNOWN OuterUnknown    OPTIONAL,
   1682         IN POOL_TYPE PoolType,
   1683         IN PPORTWAVEPCISTREAM PortStream,
   1684         IN ULONG Pin,
   1685         IN BOOLEAN Capture,
   1686         IN PKSDATAFORMAT DataFormat,
   1687         OUT PDMACHANNEL * DmaChannel,
   1688         OUT PSERVICEGROUP * ServiceGroup)PURE;
   1689 
   1690     STDMETHOD_(void,Service)(THIS)PURE;
   1691 };
   1692 
   1693 typedef IMiniportWavePci *PMINIPORTWAVEPCI;
   1694 
   1695 
   1696 #if !defined(DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM)
   1697 
   1698 #define DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()                 \
   1699     STDMETHOD_(NTSTATUS,SetFormat)                             \
   1700     (   THIS_                                                  \
   1701         IN      PKSDATAFORMAT   DataFormat                   \
   1702     )   PURE;                                                  \
   1703     STDMETHOD_(NTSTATUS,SetState)                              \
   1704     (   THIS_                                                  \
   1705         IN      KSSTATE         State                        \
   1706     )   PURE;                                                  \
   1707     STDMETHOD_(NTSTATUS,GetPosition)                           \
   1708     (   THIS_                                                  \
   1709         OUT     PKSAUDIO_POSITION   Position                 \
   1710     )   PURE;                                                  \
   1711     STDMETHOD_(NTSTATUS,AllocateAudioBuffer)                   \
   1712     (   THIS_                                                  \
   1713         IN  ULONG                   RequestedSize,           \
   1714         OUT PMDL                    *AudioBufferMdl,         \
   1715         OUT ULONG                   *ActualSize,             \
   1716         OUT ULONG                   *OffsetFromFirstPage,    \
   1717         OUT MEMORY_CACHING_TYPE     *CacheType               \
   1718     ) PURE;                                                    \
   1719     STDMETHOD_(VOID,FreeAudioBuffer)                           \
   1720     (   THIS_                                                  \
   1721         IN     PMDL                    AudioBufferMdl,          \
   1722         IN     ULONG                   BufferSize               \
   1723     ) PURE;                                                    \
   1724     STDMETHOD_(VOID,GetHWLatency)                              \
   1725     (   THIS_                                                  \
   1726         OUT KSRTAUDIO_HWLATENCY     *hwLatency               \
   1727     ) PURE;                                                    \
   1728     STDMETHOD_(NTSTATUS,GetPositionRegister)                   \
   1729     (   THIS_                                                  \
   1730         OUT KSRTAUDIO_HWREGISTER    *Register                \
   1731     ) PURE;                                                    \
   1732     STDMETHOD_(NTSTATUS,GetClockRegister)                      \
   1733     (   THIS_                                                  \
   1734         OUT KSRTAUDIO_HWREGISTER    *Register                \
   1735     ) PURE;
   1736 
   1737 #endif
   1738 
   1739 
   1740 /* ===============================================================
   1741     IAdapterPowerManagement Interface
   1742 */
   1743 
   1744 #if (NTDDI_VERSION >= NTDDI_VISTA)
   1745 /* ===============================================================
   1746     IPortWaveRT Interface
   1747 */
   1748 
   1749 DEFINE_GUID(CLSID_PortWaveRT, 0xcc9be57a, 0xeb9e, 0x42b4, 0x94, 0xfc, 0xc, 0xad, 0x3d, 0xbc, 0xe7, 0xfa);
   1750 DEFINE_GUID(IID_IPortWaveRT, 0x339ff909, 0x68a9, 0x4310, 0xb0, 0x9b, 0x27, 0x4e, 0x96, 0xee, 0x4c, 0xbd);
   1751 
   1752 #undef INTERFACE
   1753 #define INTERFACE IPortWaveRT
   1754 
   1755 DECLARE_INTERFACE_(IPortWaveRT,IPort)
   1756 {
   1757     DEFINE_ABSTRACT_UNKNOWN()   //  For IUnknown
   1758 
   1759     DEFINE_ABSTRACT_PORT()      //  For IPort
   1760 };
   1761 
   1762 typedef IPortWaveRT *PPORTWAVERT;
   1763 
   1764 #ifdef PC_IMPLEMENTATION
   1765 #define IMP_IPortWaveRT IMP_IPort
   1766 #endif
   1767 
   1768 
   1769 /* ===============================================================
   1770     IPortWaveRTStream Interface
   1771 */
   1772 
   1773 #undef INTERFACE
   1774 #define INTERFACE IPortWaveRTStream
   1775 
   1776 DEFINE_GUID(IID_IPortWaveRTStream, 0x1809ce5a, 0x64bc, 0x4e62, 0xbd, 0x7d, 0x95, 0xbc, 0xe4, 0x3d, 0xe3, 0x93);
   1777 
   1778 DECLARE_INTERFACE_(IPortWaveRTStream, IUnknown)
   1779 {
   1780     DEFINE_ABSTRACT_UNKNOWN()
   1781 
   1782     STDMETHOD_(PMDL, AllocatePagesForMdl)
   1783     (   THIS_
   1784         IN      PHYSICAL_ADDRESS    HighAddress,
   1785         IN      SIZE_T              TotalBytes
   1786     )   PURE;
   1787 
   1788     STDMETHOD_(PMDL, AllocateContiguousPagesForMdl)
   1789     (   THIS_
   1790         IN      PHYSICAL_ADDRESS    LowAddress,
   1791         IN      PHYSICAL_ADDRESS    HighAddress,
   1792         IN      SIZE_T              TotalBytes
   1793     )   PURE;
   1794 
   1795     STDMETHOD_(PVOID, MapAllocatedPages)
   1796     (   THIS_
   1797         IN      PMDL                    MemoryDescriptorList,
   1798         IN      MEMORY_CACHING_TYPE     CacheType
   1799     )   PURE;
   1800 
   1801     STDMETHOD_(VOID, UnmapAllocatedPages)
   1802     (   THIS_
   1803         IN      PVOID   BaseAddress,
   1804         IN      PMDL    MemoryDescriptorList
   1805     )   PURE;
   1806 
   1807     STDMETHOD_(VOID, FreePagesFromMdl)
   1808     (   THIS_
   1809         IN      PMDL    MemoryDescriptorList
   1810     )   PURE;
   1811 
   1812     STDMETHOD_(ULONG, GetPhysicalPagesCount)
   1813     (   THIS_
   1814         IN      PMDL    MemoryDescriptorList
   1815     )   PURE;
   1816 
   1817     STDMETHOD_(PHYSICAL_ADDRESS, GetPhysicalPageAddress)
   1818     (   THIS_
   1819         IN      PMDL    MemoryDescriptorList,
   1820         IN      ULONG   Index
   1821     )   PURE;
   1822 };
   1823 
   1824 typedef IPortWaveRTStream *PPORTWAVERTSTREAM;
   1825 
   1826 
   1827 /* ===============================================================
   1828     IMiniportWaveRTStream Interface
   1829 */
   1830 
   1831 #undef INTERFACE
   1832 #define INTERFACE IMiniportWaveRTStream
   1833 
   1834 DEFINE_GUID(IID_IMiniportWaveRTStream, 0xac9ab, 0xfaab, 0x4f3d, 0x94, 0x55, 0x6f, 0xf8, 0x30, 0x6a, 0x74, 0xa0);
   1835 
   1836 DECLARE_INTERFACE_(IMiniportWaveRTStream, IUnknown)
   1837 {
   1838     DEFINE_ABSTRACT_UNKNOWN()
   1839     DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()
   1840 };
   1841 
   1842 typedef IMiniportWaveRTStream *PMINIPORTWAVERTSTREAM;
   1843 
   1844 
   1845 /* ===============================================================
   1846     IMiniportWaveRTStreamNotification Interface
   1847 */
   1848 
   1849 #undef INTERFACE
   1850 #define INTERFACE IMiniportWaveRTStreamNotification
   1851 
   1852 DEFINE_GUID(IID_IMiniportWaveRTStreamNotification, 0x23759128, 0x96f1, 0x423b, 0xab, 0x4d, 0x81, 0x63, 0x5b, 0xcf, 0x8c, 0xa1);
   1853 
   1854 DECLARE_INTERFACE_(IMiniportWaveRTStreamNotification, IMiniportWaveRTStream)
   1855 {
   1856     DEFINE_ABSTRACT_UNKNOWN()
   1857 
   1858     DEFINE_ABSTRACT_MINIPORTWAVERTSTREAM()
   1859 
   1860     STDMETHOD_(NTSTATUS,AllocateBufferWithNotification)
   1861     (   THIS_
   1862         IN      ULONG                   NotificationCount,
   1863         IN      ULONG                   RequestedSize,
   1864         OUT     PMDL                    *AudioBufferMdl,
   1865         OUT     ULONG                   *ActualSize,
   1866         OUT     ULONG                   *OffsetFromFirstPage,
   1867         OUT     MEMORY_CACHING_TYPE     *CacheType
   1868     )   PURE;
   1869 
   1870     STDMETHOD_(VOID,FreeBufferWithNotification)
   1871     (   THIS_
   1872         IN      PMDL            AudioBufferMdl,
   1873         IN      ULONG           BufferSize
   1874     )   PURE;
   1875 
   1876     STDMETHOD_(NTSTATUS,RegisterNotificationEvent)
   1877     (   THIS_
   1878         IN      PKEVENT         NotificationEvent
   1879     )   PURE;
   1880 
   1881     STDMETHOD_(NTSTATUS,UnregisterNotificationEvent)
   1882     (   THIS_
   1883         IN      PKEVENT         NotificationEvent
   1884     )   PURE;
   1885 };
   1886 
   1887 /* ===============================================================
   1888     IMiniportWaveRT Interface
   1889 */
   1890 
   1891 #undef INTERFACE
   1892 #define INTERFACE IMiniportWaveRT
   1893 
   1894 DEFINE_GUID(IID_IMiniportWaveRT, 0xf9fc4d6, 0x6061, 0x4f3c, 0xb1, 0xfc, 0x7, 0x5e, 0x35, 0xf7, 0x96, 0xa);
   1895 
   1896 DECLARE_INTERFACE_(IMiniportWaveRT, IMiniport)
   1897 {
   1898     DEFINE_ABSTRACT_UNKNOWN()
   1899 
   1900     DEFINE_ABSTRACT_MINIPORT()
   1901 
   1902     STDMETHOD_(NTSTATUS,Init)
   1903     (   THIS_
   1904         IN      PUNKNOWN            UnknownAdapter,
   1905         IN      PRESOURCELIST       ResourceList,
   1906         IN      PPORTWAVERT             Port
   1907     )   PURE;
   1908 
   1909     STDMETHOD_(NTSTATUS,NewStream)
   1910     (   THIS_
   1911         OUT     PMINIPORTWAVERTSTREAM *         Stream,
   1912         IN      PPORTWAVERTSTREAM               PortStream,
   1913         IN      ULONG                       Pin,
   1914         IN      BOOLEAN                     Capture,
   1915         IN      PKSDATAFORMAT               DataFormat
   1916     )   PURE;
   1917 
   1918     STDMETHOD_(NTSTATUS,GetDeviceDescription)
   1919     (   THIS_
   1920         OUT     PDEVICE_DESCRIPTION     DeviceDescription
   1921     )   PURE;
   1922 };
   1923 
   1924 typedef IMiniportWaveRT *PMINIPORTWAVERT;
   1925 
   1926 #endif
   1927 
   1928 /* ===============================================================
   1929     IAdapterPowerManagement Interface
   1930 */
   1931 
   1932 #undef INTERFACE
   1933 #define INTERFACE IAdapterPowerManagement
   1934 
   1935 DEFINE_GUID(IID_IAdapterPowerManagement, 0x793417D0L, 0x35FE, 0x11D1, 0xAD, 0x08, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0xB0);
   1936 
   1937 DECLARE_INTERFACE_(IAdapterPowerManagement, IUnknown)
   1938 {
   1939     DEFINE_ABSTRACT_UNKNOWN()
   1940 
   1941     STDMETHOD_(void,PowerChangeState)(THIS_
   1942         IN POWER_STATE NewState) PURE;
   1943 
   1944     STDMETHOD_(NTSTATUS,QueryPowerChangeState)(THIS_
   1945         IN POWER_STATE NewStateQuery) PURE;
   1946 
   1947     STDMETHOD_(NTSTATUS,QueryDeviceCapabilities)(THIS_
   1948         IN PDEVICE_CAPABILITIES PowerDeviceCaps) PURE;
   1949 };
   1950 
   1951 #define IMP_IAdapterPowerManagement                       \
   1952     STDMETHODIMP_(void) PowerChangeState                  \
   1953     (   IN      POWER_STATE     NewState                  \
   1954     );                                                    \
   1955     STDMETHODIMP_(NTSTATUS) QueryPowerChangeState         \
   1956     (   IN      POWER_STATE     NewStateQuery             \
   1957     );                                                    \
   1958     STDMETHODIMP_(NTSTATUS) QueryDeviceCapabilities       \
   1959     (   IN      PDEVICE_CAPABILITIES    PowerDeviceCaps   \
   1960     )
   1961 
   1962 typedef IAdapterPowerManagement *PADAPTERPOWERMANAGEMENT;
   1963 
   1964 
   1965 /* ===============================================================
   1966     IPowerNotify Interface
   1967 */
   1968 
   1969 #undef INTERFACE
   1970 #define INTERFACE IPowerNotify
   1971 
   1972 DEFINE_GUID(IID_IPowerNotify, 0x3DD648B8L, 0x969F, 0x11D1, 0x95, 0xA9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
   1973 
   1974 DECLARE_INTERFACE_(IPowerNotify, IUnknown)
   1975 {
   1976     DEFINE_ABSTRACT_UNKNOWN()
   1977 
   1978     STDMETHOD_(void, PowerChangeNotify)(THIS_
   1979         IN POWER_STATE PowerState)PURE;
   1980 };
   1981 
   1982 typedef IPowerNotify *PPOWERNOTIFY;
   1983 
   1984 #undef INTERFACE
   1985 
   1986 /* ===============================================================
   1987     IPinCount Interface
   1988 */
   1989 #if (NTDDI_VERSION >= NTDDI_WINXP)
   1990 
   1991 #undef INTERFACE
   1992 #define INTERFACE IPinCount
   1993 
   1994 DEFINE_GUID(IID_IPinCount, 0x5dadb7dcL, 0xa2cb, 0x4540, 0xa4, 0xa8, 0x42, 0x5e, 0xe4, 0xae, 0x90, 0x51);
   1995 
   1996 DECLARE_INTERFACE_(IPinCount, IUnknown)
   1997 {
   1998     DEFINE_ABSTRACT_UNKNOWN()
   1999 
   2000     STDMETHOD_(void,PinCount)(THIS_
   2001         IN ULONG PinId,
   2002         IN OUT PULONG FilterNecessary,
   2003         IN OUT PULONG FilterCurrent,
   2004         IN OUT PULONG FilterPossible,
   2005         IN OUT PULONG GlobalCurrent,
   2006         IN OUT PULONG GlobalPossible) PURE;
   2007 };
   2008 typedef IPinCount *PPINCOUNT;
   2009 
   2010 #undef INTERFACE
   2011 #endif
   2012 
   2013 
   2014 /* ===============================================================
   2015     IPortEvents Interface
   2016 */
   2017 
   2018 #undef INTERFACE
   2019 #define INTERFACE IPortEvents
   2020 
   2021 DEFINE_GUID(IID_IPortEvents, 0xA80F29C4L, 0x5498, 0x11D2, 0x95, 0xD9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3);
   2022 DECLARE_INTERFACE_(IPortEvents, IUnknown)
   2023 {
   2024     DEFINE_ABSTRACT_UNKNOWN()
   2025 
   2026     STDMETHOD_(void,AddEventToEventList)(THIS_
   2027         IN  PKSEVENT_ENTRY EventEntry)PURE;
   2028 
   2029     STDMETHOD_(void,GenerateEventList)(THIS_
   2030         IN  GUID* Set OPTIONAL,
   2031         IN  ULONG EventId,
   2032         IN  BOOL  PinEvent,
   2033         IN  ULONG PinId,
   2034         IN  BOOL  NodeEvent,
   2035         IN  ULONG NodeId)PURE;
   2036 };
   2037 
   2038 typedef IPortEvents *PPORTEVENTS;
   2039 
   2040 
   2041 #define IMP_IPortEvents                        \
   2042     STDMETHODIMP_(void) AddEventToEventList(   \
   2043         IN  PKSEVENT_ENTRY EventEntry);        \
   2044                                                \
   2045     STDMETHODIMP_(void) GenerateEventList(     \
   2046         IN  GUID* Set OPTIONAL,                \
   2047         IN  ULONG EventId,                     \
   2048         IN  BOOL  PinEvent,                    \
   2049         IN  ULONG PinId,                       \
   2050         IN  BOOL  NodeEvent,                   \
   2051         IN  ULONG NodeId)
   2052 
   2053 /* ===============================================================
   2054     IDrmPort / IDrmPort2 Interfaces
   2055     These are almost identical, except for the addition of two extra methods.
   2056 */
   2057 
   2058 #undef INTERFACE
   2059 #define INTERFACE IDrmPort
   2060 
   2061 #if (NTDDI_VERSION >= NTDDI_WINXP)
   2062 DEFINE_GUID(IID_IDrmPort, 0x286D3DF8L, 0xCA22, 0x4E2E, 0xB9, 0xBC, 0x20, 0xB4, 0xF0, 0xE2, 0x01, 0xCE);
   2063 #endif
   2064 
   2065 #define DEFINE_ABSTRACT_DRMPORT()                          \
   2066     STDMETHOD_(NTSTATUS,CreateContentMixed)(THIS_          \
   2067         IN  PULONG paContentId,                            \
   2068         IN  ULONG cContentId,                              \
   2069         OUT PULONG pMixedContentId)PURE;                   \
   2070                                                            \
   2071     STDMETHOD_(NTSTATUS,DestroyContent)(THIS_              \
   2072         IN ULONG ContentId)PURE;                           \
   2073                                                            \
   2074     STDMETHOD_(NTSTATUS,ForwardContentToFileObject)(THIS_  \
   2075         IN ULONG        ContentId,                         \
   2076         IN PFILE_OBJECT FileObject)PURE;                   \
   2077                                                            \
   2078     STDMETHOD_(NTSTATUS,ForwardContentToInterface)(THIS_   \
   2079         IN ULONG ContentId,                                \
   2080         IN PUNKNOWN pUnknown,                              \
   2081         IN ULONG NumMethods)PURE;                          \
   2082                                                            \
   2083     STDMETHOD_(NTSTATUS,GetContentRights)(THIS_            \
   2084         IN  ULONG ContentId,                               \
   2085         OUT PDRMRIGHTS  DrmRights)PURE;
   2086 
   2087 DECLARE_INTERFACE_(IDrmPort, IUnknown)
   2088 {
   2089     DEFINE_ABSTRACT_UNKNOWN()
   2090     DEFINE_ABSTRACT_DRMPORT()
   2091 };
   2092 
   2093 typedef IDrmPort *PDRMPORT;
   2094 
   2095 #define IMP_IDrmPort                                       \
   2096     STDMETHODIMP_(NTSTATUS) CreateContentMixed(            \
   2097         IN  PULONG paContentId,                            \
   2098         IN  ULONG cContentId,                              \
   2099         OUT PULONG pMixedContentId);                       \
   2100                                                            \
   2101     STDMETHODIMP_(NTSTATUS) DestroyContent(                \
   2102         IN ULONG ContentId);                               \
   2103                                                            \
   2104     STDMETHODIMP_(NTSTATUS) ForwardContentToFileObject(    \
   2105         IN ULONG        ContentId,                         \
   2106         IN PFILE_OBJECT FileObject);                       \
   2107                                                            \
   2108     STDMETHODIMP_(NTSTATUS) ForwardContentToInterface(     \
   2109         IN ULONG ContentId,                                \
   2110         IN PUNKNOWN pUnknown,                              \
   2111         IN ULONG NumMethods);                              \
   2112                                                            \
   2113     STDMETHODIMP_(NTSTATUS) GetContentRights(              \
   2114         IN  ULONG ContentId,                               \
   2115         OUT PDRMRIGHTS  DrmRights)
   2116 
   2117 
   2118 /* ===============================================================
   2119     IDrmPort2 Interface
   2120 */
   2121 
   2122 #undef INTERFACE
   2123 #define INTERFACE IDrmPort2
   2124 
   2125 #if (NTDDI_VERSION >= NTDDI_WINXP)
   2126 DEFINE_GUID(IID_IDrmPort2, 0x1ACCE59CL, 0x7311, 0x4B6B, 0x9F, 0xBA, 0xCC, 0x3B, 0xA5, 0x9A, 0xCD, 0xCE);
   2127 #endif
   2128 
   2129 DECLARE_INTERFACE_(IDrmPort2, IDrmPort)
   2130 {
   2131     DEFINE_ABSTRACT_UNKNOWN()
   2132     DEFINE_ABSTRACT_DRMPORT()
   2133 
   2134     STDMETHOD_(NTSTATUS,AddContentHandlers)(THIS_
   2135         IN ULONG ContentId,
   2136         IN PVOID * paHandlers,
   2137         IN ULONG NumHandlers)PURE;
   2138 
   2139     STDMETHOD_(NTSTATUS,ForwardContentToDeviceObject)(THIS_
   2140         IN ULONG ContentId,
   2141         IN PVOID Reserved,
   2142         IN PCDRMFORWARD DrmForward)PURE;
   2143 };
   2144 
   2145 typedef IDrmPort2 *PDRMPORT2;
   2146 
   2147 #define IMP_IDrmPort2                                                \
   2148     IMP_IDrmPort;                                                    \
   2149     STDMETHODIMP_(NTSTATUS) AddContentHandlers(                      \
   2150         IN ULONG ContentId,                                          \
   2151         IN PVOID * paHandlers,                                       \
   2152         IN ULONG NumHandlers);                                       \
   2153                                                                      \
   2154     STDMETHODIMP_(NTSTATUS) ForwardContentToDeviceObject(            \
   2155         IN ULONG ContentId,                                          \
   2156         IN PVOID Reserved,                                           \
   2157         IN PCDRMFORWARD DrmForward)
   2158 
   2159 
   2160 /* ===============================================================
   2161     IPortClsVersion Interface
   2162 */
   2163 #undef INTERFACE
   2164 #define INTERFACE IPortClsVersion
   2165 
   2166 #if (NTDDI_VERSION >= NTDDI_WINXP)
   2167 DEFINE_GUID(IID_IPortClsVersion, 0x7D89A7BBL, 0x869B, 0x4567, 0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE);
   2168 #endif
   2169 
   2170 DECLARE_INTERFACE_(IPortClsVersion, IUnknown)
   2171 {
   2172     DEFINE_ABSTRACT_UNKNOWN()
   2173 
   2174     STDMETHOD_(DWORD, GetVersion)(THIS) PURE;
   2175 };
   2176 
   2177 #define IMP_IPortClsVersion \
   2178     STDMETHODIMP_(DWORD) GetVersion(void);
   2179 
   2180 typedef IPortClsVersion *PPORTCLSVERSION;
   2181 
   2182 #undef INTERFACE
   2183 
   2184 /* ===============================================================
   2185     IDmaOperations Interface
   2186 */
   2187 
   2188 /* ===============================================================
   2189     IPreFetchOffset Interface
   2190 */
   2191 
   2192 
   2193 
   2194 /* ===============================================================
   2195     PortCls API Functions
   2196 */
   2197 
   2198 typedef NTSTATUS (NTAPI *PCPFNSTARTDEVICE)(
   2199     IN  PDEVICE_OBJECT DeviceObject,
   2200     IN  PIRP Irp,
   2201     IN  PRESOURCELIST ResourceList);
   2202 
   2203 /* This is in NTDDK.H */
   2204 /*
   2205 typedef NTSTATUS (*PDRIVER_ADD_DEVICE)(
   2206     IN struct _DRIVER_OBJECT* DriverObject,
   2207     IN struct _DEVICE_OBJECT* PhysicalDeviceObject);
   2208 */
   2209 
   2210 PORTCLASSAPI NTSTATUS NTAPI
   2211 PcAddAdapterDevice(
   2212     IN  PDRIVER_OBJECT DriverObject,
   2213     IN  PDEVICE_OBJECT PhysicalDeviceObject,
   2214     IN  PCPFNSTARTDEVICE StartDevice,
   2215     IN  ULONG MaxObjects,
   2216     IN  ULONG DeviceExtensionSize);
   2217 
   2218 PORTCLASSAPI NTSTATUS NTAPI
   2219 PcInitializeAdapterDriver(
   2220     IN  PDRIVER_OBJECT DriverObject,
   2221     IN  PUNICODE_STRING RegistryPathName,
   2222     IN  PDRIVER_ADD_DEVICE AddDevice);
   2223 
   2224 
   2225 /* ===============================================================
   2226     Factories (TODO: Move elsewhere)
   2227 */
   2228 
   2229 PORTCLASSAPI NTSTATUS NTAPI
   2230 PcNewDmaChannel(
   2231     OUT PDMACHANNEL* OutDmaChannel,
   2232     IN  PUNKNOWN OuterUnknown OPTIONAL,
   2233     IN  POOL_TYPE PoolType,
   2234     IN  PDEVICE_DESCRIPTION DeviceDescription,
   2235     IN  PDEVICE_OBJECT DeviceObject);
   2236 
   2237 PORTCLASSAPI NTSTATUS NTAPI
   2238 PcNewInterruptSync(
   2239     OUT PINTERRUPTSYNC* OUtInterruptSync,
   2240     IN  PUNKNOWN OuterUnknown OPTIONAL,
   2241     IN  PRESOURCELIST ResourceList,
   2242     IN  ULONG ResourceIndex,
   2243     IN  INTERRUPTSYNCMODE Mode);
   2244 
   2245 PORTCLASSAPI NTSTATUS NTAPI
   2246 PcNewMiniport(
   2247     OUT PMINIPORT* OutMiniport,
   2248     IN  REFCLSID ClassId);
   2249 
   2250 PORTCLASSAPI NTSTATUS NTAPI
   2251 PcNewPort(
   2252     OUT PPORT* OutPort,
   2253     IN  REFCLSID ClassId);
   2254 
   2255 PORTCLASSAPI NTSTATUS NTAPI
   2256 PcNewRegistryKey(
   2257     OUT PREGISTRYKEY* OutRegistryKey,
   2258     IN  PUNKNOWN OuterUnknown OPTIONAL,
   2259     IN  ULONG RegistryKeyType,
   2260     IN  ACCESS_MASK DesiredAccess,
   2261     IN  PVOID DeviceObject OPTIONAL,
   2262     IN  PVOID SubDevice OPTIONAL,
   2263     IN  POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
   2264     IN  ULONG CreateOptions OPTIONAL,
   2265     OUT PULONG Disposition OPTIONAL);
   2266 
   2267 PORTCLASSAPI NTSTATUS NTAPI
   2268 PcNewResourceList(
   2269     OUT PRESOURCELIST* OutResourceList,
   2270     IN  PUNKNOWN OuterUnknown OPTIONAL,
   2271     IN  POOL_TYPE PoolType,
   2272     IN  PCM_RESOURCE_LIST TranslatedResources,
   2273     IN  PCM_RESOURCE_LIST UntranslatedResources);
   2274 
   2275 PORTCLASSAPI NTSTATUS NTAPI
   2276 PcNewResourceSublist(
   2277     OUT PRESOURCELIST* OutResourceList,
   2278     IN  PUNKNOWN OuterUnknown OPTIONAL,
   2279     IN  POOL_TYPE PoolType,
   2280     IN  PRESOURCELIST ParentList,
   2281     IN  ULONG MaximumEntries);
   2282 
   2283 PORTCLASSAPI NTSTATUS NTAPI
   2284 PcNewServiceGroup(
   2285     OUT PSERVICEGROUP* OutServiceGroup,
   2286     IN  PUNKNOWN OuterUnknown OPTIONAL);
   2287 
   2288 
   2289 /* ===============================================================
   2290     IRP Handling
   2291 */
   2292 
   2293 PORTCLASSAPI NTSTATUS NTAPI
   2294 PcDispatchIrp(
   2295     IN  PDEVICE_OBJECT DeviceObject,
   2296     IN  PIRP Irp);
   2297 
   2298 PORTCLASSAPI NTSTATUS NTAPI
   2299 PcCompleteIrp(
   2300     IN  PDEVICE_OBJECT DeviceObject,
   2301     IN  PIRP Irp,
   2302     IN  NTSTATUS Status);
   2303 
   2304 PORTCLASSAPI NTSTATUS NTAPI
   2305 PcForwardIrpSynchronous(
   2306     IN  PDEVICE_OBJECT DeviceObject,
   2307     IN  PIRP Irp);
   2308 
   2309 
   2310 /* ===============================================================
   2311     Power Management
   2312 */
   2313 
   2314 PORTCLASSAPI NTSTATUS NTAPI
   2315 PcRegisterAdapterPowerManagement(
   2316     IN  PUNKNOWN pUnknown,
   2317     IN  PVOID pvContext1);
   2318 
   2319 PORTCLASSAPI NTSTATUS NTAPI
   2320 PcRequestNewPowerState(
   2321     IN  PDEVICE_OBJECT pDeviceObject,
   2322     IN  DEVICE_POWER_STATE RequestedNewState);
   2323 
   2324 
   2325 /* ===============================================================
   2326     Properties
   2327 */
   2328 
   2329 PORTCLASSAPI NTSTATUS NTAPI
   2330 PcGetDeviceProperty(
   2331     IN  PVOID DeviceObject,
   2332     IN  DEVICE_REGISTRY_PROPERTY DeviceProperty,
   2333     IN  ULONG BufferLength,
   2334     OUT PVOID PropertyBuffer,
   2335     OUT PULONG ResultLength);
   2336 
   2337 PORTCLASSAPI NTSTATUS NTAPI
   2338 PcCompletePendingPropertyRequest(
   2339     IN  PPCPROPERTY_REQUEST PropertyRequest,
   2340     IN  NTSTATUS NtStatus);
   2341 
   2342 
   2343 /* ===============================================================
   2344     I/O Timeouts
   2345 */
   2346 
   2347 PORTCLASSAPI NTSTATUS NTAPI
   2348 PcRegisterIoTimeout(
   2349     IN  PDEVICE_OBJECT pDeviceObject,
   2350     IN  PIO_TIMER_ROUTINE pTimerRoutine,
   2351     IN  PVOID pContext);
   2352 
   2353 PORTCLASSAPI NTSTATUS NTAPI
   2354 PcUnregisterIoTimeout(
   2355     IN  PDEVICE_OBJECT pDeviceObject,
   2356     IN  PIO_TIMER_ROUTINE pTimerRoutine,
   2357     IN  PVOID pContext);
   2358 
   2359 
   2360 /* ===============================================================
   2361     Physical Connections
   2362 */
   2363 
   2364 PORTCLASSAPI NTSTATUS NTAPI
   2365 PcRegisterPhysicalConnection(
   2366     IN  PDEVICE_OBJECT DeviceObject,
   2367     IN  PUNKNOWN FromUnknown,
   2368     IN  ULONG FromPin,
   2369     IN  PUNKNOWN ToUnknown,
   2370     IN  ULONG ToPin);
   2371 
   2372 PORTCLASSAPI NTSTATUS NTAPI
   2373 PcRegisterPhysicalConnectionFromExternal(
   2374     IN  PDEVICE_OBJECT DeviceObject,
   2375     IN  PUNICODE_STRING FromString,
   2376     IN  ULONG FromPin,
   2377     IN  PUNKNOWN ToUnknown,
   2378     IN  ULONG ToPin);
   2379 
   2380 PORTCLASSAPI NTSTATUS NTAPI
   2381 PcRegisterPhysicalConnectionToExternal(
   2382     IN  PDEVICE_OBJECT DeviceObject,
   2383     IN  PUNKNOWN FromUnknown,
   2384     IN  ULONG FromPin,
   2385     IN  PUNICODE_STRING ToString,
   2386     IN  ULONG ToPin);
   2387 
   2388 
   2389 /* ===============================================================
   2390     Misc
   2391 */
   2392 
   2393 PORTCLASSAPI ULONGLONG NTAPI
   2394 PcGetTimeInterval(
   2395     IN  ULONGLONG Since);
   2396 
   2397 PORTCLASSAPI NTSTATUS NTAPI
   2398 PcRegisterSubdevice(
   2399     IN  PDEVICE_OBJECT DeviceObject,
   2400     IN  PWCHAR Name,
   2401     IN  PUNKNOWN Unknown);
   2402 
   2403 
   2404 /* ===============================================================
   2405     Digital Rights Management Functions
   2406     Implemented in XP and above
   2407 */
   2408 
   2409 PORTCLASSAPI NTSTATUS NTAPI
   2410 PcAddContentHandlers(
   2411     IN  ULONG ContentId,
   2412     IN  PVOID *paHandlers,
   2413     IN  ULONG NumHandlers);
   2414 
   2415 PORTCLASSAPI NTSTATUS NTAPI
   2416 PcCreateContentMixed(
   2417     IN  PULONG paContentId,
   2418     IN  ULONG cContentId,
   2419     OUT PULONG pMixedContentId);
   2420 
   2421 PORTCLASSAPI NTSTATUS NTAPI
   2422 PcDestroyContent(
   2423     IN  ULONG ContentId);
   2424 
   2425 PORTCLASSAPI NTSTATUS NTAPI
   2426 PcForwardContentToDeviceObject(
   2427     IN  ULONG ContentId,
   2428     IN  PVOID Reserved,
   2429     IN  PCDRMFORWARD DrmForward);
   2430 
   2431 PORTCLASSAPI NTSTATUS NTAPI
   2432 PcForwardContentToFileObject(
   2433     IN  ULONG ContentId,
   2434     IN  PFILE_OBJECT FileObject);
   2435 
   2436 PORTCLASSAPI NTSTATUS NTAPI
   2437 PcForwardContentToInterface(
   2438     IN  ULONG ContentId,
   2439     IN  PUNKNOWN pUnknown,
   2440     IN  ULONG NumMethods);
   2441 
   2442 PORTCLASSAPI NTSTATUS NTAPI
   2443 PcGetContentRights(
   2444     IN  ULONG ContentId,
   2445     OUT PDRMRIGHTS DrmRights);
   2446 
   2447 
   2448 #endif /* PORTCLS_H */
   2449 
   2450