Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _KS_
      7 #define _KS_
      8 
      9 #ifdef __TCS__
     10 #define _KS_NO_ANONYMOUS_STRUCTURES_ 1
     11 #endif
     12 
     13 #ifdef  _KS_NO_ANONYMOUS_STRUCTURES_
     14 #define _KS_ANON_STRUCT(X)			struct X
     15 #else
     16 #define _KS_ANON_STRUCT(X)	__C89_NAMELESS struct
     17 #endif
     18 
     19 #ifndef _NTRTL_
     20 #ifndef DEFINE_GUIDEX
     21 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
     22 #endif
     23 #ifndef STATICGUIDOF
     24 #define STATICGUIDOF(guid) STATIC_##guid
     25 #endif
     26 #endif /* _NTRTL_ */
     27 
     28 #ifndef SIZEOF_ARRAY
     29 #define SIZEOF_ARRAY(ar) (sizeof(ar)/sizeof((ar)[0]))
     30 #endif
     31 
     32 #define DEFINE_GUIDSTRUCT(g,n) DEFINE_GUIDEX(n)
     33 #define DEFINE_GUIDNAMED(n) n
     34 
     35 #define STATIC_GUID_NULL						\
     36 	0x00000000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
     37 
     38 DEFINE_GUIDSTRUCT("00000000-0000-0000-0000-000000000000",GUID_NULL);
     39 #define GUID_NULL DEFINE_GUIDNAMED(GUID_NULL)
     40 
     41 #define IOCTL_KS_PROPERTY CTL_CODE(FILE_DEVICE_KS,0x000,METHOD_NEITHER,FILE_ANY_ACCESS)
     42 #define IOCTL_KS_ENABLE_EVENT CTL_CODE(FILE_DEVICE_KS,0x001,METHOD_NEITHER,FILE_ANY_ACCESS)
     43 #define IOCTL_KS_DISABLE_EVENT CTL_CODE(FILE_DEVICE_KS,0x002,METHOD_NEITHER,FILE_ANY_ACCESS)
     44 #define IOCTL_KS_METHOD CTL_CODE(FILE_DEVICE_KS,0x003,METHOD_NEITHER,FILE_ANY_ACCESS)
     45 #define IOCTL_KS_WRITE_STREAM CTL_CODE(FILE_DEVICE_KS,0x004,METHOD_NEITHER,FILE_WRITE_ACCESS)
     46 #define IOCTL_KS_READ_STREAM CTL_CODE(FILE_DEVICE_KS,0x005,METHOD_NEITHER,FILE_READ_ACCESS)
     47 #define IOCTL_KS_RESET_STATE CTL_CODE(FILE_DEVICE_KS,0x006,METHOD_NEITHER,FILE_ANY_ACCESS)
     48 
     49 typedef enum {
     50   KSRESET_BEGIN,
     51   KSRESET_END
     52 } KSRESET;
     53 
     54 typedef enum {
     55   KSSTATE_STOP,
     56   KSSTATE_ACQUIRE,
     57   KSSTATE_PAUSE,
     58   KSSTATE_RUN
     59 } KSSTATE,*PKSSTATE;
     60 
     61 #define KSPRIORITY_LOW		0x00000001
     62 #define KSPRIORITY_NORMAL	0x40000000
     63 #define KSPRIORITY_HIGH		0x80000000
     64 #define KSPRIORITY_EXCLUSIVE	0xFFFFFFFF
     65 
     66 typedef struct {
     67   ULONG PriorityClass;
     68   ULONG PrioritySubClass;
     69 } KSPRIORITY,*PKSPRIORITY;
     70 
     71 typedef struct {
     72   __C89_NAMELESS union {
     73     _KS_ANON_STRUCT(_IDENTIFIER)
     74     {
     75       GUID Set;
     76       ULONG Id;
     77       ULONG Flags;
     78     };
     79     LONGLONG Alignment;
     80   };
     81 } KSIDENTIFIER,*PKSIDENTIFIER;
     82 
     83 typedef KSIDENTIFIER KSPROPERTY,*PKSPROPERTY,KSMETHOD,*PKSMETHOD,KSEVENT,*PKSEVENT;
     84 
     85 #define KSMETHOD_TYPE_NONE		0x00000000
     86 #define KSMETHOD_TYPE_READ		0x00000001
     87 #define KSMETHOD_TYPE_WRITE		0x00000002
     88 #define KSMETHOD_TYPE_MODIFY		0x00000003
     89 #define KSMETHOD_TYPE_SOURCE		0x00000004
     90 
     91 #define KSMETHOD_TYPE_SEND		0x00000001
     92 #define KSMETHOD_TYPE_SETSUPPORT	0x00000100
     93 #define KSMETHOD_TYPE_BASICSUPPORT	0x00000200
     94 
     95 #define KSMETHOD_TYPE_TOPOLOGY		0x10000000
     96 
     97 #define KSPROPERTY_TYPE_GET		0x00000001
     98 #define KSPROPERTY_TYPE_SET		0x00000002
     99 #define KSPROPERTY_TYPE_SETSUPPORT	0x00000100
    100 #define KSPROPERTY_TYPE_BASICSUPPORT	0x00000200
    101 #define KSPROPERTY_TYPE_RELATIONS	0x00000400
    102 #define KSPROPERTY_TYPE_SERIALIZESET	0x00000800
    103 #define KSPROPERTY_TYPE_UNSERIALIZESET	0x00001000
    104 #define KSPROPERTY_TYPE_SERIALIZERAW	0x00002000
    105 #define KSPROPERTY_TYPE_UNSERIALIZERAW	0x00004000
    106 #define KSPROPERTY_TYPE_SERIALIZESIZE	0x00008000
    107 #define KSPROPERTY_TYPE_DEFAULTVALUES	0x00010000
    108 
    109 #define KSPROPERTY_TYPE_TOPOLOGY	0x10000000
    110 
    111 typedef struct {
    112   KSPROPERTY Property;
    113   ULONG NodeId;
    114   ULONG Reserved;
    115 } KSP_NODE,*PKSP_NODE;
    116 
    117 typedef struct {
    118   KSMETHOD Method;
    119   ULONG NodeId;
    120   ULONG Reserved;
    121 } KSM_NODE,*PKSM_NODE;
    122 
    123 typedef struct {
    124   KSEVENT Event;
    125   ULONG NodeId;
    126   ULONG Reserved;
    127 } KSE_NODE,*PKSE_NODE;
    128 
    129 #define STATIC_KSPROPTYPESETID_General					\
    130 	0x97E99BA0,0xBDEA,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    131 DEFINE_GUIDSTRUCT("97E99BA0-BDEA-11CF-A5D6-28DB04C10000",KSPROPTYPESETID_General);
    132 #define KSPROPTYPESETID_General DEFINE_GUIDNAMED(KSPROPTYPESETID_General)
    133 
    134 #if defined(_NTDDK_)
    135 #include <psdk_inc/_varenum.h>
    136 #endif
    137 
    138 typedef struct {
    139   ULONG Size;
    140   ULONG Count;
    141 } KSMULTIPLE_ITEM,*PKSMULTIPLE_ITEM;
    142 
    143 typedef struct {
    144   ULONG AccessFlags;
    145   ULONG DescriptionSize;
    146   KSIDENTIFIER PropTypeSet;
    147   ULONG MembersListCount;
    148   ULONG Reserved;
    149 } KSPROPERTY_DESCRIPTION,*PKSPROPERTY_DESCRIPTION;
    150 
    151 #define KSPROPERTY_MEMBER_RANGES		0x00000001
    152 #define KSPROPERTY_MEMBER_STEPPEDRANGES		0x00000002
    153 #define KSPROPERTY_MEMBER_VALUES		0x00000003
    154 
    155 #define KSPROPERTY_MEMBER_FLAG_DEFAULT		0x00000001
    156 #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_MULTICHANNEL 0x00000002
    157 #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_UNIFORM	0x00000004
    158 
    159 typedef struct {
    160   ULONG MembersFlags;
    161   ULONG MembersSize;
    162   ULONG MembersCount;
    163   ULONG Flags;
    164 } KSPROPERTY_MEMBERSHEADER,*PKSPROPERTY_MEMBERSHEADER;
    165 
    166 typedef union {
    167   _KS_ANON_STRUCT(_SIGNED)
    168   {
    169     LONG SignedMinimum;
    170     LONG SignedMaximum;
    171   };
    172   _KS_ANON_STRUCT(_UNSIGNED)
    173   {
    174     ULONG UnsignedMinimum;
    175     ULONG UnsignedMaximum;
    176   };
    177 } KSPROPERTY_BOUNDS_LONG,*PKSPROPERTY_BOUNDS_LONG;
    178 
    179 typedef union {
    180   _KS_ANON_STRUCT(_SIGNED64)
    181   {
    182     LONGLONG SignedMinimum;
    183     LONGLONG SignedMaximum;
    184   };
    185   _KS_ANON_STRUCT(_UNSIGNED64)
    186   {
    187     DWORDLONG UnsignedMinimum;
    188     DWORDLONG UnsignedMaximum;
    189   };
    190 } KSPROPERTY_BOUNDS_LONGLONG,*PKSPROPERTY_BOUNDS_LONGLONG;
    191 
    192 typedef struct {
    193   ULONG SteppingDelta;
    194   ULONG Reserved;
    195   KSPROPERTY_BOUNDS_LONG Bounds;
    196 } KSPROPERTY_STEPPING_LONG,*PKSPROPERTY_STEPPING_LONG;
    197 
    198 typedef struct {
    199   DWORDLONG SteppingDelta;
    200   KSPROPERTY_BOUNDS_LONGLONG Bounds;
    201 } KSPROPERTY_STEPPING_LONGLONG,*PKSPROPERTY_STEPPING_LONGLONG;
    202 
    203 #if defined(_NTDDK_)
    204 typedef struct _KSDEVICE_DESCRIPTOR KSDEVICE_DESCRIPTOR, *PKSDEVICE_DESCRIPTOR;
    205 typedef struct _KSDEVICE_DISPATCH KSDEVICE_DISPATCH, *PKSDEVICE_DISPATCH;
    206 typedef struct _KSDEVICE KSDEVICE, *PKSDEVICE;
    207 typedef struct _KSFILTERFACTORY KSFILTERFACTORY, *PKSFILTERFACTORY;
    208 typedef struct _KSFILTER_DESCRIPTOR KSFILTER_DESCRIPTOR, *PKSFILTER_DESCRIPTOR;
    209 typedef struct _KSFILTER_DISPATCH KSFILTER_DISPATCH, *PKSFILTER_DISPATCH;
    210 typedef struct _KSFILTER KSFILTER, *PKSFILTER;
    211 typedef struct _KSPIN_DESCRIPTOR_EX KSPIN_DESCRIPTOR_EX, *PKSPIN_DESCRIPTOR_EX;
    212 typedef struct _KSPIN_DISPATCH KSPIN_DISPATCH, *PKSPIN_DISPATCH;
    213 typedef struct _KSCLOCK_DISPATCH KSCLOCK_DISPATCH, *PKSCLOCK_DISPATCH;
    214 typedef struct _KSALLOCATOR_DISPATCH KSALLOCATOR_DISPATCH, *PKSALLOCATOR_DISPATCH;
    215 typedef struct _KSPIN KSPIN, *PKSPIN;
    216 typedef struct _KSNODE_DESCRIPTOR KSNODE_DESCRIPTOR, *PKSNODE_DESCRIPTOR;
    217 typedef struct _KSSTREAM_POINTER_OFFSET KSSTREAM_POINTER_OFFSET, *PKSSTREAM_POINTER_OFFSET;
    218 typedef struct _KSSTREAM_POINTER KSSTREAM_POINTER, *PKSSTREAM_POINTER;
    219 typedef struct _KSMAPPING KSMAPPING, *PKSMAPPING;
    220 typedef struct _KSPROCESSPIN KSPROCESSPIN, *PKSPROCESSPIN;
    221 typedef struct _KSPROCESSPIN_INDEXENTRY KSPROCESSPIN_INDEXENTRY, *PKSPROCESSPIN_INDEXENTRY;
    222 #endif /* _NTDDK_ */
    223 
    224 typedef PVOID PKSWORKER;
    225 
    226 
    227 typedef struct {
    228   ULONG NotificationType;
    229   __C89_NAMELESS union {
    230     struct {
    231       HANDLE Event;
    232       ULONG_PTR Reserved[2];
    233     } EventHandle;
    234     struct {
    235       HANDLE Semaphore;
    236       ULONG Reserved;
    237       LONG Adjustment;
    238     } SemaphoreHandle;
    239 #if defined(_NTDDK_)
    240     struct {
    241       PVOID Event;
    242       KPRIORITY Increment;
    243       ULONG_PTR Reserved;
    244     } EventObject;
    245     struct {
    246       PVOID Semaphore;
    247       KPRIORITY Increment;
    248       LONG Adjustment;
    249     } SemaphoreObject;
    250     struct {
    251       PKDPC Dpc;
    252       ULONG ReferenceCount;
    253       ULONG_PTR Reserved;
    254     } Dpc;
    255     struct {
    256       PWORK_QUEUE_ITEM WorkQueueItem;
    257       WORK_QUEUE_TYPE WorkQueueType;
    258       ULONG_PTR Reserved;
    259     } WorkItem;
    260     struct {
    261       PWORK_QUEUE_ITEM WorkQueueItem;
    262       PKSWORKER KsWorkerObject;
    263       ULONG_PTR Reserved;
    264     } KsWorkItem;
    265 #endif /* _NTDDK_ */
    266     struct {
    267       PVOID Unused;
    268       LONG_PTR Alignment[2];
    269     } Alignment;
    270   };
    271 } KSEVENTDATA,*PKSEVENTDATA;
    272 
    273 #define KSEVENTF_EVENT_HANDLE		0x00000001
    274 #define KSEVENTF_SEMAPHORE_HANDLE	0x00000002
    275 #if defined(_NTDDK_)
    276 #define KSEVENTF_EVENT_OBJECT		0x00000004
    277 #define KSEVENTF_SEMAPHORE_OBJECT	0x00000008
    278 #define KSEVENTF_DPC			0x00000010
    279 #define KSEVENTF_WORKITEM		0x00000020
    280 #define KSEVENTF_KSWORKITEM		0x00000080
    281 #endif /* _NTDDK_ */
    282 
    283 #define KSEVENT_TYPE_ENABLE		0x00000001
    284 #define KSEVENT_TYPE_ONESHOT		0x00000002
    285 #define KSEVENT_TYPE_ENABLEBUFFERED	0x00000004
    286 #define KSEVENT_TYPE_SETSUPPORT		0x00000100
    287 #define KSEVENT_TYPE_BASICSUPPORT	0x00000200
    288 #define KSEVENT_TYPE_QUERYBUFFER	0x00000400
    289 
    290 #define KSEVENT_TYPE_TOPOLOGY		0x10000000
    291 
    292 typedef struct {
    293   KSEVENT Event;
    294   PKSEVENTDATA EventData;
    295   PVOID Reserved;
    296 } KSQUERYBUFFER,*PKSQUERYBUFFER;
    297 
    298 typedef struct {
    299   ULONG Size;
    300   ULONG Flags;
    301   __C89_NAMELESS union {
    302     HANDLE ObjectHandle;
    303     PVOID ObjectPointer;
    304   };
    305   PVOID Reserved;
    306   KSEVENT Event;
    307   KSEVENTDATA EventData;
    308 } KSRELATIVEEVENT;
    309 
    310 #define KSRELATIVEEVENT_FLAG_HANDLE	0x00000001
    311 #define KSRELATIVEEVENT_FLAG_POINTER	0x00000002
    312 
    313 typedef struct {
    314   KSEVENTDATA EventData;
    315   LONGLONG MarkTime;
    316 } KSEVENT_TIME_MARK,*PKSEVENT_TIME_MARK;
    317 
    318 typedef struct {
    319   KSEVENTDATA EventData;
    320   LONGLONG TimeBase;
    321   LONGLONG Interval;
    322 } KSEVENT_TIME_INTERVAL,*PKSEVENT_TIME_INTERVAL;
    323 
    324 typedef struct {
    325   LONGLONG TimeBase;
    326   LONGLONG Interval;
    327 } KSINTERVAL,*PKSINTERVAL;
    328 
    329 #define STATIC_KSPROPSETID_General					\
    330 	0x1464EDA5,0x6A8F,0x11D1,0x9A,0xA7,0x00,0xA0,0xC9,0x22,0x31,0x96
    331 DEFINE_GUIDSTRUCT("1464EDA5-6A8F-11D1-9AA7-00A0C9223196",KSPROPSETID_General);
    332 #define KSPROPSETID_General DEFINE_GUIDNAMED(KSPROPSETID_General)
    333 
    334 typedef enum {
    335   KSPROPERTY_GENERAL_COMPONENTID
    336 } KSPROPERTY_GENERAL;
    337 
    338 typedef struct {
    339   GUID Manufacturer;
    340   GUID Product;
    341   GUID Component;
    342   GUID Name;
    343   ULONG Version;
    344   ULONG Revision;
    345 } KSCOMPONENTID,*PKSCOMPONENTID;
    346 
    347 #define DEFINE_KSPROPERTY_ITEM_GENERAL_COMPONENTID(Handler)		\
    348 	DEFINE_KSPROPERTY_ITEM(						\
    349 				KSPROPERTY_GENERAL_COMPONENTID,		\
    350 				(Handler),				\
    351 				sizeof(KSPROPERTY),			\
    352 				sizeof(KSCOMPONENTID),			\
    353 				NULL, NULL, 0, NULL, NULL, 0)
    354 
    355 #define STATIC_KSMETHODSETID_StreamIo	\
    356 	0x65D003CA,0x1523,0x11D2,0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96
    357 DEFINE_GUIDSTRUCT("65D003CA-1523-11D2-B27A-00A0C9223196",KSMETHODSETID_StreamIo);
    358 #define KSMETHODSETID_StreamIo DEFINE_GUIDNAMED(KSMETHODSETID_StreamIo)
    359 
    360 typedef enum {
    361   KSMETHOD_STREAMIO_READ,
    362   KSMETHOD_STREAMIO_WRITE
    363 } KSMETHOD_STREAMIO;
    364 
    365 #define DEFINE_KSMETHOD_ITEM_STREAMIO_READ(Handler)			\
    366 	DEFINE_KSMETHOD_ITEM(						\
    367 				KSMETHOD_STREAMIO_READ,			\
    368 				KSMETHOD_TYPE_WRITE,			\
    369 				(Handler),				\
    370 				sizeof(KSMETHOD),			\
    371 				0,					\
    372 				NULL)
    373 
    374 #define DEFINE_KSMETHOD_ITEM_STREAMIO_WRITE(Handler)			\
    375 	DEFINE_KSMETHOD_ITEM(						\
    376 				KSMETHOD_STREAMIO_WRITE,		\
    377 				KSMETHOD_TYPE_READ,			\
    378 				(Handler),				\
    379 				sizeof(KSMETHOD),			\
    380 				0,					\
    381 				NULL)
    382 
    383 #define STATIC_KSPROPSETID_MediaSeeking					\
    384 	0xEE904F0C,0xD09B,0x11D0,0xAB,0xE9,0x00,0xA0,0xC9,0x22,0x31,0x96
    385 DEFINE_GUIDSTRUCT("EE904F0C-D09B-11D0-ABE9-00A0C9223196",KSPROPSETID_MediaSeeking);
    386 #define KSPROPSETID_MediaSeeking DEFINE_GUIDNAMED(KSPROPSETID_MediaSeeking)
    387 
    388 typedef enum {
    389   KSPROPERTY_MEDIASEEKING_CAPABILITIES,
    390   KSPROPERTY_MEDIASEEKING_FORMATS,
    391   KSPROPERTY_MEDIASEEKING_TIMEFORMAT,
    392   KSPROPERTY_MEDIASEEKING_POSITION,
    393   KSPROPERTY_MEDIASEEKING_STOPPOSITION,
    394   KSPROPERTY_MEDIASEEKING_POSITIONS,
    395   KSPROPERTY_MEDIASEEKING_DURATION,
    396   KSPROPERTY_MEDIASEEKING_AVAILABLE,
    397   KSPROPERTY_MEDIASEEKING_PREROLL,
    398   KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT
    399 } KSPROPERTY_MEDIASEEKING;
    400 
    401 typedef enum {
    402   KS_SEEKING_NoPositioning,
    403   KS_SEEKING_AbsolutePositioning,
    404   KS_SEEKING_RelativePositioning,
    405   KS_SEEKING_IncrementalPositioning,
    406   KS_SEEKING_PositioningBitsMask = 0x3,
    407   KS_SEEKING_SeekToKeyFrame,
    408   KS_SEEKING_ReturnTime = 0x8
    409 } KS_SEEKING_FLAGS;
    410 
    411 typedef enum {
    412   KS_SEEKING_CanSeekAbsolute = 0x1,
    413   KS_SEEKING_CanSeekForwards = 0x2,
    414   KS_SEEKING_CanSeekBackwards = 0x4,
    415   KS_SEEKING_CanGetCurrentPos = 0x8,
    416   KS_SEEKING_CanGetStopPos = 0x10,
    417   KS_SEEKING_CanGetDuration = 0x20,
    418   KS_SEEKING_CanPlayBackwards = 0x40
    419 } KS_SEEKING_CAPABILITIES;
    420 
    421 typedef struct {
    422   LONGLONG Current;
    423   LONGLONG Stop;
    424   KS_SEEKING_FLAGS CurrentFlags;
    425   KS_SEEKING_FLAGS StopFlags;
    426 } KSPROPERTY_POSITIONS,*PKSPROPERTY_POSITIONS;
    427 
    428 typedef struct {
    429   LONGLONG Earliest;
    430   LONGLONG Latest;
    431 } KSPROPERTY_MEDIAAVAILABLE,*PKSPROPERTY_MEDIAAVAILABLE;
    432 
    433 typedef struct {
    434   KSPROPERTY Property;
    435   GUID SourceFormat;
    436   GUID TargetFormat;
    437   LONGLONG Time;
    438 } KSP_TIMEFORMAT,*PKSP_TIMEFORMAT;
    439 
    440 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CAPABILITIES(Handler)	\
    441 	DEFINE_KSPROPERTY_ITEM(						\
    442 				KSPROPERTY_MEDIASEEKING_CAPABILITIES,	\
    443 				(Handler),				\
    444 				sizeof(KSPROPERTY),			\
    445 				sizeof(KS_SEEKING_CAPABILITIES),	\
    446 				NULL, NULL, 0, NULL, NULL, 0)
    447 
    448 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_FORMATS(Handler)		\
    449 	DEFINE_KSPROPERTY_ITEM(						\
    450 				KSPROPERTY_MEDIASEEKING_FORMATS,	\
    451 				(Handler),				\
    452 				sizeof(KSPROPERTY),			\
    453 				0,					\
    454 				NULL, NULL, 0, NULL, NULL, 0)
    455 
    456 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_TIMEFORMAT(GetHandler,SetHandler) \
    457 	DEFINE_KSPROPERTY_ITEM(						\
    458 				KSPROPERTY_MEDIASEEKING_TIMEFORMAT,	\
    459 				(GetHandler),				\
    460 				sizeof(KSPROPERTY),			\
    461 				sizeof(GUID),				\
    462 				(SetHandler),				\
    463 				NULL, 0, NULL, NULL, 0)
    464 
    465 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITION(Handler)		\
    466 	DEFINE_KSPROPERTY_ITEM(						\
    467 				KSPROPERTY_MEDIASEEKING_POSITION,	\
    468 				(Handler),				\
    469 				sizeof(KSPROPERTY),			\
    470 				sizeof(LONGLONG),			\
    471 				NULL, NULL, 0, NULL, NULL, 0)
    472 
    473 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_STOPPOSITION(Handler)	\
    474 	DEFINE_KSPROPERTY_ITEM(						\
    475 				KSPROPERTY_MEDIASEEKING_STOPPOSITION,	\
    476 				(Handler),				\
    477 				sizeof(KSPROPERTY),			\
    478 				sizeof(LONGLONG),			\
    479 				NULL, NULL, 0, NULL, NULL, 0)
    480 
    481 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITIONS(Handler)		\
    482 	DEFINE_KSPROPERTY_ITEM(						\
    483 				KSPROPERTY_MEDIASEEKING_POSITIONS,	\
    484 				NULL,					\
    485 				sizeof(KSPROPERTY),			\
    486 				sizeof(KSPROPERTY_POSITIONS),		\
    487 				(Handler),				\
    488 				NULL, 0, NULL, NULL, 0)
    489 
    490 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_DURATION(Handler)		\
    491 	DEFINE_KSPROPERTY_ITEM(						\
    492 				KSPROPERTY_MEDIASEEKING_DURATION,	\
    493 				(Handler),				\
    494 				sizeof(KSPROPERTY),			\
    495 				sizeof(LONGLONG),			\
    496 				NULL, NULL, 0, NULL, NULL, 0)
    497 
    498 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_AVAILABLE(Handler)		\
    499 	DEFINE_KSPROPERTY_ITEM(						\
    500 				KSPROPERTY_MEDIASEEKING_AVAILABLE,	\
    501 				(Handler),				\
    502 				sizeof(KSPROPERTY),			\
    503 				sizeof(KSPROPERTY_MEDIAAVAILABLE),	\
    504 				NULL, NULL, 0, NULL, NULL, 0)
    505 
    506 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_PREROLL(Handler)		\
    507 	DEFINE_KSPROPERTY_ITEM(						\
    508 				KSPROPERTY_MEDIASEEKING_PREROLL,	\
    509 				(Handler),				\
    510 				sizeof(KSPROPERTY),			\
    511 				sizeof(LONGLONG),			\
    512 				NULL, NULL, 0, NULL, NULL, 0)
    513 
    514 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CONVERTTIMEFORMAT(Handler)	\
    515 	DEFINE_KSPROPERTY_ITEM(						\
    516 				KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT, \
    517 				(Handler),				\
    518 				sizeof(KSP_TIMEFORMAT),			\
    519 				sizeof(LONGLONG),			\
    520 				NULL, NULL, 0, NULL, NULL, 0)
    521 
    522 #define STATIC_KSPROPSETID_Topology					\
    523 	0x720D4AC0,0x7533,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    524 DEFINE_GUIDSTRUCT("720D4AC0-7533-11D0-A5D6-28DB04C10000",KSPROPSETID_Topology);
    525 #define KSPROPSETID_Topology DEFINE_GUIDNAMED(KSPROPSETID_Topology)
    526 
    527 typedef enum {
    528   KSPROPERTY_TOPOLOGY_CATEGORIES,
    529   KSPROPERTY_TOPOLOGY_NODES,
    530   KSPROPERTY_TOPOLOGY_CONNECTIONS,
    531   KSPROPERTY_TOPOLOGY_NAME
    532 } KSPROPERTY_TOPOLOGY;
    533 
    534 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler)		\
    535 	DEFINE_KSPROPERTY_ITEM(						\
    536 				KSPROPERTY_TOPOLOGY_CATEGORIES,		\
    537 				(Handler),				\
    538 				sizeof(KSPROPERTY),			\
    539 				0,					\
    540 				NULL, NULL, 0,NULL, NULL, 0)
    541 
    542 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler)			\
    543 	DEFINE_KSPROPERTY_ITEM(						\
    544 				KSPROPERTY_TOPOLOGY_NODES,		\
    545 				(Handler),				\
    546 				sizeof(KSPROPERTY),			\
    547 				0,					\
    548 				NULL, NULL, 0, NULL, NULL, 0)
    549 
    550 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler)		\
    551 	DEFINE_KSPROPERTY_ITEM(						\
    552 				KSPROPERTY_TOPOLOGY_CONNECTIONS,	\
    553 				(Handler),				\
    554 				sizeof(KSPROPERTY),			\
    555 				0,					\
    556 				NULL, NULL, 0, NULL, NULL, 0)
    557 
    558 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)			\
    559 	DEFINE_KSPROPERTY_ITEM(						\
    560 				KSPROPERTY_TOPOLOGY_NAME,		\
    561 				(Handler),				\
    562 				sizeof(KSP_NODE),			\
    563 				0,					\
    564 				NULL, NULL, 0, NULL, NULL, 0)
    565 
    566 #define DEFINE_KSPROPERTY_TOPOLOGYSET(TopologySet,Handler)		\
    567 DEFINE_KSPROPERTY_TABLE(TopologySet) {					\
    568 	DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler),		\
    569 	DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler),			\
    570 	DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler),		\
    571 	DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)			\
    572 }
    573 
    574 #define STATIC_KSCATEGORY_BRIDGE					\
    575 	0x085AFF00,0x62CE,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    576 DEFINE_GUIDSTRUCT("085AFF00-62CE-11CF-A5D6-28DB04C10000",KSCATEGORY_BRIDGE);
    577 #define KSCATEGORY_BRIDGE DEFINE_GUIDNAMED(KSCATEGORY_BRIDGE)
    578 
    579 #define STATIC_KSCATEGORY_CAPTURE					\
    580 	0x65E8773D,0x8F56,0x11D0,0xA3,0xB9,0x00,0xA0,0xC9,0x22,0x31,0x96
    581 DEFINE_GUIDSTRUCT("65E8773D-8F56-11D0-A3B9-00A0C9223196",KSCATEGORY_CAPTURE);
    582 #define KSCATEGORY_CAPTURE DEFINE_GUIDNAMED(KSCATEGORY_CAPTURE)
    583 
    584 #define STATIC_KSCATEGORY_RENDER					\
    585 	0x65E8773E,0x8F56,0x11D0,0xA3,0xB9,0x00,0xA0,0xC9,0x22,0x31,0x96
    586 DEFINE_GUIDSTRUCT("65E8773E-8F56-11D0-A3B9-00A0C9223196",KSCATEGORY_RENDER);
    587 #define KSCATEGORY_RENDER DEFINE_GUIDNAMED(KSCATEGORY_RENDER)
    588 
    589 #define STATIC_KSCATEGORY_MIXER						\
    590 	0xAD809C00,0x7B88,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    591 DEFINE_GUIDSTRUCT("AD809C00-7B88-11D0-A5D6-28DB04C10000",KSCATEGORY_MIXER);
    592 #define KSCATEGORY_MIXER DEFINE_GUIDNAMED(KSCATEGORY_MIXER)
    593 
    594 #define STATIC_KSCATEGORY_SPLITTER					\
    595 	0x0A4252A0,0x7E70,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    596 DEFINE_GUIDSTRUCT("0A4252A0-7E70-11D0-A5D6-28DB04C10000",KSCATEGORY_SPLITTER);
    597 #define KSCATEGORY_SPLITTER DEFINE_GUIDNAMED(KSCATEGORY_SPLITTER)
    598 
    599 #define STATIC_KSCATEGORY_DATACOMPRESSOR				\
    600 	0x1E84C900,0x7E70,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    601 DEFINE_GUIDSTRUCT("1E84C900-7E70-11D0-A5D6-28DB04C10000",KSCATEGORY_DATACOMPRESSOR);
    602 #define KSCATEGORY_DATACOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATACOMPRESSOR)
    603 
    604 #define STATIC_KSCATEGORY_DATADECOMPRESSOR				\
    605 	0x2721AE20,0x7E70,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    606 DEFINE_GUIDSTRUCT("2721AE20-7E70-11D0-A5D6-28DB04C10000",KSCATEGORY_DATADECOMPRESSOR);
    607 #define KSCATEGORY_DATADECOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATADECOMPRESSOR)
    608 
    609 #define STATIC_KSCATEGORY_DATATRANSFORM					\
    610 	0x2EB07EA0,0x7E70,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    611 DEFINE_GUIDSTRUCT("2EB07EA0-7E70-11D0-A5D6-28DB04C10000",KSCATEGORY_DATATRANSFORM);
    612 #define KSCATEGORY_DATATRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_DATATRANSFORM)
    613 
    614 #define STATIC_KSCATEGORY_COMMUNICATIONSTRANSFORM			\
    615 	0xCF1DDA2C,0x9743,0x11D0,0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96
    616 DEFINE_GUIDSTRUCT("CF1DDA2C-9743-11D0-A3EE-00A0C9223196",KSCATEGORY_COMMUNICATIONSTRANSFORM);
    617 #define KSCATEGORY_COMMUNICATIONSTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_COMMUNICATIONSTRANSFORM)
    618 
    619 #define STATIC_KSCATEGORY_INTERFACETRANSFORM				\
    620 	0xCF1DDA2D,0x9743,0x11D0,0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96
    621 DEFINE_GUIDSTRUCT("CF1DDA2D-9743-11D0-A3EE-00A0C9223196",KSCATEGORY_INTERFACETRANSFORM);
    622 #define KSCATEGORY_INTERFACETRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_INTERFACETRANSFORM)
    623 
    624 #define STATIC_KSCATEGORY_MEDIUMTRANSFORM				\
    625 	0xCF1DDA2E,0x9743,0x11D0,0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96
    626 DEFINE_GUIDSTRUCT("CF1DDA2E-9743-11D0-A3EE-00A0C9223196",KSCATEGORY_MEDIUMTRANSFORM);
    627 #define KSCATEGORY_MEDIUMTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_MEDIUMTRANSFORM)
    628 
    629 #define STATIC_KSCATEGORY_FILESYSTEM					\
    630 	0x760FED5E,0x9357,0x11D0,0xA3,0xCC,0x00,0xA0,0xC9,0x22,0x31,0x96
    631 DEFINE_GUIDSTRUCT("760FED5E-9357-11D0-A3CC-00A0C9223196",KSCATEGORY_FILESYSTEM);
    632 #define KSCATEGORY_FILESYSTEM DEFINE_GUIDNAMED(KSCATEGORY_FILESYSTEM)
    633 
    634 #define STATIC_KSCATEGORY_CLOCK						\
    635 	0x53172480,0x4791,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    636 DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000",KSCATEGORY_CLOCK);
    637 #define KSCATEGORY_CLOCK DEFINE_GUIDNAMED(KSCATEGORY_CLOCK)
    638 
    639 #define STATIC_KSCATEGORY_PROXY						\
    640 	0x97EBAACA,0x95BD,0x11D0,0xA3,0xEA,0x00,0xA0,0xC9,0x22,0x31,0x96
    641 DEFINE_GUIDSTRUCT("97EBAACA-95BD-11D0-A3EA-00A0C9223196",KSCATEGORY_PROXY);
    642 #define KSCATEGORY_PROXY DEFINE_GUIDNAMED(KSCATEGORY_PROXY)
    643 
    644 #define STATIC_KSCATEGORY_QUALITY					\
    645 	0x97EBAACB,0x95BD,0x11D0,0xA3,0xEA,0x00,0xA0,0xC9,0x22,0x31,0x96
    646 DEFINE_GUIDSTRUCT("97EBAACB-95BD-11D0-A3EA-00A0C9223196",KSCATEGORY_QUALITY);
    647 #define KSCATEGORY_QUALITY DEFINE_GUIDNAMED(KSCATEGORY_QUALITY)
    648 
    649 typedef struct {
    650   ULONG FromNode;
    651   ULONG FromNodePin;
    652   ULONG ToNode;
    653   ULONG ToNodePin;
    654 } KSTOPOLOGY_CONNECTION,*PKSTOPOLOGY_CONNECTION;
    655 
    656 typedef struct {
    657   ULONG CategoriesCount;
    658   const GUID *Categories;
    659   ULONG TopologyNodesCount;
    660   const GUID *TopologyNodes;
    661   ULONG TopologyConnectionsCount;
    662   const KSTOPOLOGY_CONNECTION *TopologyConnections;
    663   const GUID *TopologyNodesNames;
    664   ULONG Reserved;
    665 } KSTOPOLOGY,*PKSTOPOLOGY;
    666 
    667 #define KSFILTER_NODE	((ULONG)-1)
    668 #define KSALL_NODES	((ULONG)-1)
    669 
    670 typedef struct {
    671   ULONG CreateFlags;
    672   ULONG Node;
    673 } KSNODE_CREATE,*PKSNODE_CREATE;
    674 
    675 #define STATIC_KSTIME_FORMAT_NONE	STATIC_GUID_NULL
    676 #define KSTIME_FORMAT_NONE		GUID_NULL
    677 
    678 #define STATIC_KSTIME_FORMAT_FRAME					\
    679 	0x7b785570,0x8c82,0x11cf,0xbc,0x0c,0x00,0xaa,0x00,0xac,0x74,0xf6
    680 DEFINE_GUIDSTRUCT("7b785570-8c82-11cf-bc0c-00aa00ac74f6",KSTIME_FORMAT_FRAME);
    681 #define KSTIME_FORMAT_FRAME DEFINE_GUIDNAMED(KSTIME_FORMAT_FRAME)
    682 
    683 #define STATIC_KSTIME_FORMAT_BYTE					\
    684 	0x7b785571,0x8c82,0x11cf,0xbc,0x0c,0x00,0xaa,0x00,0xac,0x74,0xf6
    685 DEFINE_GUIDSTRUCT("7b785571-8c82-11cf-bc0c-00aa00ac74f6",KSTIME_FORMAT_BYTE);
    686 #define KSTIME_FORMAT_BYTE DEFINE_GUIDNAMED(KSTIME_FORMAT_BYTE)
    687 
    688 #define STATIC_KSTIME_FORMAT_SAMPLE					\
    689 	0x7b785572,0x8c82,0x11cf,0xbc,0x0c,0x00,0xaa,0x00,0xac,0x74,0xf6
    690 DEFINE_GUIDSTRUCT("7b785572-8c82-11cf-bc0c-00aa00ac74f6",KSTIME_FORMAT_SAMPLE);
    691 #define KSTIME_FORMAT_SAMPLE DEFINE_GUIDNAMED(KSTIME_FORMAT_SAMPLE)
    692 
    693 #define STATIC_KSTIME_FORMAT_FIELD					\
    694 	0x7b785573,0x8c82,0x11cf,0xbc,0x0c,0x00,0xaa,0x00,0xac,0x74,0xf6
    695 DEFINE_GUIDSTRUCT("7b785573-8c82-11cf-bc0c-00aa00ac74f6",KSTIME_FORMAT_FIELD);
    696 #define KSTIME_FORMAT_FIELD DEFINE_GUIDNAMED(KSTIME_FORMAT_FIELD)
    697 
    698 #define STATIC_KSTIME_FORMAT_MEDIA_TIME					\
    699 	0x7b785574,0x8c82,0x11cf,0xbc,0x0c,0x00,0xaa,0x00,0xac,0x74,0xf6
    700 DEFINE_GUIDSTRUCT("7b785574-8c82-11cf-bc0c-00aa00ac74f6",KSTIME_FORMAT_MEDIA_TIME);
    701 #define KSTIME_FORMAT_MEDIA_TIME DEFINE_GUIDNAMED(KSTIME_FORMAT_MEDIA_TIME)
    702 
    703 typedef KSIDENTIFIER KSPIN_INTERFACE,*PKSPIN_INTERFACE;
    704 
    705 #define STATIC_KSINTERFACESETID_Standard				\
    706 	0x1A8766A0,0x62CE,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    707 DEFINE_GUIDSTRUCT("1A8766A0-62CE-11CF-A5D6-28DB04C10000",KSINTERFACESETID_Standard);
    708 #define KSINTERFACESETID_Standard DEFINE_GUIDNAMED(KSINTERFACESETID_Standard)
    709 
    710 typedef enum {
    711   KSINTERFACE_STANDARD_STREAMING,
    712   KSINTERFACE_STANDARD_LOOPED_STREAMING,
    713   KSINTERFACE_STANDARD_CONTROL
    714 } KSINTERFACE_STANDARD;
    715 
    716 #define STATIC_KSINTERFACESETID_FileIo					\
    717 	0x8C6F932C,0xE771,0x11D0,0xB8,0xFF,0x00,0xA0,0xC9,0x22,0x31,0x96
    718 DEFINE_GUIDSTRUCT("8C6F932C-E771-11D0-B8FF-00A0C9223196",KSINTERFACESETID_FileIo);
    719 #define KSINTERFACESETID_FileIo DEFINE_GUIDNAMED(KSINTERFACESETID_FileIo)
    720 
    721 typedef enum {
    722   KSINTERFACE_FILEIO_STREAMING
    723 } KSINTERFACE_FILEIO;
    724 
    725 #define KSMEDIUM_TYPE_ANYINSTANCE		0
    726 
    727 #define STATIC_KSMEDIUMSETID_Standard					\
    728 	0x4747B320,0x62CE,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
    729 DEFINE_GUIDSTRUCT("4747B320-62CE-11CF-A5D6-28DB04C10000",KSMEDIUMSETID_Standard);
    730 #define KSMEDIUMSETID_Standard DEFINE_GUIDNAMED(KSMEDIUMSETID_Standard)
    731 
    732 #define KSMEDIUM_STANDARD_DEVIO KSMEDIUM_TYPE_ANYINSTANCE
    733 
    734 #define STATIC_KSPROPSETID_Pin						\
    735 	0x8C134960,0x51AD,0x11CF,0x87,0x8A,0x94,0xF8,0x01,0xC1,0x00,0x00
    736 DEFINE_GUIDSTRUCT("8C134960-51AD-11CF-878A-94F801C10000",KSPROPSETID_Pin);
    737 #define KSPROPSETID_Pin DEFINE_GUIDNAMED(KSPROPSETID_Pin)
    738 
    739 typedef enum {
    740   KSPROPERTY_PIN_CINSTANCES,
    741   KSPROPERTY_PIN_CTYPES,
    742   KSPROPERTY_PIN_DATAFLOW,
    743   KSPROPERTY_PIN_DATARANGES,
    744   KSPROPERTY_PIN_DATAINTERSECTION,
    745   KSPROPERTY_PIN_INTERFACES,
    746   KSPROPERTY_PIN_MEDIUMS,
    747   KSPROPERTY_PIN_COMMUNICATION,
    748   KSPROPERTY_PIN_GLOBALCINSTANCES,
    749   KSPROPERTY_PIN_NECESSARYINSTANCES,
    750   KSPROPERTY_PIN_PHYSICALCONNECTION,
    751   KSPROPERTY_PIN_CATEGORY,
    752   KSPROPERTY_PIN_NAME,
    753   KSPROPERTY_PIN_CONSTRAINEDDATARANGES,
    754   KSPROPERTY_PIN_PROPOSEDATAFORMAT
    755 } KSPROPERTY_PIN;
    756 
    757 typedef struct {
    758   KSPROPERTY Property;
    759   ULONG PinId;
    760   ULONG Reserved;
    761 } KSP_PIN,*PKSP_PIN;
    762 
    763 #define KSINSTANCE_INDETERMINATE	((ULONG)-1)
    764 
    765 typedef struct {
    766   ULONG PossibleCount;
    767   ULONG CurrentCount;
    768 } KSPIN_CINSTANCES,*PKSPIN_CINSTANCES;
    769 
    770 typedef enum {
    771   KSPIN_DATAFLOW_IN = 1,
    772   KSPIN_DATAFLOW_OUT
    773 } KSPIN_DATAFLOW,*PKSPIN_DATAFLOW;
    774 
    775 #define KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION	0
    776 #define KSDATAFORMAT_TEMPORAL_COMPRESSION	(1 << KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION)
    777 #define KSDATAFORMAT_BIT_ATTRIBUTES		1
    778 #define KSDATAFORMAT_ATTRIBUTES			(1 << KSDATAFORMAT_BIT_ATTRIBUTES)
    779 
    780 #define KSDATARANGE_BIT_ATTRIBUTES		1
    781 #define KSDATARANGE_ATTRIBUTES			(1 << KSDATARANGE_BIT_ATTRIBUTES)
    782 #define KSDATARANGE_BIT_REQUIRED_ATTRIBUTES	2
    783 #define KSDATARANGE_REQUIRED_ATTRIBUTES		(1 << KSDATARANGE_BIT_REQUIRED_ATTRIBUTES)
    784 
    785 typedef union {
    786   __C89_NAMELESS struct {
    787     ULONG FormatSize;
    788     ULONG Flags;
    789     ULONG SampleSize;
    790     ULONG Reserved;
    791     GUID MajorFormat;
    792     GUID SubFormat;
    793     GUID Specifier;
    794   };
    795   LONGLONG Alignment;
    796 } KSDATAFORMAT,*PKSDATAFORMAT,KSDATARANGE,*PKSDATARANGE;
    797 
    798 #define KSATTRIBUTE_REQUIRED		0x00000001
    799 
    800 typedef struct {
    801   ULONG Size;
    802   ULONG Flags;
    803   GUID Attribute;
    804 } KSATTRIBUTE,*PKSATTRIBUTE;
    805 
    806 #if defined(_NTDDK_)
    807 typedef struct {
    808   ULONG Count;
    809   PKSATTRIBUTE *Attributes;
    810 } KSATTRIBUTE_LIST,*PKSATTRIBUTE_LIST;
    811 #endif /* _NTDDK_ */
    812 
    813 typedef enum {
    814   KSPIN_COMMUNICATION_NONE,
    815   KSPIN_COMMUNICATION_SINK,
    816   KSPIN_COMMUNICATION_SOURCE,
    817   KSPIN_COMMUNICATION_BOTH,
    818   KSPIN_COMMUNICATION_BRIDGE
    819 } KSPIN_COMMUNICATION,*PKSPIN_COMMUNICATION;
    820 
    821 typedef KSIDENTIFIER KSPIN_MEDIUM,*PKSPIN_MEDIUM;
    822 
    823 typedef struct {
    824   KSPIN_INTERFACE Interface;
    825   KSPIN_MEDIUM Medium;
    826   ULONG PinId;
    827   HANDLE PinToHandle;
    828   KSPRIORITY Priority;
    829 } KSPIN_CONNECT,*PKSPIN_CONNECT;
    830 
    831 typedef struct {
    832   ULONG Size;
    833   ULONG Pin;
    834   WCHAR SymbolicLinkName[1];
    835 } KSPIN_PHYSICALCONNECTION,*PKSPIN_PHYSICALCONNECTION;
    836 
    837 #if defined(_NTDDK_)
    838 typedef NTSTATUS (*PFNKSINTERSECTHANDLER) ( PIRP Irp, PKSP_PIN Pin,
    839 					    PKSDATARANGE DataRange,
    840 					    PVOID Data);
    841 typedef NTSTATUS (*PFNKSINTERSECTHANDLEREX)(PVOID Context, PIRP Irp,
    842 					    PKSP_PIN Pin,
    843 					    PKSDATARANGE DataRange,
    844 					    PKSDATARANGE MatchingDataRange,
    845 					    ULONG DataBufferSize,
    846 					    PVOID Data,
    847 					    PULONG DataSize);
    848 #endif /* _NTDDK_ */
    849 
    850 #define DEFINE_KSPIN_INTERFACE_TABLE(tablename)				\
    851 	const KSPIN_INTERFACE tablename[] =
    852 
    853 #define DEFINE_KSPIN_INTERFACE_ITEM(guid,_interFace)			\
    854 	{								\
    855 		STATICGUIDOF(guid),					\
    856 		(_interFace),						\
    857 		0							\
    858 	}
    859 
    860 #define DEFINE_KSPIN_MEDIUM_TABLE(tablename)				\
    861 	const KSPIN_MEDIUM tablename[] =
    862 
    863 #define DEFINE_KSPIN_MEDIUM_ITEM(guid,medium)				\
    864 		DEFINE_KSPIN_INTERFACE_ITEM(guid,medium)
    865 
    866 #define DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(Handler)			\
    867 	DEFINE_KSPROPERTY_ITEM(						\
    868 				KSPROPERTY_PIN_CINSTANCES,		\
    869 				(Handler),				\
    870 				sizeof(KSP_PIN),			\
    871 				sizeof(KSPIN_CINSTANCES),		\
    872 				NULL, NULL, 0, NULL, NULL, 0)
    873 
    874 #define DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(Handler)			\
    875 	DEFINE_KSPROPERTY_ITEM(						\
    876 				KSPROPERTY_PIN_CTYPES,			\
    877 				(Handler),				\
    878 				sizeof(KSPROPERTY),			\
    879 				sizeof(ULONG),				\
    880 				NULL, NULL, 0, NULL, NULL, 0)
    881 
    882 #define DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(Handler)			\
    883 	DEFINE_KSPROPERTY_ITEM(						\
    884 				KSPROPERTY_PIN_DATAFLOW,		\
    885 				(Handler),				\
    886 				sizeof(KSP_PIN),			\
    887 				sizeof(KSPIN_DATAFLOW),			\
    888 				NULL, NULL, 0, NULL, NULL, 0)
    889 
    890 #define DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(Handler)			\
    891 	DEFINE_KSPROPERTY_ITEM(						\
    892 				KSPROPERTY_PIN_DATARANGES,		\
    893 				(Handler),				\
    894 				sizeof(KSP_PIN),			\
    895 				0,					\
    896 				NULL, NULL, 0, NULL, NULL, 0)
    897 
    898 #define DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(Handler)		\
    899 	DEFINE_KSPROPERTY_ITEM(						\
    900 				KSPROPERTY_PIN_DATAINTERSECTION,	\
    901 				(Handler),				\
    902 				sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM),\
    903 				0,					\
    904 				NULL, NULL, 0, NULL, NULL, 0)
    905 
    906 #define DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(Handler)			\
    907 	DEFINE_KSPROPERTY_ITEM(						\
    908 				KSPROPERTY_PIN_INTERFACES,		\
    909 				(Handler),				\
    910 				sizeof(KSP_PIN),			\
    911 				0,					\
    912 				NULL, NULL, 0, NULL, NULL, 0)
    913 
    914 #define DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(Handler)			\
    915 	DEFINE_KSPROPERTY_ITEM(						\
    916 				KSPROPERTY_PIN_MEDIUMS,			\
    917 				(Handler),				\
    918 				sizeof(KSP_PIN),			\
    919 				0,					\
    920 				NULL, NULL, 0, NULL, NULL, 0)
    921 
    922 #define DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(Handler)		\
    923 	DEFINE_KSPROPERTY_ITEM(						\
    924 				KSPROPERTY_PIN_COMMUNICATION,		\
    925 				(Handler),				\
    926 				sizeof(KSP_PIN),			\
    927 				sizeof(KSPIN_COMMUNICATION),		\
    928 				NULL, NULL, 0, NULL, NULL, 0)
    929 
    930 #define DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES(Handler)		\
    931 	DEFINE_KSPROPERTY_ITEM(						\
    932 				KSPROPERTY_PIN_GLOBALCINSTANCES,	\
    933 				(Handler),				\
    934 				sizeof(KSP_PIN),			\
    935 				sizeof(KSPIN_CINSTANCES),		\
    936 				NULL, NULL, 0, NULL, NULL, 0)
    937 
    938 #define DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES(Handler)		\
    939 	DEFINE_KSPROPERTY_ITEM(						\
    940 				KSPROPERTY_PIN_NECESSARYINSTANCES,	\
    941 				(Handler),				\
    942 				sizeof(KSP_PIN),			\
    943 				sizeof(ULONG),				\
    944 				NULL, NULL, 0, NULL, NULL, 0)
    945 
    946 #define DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION(Handler)		\
    947 	DEFINE_KSPROPERTY_ITEM(						\
    948 				KSPROPERTY_PIN_PHYSICALCONNECTION,	\
    949 				(Handler),				\
    950 				sizeof(KSP_PIN),			\
    951 				0,					\
    952 				NULL, NULL, 0, NULL, NULL, 0)
    953 
    954 #define DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(Handler)			\
    955 	DEFINE_KSPROPERTY_ITEM(						\
    956 				KSPROPERTY_PIN_CATEGORY,		\
    957 				(Handler),				\
    958 				sizeof(KSP_PIN),			\
    959 				sizeof(GUID),				\
    960 				NULL, NULL, 0, NULL, NULL, 0)
    961 
    962 #define DEFINE_KSPROPERTY_ITEM_PIN_NAME(Handler)			\
    963 	DEFINE_KSPROPERTY_ITEM(						\
    964 				KSPROPERTY_PIN_NAME,			\
    965 				(Handler),				\
    966 				sizeof(KSP_PIN),			\
    967 				0,					\
    968 				NULL, NULL, 0, NULL, NULL, 0)
    969 
    970 #define DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(Handler)	\
    971 	DEFINE_KSPROPERTY_ITEM(						\
    972 				KSPROPERTY_PIN_CONSTRAINEDDATARANGES,	\
    973 				(Handler),				\
    974 				sizeof(KSP_PIN),			\
    975 				0,					\
    976 				NULL, NULL, 0, NULL, NULL, 0)
    977 
    978 #define DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT(Handler)		\
    979 	DEFINE_KSPROPERTY_ITEM(						\
    980 				KSPROPERTY_PIN_PROPOSEDATAFORMAT,	\
    981 				NULL,					\
    982 				sizeof(KSP_PIN),			\
    983 				sizeof(KSDATAFORMAT),			\
    984 				(Handler), NULL, 0, NULL, NULL, 0)
    985 
    986 #define DEFINE_KSPROPERTY_PINSET(PinSet,PropGeneral,PropInstances,PropIntersection) \
    987 DEFINE_KSPROPERTY_TABLE(PinSet) {					\
    988 	DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),		\
    989 	DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),			\
    990 	DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),		\
    991 	DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),		\
    992 	DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),	\
    993 	DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),		\
    994 	DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),		\
    995 	DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),		\
    996 	DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),		\
    997 	DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral)			\
    998 }
    999 
   1000 #define DEFINE_KSPROPERTY_PINSETCONSTRAINED(PinSet,PropGeneral,PropInstances,PropIntersection) \
   1001 DEFINE_KSPROPERTY_TABLE(PinSet) {					\
   1002 	DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),		\
   1003 	DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),			\
   1004 	DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),		\
   1005 	DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),		\
   1006 	DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),	\
   1007 	DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),		\
   1008 	DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),		\
   1009 	DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),		\
   1010 	DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),		\
   1011 	DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral),			\
   1012 	DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(PropGeneral)	\
   1013 }
   1014 
   1015 #define STATIC_KSNAME_Filter						\
   1016 	0x9b365890,0x165f,0x11d0,0xa1,0x95,0x00,0x20,0xaf,0xd1,0x56,0xe4
   1017 DEFINE_GUIDSTRUCT("9b365890-165f-11d0-a195-0020afd156e4",KSNAME_Filter);
   1018 #define KSNAME_Filter DEFINE_GUIDNAMED(KSNAME_Filter)
   1019 
   1020 #define KSSTRING_Filter		L"{9B365890-165F-11D0-A195-0020AFD156E4}"
   1021 
   1022 #define STATIC_KSNAME_Pin						\
   1023 	0x146F1A80,0x4791,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1024 DEFINE_GUIDSTRUCT("146F1A80-4791-11D0-A5D6-28DB04C10000",KSNAME_Pin);
   1025 #define KSNAME_Pin DEFINE_GUIDNAMED(KSNAME_Pin)
   1026 
   1027 #define KSSTRING_Pin		L"{146F1A80-4791-11D0-A5D6-28DB04C10000}"
   1028 
   1029 #define STATIC_KSNAME_Clock						\
   1030 	0x53172480,0x4791,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1031 DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000",KSNAME_Clock);
   1032 #define KSNAME_Clock DEFINE_GUIDNAMED(KSNAME_Clock)
   1033 
   1034 #define KSSTRING_Clock		L"{53172480-4791-11D0-A5D6-28DB04C10000}"
   1035 
   1036 #define STATIC_KSNAME_Allocator						\
   1037 	0x642F5D00,0x4791,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1038 DEFINE_GUIDSTRUCT("642F5D00-4791-11D0-A5D6-28DB04C10000",KSNAME_Allocator);
   1039 #define KSNAME_Allocator DEFINE_GUIDNAMED(KSNAME_Allocator)
   1040 
   1041 #define KSSTRING_Allocator	L"{642F5D00-4791-11D0-A5D6-28DB04C10000}"
   1042 
   1043 #define KSSTRING_AllocatorEx	L"{091BB63B-603F-11D1-B067-00A0C9062802}"
   1044 
   1045 #define STATIC_KSNAME_TopologyNode					\
   1046 	0x0621061A,0xEE75,0x11D0,0xB9,0x15,0x00,0xA0,0xC9,0x22,0x31,0x96
   1047 DEFINE_GUIDSTRUCT("0621061A-EE75-11D0-B915-00A0C9223196",KSNAME_TopologyNode);
   1048 #define KSNAME_TopologyNode DEFINE_GUIDNAMED(KSNAME_TopologyNode)
   1049 
   1050 #define KSSTRING_TopologyNode	L"{0621061A-EE75-11D0-B915-00A0C9223196}"
   1051 
   1052 #if defined(_NTDDK_)
   1053 typedef struct {
   1054   ULONG InterfacesCount;
   1055   const KSPIN_INTERFACE *Interfaces;
   1056   ULONG MediumsCount;
   1057   const KSPIN_MEDIUM *Mediums;
   1058   ULONG DataRangesCount;
   1059   const PKSDATARANGE *DataRanges;
   1060   KSPIN_DATAFLOW DataFlow;
   1061   KSPIN_COMMUNICATION Communication;
   1062   const GUID *Category;
   1063   const GUID *Name;
   1064   __C89_NAMELESS union {
   1065     LONGLONG Reserved;
   1066     __C89_NAMELESS struct {
   1067       ULONG ConstrainedDataRangesCount;
   1068       PKSDATARANGE *ConstrainedDataRanges;
   1069     };
   1070   };
   1071 } KSPIN_DESCRIPTOR, *PKSPIN_DESCRIPTOR;
   1072 typedef const KSPIN_DESCRIPTOR *PCKSPIN_DESCRIPTOR;
   1073 
   1074 #define DEFINE_KSPIN_DESCRIPTOR_TABLE(tablename)			\
   1075 	const KSPIN_DESCRIPTOR tablename[] =
   1076 
   1077 #define DEFINE_KSPIN_DESCRIPTOR_ITEM(InterfacesCount,Interfaces,MediumsCount, Mediums,DataRangesCount,DataRanges,DataFlow,Communication)\
   1078 {									\
   1079 		InterfacesCount, Interfaces, MediumsCount, Mediums,	\
   1080 		DataRangesCount, DataRanges, DataFlow, Communication,	\
   1081 		NULL, NULL, 0						\
   1082 }
   1083 
   1084 #define DEFINE_KSPIN_DESCRIPTOR_ITEMEX(InterfacesCount,Interfaces,MediumsCount,Mediums,DataRangesCount,DataRanges,DataFlow,Communication,Category,Name)\
   1085 {									\
   1086 		InterfacesCount, Interfaces, MediumsCount, Mediums,	\
   1087 		DataRangesCount, DataRanges, DataFlow, Communication,	\
   1088 		Category, Name, 0					\
   1089 }
   1090 #endif /* _NTDDK_ */
   1091 
   1092 #define STATIC_KSDATAFORMAT_TYPE_WILDCARD	STATIC_GUID_NULL
   1093 #define KSDATAFORMAT_TYPE_WILDCARD		GUID_NULL
   1094 
   1095 #define STATIC_KSDATAFORMAT_SUBTYPE_WILDCARD	STATIC_GUID_NULL
   1096 #define KSDATAFORMAT_SUBTYPE_WILDCARD		GUID_NULL
   1097 
   1098 #define STATIC_KSDATAFORMAT_TYPE_STREAM					\
   1099 	0xE436EB83,0x524F,0x11CE,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70
   1100 DEFINE_GUIDSTRUCT("E436EB83-524F-11CE-9F53-0020AF0BA770",KSDATAFORMAT_TYPE_STREAM);
   1101 #define KSDATAFORMAT_TYPE_STREAM DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_STREAM)
   1102 
   1103 #define STATIC_KSDATAFORMAT_SUBTYPE_NONE				\
   1104 	0xE436EB8E,0x524F,0x11CE,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70
   1105 DEFINE_GUIDSTRUCT("E436EB8E-524F-11CE-9F53-0020AF0BA770",KSDATAFORMAT_SUBTYPE_NONE);
   1106 #define KSDATAFORMAT_SUBTYPE_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_NONE)
   1107 
   1108 #define STATIC_KSDATAFORMAT_SPECIFIER_WILDCARD	STATIC_GUID_NULL
   1109 #define KSDATAFORMAT_SPECIFIER_WILDCARD		GUID_NULL
   1110 
   1111 #define STATIC_KSDATAFORMAT_SPECIFIER_FILENAME				\
   1112 	0xAA797B40,0xE974,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1113 DEFINE_GUIDSTRUCT("AA797B40-E974-11CF-A5D6-28DB04C10000",KSDATAFORMAT_SPECIFIER_FILENAME);
   1114 #define KSDATAFORMAT_SPECIFIER_FILENAME DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_FILENAME)
   1115 
   1116 #define STATIC_KSDATAFORMAT_SPECIFIER_FILEHANDLE			\
   1117 	0x65E8773C,0x8F56,0x11D0,0xA3,0xB9,0x00,0xA0,0xC9,0x22,0x31,0x96
   1118 DEFINE_GUIDSTRUCT("65E8773C-8F56-11D0-A3B9-00A0C9223196",KSDATAFORMAT_SPECIFIER_FILEHANDLE);
   1119 #define KSDATAFORMAT_SPECIFIER_FILEHANDLE DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_FILEHANDLE)
   1120 
   1121 #define STATIC_KSDATAFORMAT_SPECIFIER_NONE				\
   1122 	0x0F6417D6,0xC318,0x11D0,0xA4,0x3F,0x00,0xA0,0xC9,0x22,0x31,0x96
   1123 DEFINE_GUIDSTRUCT("0F6417D6-C318-11D0-A43F-00A0C9223196",KSDATAFORMAT_SPECIFIER_NONE);
   1124 #define KSDATAFORMAT_SPECIFIER_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_NONE)
   1125 
   1126 #define STATIC_KSPROPSETID_Quality					\
   1127 	0xD16AD380,0xAC1A,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1128 DEFINE_GUIDSTRUCT("D16AD380-AC1A-11CF-A5D6-28DB04C10000",KSPROPSETID_Quality);
   1129 #define KSPROPSETID_Quality DEFINE_GUIDNAMED(KSPROPSETID_Quality)
   1130 
   1131 typedef enum {
   1132   KSPROPERTY_QUALITY_REPORT,
   1133   KSPROPERTY_QUALITY_ERROR
   1134 } KSPROPERTY_QUALITY;
   1135 
   1136 #define DEFINE_KSPROPERTY_ITEM_QUALITY_REPORT(GetHandler,SetHandler)	\
   1137 	DEFINE_KSPROPERTY_ITEM(						\
   1138 				KSPROPERTY_QUALITY_REPORT,		\
   1139 				(GetHandler),				\
   1140 				sizeof(KSPROPERTY),			\
   1141 				sizeof(KSQUALITY),			\
   1142 				(SetHandler),				\
   1143 				NULL, 0, NULL, NULL, 0)
   1144 
   1145 #define DEFINE_KSPROPERTY_ITEM_QUALITY_ERROR(GetHandler,SetHandler)	\
   1146 	DEFINE_KSPROPERTY_ITEM(						\
   1147 				KSPROPERTY_QUALITY_ERROR,		\
   1148 				(GetHandler),				\
   1149 				sizeof(KSPROPERTY),			\
   1150 				sizeof(KSERROR),			\
   1151 				(SetHandler),				\
   1152 				NULL, 0, NULL, NULL, 0)
   1153 
   1154 #define STATIC_KSPROPSETID_Connection					\
   1155 	0x1D58C920,0xAC9B,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1156 DEFINE_GUIDSTRUCT("1D58C920-AC9B-11CF-A5D6-28DB04C10000",KSPROPSETID_Connection);
   1157 #define KSPROPSETID_Connection DEFINE_GUIDNAMED(KSPROPSETID_Connection)
   1158 
   1159 typedef enum {
   1160   KSPROPERTY_CONNECTION_STATE,
   1161   KSPROPERTY_CONNECTION_PRIORITY,
   1162   KSPROPERTY_CONNECTION_DATAFORMAT,
   1163   KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
   1164   KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,
   1165   KSPROPERTY_CONNECTION_ACQUIREORDERING,
   1166   KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,
   1167   KSPROPERTY_CONNECTION_STARTAT
   1168 } KSPROPERTY_CONNECTION;
   1169 
   1170 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE(GetHandler,SetHandler)	\
   1171 	DEFINE_KSPROPERTY_ITEM(						\
   1172 				KSPROPERTY_CONNECTION_STATE,		\
   1173 				(GetHandler),				\
   1174 				sizeof(KSPROPERTY),			\
   1175 				sizeof(KSSTATE),			\
   1176 				(SetHandler),				\
   1177 				NULL, 0, NULL, NULL, 0)
   1178 
   1179 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PRIORITY(GetHandler,SetHandler) \
   1180 	DEFINE_KSPROPERTY_ITEM(						\
   1181 				KSPROPERTY_CONNECTION_PRIORITY,		\
   1182 				(GetHandler),				\
   1183 				sizeof(KSPROPERTY),			\
   1184 				sizeof(KSPRIORITY),			\
   1185 				(SetHandler),				\
   1186 				NULL, 0, NULL, NULL, 0)
   1187 
   1188 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT(GetHandler,SetHandler)\
   1189 	DEFINE_KSPROPERTY_ITEM(						\
   1190 				KSPROPERTY_CONNECTION_DATAFORMAT,	\
   1191 				(GetHandler),				\
   1192 				sizeof(KSPROPERTY),			\
   1193 				0,					\
   1194 				(SetHandler),				\
   1195 				NULL, 0, NULL, NULL, 0)
   1196 
   1197 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING(Handler)	\
   1198 	DEFINE_KSPROPERTY_ITEM(						\
   1199 				KSPROPERTY_CONNECTION_ALLOCATORFRAMING,	\
   1200 				(Handler),				\
   1201 				sizeof(KSPROPERTY),			\
   1202 				sizeof(KSALLOCATOR_FRAMING),		\
   1203 				NULL, NULL, 0, NULL, NULL, 0)
   1204 
   1205 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING_EX(Handler)	\
   1206 	DEFINE_KSPROPERTY_ITEM(						\
   1207 				KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,\
   1208 				(Handler),				\
   1209 				sizeof(KSPROPERTY),			\
   1210 				0,					\
   1211 				NULL, NULL, 0, NULL, NULL, 0)
   1212 
   1213 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PROPOSEDATAFORMAT(Handler)	\
   1214 	DEFINE_KSPROPERTY_ITEM(						\
   1215 				KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,\
   1216 				NULL,					\
   1217 				sizeof(KSPROPERTY),			\
   1218 				sizeof(KSDATAFORMAT),			\
   1219 				(Handler),				\
   1220 				NULL, 0, NULL, NULL, 0)
   1221 
   1222 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ACQUIREORDERING(Handler)	\
   1223 	DEFINE_KSPROPERTY_ITEM(						\
   1224 				KSPROPERTY_CONNECTION_ACQUIREORDERING,	\
   1225 				(Handler),				\
   1226 				sizeof(KSPROPERTY),			\
   1227 				sizeof(int),				\
   1228 				NULL, NULL, 0, NULL, NULL, 0)
   1229 
   1230 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STARTAT(Handler)		\
   1231 	DEFINE_KSPROPERTY_ITEM(						\
   1232 				KSPROPERTY_CONNECTION_STARTAT,		\
   1233 				NULL,					\
   1234 				sizeof(KSPROPERTY),			\
   1235 				sizeof(KSRELATIVEEVENT),		\
   1236 				(Handler),				\
   1237 				NULL, 0, NULL, NULL, 0)
   1238 
   1239 #define STATIC_KSPROPSETID_MemoryTransport				\
   1240 	0xA3D1C5D,0x5243,0x4819,0x9E,0xD0,0xAE,0xE8,0x4,0x4C,0xEE,0x2B
   1241 DEFINE_GUIDSTRUCT("0A3D1C5D-5243-4819-9ED0-AEE8044CEE2B", KSPROPSETID_MemoryTransport);
   1242 #define KSPROPSETID_MemoryTransport DEFINE_GUIDNAMED(KSPROPSETID_MemoryTransport)
   1243 
   1244 enum {
   1245   KSPROPERTY_MEMORY_TRANSPORT = 1
   1246 };
   1247 
   1248 #define DEFINE_KSPROPERTY_ITEM_MEMORY_TRANSPORT(SetHandler)		\
   1249 	DEFINE_KSPROPERTY_ITEM(						\
   1250 				KSPROPERTY_MEMORY_TRANSPORT,		\
   1251 				NULL,					\
   1252 				sizeof(KSPROPERTY),			\
   1253 				sizeof(WINBOOL),			\
   1254 				(SetHandler), NULL,0,NULL,NULL,0)
   1255 
   1256 #define KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER	0x00000001
   1257 #define KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY		0x00000002
   1258 #define KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY	0x00000004
   1259 #define KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE		0x00000008
   1260 #define KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY	0x80000000
   1261 
   1262 #define KSALLOCATOR_OPTIONF_COMPATIBLE			0x00000001
   1263 #define KSALLOCATOR_OPTIONF_SYSTEM_MEMORY		0x00000002
   1264 #define KSALLOCATOR_OPTIONF_VALID			0x00000003
   1265 
   1266 #define KSALLOCATOR_FLAG_PARTIAL_READ_SUPPORT		0x00000010
   1267 #define KSALLOCATOR_FLAG_DEVICE_SPECIFIC		0x00000020
   1268 #define KSALLOCATOR_FLAG_CAN_ALLOCATE			0x00000040
   1269 #define KSALLOCATOR_FLAG_INSIST_ON_FRAMESIZE_RATIO	0x00000080
   1270 #define KSALLOCATOR_FLAG_NO_FRAME_INTEGRITY		0x00000100
   1271 #define KSALLOCATOR_FLAG_MULTIPLE_OUTPUT		0x00000200
   1272 #define KSALLOCATOR_FLAG_CYCLE				0x00000400
   1273 #define KSALLOCATOR_FLAG_ALLOCATOR_EXISTS		0x00000800
   1274 #define KSALLOCATOR_FLAG_INDEPENDENT_RANGES		0x00001000
   1275 #define KSALLOCATOR_FLAG_ATTENTION_STEPPING		0x00002000
   1276 
   1277 typedef struct {
   1278   __C89_NAMELESS union {
   1279     ULONG OptionsFlags;
   1280     ULONG RequirementsFlags;
   1281   };
   1282 #if defined(_NTDDK_)
   1283   POOL_TYPE PoolType;
   1284 #else
   1285   ULONG PoolType;
   1286 #endif /* _NTDDK_ */
   1287   ULONG Frames;
   1288   ULONG FrameSize;
   1289   ULONG FileAlignment;
   1290   ULONG Reserved;
   1291 } KSALLOCATOR_FRAMING,*PKSALLOCATOR_FRAMING;
   1292 
   1293 #if defined(_NTDDK_)
   1294 typedef PVOID (*PFNKSDEFAULTALLOCATE)(PVOID Context);
   1295 typedef VOID (*PFNKSDEFAULTFREE)(PVOID Context, PVOID Buffer);
   1296 typedef NTSTATUS (*PFNKSINITIALIZEALLOCATOR)(PVOID InitialContext,
   1297 					PKSALLOCATOR_FRAMING AllocatorFraming,
   1298 					PVOID* Context);
   1299 typedef VOID (*PFNKSDELETEALLOCATOR) (PVOID Context);
   1300 #endif /* _NTDDK_ */
   1301 
   1302 typedef struct {
   1303   ULONG MinFrameSize;
   1304   ULONG MaxFrameSize;
   1305   ULONG Stepping;
   1306 } KS_FRAMING_RANGE,*PKS_FRAMING_RANGE;
   1307 
   1308 typedef struct {
   1309   KS_FRAMING_RANGE Range;
   1310   ULONG InPlaceWeight;
   1311   ULONG NotInPlaceWeight;
   1312 } KS_FRAMING_RANGE_WEIGHTED,*PKS_FRAMING_RANGE_WEIGHTED;
   1313 
   1314 typedef struct {
   1315   ULONG RatioNumerator;
   1316   ULONG RatioDenominator;
   1317   ULONG RatioConstantMargin;
   1318 } KS_COMPRESSION,*PKS_COMPRESSION;
   1319 
   1320 typedef struct {
   1321   GUID MemoryType;
   1322   GUID BusType;
   1323   ULONG MemoryFlags;
   1324   ULONG BusFlags;
   1325   ULONG Flags;
   1326   ULONG Frames;
   1327   ULONG FileAlignment;
   1328   ULONG MemoryTypeWeight;
   1329   KS_FRAMING_RANGE PhysicalRange;
   1330   KS_FRAMING_RANGE_WEIGHTED FramingRange;
   1331 } KS_FRAMING_ITEM,*PKS_FRAMING_ITEM;
   1332 
   1333 typedef struct {
   1334   ULONG CountItems;
   1335   ULONG PinFlags;
   1336   KS_COMPRESSION OutputCompression;
   1337   ULONG PinWeight;
   1338   KS_FRAMING_ITEM FramingItem[1];
   1339 } KSALLOCATOR_FRAMING_EX,*PKSALLOCATOR_FRAMING_EX;
   1340 
   1341 #define KSMEMORY_TYPE_WILDCARD		GUID_NULL
   1342 #define STATIC_KSMEMORY_TYPE_WILDCARD	STATIC_GUID_NULL
   1343 
   1344 #define KSMEMORY_TYPE_DONT_CARE		GUID_NULL
   1345 #define STATIC_KSMEMORY_TYPE_DONT_CARE	STATIC_GUID_NULL
   1346 
   1347 #define KS_TYPE_DONT_CARE		GUID_NULL
   1348 #define STATIC_KS_TYPE_DONT_CARE	STATIC_GUID_NULL
   1349 
   1350 #define STATIC_KSMEMORY_TYPE_SYSTEM					\
   1351 	0x091bb638,0x603f,0x11d1,0xb0,0x67,0x00,0xa0,0xc9,0x06,0x28,0x02
   1352 DEFINE_GUIDSTRUCT("091bb638-603f-11d1-b067-00a0c9062802",KSMEMORY_TYPE_SYSTEM);
   1353 #define KSMEMORY_TYPE_SYSTEM DEFINE_GUIDNAMED(KSMEMORY_TYPE_SYSTEM)
   1354 
   1355 #define STATIC_KSMEMORY_TYPE_USER					\
   1356 	0x8cb0fc28,0x7893,0x11d1,0xb0,0x69,0x00,0xa0,0xc9,0x06,0x28,0x02
   1357 DEFINE_GUIDSTRUCT("8cb0fc28-7893-11d1-b069-00a0c9062802",KSMEMORY_TYPE_USER);
   1358 #define KSMEMORY_TYPE_USER DEFINE_GUIDNAMED(KSMEMORY_TYPE_USER)
   1359 
   1360 #define STATIC_KSMEMORY_TYPE_KERNEL_PAGED				\
   1361 	0xd833f8f8,0x7894,0x11d1,0xb0,0x69,0x00,0xa0,0xc9,0x06,0x28,0x02
   1362 DEFINE_GUIDSTRUCT("d833f8f8-7894-11d1-b069-00a0c9062802",KSMEMORY_TYPE_KERNEL_PAGED);
   1363 #define KSMEMORY_TYPE_KERNEL_PAGED DEFINE_GUIDNAMED(KSMEMORY_TYPE_KERNEL_PAGED)
   1364 
   1365 #define STATIC_KSMEMORY_TYPE_KERNEL_NONPAGED				\
   1366 	0x4a6d5fc4,0x7895,0x11d1,0xb0,0x69,0x00,0xa0,0xc9,0x06,0x28,0x02
   1367 DEFINE_GUIDSTRUCT("4a6d5fc4-7895-11d1-b069-00a0c9062802",KSMEMORY_TYPE_KERNEL_NONPAGED);
   1368 #define KSMEMORY_TYPE_KERNEL_NONPAGED DEFINE_GUIDNAMED(KSMEMORY_TYPE_KERNEL_NONPAGED)
   1369 
   1370 #define STATIC_KSMEMORY_TYPE_DEVICE_UNKNOWN				\
   1371 	0x091bb639,0x603f,0x11d1,0xb0,0x67,0x00,0xa0,0xc9,0x06,0x28,0x02
   1372 DEFINE_GUIDSTRUCT("091bb639-603f-11d1-b067-00a0c9062802",KSMEMORY_TYPE_DEVICE_UNKNOWN);
   1373 #define KSMEMORY_TYPE_DEVICE_UNKNOWN DEFINE_GUIDNAMED(KSMEMORY_TYPE_DEVICE_UNKNOWN)
   1374 
   1375 #define DECLARE_SIMPLE_FRAMING_EX(FramingExName,MemoryType,Flags,Frames,Alignment,MinFrameSize,MaxFrameSize) \
   1376 const KSALLOCATOR_FRAMING_EX FramingExName =				\
   1377 {									\
   1378 	1,								\
   1379 	0,								\
   1380 	{								\
   1381 		1,							\
   1382 		1,							\
   1383 		0							\
   1384 	},								\
   1385 	0,								\
   1386 	{								\
   1387 		{							\
   1388 			MemoryType,					\
   1389 			STATIC_KS_TYPE_DONT_CARE,			\
   1390 			0,						\
   1391 			0,						\
   1392 			Flags,						\
   1393 			Frames,						\
   1394 			Alignment,					\
   1395 			0,						\
   1396 			{						\
   1397 				0,					\
   1398 				(ULONG)-1,				\
   1399 				1					\
   1400 			},						\
   1401 			{						\
   1402 				{					\
   1403 					MinFrameSize,			\
   1404 					MaxFrameSize,			\
   1405 					1				\
   1406 				},					\
   1407 				0,					\
   1408 				0					\
   1409 			}						\
   1410 		}							\
   1411 	}								\
   1412 }
   1413 
   1414 #define SetDefaultKsCompression(KsCompressionPointer)			\
   1415 {									\
   1416 	KsCompressionPointer->RatioNumerator = 1;			\
   1417 	KsCompressionPointer->RatioDenominator = 1;			\
   1418 	KsCompressionPointer->RatioConstantMargin = 0;			\
   1419 }
   1420 
   1421 #define SetDontCareKsFramingRange(KsFramingRangePointer)		\
   1422 {									\
   1423 	KsFramingRangePointer->MinFrameSize = 0;			\
   1424 	KsFramingRangePointer->MaxFrameSize = (ULONG) -1;		\
   1425 	KsFramingRangePointer->Stepping = 1;				\
   1426 }
   1427 
   1428 #define SetKsFramingRange(KsFramingRangePointer,P_MinFrameSize,P_MaxFrameSize) \
   1429 {									\
   1430 	KsFramingRangePointer->MinFrameSize = P_MinFrameSize;		\
   1431 	KsFramingRangePointer->MaxFrameSize = P_MaxFrameSize;		\
   1432 	KsFramingRangePointer->Stepping = 1;				\
   1433 }
   1434 
   1435 #define SetKsFramingRangeWeighted(KsFramingRangeWeightedPointer,P_MinFrameSize,P_MaxFrameSize) \
   1436 {									\
   1437 	KS_FRAMING_RANGE *KsFramingRange =				\
   1438 				&KsFramingRangeWeightedPointer->Range;	\
   1439 	SetKsFramingRange(KsFramingRange,P_MinFrameSize,P_MaxFrameSize);\
   1440 	KsFramingRangeWeightedPointer->InPlaceWeight = 0;		\
   1441 	KsFramingRangeWeightedPointer->NotInPlaceWeight = 0;		\
   1442 }
   1443 
   1444 #define INITIALIZE_SIMPLE_FRAMING_EX(FramingExPointer,P_MemoryType,P_Flags,P_Frames,P_Alignment,P_MinFrameSize,P_MaxFrameSize) \
   1445 {									\
   1446 	KS_COMPRESSION *KsCompression =					\
   1447 			&FramingExPointer->OutputCompression;		\
   1448 	KS_FRAMING_RANGE *KsFramingRange =				\
   1449 			&FramingExPointer->FramingItem[0].PhysicalRange;\
   1450 	KS_FRAMING_RANGE_WEIGHTED *KsFramingRangeWeighted =		\
   1451 			&FramingExPointer->FramingItem[0].FramingRange;	\
   1452 	FramingExPointer->CountItems = 1;				\
   1453 	FramingExPointer->PinFlags = 0;					\
   1454 	SetDefaultKsCompression(KsCompression);				\
   1455 	FramingExPointer->PinWeight = 0;				\
   1456 	FramingExPointer->FramingItem[0].MemoryType = P_MemoryType;	\
   1457 	FramingExPointer->FramingItem[0].BusType = KS_TYPE_DONT_CARE;	\
   1458 	FramingExPointer->FramingItem[0].MemoryFlags = 0;		\
   1459 	FramingExPointer->FramingItem[0].BusFlags = 0;			\
   1460 	FramingExPointer->FramingItem[0].Flags = P_Flags;		\
   1461 	FramingExPointer->FramingItem[0].Frames = P_Frames;		\
   1462 	FramingExPointer->FramingItem[0].FileAlignment = P_Alignment;	\
   1463 	FramingExPointer->FramingItem[0].MemoryTypeWeight = 0;		\
   1464 	SetDontCareKsFramingRange(KsFramingRange);			\
   1465 	SetKsFramingRangeWeighted(KsFramingRangeWeighted,		\
   1466 				  P_MinFrameSize,P_MaxFrameSize);	\
   1467 }
   1468 
   1469 #define STATIC_KSEVENTSETID_StreamAllocator				\
   1470 	0x75d95571,0x073c,0x11d0,0xa1,0x61,0x00,0x20,0xaf,0xd1,0x56,0xe4
   1471 DEFINE_GUIDSTRUCT("75d95571-073c-11d0-a161-0020afd156e4",KSEVENTSETID_StreamAllocator);
   1472 #define KSEVENTSETID_StreamAllocator DEFINE_GUIDNAMED(KSEVENTSETID_StreamAllocator)
   1473 
   1474 typedef enum {
   1475   KSEVENT_STREAMALLOCATOR_INTERNAL_FREEFRAME,
   1476   KSEVENT_STREAMALLOCATOR_FREEFRAME
   1477 } KSEVENT_STREAMALLOCATOR;
   1478 
   1479 #define STATIC_KSMETHODSETID_StreamAllocator				\
   1480 	0xcf6e4341,0xec87,0x11cf,0xa1,0x30,0x00,0x20,0xaf,0xd1,0x56,0xe4
   1481 DEFINE_GUIDSTRUCT("cf6e4341-ec87-11cf-a130-0020afd156e4",KSMETHODSETID_StreamAllocator);
   1482 #define KSMETHODSETID_StreamAllocator DEFINE_GUIDNAMED(KSMETHODSETID_StreamAllocator)
   1483 
   1484 typedef enum {
   1485   KSMETHOD_STREAMALLOCATOR_ALLOC,
   1486   KSMETHOD_STREAMALLOCATOR_FREE
   1487 } KSMETHOD_STREAMALLOCATOR;
   1488 
   1489 #define DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_ALLOC(Handler)		\
   1490 	DEFINE_KSMETHOD_ITEM(						\
   1491 				KSMETHOD_STREAMALLOCATOR_ALLOC,		\
   1492 				KSMETHOD_TYPE_WRITE,			\
   1493 				(Handler),				\
   1494 				sizeof(KSMETHOD),			\
   1495 				sizeof(PVOID),				\
   1496 				NULL)
   1497 
   1498 #define DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_FREE(Handler)		\
   1499 	DEFINE_KSMETHOD_ITEM(						\
   1500 				KSMETHOD_STREAMALLOCATOR_FREE,		\
   1501 				KSMETHOD_TYPE_READ,			\
   1502 				(Handler),				\
   1503 				sizeof(KSMETHOD),			\
   1504 				sizeof(PVOID),				\
   1505 				NULL)
   1506 
   1507 #define DEFINE_KSMETHOD_ALLOCATORSET(AllocatorSet,MethodAlloc,MethodFree)\
   1508 DEFINE_KSMETHOD_TABLE(AllocatorSet) {					\
   1509 	DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_ALLOC(MethodAlloc),	\
   1510 	DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_FREE(MethodFree)		\
   1511 }
   1512 
   1513 #define STATIC_KSPROPSETID_StreamAllocator				\
   1514 	0xcf6e4342,0xec87,0x11cf,0xa1,0x30,0x00,0x20,0xaf,0xd1,0x56,0xe4
   1515 DEFINE_GUIDSTRUCT("cf6e4342-ec87-11cf-a130-0020afd156e4",KSPROPSETID_StreamAllocator);
   1516 #define KSPROPSETID_StreamAllocator DEFINE_GUIDNAMED(KSPROPSETID_StreamAllocator)
   1517 
   1518 #if defined(_NTDDK_)
   1519 typedef enum {
   1520   KSPROPERTY_STREAMALLOCATOR_FUNCTIONTABLE,
   1521   KSPROPERTY_STREAMALLOCATOR_STATUS
   1522 } KSPROPERTY_STREAMALLOCATOR;
   1523 
   1524 #define DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_FUNCTIONTABLE(Handler)	\
   1525 	DEFINE_KSPROPERTY_ITEM(						\
   1526 				KSPROPERTY_STREAMALLOCATOR_FUNCTIONTABLE,\
   1527 				(Handler),				\
   1528 				sizeof(KSPROPERTY),			\
   1529 				sizeof(KSSTREAMALLOCATOR_FUNCTIONTABLE),\
   1530 				NULL, NULL, 0, NULL, NULL, 0)
   1531 
   1532 #define DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_STATUS(Handler)		\
   1533 	DEFINE_KSPROPERTY_ITEM(						\
   1534 				KSPROPERTY_STREAMALLOCATOR_STATUS,	\
   1535 				(Handler),				\
   1536 				sizeof(KSPROPERTY),			\
   1537 				sizeof(KSSTREAMALLOCATOR_STATUS),	\
   1538 				NULL, NULL, 0, NULL, NULL, 0)
   1539 
   1540 #define DEFINE_KSPROPERTY_ALLOCATORSET(AllocatorSet,PropFunctionTable,PropStatus)\
   1541 DEFINE_KSPROPERTY_TABLE(AllocatorSet) {					\
   1542 	DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_STATUS(PropStatus),	\
   1543 	DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_FUNCTIONTABLE(PropFunctionTable)\
   1544 }
   1545 
   1546 typedef NTSTATUS (*PFNALLOCATOR_ALLOCATEFRAME) (PFILE_OBJECT FileObject,
   1547 						PVOID *Frame);
   1548 typedef VOID (*PFNALLOCATOR_FREEFRAME) (PFILE_OBJECT FileObject, PVOID Frame);
   1549 
   1550 typedef struct {
   1551   PFNALLOCATOR_ALLOCATEFRAME AllocateFrame;
   1552   PFNALLOCATOR_FREEFRAME FreeFrame;
   1553 } KSSTREAMALLOCATOR_FUNCTIONTABLE, *PKSSTREAMALLOCATOR_FUNCTIONTABLE;
   1554 #endif /* _NTDDK_ */
   1555 
   1556 typedef struct {
   1557   KSALLOCATOR_FRAMING Framing;
   1558   ULONG AllocatedFrames;
   1559   ULONG Reserved;
   1560 } KSSTREAMALLOCATOR_STATUS,*PKSSTREAMALLOCATOR_STATUS;
   1561 
   1562 typedef struct {
   1563   KSALLOCATOR_FRAMING_EX Framing;
   1564   ULONG AllocatedFrames;
   1565   ULONG Reserved;
   1566 } KSSTREAMALLOCATOR_STATUS_EX,*PKSSTREAMALLOCATOR_STATUS_EX;
   1567 
   1568 #define KSSTREAM_HEADER_OPTIONSF_SPLICEPOINT		0x00000001
   1569 #define KSSTREAM_HEADER_OPTIONSF_PREROLL		0x00000002
   1570 #define KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY	0x00000004
   1571 #define KSSTREAM_HEADER_OPTIONSF_TYPECHANGED		0x00000008
   1572 #define KSSTREAM_HEADER_OPTIONSF_TIMEVALID		0x00000010
   1573 #define KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY	0x00000040
   1574 #define KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE		0x00000080
   1575 #define KSSTREAM_HEADER_OPTIONSF_DURATIONVALID		0x00000100
   1576 #define KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM		0x00000200
   1577 #define KSSTREAM_HEADER_OPTIONSF_BUFFEREDTRANSFER	0x00000400
   1578 #define KSSTREAM_HEADER_OPTIONSF_VRAM_DATA_TRANSFER	0x00000800
   1579 #define KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA		0x80000000
   1580 
   1581 typedef struct {
   1582   LONGLONG Time;
   1583   ULONG Numerator;
   1584   ULONG Denominator;
   1585 } KSTIME,*PKSTIME;
   1586 
   1587 typedef struct {
   1588   ULONG Size;
   1589   ULONG TypeSpecificFlags;
   1590   KSTIME PresentationTime;
   1591   LONGLONG Duration;
   1592   ULONG FrameExtent;
   1593   ULONG DataUsed;
   1594   PVOID Data;
   1595   ULONG OptionsFlags;
   1596 #ifdef _WIN64
   1597   ULONG Reserved;
   1598 #endif
   1599 } KSSTREAM_HEADER,*PKSSTREAM_HEADER;
   1600 
   1601 #define STATIC_KSPROPSETID_StreamInterface				\
   1602 	0x1fdd8ee1,0x9cd3,0x11d0,0x82,0xaa,0x00,0x00,0xf8,0x22,0xfe,0x8a
   1603 DEFINE_GUIDSTRUCT("1fdd8ee1-9cd3-11d0-82aa-0000f822fe8a",KSPROPSETID_StreamInterface);
   1604 #define KSPROPSETID_StreamInterface DEFINE_GUIDNAMED(KSPROPSETID_StreamInterface)
   1605 
   1606 typedef enum {
   1607   KSPROPERTY_STREAMINTERFACE_HEADERSIZE
   1608 } KSPROPERTY_STREAMINTERFACE;
   1609 
   1610 #define DEFINE_KSPROPERTY_ITEM_STREAMINTERFACE_HEADERSIZE(GetHandler)	\
   1611 	DEFINE_KSPROPERTY_ITEM(						\
   1612 				KSPROPERTY_STREAMINTERFACE_HEADERSIZE,	\
   1613 				(GetHandler),				\
   1614 				sizeof(KSPROPERTY),			\
   1615 				sizeof(ULONG),				\
   1616 				NULL,NULL,0,NULL,NULL,0)
   1617 
   1618 #define DEFINE_KSPROPERTY_STREAMINTERFACESET(StreamInterfaceSet,HeaderSizeHandler) \
   1619 DEFINE_KSPROPERTY_TABLE(StreamInterfaceSet) {				\
   1620 	DEFINE_KSPROPERTY_ITEM_STREAMINTERFACE_HEADERSIZE(HeaderSizeHandler)\
   1621 }
   1622 
   1623 #define STATIC_KSPROPSETID_Stream					\
   1624 	0x65aaba60,0x98ae,0x11cf,0xa1,0x0d,0x00,0x20,0xaf,0xd1,0x56,0xe4
   1625 DEFINE_GUIDSTRUCT("65aaba60-98ae-11cf-a10d-0020afd156e4",KSPROPSETID_Stream);
   1626 #define KSPROPSETID_Stream DEFINE_GUIDNAMED(KSPROPSETID_Stream)
   1627 
   1628 typedef enum {
   1629   KSPROPERTY_STREAM_ALLOCATOR,
   1630   KSPROPERTY_STREAM_QUALITY,
   1631   KSPROPERTY_STREAM_DEGRADATION,
   1632   KSPROPERTY_STREAM_MASTERCLOCK,
   1633   KSPROPERTY_STREAM_TIMEFORMAT,
   1634   KSPROPERTY_STREAM_PRESENTATIONTIME,
   1635   KSPROPERTY_STREAM_PRESENTATIONEXTENT,
   1636   KSPROPERTY_STREAM_FRAMETIME,
   1637   KSPROPERTY_STREAM_RATECAPABILITY,
   1638   KSPROPERTY_STREAM_RATE,
   1639   KSPROPERTY_STREAM_PIPE_ID
   1640 } KSPROPERTY_STREAM;
   1641 
   1642 #define DEFINE_KSPROPERTY_ITEM_STREAM_ALLOCATOR(GetHandler,SetHandler)	\
   1643 	DEFINE_KSPROPERTY_ITEM(						\
   1644 				KSPROPERTY_STREAM_ALLOCATOR,		\
   1645 				(GetHandler),				\
   1646 				sizeof(KSPROPERTY),			\
   1647 				sizeof(HANDLE),				\
   1648 				(SetHandler),				\
   1649 				NULL, 0, NULL, NULL, 0)
   1650 
   1651 #define DEFINE_KSPROPERTY_ITEM_STREAM_QUALITY(Handler)			\
   1652 	DEFINE_KSPROPERTY_ITEM(						\
   1653 				KSPROPERTY_STREAM_QUALITY,		\
   1654 				(Handler),				\
   1655 				sizeof(KSPROPERTY),			\
   1656 				sizeof(KSQUALITY_MANAGER),		\
   1657 				NULL, NULL, 0, NULL, NULL, 0)
   1658 
   1659 #define DEFINE_KSPROPERTY_ITEM_STREAM_DEGRADATION(GetHandler,SetHandler)\
   1660 	DEFINE_KSPROPERTY_ITEM(						\
   1661 				KSPROPERTY_STREAM_DEGRADATION,		\
   1662 				(GetHandler),				\
   1663 				sizeof(KSPROPERTY),			\
   1664 				0,					\
   1665 				(SetHandler),				\
   1666 				NULL, 0, NULL, NULL, 0)
   1667 
   1668 #define DEFINE_KSPROPERTY_ITEM_STREAM_MASTERCLOCK(GetHandler,SetHandler)\
   1669 	DEFINE_KSPROPERTY_ITEM(						\
   1670 				KSPROPERTY_STREAM_MASTERCLOCK,		\
   1671 				(GetHandler),				\
   1672 				sizeof(KSPROPERTY),			\
   1673 				sizeof(HANDLE),				\
   1674 				(SetHandler),				\
   1675 				NULL, 0, NULL, NULL, 0)
   1676 
   1677 #define DEFINE_KSPROPERTY_ITEM_STREAM_TIMEFORMAT(Handler)		\
   1678 	DEFINE_KSPROPERTY_ITEM(						\
   1679 				KSPROPERTY_STREAM_TIMEFORMAT,		\
   1680 				(Handler),				\
   1681 				sizeof(KSPROPERTY),			\
   1682 				sizeof(GUID),				\
   1683 				NULL, NULL, 0, NULL, NULL, 0)
   1684 
   1685 #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONTIME(GetHandler,SetHandler)\
   1686 	DEFINE_KSPROPERTY_ITEM(						\
   1687 				KSPROPERTY_STREAM_PRESENTATIONTIME,	\
   1688 				(GetHandler),				\
   1689 				sizeof(KSPROPERTY),			\
   1690 				sizeof(KSTIME),				\
   1691 				(SetHandler),				\
   1692 				NULL, 0, NULL, NULL, 0)
   1693 
   1694 #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONEXTENT(Handler)	\
   1695 	DEFINE_KSPROPERTY_ITEM(						\
   1696 				KSPROPERTY_STREAM_PRESENTATIONEXTENT,	\
   1697 				(Handler),				\
   1698 				sizeof(KSPROPERTY),			\
   1699 				sizeof(LONGLONG),			\
   1700 				NULL, NULL, 0, NULL, NULL, 0)
   1701 
   1702 #define DEFINE_KSPROPERTY_ITEM_STREAM_FRAMETIME(Handler)		\
   1703 	DEFINE_KSPROPERTY_ITEM(						\
   1704 				KSPROPERTY_STREAM_FRAMETIME,		\
   1705 				(Handler),				\
   1706 				sizeof(KSPROPERTY),			\
   1707 				sizeof(KSFRAMETIME),			\
   1708 				NULL, NULL, 0, NULL, NULL, 0)
   1709 
   1710 #define DEFINE_KSPROPERTY_ITEM_STREAM_RATECAPABILITY(Handler)		\
   1711 	DEFINE_KSPROPERTY_ITEM(						\
   1712 				KSPROPERTY_STREAM_RATECAPABILITY,	\
   1713 				(Handler),				\
   1714 				sizeof(KSRATE_CAPABILITY),		\
   1715 				sizeof(KSRATE),				\
   1716 				NULL, NULL, 0, NULL, NULL, 0)
   1717 
   1718 #define DEFINE_KSPROPERTY_ITEM_STREAM_RATE(GetHandler,SetHandler)	\
   1719 	DEFINE_KSPROPERTY_ITEM(						\
   1720 				KSPROPERTY_STREAM_RATE,			\
   1721 				(GetHandler),				\
   1722 				sizeof(KSPROPERTY),			\
   1723 				sizeof(KSRATE),				\
   1724 				(SetHandler),				\
   1725 				NULL, 0, NULL, NULL, 0)
   1726 
   1727 #define DEFINE_KSPROPERTY_ITEM_STREAM_PIPE_ID(GetHandler,SetHandler)	\
   1728 	DEFINE_KSPROPERTY_ITEM(						\
   1729 				KSPROPERTY_STREAM_PIPE_ID,		\
   1730 				(GetHandler),				\
   1731 				sizeof(KSPROPERTY),			\
   1732 				sizeof(HANDLE),				\
   1733 				(SetHandler),				\
   1734 				NULL, 0, NULL, NULL, 0)
   1735 
   1736 typedef struct {
   1737   HANDLE QualityManager;
   1738   PVOID Context;
   1739 } KSQUALITY_MANAGER,*PKSQUALITY_MANAGER;
   1740 
   1741 typedef struct {
   1742   LONGLONG Duration;
   1743   ULONG FrameFlags;
   1744   ULONG Reserved;
   1745 } KSFRAMETIME,*PKSFRAMETIME;
   1746 
   1747 #define KSFRAMETIME_VARIABLESIZE	0x00000001
   1748 
   1749 typedef struct {
   1750   LONGLONG PresentationStart;
   1751   LONGLONG Duration;
   1752   KSPIN_INTERFACE Interface;
   1753   LONG Rate;
   1754   ULONG Flags;
   1755 } KSRATE,*PKSRATE;
   1756 
   1757 #define KSRATE_NOPRESENTATIONSTART	0x00000001
   1758 #define KSRATE_NOPRESENTATIONDURATION	0x00000002
   1759 
   1760 typedef struct {
   1761   KSPROPERTY Property;
   1762   KSRATE Rate;
   1763 } KSRATE_CAPABILITY,*PKSRATE_CAPABILITY;
   1764 
   1765 #define STATIC_KSPROPSETID_Clock					\
   1766 	0xDF12A4C0,0xAC17,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1767 DEFINE_GUIDSTRUCT("DF12A4C0-AC17-11CF-A5D6-28DB04C10000",KSPROPSETID_Clock);
   1768 #define KSPROPSETID_Clock DEFINE_GUIDNAMED(KSPROPSETID_Clock)
   1769 
   1770 #define NANOSECONDS 10000000
   1771 #define KSCONVERT_PERFORMANCE_TIME(Frequency,PerformanceTime)		\
   1772 	((((ULONGLONG)(ULONG)(PerformanceTime).HighPart *NANOSECONDS / (Frequency)) << 32) +	\
   1773 	 ((((((ULONGLONG)(ULONG)(PerformanceTime).HighPart *NANOSECONDS) % (Frequency)) << 32) +\
   1774 	 ((ULONGLONG)(PerformanceTime).LowPart *NANOSECONDS)) / (Frequency)))
   1775 
   1776 typedef struct {
   1777   ULONG CreateFlags;
   1778 } KSCLOCK_CREATE,*PKSCLOCK_CREATE;
   1779 
   1780 typedef struct {
   1781   LONGLONG Time;
   1782   LONGLONG SystemTime;
   1783 } KSCORRELATED_TIME,*PKSCORRELATED_TIME;
   1784 
   1785 typedef struct {
   1786   LONGLONG Granularity;
   1787   LONGLONG Error;
   1788 } KSRESOLUTION,*PKSRESOLUTION;
   1789 
   1790 typedef enum {
   1791   KSPROPERTY_CLOCK_TIME,
   1792   KSPROPERTY_CLOCK_PHYSICALTIME,
   1793   KSPROPERTY_CLOCK_CORRELATEDTIME,
   1794   KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME,
   1795   KSPROPERTY_CLOCK_RESOLUTION,
   1796   KSPROPERTY_CLOCK_STATE,
   1797 #if defined(_NTDDK_)
   1798   KSPROPERTY_CLOCK_FUNCTIONTABLE
   1799 #endif /* _NTDDK_ */
   1800 } KSPROPERTY_CLOCK;
   1801 
   1802 #if defined(_NTDDK_)
   1803 typedef LONGLONG (FASTCALL *PFNKSCLOCK_GETTIME)(PFILE_OBJECT FileObject);
   1804 typedef LONGLONG (FASTCALL *PFNKSCLOCK_CORRELATEDTIME)(PFILE_OBJECT FileObject,
   1805 							PLONGLONG SystemTime);
   1806 
   1807 typedef struct {
   1808    PFNKSCLOCK_GETTIME GetTime;
   1809    PFNKSCLOCK_GETTIME GetPhysicalTime;
   1810    PFNKSCLOCK_CORRELATEDTIME GetCorrelatedTime;
   1811    PFNKSCLOCK_CORRELATEDTIME GetCorrelatedPhysicalTime;
   1812 } KSCLOCK_FUNCTIONTABLE, *PKSCLOCK_FUNCTIONTABLE;
   1813 
   1814 typedef BOOLEAN (*PFNKSSETTIMER)(PVOID Context, PKTIMER Timer,
   1815 				 LARGE_INTEGER DueTime, PKDPC Dpc);
   1816 typedef BOOLEAN (*PFNKSCANCELTIMER) (PVOID Context, PKTIMER Timer);
   1817 typedef LONGLONG (FASTCALL *PFNKSCORRELATEDTIME)(PVOID Context,
   1818 						 PLONGLONG SystemTime);
   1819 
   1820 typedef PVOID			PKSDEFAULTCLOCK;
   1821 
   1822 #define DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(Handler)			\
   1823 	DEFINE_KSPROPERTY_ITEM(						\
   1824 				KSPROPERTY_CLOCK_TIME,			\
   1825 				(Handler),				\
   1826 				sizeof(KSPROPERTY), sizeof(LONGLONG),	\
   1827 				NULL, NULL, 0, NULL, NULL, 0)
   1828 
   1829 #define DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(Handler)		\
   1830 	DEFINE_KSPROPERTY_ITEM(						\
   1831 				KSPROPERTY_CLOCK_PHYSICALTIME,		\
   1832 				(Handler),				\
   1833 				sizeof(KSPROPERTY), sizeof(LONGLONG),	\
   1834 				NULL, NULL, 0, NULL, NULL, 0)
   1835 
   1836 #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(Handler)		\
   1837 	DEFINE_KSPROPERTY_ITEM(						\
   1838 				KSPROPERTY_CLOCK_CORRELATEDTIME,	\
   1839 				(Handler),				\
   1840 				sizeof(KSPROPERTY),			\
   1841 				sizeof(KSCORRELATED_TIME),		\
   1842 				NULL, NULL, 0, NULL, NULL, 0)
   1843 
   1844 #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(Handler)	\
   1845 	DEFINE_KSPROPERTY_ITEM(						\
   1846 				KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME,\
   1847 				(Handler),				\
   1848 				sizeof(KSPROPERTY),			\
   1849 				sizeof(KSCORRELATED_TIME),		\
   1850 				NULL, NULL, 0, NULL, NULL, 0)
   1851 
   1852 #define DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(Handler)		\
   1853 	DEFINE_KSPROPERTY_ITEM(						\
   1854 				KSPROPERTY_CLOCK_RESOLUTION,		\
   1855 				(Handler),				\
   1856 				sizeof(KSPROPERTY),sizeof(KSRESOLUTION),\
   1857 				NULL, NULL, 0, NULL, NULL, 0)
   1858 
   1859 #define DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(Handler)			\
   1860 	DEFINE_KSPROPERTY_ITEM(						\
   1861 				KSPROPERTY_CLOCK_STATE,			\
   1862 				(Handler),				\
   1863 				sizeof(KSPROPERTY), sizeof(KSSTATE),	\
   1864 				NULL, NULL, 0, NULL, NULL, 0)
   1865 
   1866 #define DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(Handler)		\
   1867 	DEFINE_KSPROPERTY_ITEM(						\
   1868 				KSPROPERTY_CLOCK_FUNCTIONTABLE,		\
   1869 				(Handler),				\
   1870 				sizeof(KSPROPERTY),			\
   1871 				sizeof(KSCLOCK_FUNCTIONTABLE),		\
   1872 				NULL, NULL, 0, NULL, NULL, 0)
   1873 
   1874 #define DEFINE_KSPROPERTY_CLOCKSET(ClockSet,PropTime,PropPhysicalTime,PropCorrelatedTime,PropCorrelatedPhysicalTime,PropResolution,PropState,PropFunctionTable)\
   1875 DEFINE_KSPROPERTY_TABLE(ClockSet) {					\
   1876 	DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(PropTime),			\
   1877 	DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(PropPhysicalTime),	\
   1878 	DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(PropCorrelatedTime),\
   1879 	DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(PropCorrelatedPhysicalTime),\
   1880 	DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(PropResolution),	\
   1881 	DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(PropState),			\
   1882 	DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(PropFunctionTable),	\
   1883 }
   1884 #endif /* _NTDDK_ */
   1885 
   1886 #define STATIC_KSEVENTSETID_Clock					\
   1887 	0x364D8E20,0x62C7,0x11CF,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1888 DEFINE_GUIDSTRUCT("364D8E20-62C7-11CF-A5D6-28DB04C10000",KSEVENTSETID_Clock);
   1889 #define KSEVENTSETID_Clock DEFINE_GUIDNAMED(KSEVENTSETID_Clock)
   1890 
   1891 typedef enum {
   1892   KSEVENT_CLOCK_INTERVAL_MARK,
   1893   KSEVENT_CLOCK_POSITION_MARK
   1894 } KSEVENT_CLOCK_POSITION;
   1895 
   1896 #define STATIC_KSEVENTSETID_Connection					\
   1897 	0x7f4bcbe0,0x9ea5,0x11cf,0xa5,0xd6,0x28,0xdb,0x04,0xc1,0x00,0x00
   1898 DEFINE_GUIDSTRUCT("7f4bcbe0-9ea5-11cf-a5d6-28db04c10000",KSEVENTSETID_Connection);
   1899 #define KSEVENTSETID_Connection DEFINE_GUIDNAMED(KSEVENTSETID_Connection)
   1900 
   1901 typedef enum {
   1902   KSEVENT_CONNECTION_POSITIONUPDATE,
   1903   KSEVENT_CONNECTION_DATADISCONTINUITY,
   1904   KSEVENT_CONNECTION_TIMEDISCONTINUITY,
   1905   KSEVENT_CONNECTION_PRIORITY,
   1906   KSEVENT_CONNECTION_ENDOFSTREAM
   1907 } KSEVENT_CONNECTION;
   1908 
   1909 typedef struct {
   1910   PVOID Context;
   1911   ULONG Proportion;
   1912   LONGLONG DeltaTime;
   1913 } KSQUALITY,*PKSQUALITY;
   1914 
   1915 typedef struct {
   1916   PVOID Context;
   1917   ULONG Status;
   1918 } KSERROR,*PKSERROR;
   1919 
   1920 typedef KSIDENTIFIER KSDEGRADE,*PKSDEGRADE;
   1921 
   1922 #define STATIC_KSDEGRADESETID_Standard					\
   1923 	0x9F564180,0x704C,0x11D0,0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00
   1924 DEFINE_GUIDSTRUCT("9F564180-704C-11D0-A5D6-28DB04C10000",KSDEGRADESETID_Standard);
   1925 #define KSDEGRADESETID_Standard DEFINE_GUIDNAMED(KSDEGRADESETID_Standard)
   1926 
   1927 typedef enum {
   1928   KSDEGRADE_STANDARD_SAMPLE,
   1929   KSDEGRADE_STANDARD_QUALITY,
   1930   KSDEGRADE_STANDARD_COMPUTATION,
   1931   KSDEGRADE_STANDARD_SKIP
   1932 } KSDEGRADE_STANDARD;
   1933 
   1934 #if defined(_NTDDK_)
   1935 
   1936 #define KSPROBE_STREAMREAD		0x00000000
   1937 #define KSPROBE_STREAMWRITE		0x00000001
   1938 #define KSPROBE_ALLOCATEMDL		0x00000010
   1939 #define KSPROBE_PROBEANDLOCK		0x00000020
   1940 #define KSPROBE_SYSTEMADDRESS		0x00000040
   1941 #define KSPROBE_MODIFY			0x00000200
   1942 #define KSPROBE_STREAMWRITEMODIFY	(KSPROBE_MODIFY | KSPROBE_STREAMWRITE)
   1943 #define KSPROBE_ALLOWFORMATCHANGE	0x00000080
   1944 #define KSSTREAM_READ			KSPROBE_STREAMREAD
   1945 #define KSSTREAM_WRITE			KSPROBE_STREAMWRITE
   1946 #define KSSTREAM_PAGED_DATA		0x00000000
   1947 #define KSSTREAM_NONPAGED_DATA		0x00000100
   1948 #define KSSTREAM_SYNCHRONOUS		0x00001000
   1949 #define KSSTREAM_FAILUREEXCEPTION	0x00002000
   1950 
   1951 typedef NTSTATUS (*PFNKSCONTEXT_DISPATCH)(PVOID Context, PIRP Irp);
   1952 typedef NTSTATUS (*PFNKSHANDLER)(PIRP Irp, PKSIDENTIFIER Request, PVOID Data);
   1953 typedef BOOLEAN (*PFNKSFASTHANDLER)(PFILE_OBJECT FileObject,
   1954 				    PKSIDENTIFIER Request,
   1955 				    ULONG RequestLength, PVOID Data,
   1956 				    ULONG DataLength,
   1957 				    PIO_STATUS_BLOCK IoStatus);
   1958 typedef NTSTATUS (*PFNKSALLOCATOR) (PIRP Irp, ULONG BufferSize,
   1959 				    BOOLEAN InputOperation);
   1960 
   1961 typedef struct {
   1962   KSPROPERTY_MEMBERSHEADER MembersHeader;
   1963   const VOID *Members;
   1964 } KSPROPERTY_MEMBERSLIST, *PKSPROPERTY_MEMBERSLIST;
   1965 
   1966 typedef struct {
   1967   KSIDENTIFIER PropTypeSet;
   1968   ULONG MembersListCount;
   1969   const KSPROPERTY_MEMBERSLIST *MembersList;
   1970 } KSPROPERTY_VALUES, *PKSPROPERTY_VALUES;
   1971 
   1972 #define DEFINE_KSPROPERTY_TABLE(tablename)				\
   1973 	const KSPROPERTY_ITEM tablename[] =
   1974 
   1975 #define DEFINE_KSPROPERTY_ITEM(PropertyId,GetHandler,MinProperty,MinData,SetHandler,Values,RelationsCount,Relations,SupportHandler,SerializedSize)\
   1976 {									\
   1977 			PropertyId, (PFNKSHANDLER)GetHandler,		\
   1978 			MinProperty, MinData,				\
   1979 			(PFNKSHANDLER)SetHandler,			\
   1980 			(PKSPROPERTY_VALUES)Values, RelationsCount,	\
   1981 			(PKSPROPERTY)Relations,				\
   1982 			(PFNKSHANDLER)SupportHandler,			\
   1983 			(ULONG)SerializedSize				\
   1984 }
   1985 
   1986 typedef struct {
   1987   ULONG PropertyId;
   1988   __C89_NAMELESS union {
   1989     PFNKSHANDLER GetPropertyHandler;
   1990     BOOLEAN GetSupported;
   1991   };
   1992   ULONG MinProperty;
   1993   ULONG MinData;
   1994   __C89_NAMELESS union {
   1995     PFNKSHANDLER SetPropertyHandler;
   1996     BOOLEAN SetSupported;
   1997   };
   1998   const KSPROPERTY_VALUES *Values;
   1999   ULONG RelationsCount;
   2000   const KSPROPERTY *Relations;
   2001   PFNKSHANDLER SupportHandler;
   2002   ULONG SerializedSize;
   2003 } KSPROPERTY_ITEM, *PKSPROPERTY_ITEM;
   2004 
   2005 #define DEFINE_KSFASTPROPERTY_ITEM(PropertyId, GetHandler, SetHandler)	\
   2006 {									\
   2007 			PropertyId, (PFNKSFASTHANDLER)GetHandler,	\
   2008 			(PFNKSFASTHANDLER)SetHandler, 0			\
   2009 }
   2010 
   2011 typedef struct {
   2012   ULONG PropertyId;
   2013   __C89_NAMELESS union {
   2014     PFNKSFASTHANDLER GetPropertyHandler;
   2015     BOOLEAN GetSupported;
   2016   };
   2017   __C89_NAMELESS union {
   2018     PFNKSFASTHANDLER SetPropertyHandler;
   2019     BOOLEAN SetSupported;
   2020   };
   2021   ULONG Reserved;
   2022 } KSFASTPROPERTY_ITEM, *PKSFASTPROPERTY_ITEM;
   2023 
   2024 #define DEFINE_KSPROPERTY_SET(Set,PropertiesCount,PropertyItem,FastIoCount,FastIoTable)\
   2025 {									\
   2026 			Set,						\
   2027 			PropertiesCount, PropertyItem,			\
   2028 			FastIoCount, FastIoTable			\
   2029 }
   2030 
   2031 #define DEFINE_KSPROPERTY_SET_TABLE(tablename)				\
   2032 	const KSPROPERTY_SET tablename[] =
   2033 
   2034 typedef struct {
   2035   const GUID *Set;
   2036   ULONG PropertiesCount;
   2037   const KSPROPERTY_ITEM *PropertyItem;
   2038   ULONG FastIoCount;
   2039   const KSFASTPROPERTY_ITEM *FastIoTable;
   2040 } KSPROPERTY_SET, *PKSPROPERTY_SET;
   2041 
   2042 #define DEFINE_KSMETHOD_TABLE(tablename)				\
   2043 	const KSMETHOD_ITEM tablename[] =
   2044 
   2045 #define DEFINE_KSMETHOD_ITEM(MethodId,Flags,MethodHandler,MinMethod,MinData,SupportHandler)\
   2046 {									\
   2047 			MethodId, (PFNKSHANDLER)MethodHandler,		\
   2048 			MinMethod, MinData,				\
   2049 			SupportHandler, Flags				\
   2050 }
   2051 
   2052 typedef struct {
   2053   ULONG MethodId;
   2054   __C89_NAMELESS union {
   2055     PFNKSHANDLER MethodHandler;
   2056     BOOLEAN MethodSupported;
   2057   };
   2058   ULONG MinMethod;
   2059   ULONG MinData;
   2060   PFNKSHANDLER SupportHandler;
   2061   ULONG Flags;
   2062 } KSMETHOD_ITEM, *PKSMETHOD_ITEM;
   2063 
   2064 #define DEFINE_KSFASTMETHOD_ITEM(MethodId,MethodHandler)		\
   2065 {									\
   2066 			MethodId, (PFNKSFASTHANDLER)MethodHandler	\
   2067 }
   2068 
   2069 typedef struct {
   2070   ULONG MethodId;
   2071   __C89_NAMELESS union {
   2072     PFNKSFASTHANDLER MethodHandler;
   2073     BOOLEAN MethodSupported;
   2074   };
   2075 } KSFASTMETHOD_ITEM, *PKSFASTMETHOD_ITEM;
   2076 
   2077 #define DEFINE_KSMETHOD_SET(Set,MethodsCount,MethodItem,FastIoCount,FastIoTable)\
   2078 {									\
   2079 			Set,						\
   2080 			MethodsCount, MethodItem,			\
   2081 			FastIoCount, FastIoTable			\
   2082 }
   2083 
   2084 #define DEFINE_KSMETHOD_SET_TABLE(tablename)				\
   2085 	const KSMETHOD_SET tablename[] =
   2086 
   2087 typedef struct {
   2088   const GUID *Set;
   2089   ULONG MethodsCount;
   2090   const KSMETHOD_ITEM *MethodItem;
   2091   ULONG FastIoCount;
   2092   const KSFASTMETHOD_ITEM *FastIoTable;
   2093 } KSMETHOD_SET, *PKSMETHOD_SET;
   2094 
   2095 typedef struct _KSEVENT_ENTRY	KSEVENT_ENTRY, *PKSEVENT_ENTRY;
   2096 typedef NTSTATUS (*PFNKSADDEVENT)(PIRP Irp, PKSEVENTDATA EventData,
   2097 				  struct _KSEVENT_ENTRY* EventEntry);
   2098 typedef VOID (*PFNKSREMOVEEVENT)(PFILE_OBJECT FileObject,
   2099 				 struct _KSEVENT_ENTRY* EventEntry);
   2100 
   2101 #define DEFINE_KSEVENT_TABLE(tablename)					\
   2102 	const KSEVENT_ITEM tablename[] =
   2103 
   2104 #define DEFINE_KSEVENT_ITEM(EventId,DataInput,ExtraEntryData,AddHandler,RemoveHandler,SupportHandler)\
   2105 {									\
   2106 			EventId, DataInput, ExtraEntryData,		\
   2107 			AddHandler, RemoveHandler, SupportHandler	\
   2108 }
   2109 
   2110 typedef struct {
   2111   ULONG EventId;
   2112   ULONG DataInput;
   2113   ULONG ExtraEntryData;
   2114   PFNKSADDEVENT AddHandler;
   2115   PFNKSREMOVEEVENT RemoveHandler;
   2116   PFNKSHANDLER SupportHandler;
   2117 } KSEVENT_ITEM, *PKSEVENT_ITEM;
   2118 
   2119 #define DEFINE_KSEVENT_SET(Set,EventsCount,EventItem)			\
   2120 {									\
   2121 			Set, EventsCount, EventItem			\
   2122 }
   2123 
   2124 #define DEFINE_KSEVENT_SET_TABLE(tablename)				\
   2125 	const KSEVENT_SET tablename[] =
   2126 
   2127 typedef struct {
   2128   const GUID *Set;
   2129   ULONG EventsCount;
   2130   const KSEVENT_ITEM *EventItem;
   2131 } KSEVENT_SET, *PKSEVENT_SET;
   2132 
   2133 typedef struct {
   2134   KDPC Dpc;
   2135   ULONG ReferenceCount;
   2136   KSPIN_LOCK AccessLock;
   2137 } KSDPC_ITEM, *PKSDPC_ITEM;
   2138 
   2139 typedef struct {
   2140   KSDPC_ITEM DpcItem;
   2141   LIST_ENTRY BufferList;
   2142 } KSBUFFER_ITEM, *PKSBUFFER_ITEM;
   2143 
   2144 
   2145 #define KSEVENT_ENTRY_DELETED		1
   2146 #define KSEVENT_ENTRY_ONESHOT		2
   2147 #define KSEVENT_ENTRY_BUFFERED		4
   2148 
   2149 struct _KSEVENT_ENTRY {
   2150   LIST_ENTRY ListEntry;
   2151   PVOID Object;
   2152   __C89_NAMELESS union {
   2153     PKSDPC_ITEM DpcItem;
   2154     PKSBUFFER_ITEM BufferItem;
   2155   };
   2156   PKSEVENTDATA EventData;
   2157   ULONG NotificationType;
   2158   const KSEVENT_SET *EventSet;
   2159   const KSEVENT_ITEM *EventItem;
   2160   PFILE_OBJECT FileObject;
   2161   ULONG SemaphoreAdjustment;
   2162   ULONG Reserved;
   2163   ULONG Flags;
   2164 };
   2165 
   2166 typedef enum {
   2167   KSEVENTS_NONE,
   2168   KSEVENTS_SPINLOCK,
   2169   KSEVENTS_MUTEX,
   2170   KSEVENTS_FMUTEX,
   2171   KSEVENTS_FMUTEXUNSAFE,
   2172   KSEVENTS_INTERRUPT,
   2173   KSEVENTS_ERESOURCE
   2174 } KSEVENTS_LOCKTYPE;
   2175 
   2176 #define KSDISPATCH_FASTIO			0x80000000
   2177 
   2178 typedef struct {
   2179   PDRIVER_DISPATCH Create;
   2180   PVOID Context;
   2181   UNICODE_STRING ObjectClass;
   2182   PSECURITY_DESCRIPTOR SecurityDescriptor;
   2183   ULONG Flags;
   2184 } KSOBJECT_CREATE_ITEM, *PKSOBJECT_CREATE_ITEM;
   2185 
   2186 typedef VOID (*PFNKSITEMFREECALLBACK)(PKSOBJECT_CREATE_ITEM CreateItem);
   2187 
   2188 #define KSCREATE_ITEM_SECURITYCHANGED		0x00000001
   2189 #define KSCREATE_ITEM_WILDCARD			0x00000002
   2190 #define KSCREATE_ITEM_NOPARAMETERS		0x00000004
   2191 #define KSCREATE_ITEM_FREEONSTOP		0x00000008
   2192 
   2193 #define DEFINE_KSCREATE_DISPATCH_TABLE( tablename )			\
   2194 	KSOBJECT_CREATE_ITEM tablename[] =
   2195 
   2196 #define DEFINE_KSCREATE_ITEM(DispatchCreate,TypeName,Context)		\
   2197 {									\
   2198 			(DispatchCreate), (PVOID)(Context),		\
   2199 			{						\
   2200 				sizeof(TypeName) - sizeof(UNICODE_NULL),\
   2201 				sizeof(TypeName),			\
   2202 				(PWCHAR)(TypeName)			\
   2203 			},						\
   2204 			NULL, 0						\
   2205 }
   2206 
   2207 #define DEFINE_KSCREATE_ITEMEX(DispatchCreate,TypeName,Context,Flags)	\
   2208 {									\
   2209 			(DispatchCreate),				\
   2210 			(PVOID)(Context),				\
   2211 			{						\
   2212 				sizeof(TypeName) - sizeof(UNICODE_NULL),\
   2213 				sizeof(TypeName),			\
   2214 				(PWCHAR)(TypeName)			\
   2215 			},						\
   2216 			NULL, (Flags)					\
   2217 }
   2218 
   2219 #define DEFINE_KSCREATE_ITEMNULL(DispatchCreate,Context)		\
   2220 {									\
   2221 			DispatchCreate, Context,			\
   2222 			{						\
   2223 				0, 0, NULL,				\
   2224 			},						\
   2225 			NULL, 0						\
   2226 }
   2227 
   2228 typedef struct {
   2229   ULONG CreateItemsCount;
   2230   PKSOBJECT_CREATE_ITEM CreateItemsList;
   2231 } KSOBJECT_CREATE, *PKSOBJECT_CREATE;
   2232 
   2233 typedef struct {
   2234   PDRIVER_DISPATCH DeviceIoControl;
   2235   PDRIVER_DISPATCH Read;
   2236   PDRIVER_DISPATCH Write;
   2237   PDRIVER_DISPATCH Flush;
   2238   PDRIVER_DISPATCH Close;
   2239   PDRIVER_DISPATCH QuerySecurity;
   2240   PDRIVER_DISPATCH SetSecurity;
   2241   PFAST_IO_DEVICE_CONTROL FastDeviceIoControl;
   2242   PFAST_IO_READ FastRead;
   2243   PFAST_IO_WRITE FastWrite;
   2244 } KSDISPATCH_TABLE, *PKSDISPATCH_TABLE;
   2245 
   2246 #define DEFINE_KSDISPATCH_TABLE(tablename,DeviceIoControl,Read,Write,Flush,Close,QuerySecurity,SetSecurity,FastDeviceIoControl,FastRead,FastWrite)\
   2247 	const KSDISPATCH_TABLE tablename =				\
   2248 	{								\
   2249 		DeviceIoControl,					\
   2250 		Read,							\
   2251 		Write,							\
   2252 		Flush,							\
   2253 		Close,							\
   2254 		QuerySecurity,						\
   2255 		SetSecurity,						\
   2256 		FastDeviceIoControl,					\
   2257 		FastRead,						\
   2258 		FastWrite,						\
   2259 	}
   2260 
   2261 #define KSCREATE_ITEM_IRP_STORAGE(Irp)					\
   2262 	(*(PKSOBJECT_CREATE_ITEM *)&(Irp)->Tail.Overlay.DriverContext[0])
   2263 #define KSEVENT_SET_IRP_STORAGE(Irp)					\
   2264 	(*(const KSEVENT_SET **)&(Irp)->Tail.Overlay.DriverContext[0])
   2265 #define KSEVENT_ITEM_IRP_STORAGE(Irp)					\
   2266 	(*(const KSEVENT_ITEM **)&(Irp)->Tail.Overlay.DriverContext[3])
   2267 #define KSEVENT_ENTRY_IRP_STORAGE(Irp)					\
   2268 	(*(PKSEVENT_ENTRY *)&(Irp)->Tail.Overlay.DriverContext[0])
   2269 #define KSMETHOD_SET_IRP_STORAGE(Irp)					\
   2270 	(*(const KSMETHOD_SET **)&(Irp)->Tail.Overlay.DriverContext[0])
   2271 #define KSMETHOD_ITEM_IRP_STORAGE(Irp)					\
   2272 	(*(const KSMETHOD_ITEM **)&(Irp)->Tail.Overlay.DriverContext[3])
   2273 #define KSMETHOD_TYPE_IRP_STORAGE(Irp)					\
   2274 	(*(ULONG_PTR *)(&(Irp)->Tail.Overlay.DriverContext[2]))
   2275 #define KSQUEUE_SPINLOCK_IRP_STORAGE(Irp)				\
   2276 	(*(PKSPIN_LOCK *)&(Irp)->Tail.Overlay.DriverContext[1])
   2277 #define KSPROPERTY_SET_IRP_STORAGE(Irp)					\
   2278 	(*(const KSPROPERTY_SET **)&(Irp)->Tail.Overlay.DriverContext[0])
   2279 #define KSPROPERTY_ITEM_IRP_STORAGE(Irp)				\
   2280 	(*(const KSPROPERTY_ITEM **)&(Irp)->Tail.Overlay.DriverContext[3])
   2281 #define KSPROPERTY_ATTRIBUTES_IRP_STORAGE(Irp)				\
   2282 	(*(PKSATTRIBUTE_LIST *)&(Irp)->Tail.Overlay.DriverContext[2])
   2283 
   2284 typedef PVOID		KSDEVICE_HEADER, KSOBJECT_HEADER;
   2285 
   2286 typedef enum {
   2287   KsInvokeOnSuccess = 1,
   2288   KsInvokeOnError = 2,
   2289   KsInvokeOnCancel = 4
   2290 } KSCOMPLETION_INVOCATION;
   2291 
   2292 typedef enum {
   2293   KsListEntryTail,
   2294   KsListEntryHead
   2295 } KSLIST_ENTRY_LOCATION;
   2296 
   2297 typedef enum {
   2298   KsAcquireOnly,
   2299   KsAcquireAndRemove,
   2300   KsAcquireOnlySingleItem,
   2301   KsAcquireAndRemoveOnlySingleItem
   2302 } KSIRP_REMOVAL_OPERATION;
   2303 
   2304 typedef enum {
   2305   KsStackCopyToNewLocation,
   2306   KsStackReuseCurrentLocation,
   2307   KsStackUseNewLocation
   2308 } KSSTACK_USE;
   2309 
   2310 typedef enum {
   2311   KSTARGET_STATE_DISABLED,
   2312   KSTARGET_STATE_ENABLED
   2313 } KSTARGET_STATE;
   2314 
   2315 typedef NTSTATUS (*PFNKSIRPLISTCALLBACK)(PIRP Irp, PVOID Context);
   2316 typedef VOID (*PFNREFERENCEDEVICEOBJECT)(PVOID Context);
   2317 typedef VOID (*PFNDEREFERENCEDEVICEOBJECT)(PVOID Context);
   2318 typedef NTSTATUS (*PFNQUERYREFERENCESTRING)(PVOID Context, PWCHAR *String);
   2319 
   2320 #define BUS_INTERFACE_REFERENCE_VERSION			0x100
   2321 
   2322 typedef struct {
   2323   INTERFACE Interface;
   2324 
   2325   PFNREFERENCEDEVICEOBJECT ReferenceDeviceObject;
   2326   PFNDEREFERENCEDEVICEOBJECT DereferenceDeviceObject;
   2327   PFNQUERYREFERENCESTRING QueryReferenceString;
   2328 } BUS_INTERFACE_REFERENCE, *PBUS_INTERFACE_REFERENCE;
   2329 
   2330 #define STATIC_REFERENCE_BUS_INTERFACE		STATIC_KSMEDIUMSETID_Standard
   2331 #define REFERENCE_BUS_INTERFACE			KSMEDIUMSETID_Standard
   2332 
   2333 typedef NTSTATUS (*PFNQUERYMEDIUMSLIST) (PVOID Context, ULONG *MediumsCount,
   2334 					 PKSPIN_MEDIUM *MediumList);
   2335 
   2336 typedef struct
   2337 {
   2338   INTERFACE Interface;
   2339   PFNQUERYMEDIUMSLIST QueryMediumsList;
   2340 } BUS_INTERFACE_MEDIUMS,*PBUS_INTERFACE_MEDIUMS;
   2341 
   2342 #define STATIC_GUID_BUS_INTERFACE_MEDIUMS				\
   2343 	0x4EC35C3E,0x201B,0x11D2,0x87,0x45,0x00,0xA0,0xC9,0x22,0x31,0x96
   2344 DEFINE_GUIDSTRUCT("4EC35C3E-201B-11D2-8745-00A0C9223196", GUID_BUS_INTERFACE_MEDIUMS);
   2345 #define GUID_BUS_INTERFACE_MEDIUMS DEFINE_GUIDNAMED(GUID_BUS_INTERFACE_MEDIUMS)
   2346 
   2347 #endif /* _NTDDK_ */
   2348 
   2349 #ifndef PACK_PRAGMAS_NOT_SUPPORTED
   2350 #include <pshpack1.h>
   2351 #endif
   2352 
   2353 typedef struct {
   2354   GUID PropertySet;
   2355   ULONG Count;
   2356 } KSPROPERTY_SERIALHDR,*PKSPROPERTY_SERIALHDR;
   2357 
   2358 #ifndef PACK_PRAGMAS_NOT_SUPPORTED
   2359 #include <poppack.h>
   2360 #endif
   2361 
   2362 typedef struct {
   2363   KSIDENTIFIER PropTypeSet;
   2364   ULONG Id;
   2365   ULONG PropertyLength;
   2366 } KSPROPERTY_SERIAL,*PKSPROPERTY_SERIAL;
   2367 
   2368 
   2369 #if defined(_NTDDK_)
   2370 
   2371 #define IOCTL_KS_HANDSHAKE						\
   2372 	CTL_CODE(FILE_DEVICE_KS, 0x007, METHOD_NEITHER, FILE_ANY_ACCESS)
   2373 
   2374 typedef struct {
   2375   GUID ProtocolId;
   2376   PVOID Argument1;
   2377   PVOID Argument2;
   2378 } KSHANDSHAKE, *PKSHANDSHAKE;
   2379 
   2380 typedef struct _KSGATE		KSGATE, *PKSGATE;
   2381 
   2382 struct _KSGATE {
   2383   LONG Count;
   2384   PKSGATE NextGate;
   2385 };
   2386 
   2387 #ifndef _NTOS_
   2388 __forceinline void KsGateTurnInputOn (PKSGATE Gate)
   2389 {
   2390 	while (Gate && (InterlockedIncrement(&Gate->Count) == 1)) {
   2391 		Gate = Gate->NextGate;
   2392 	}
   2393 }
   2394 
   2395 __forceinline void KsGateTurnInputOff (PKSGATE Gate)
   2396 {
   2397 	while (Gate && (InterlockedDecrement(&Gate->Count) == 0)) {
   2398 		Gate = Gate->NextGate;
   2399 	}
   2400 }
   2401 
   2402 __forceinline BOOLEAN KsGateGetStateUnsafe (PKSGATE Gate)
   2403 {
   2404 	return (BOOLEAN) (Gate->Count > 0);
   2405 }
   2406 
   2407 __forceinline BOOLEAN KsGateCaptureThreshold (PKSGATE Gate)
   2408 {
   2409 	BOOLEAN captured;
   2410 
   2411 	captured = (BOOLEAN) (InterlockedCompareExchange(&Gate->Count, 0, 1) == 1);
   2412 	if (captured) {
   2413 		KsGateTurnInputOff(Gate->NextGate);
   2414 	}
   2415 	return captured;
   2416 }
   2417 
   2418 __forceinline void KsGateInitialize (PKSGATE Gate, LONG InitialCount,
   2419 				     PKSGATE NextGate, BOOLEAN StateToPropagate)
   2420 {
   2421 	Gate->Count = InitialCount;
   2422 	Gate->NextGate = NextGate;
   2423 
   2424 	if (NextGate) {
   2425 		if (InitialCount > 0) {
   2426 			if (StateToPropagate)	KsGateTurnInputOn(NextGate);
   2427 		} else {
   2428 			if (! StateToPropagate)	KsGateTurnInputOff(NextGate);
   2429 		}
   2430 	}
   2431 }
   2432 
   2433 __forceinline void KsGateInitializeAnd (PKSGATE AndGate, PKSGATE NextOrGate)
   2434 {
   2435 	KsGateInitialize(AndGate, 1, NextOrGate, TRUE);
   2436 }
   2437 
   2438 __forceinline void KsGateInitializeOr (PKSGATE OrGate, PKSGATE NextAndGate)
   2439 {
   2440 	KsGateInitialize(OrGate, 0, NextAndGate, FALSE);
   2441 }
   2442 
   2443 __forceinline void KsGateAddOnInputToAnd (PKSGATE AndGate)
   2444 {
   2445 	(VOID)AndGate;
   2446 }
   2447 
   2448 __forceinline void KsGateAddOffInputToAnd (PKSGATE AndGate)
   2449 {
   2450 	KsGateTurnInputOff(AndGate);
   2451 }
   2452 
   2453 __forceinline void KsGateRemoveOnInputFromAnd (PKSGATE AndGate)
   2454 {
   2455 	(VOID)AndGate;
   2456 }
   2457 
   2458 __forceinline void KsGateRemoveOffInputFromAnd (PKSGATE AndGate)
   2459 {
   2460 	KsGateTurnInputOn(AndGate);
   2461 }
   2462 
   2463 __forceinline void KsGateAddOnInputToOr (PKSGATE OrGate)
   2464 {
   2465 	KsGateTurnInputOn(OrGate);
   2466 }
   2467 
   2468 __forceinline void KsGateAddOffInputToOr (PKSGATE OrGate)
   2469 {
   2470 	(VOID)OrGate;
   2471 }
   2472 
   2473 __forceinline void KsGateRemoveOnInputFromOr (PKSGATE OrGate)
   2474 {
   2475 	KsGateTurnInputOff(OrGate);
   2476 }
   2477 
   2478 __forceinline void KsGateRemoveOffInputFromOr (PKSGATE OrGate)
   2479 {
   2480 	(VOID)OrGate;
   2481 }
   2482 
   2483 __forceinline void KsGateTerminateAnd (PKSGATE AndGate)
   2484 {
   2485 	if (KsGateGetStateUnsafe(AndGate)) {
   2486 		KsGateRemoveOnInputFromOr(AndGate->NextGate);
   2487 	} else {
   2488 		KsGateRemoveOffInputFromOr(AndGate->NextGate);
   2489 	}
   2490 }
   2491 
   2492 __forceinline void KsGateTerminateOr (PKSGATE OrGate)
   2493 {
   2494 	if (KsGateGetStateUnsafe(OrGate)) {
   2495 		KsGateRemoveOnInputFromAnd(OrGate->NextGate);
   2496 	} else {
   2497 		KsGateRemoveOffInputFromAnd(OrGate->NextGate);
   2498 	}
   2499 }
   2500 #endif /* _NTOS_ */
   2501 
   2502 
   2503 typedef PVOID KSOBJECT_BAG;
   2504 
   2505 
   2506 typedef BOOLEAN (*PFNKSGENERATEEVENTCALLBACK)(PVOID Context,
   2507 					      PKSEVENT_ENTRY EventEntry);
   2508 
   2509 typedef NTSTATUS (*PFNKSDEVICECREATE)(PKSDEVICE Device);
   2510 
   2511 typedef NTSTATUS (*PFNKSDEVICEPNPSTART)(PKSDEVICE Device,PIRP Irp,
   2512 				PCM_RESOURCE_LIST TranslatedResourceList,
   2513 				PCM_RESOURCE_LIST UntranslatedResourceList);
   2514 
   2515 typedef NTSTATUS (*PFNKSDEVICE)(PKSDEVICE Device);
   2516 
   2517 typedef NTSTATUS (*PFNKSDEVICEIRP)(PKSDEVICE Device,PIRP Irp);
   2518 
   2519 typedef void (*PFNKSDEVICEIRPVOID)(PKSDEVICE Device,PIRP Irp);
   2520 
   2521 typedef NTSTATUS (*PFNKSDEVICEQUERYCAPABILITIES)(PKSDEVICE Device,PIRP Irp,
   2522 					 PDEVICE_CAPABILITIES Capabilities);
   2523 
   2524 typedef NTSTATUS (*PFNKSDEVICEQUERYPOWER)(PKSDEVICE Device,PIRP Irp,
   2525 					  DEVICE_POWER_STATE DeviceTo,
   2526 					  DEVICE_POWER_STATE DeviceFrom,
   2527 					  SYSTEM_POWER_STATE SystemTo,
   2528 					  SYSTEM_POWER_STATE SystemFrom,
   2529 					  POWER_ACTION Action);
   2530 
   2531 typedef void (*PFNKSDEVICESETPOWER)(PKSDEVICE Device,PIRP Irp,
   2532 				    DEVICE_POWER_STATE To,
   2533 				    DEVICE_POWER_STATE From);
   2534 
   2535 typedef NTSTATUS (*PFNKSFILTERFACTORYVOID)(PKSFILTERFACTORY FilterFactory);
   2536 
   2537 typedef void (*PFNKSFILTERFACTORYPOWER)(PKSFILTERFACTORY FilterFactory,
   2538 					DEVICE_POWER_STATE State);
   2539 
   2540 typedef NTSTATUS (*PFNKSFILTERIRP)(PKSFILTER Filter,PIRP Irp);
   2541 
   2542 typedef NTSTATUS (*PFNKSFILTERPROCESS)(PKSFILTER Filter,
   2543 					PKSPROCESSPIN_INDEXENTRY Index);
   2544 
   2545 typedef NTSTATUS (*PFNKSFILTERVOID)(PKSFILTER Filter);
   2546 
   2547 typedef void (*PFNKSFILTERPOWER)(PKSFILTER Filter,DEVICE_POWER_STATE State);
   2548 
   2549 typedef NTSTATUS (*PFNKSPINIRP)(PKSPIN Pin,PIRP Irp);
   2550 
   2551 typedef NTSTATUS (*PFNKSPINSETDEVICESTATE)(PKSPIN Pin,KSSTATE ToState,
   2552 					   KSSTATE FromState);
   2553 
   2554 typedef NTSTATUS (*PFNKSPINSETDATAFORMAT)(PKSPIN Pin,PKSDATAFORMAT OldFormat,
   2555 					  PKSMULTIPLE_ITEM OldAttributeList,
   2556 					  const KSDATARANGE *DataRange,
   2557 					  const KSATTRIBUTE_LIST *AttributeRange);
   2558 
   2559 typedef NTSTATUS (*PFNKSPINHANDSHAKE)(PKSPIN Pin,PKSHANDSHAKE In,
   2560 				      PKSHANDSHAKE Out);
   2561 
   2562 typedef NTSTATUS (*PFNKSPIN)(PKSPIN Pin);
   2563 
   2564 typedef void (*PFNKSPINVOID)(PKSPIN Pin);
   2565 
   2566 typedef void (*PFNKSPINPOWER)(PKSPIN Pin,DEVICE_POWER_STATE State);
   2567 
   2568 typedef BOOLEAN (*PFNKSPINSETTIMER)(PKSPIN Pin,PKTIMER Timer,
   2569 				    LARGE_INTEGER DueTime,PKDPC Dpc);
   2570 
   2571 typedef BOOLEAN (*PFNKSPINCANCELTIMER)(PKSPIN Pin,PKTIMER Timer);
   2572 
   2573 typedef LONGLONG (FASTCALL *PFNKSPINCORRELATEDTIME)(PKSPIN Pin,
   2574 						    PLONGLONG SystemTime);
   2575 
   2576 typedef void (*PFNKSPINRESOLUTION)(PKSPIN Pin,PKSRESOLUTION Resolution);
   2577 
   2578 typedef NTSTATUS (*PFNKSPININITIALIZEALLOCATOR)(PKSPIN Pin,
   2579 					PKSALLOCATOR_FRAMING AllocatorFraming,
   2580 					PVOID *Context);
   2581 
   2582 typedef void (*PFNKSSTREAMPOINTER)(PKSSTREAM_POINTER StreamPointer);
   2583 
   2584 
   2585 typedef struct KSAUTOMATION_TABLE_ KSAUTOMATION_TABLE,*PKSAUTOMATION_TABLE;
   2586 
   2587 struct KSAUTOMATION_TABLE_ {
   2588   ULONG PropertySetsCount;
   2589   ULONG PropertyItemSize;
   2590   const KSPROPERTY_SET *PropertySets;
   2591   ULONG MethodSetsCount;
   2592   ULONG MethodItemSize;
   2593   const KSMETHOD_SET *MethodSets;
   2594   ULONG EventSetsCount;
   2595   ULONG EventItemSize;
   2596   const KSEVENT_SET *EventSets;
   2597 #ifndef _WIN64
   2598   PVOID Alignment;
   2599 #endif
   2600 };
   2601 
   2602 #define DEFINE_KSAUTOMATION_TABLE(table)				\
   2603 		const KSAUTOMATION_TABLE table =
   2604 
   2605 #define DEFINE_KSAUTOMATION_PROPERTIES(table)				\
   2606 		SIZEOF_ARRAY(table),					\
   2607 		sizeof(KSPROPERTY_ITEM),				\
   2608 		table
   2609 
   2610 #define DEFINE_KSAUTOMATION_METHODS(table)				\
   2611 		SIZEOF_ARRAY(table),					\
   2612 		sizeof(KSMETHOD_ITEM),					\
   2613 		table
   2614 
   2615 #define DEFINE_KSAUTOMATION_EVENTS(table)				\
   2616 		SIZEOF_ARRAY(table),					\
   2617 		sizeof(KSEVENT_ITEM),					\
   2618 		table
   2619 
   2620 #define DEFINE_KSAUTOMATION_PROPERTIES_NULL				\
   2621 		0,							\
   2622 		sizeof(KSPROPERTY_ITEM),				\
   2623 		NULL
   2624 
   2625 #define DEFINE_KSAUTOMATION_METHODS_NULL				\
   2626 		0,							\
   2627 		sizeof(KSMETHOD_ITEM),					\
   2628 		NULL
   2629 
   2630 #define DEFINE_KSAUTOMATION_EVENTS_NULL					\
   2631 		0,							\
   2632 		sizeof(KSEVENT_ITEM),					\
   2633 		NULL
   2634 
   2635 #define MIN_DEV_VER_FOR_QI		(0x100)
   2636 
   2637 struct _KSDEVICE_DISPATCH {
   2638   PFNKSDEVICECREATE Add;
   2639   PFNKSDEVICEPNPSTART Start;
   2640   PFNKSDEVICE PostStart;
   2641   PFNKSDEVICEIRP QueryStop;
   2642   PFNKSDEVICEIRPVOID CancelStop;
   2643   PFNKSDEVICEIRPVOID Stop;
   2644   PFNKSDEVICEIRP QueryRemove;
   2645   PFNKSDEVICEIRPVOID CancelRemove;
   2646   PFNKSDEVICEIRPVOID Remove;
   2647   PFNKSDEVICEQUERYCAPABILITIES QueryCapabilities;
   2648   PFNKSDEVICEIRPVOID SurpriseRemoval;
   2649   PFNKSDEVICEQUERYPOWER QueryPower;
   2650   PFNKSDEVICESETPOWER SetPower;
   2651   PFNKSDEVICEIRP QueryInterface;
   2652 };
   2653 
   2654 struct _KSFILTER_DISPATCH {
   2655   PFNKSFILTERIRP Create;
   2656   PFNKSFILTERIRP Close;
   2657   PFNKSFILTERPROCESS Process;
   2658   PFNKSFILTERVOID Reset;
   2659 };
   2660 
   2661 struct _KSPIN_DISPATCH {
   2662   PFNKSPINIRP Create;
   2663   PFNKSPINIRP Close;
   2664   PFNKSPIN Process;
   2665   PFNKSPINVOID Reset;
   2666   PFNKSPINSETDATAFORMAT SetDataFormat;
   2667   PFNKSPINSETDEVICESTATE SetDeviceState;
   2668   PFNKSPIN Connect;
   2669   PFNKSPINVOID Disconnect;
   2670   const KSCLOCK_DISPATCH *Clock;
   2671   const KSALLOCATOR_DISPATCH *Allocator;
   2672 };
   2673 
   2674 struct _KSCLOCK_DISPATCH {
   2675   PFNKSPINSETTIMER SetTimer;
   2676   PFNKSPINCANCELTIMER CancelTimer;
   2677   PFNKSPINCORRELATEDTIME CorrelatedTime;
   2678   PFNKSPINRESOLUTION Resolution;
   2679 };
   2680 
   2681 struct _KSALLOCATOR_DISPATCH {
   2682   PFNKSPININITIALIZEALLOCATOR InitializeAllocator;
   2683   PFNKSDELETEALLOCATOR DeleteAllocator;
   2684   PFNKSDEFAULTALLOCATE Allocate;
   2685   PFNKSDEFAULTFREE Free;
   2686 };
   2687 
   2688 #define KSDEVICE_DESCRIPTOR_VERSION	(0x100)
   2689 
   2690 struct _KSDEVICE_DESCRIPTOR {
   2691   const KSDEVICE_DISPATCH *Dispatch;
   2692   ULONG FilterDescriptorsCount;
   2693   const KSFILTER_DESCRIPTOR*const *FilterDescriptors;
   2694   ULONG Version;
   2695 };
   2696 
   2697 struct _KSFILTER_DESCRIPTOR {
   2698   const KSFILTER_DISPATCH *Dispatch;
   2699   const KSAUTOMATION_TABLE *AutomationTable;
   2700   ULONG Version;
   2701 #define KSFILTER_DESCRIPTOR_VERSION	((ULONG)-1)
   2702   ULONG Flags;
   2703 #define KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING		0x00000001
   2704 #define KSFILTER_FLAG_CRITICAL_PROCESSING		0x00000002
   2705 #define KSFILTER_FLAG_HYPERCRITICAL_PROCESSING		0x00000004
   2706 #define KSFILTER_FLAG_RECEIVE_ZERO_LENGTH_SAMPLES	0x00000008
   2707 #define KSFILTER_FLAG_DENY_USERMODE_ACCESS		0x80000000
   2708   const GUID *ReferenceGuid;
   2709   ULONG PinDescriptorsCount;
   2710   ULONG PinDescriptorSize;
   2711   const KSPIN_DESCRIPTOR_EX *PinDescriptors;
   2712   ULONG CategoriesCount;
   2713   const GUID *Categories;
   2714   ULONG NodeDescriptorsCount;
   2715   ULONG NodeDescriptorSize;
   2716   const KSNODE_DESCRIPTOR *NodeDescriptors;
   2717   ULONG ConnectionsCount;
   2718   const KSTOPOLOGY_CONNECTION *Connections;
   2719   const KSCOMPONENTID *ComponentId;
   2720 };
   2721 
   2722 #define DEFINE_KSFILTER_DESCRIPTOR(descriptor)				\
   2723 	const KSFILTER_DESCRIPTOR descriptor =
   2724 
   2725 #define DEFINE_KSFILTER_PIN_DESCRIPTORS(table)				\
   2726 	SIZEOF_ARRAY(table),						\
   2727 	sizeof(table[0]),						\
   2728 	table
   2729 
   2730 #define DEFINE_KSFILTER_CATEGORIES(table)				\
   2731 	SIZEOF_ARRAY(table),						\
   2732 	table
   2733 
   2734 #define DEFINE_KSFILTER_CATEGORY(category)				\
   2735 	1,								\
   2736 	&(category)
   2737 
   2738 #define DEFINE_KSFILTER_CATEGORIES_NULL					\
   2739 	0,								\
   2740 	NULL
   2741 
   2742 #define DEFINE_KSFILTER_NODE_DESCRIPTORS(table)				\
   2743 	SIZEOF_ARRAY(table),						\
   2744 	sizeof(table[0]),						\
   2745 	table
   2746 
   2747 #define DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL				\
   2748 	0,								\
   2749 	sizeof(KSNODE_DESCRIPTOR),					\
   2750 	NULL
   2751 
   2752 #define DEFINE_KSFILTER_CONNECTIONS(table)				\
   2753 	SIZEOF_ARRAY(table),						\
   2754 	table
   2755 
   2756 #define DEFINE_KSFILTER_DEFAULT_CONNECTIONS				\
   2757 	0,								\
   2758 	NULL
   2759 
   2760 #define DEFINE_KSFILTER_DESCRIPTOR_TABLE(table)				\
   2761 	const KSFILTER_DESCRIPTOR*const table[] =
   2762 
   2763 struct _KSPIN_DESCRIPTOR_EX {
   2764   const KSPIN_DISPATCH *Dispatch;
   2765   const KSAUTOMATION_TABLE *AutomationTable;
   2766   KSPIN_DESCRIPTOR PinDescriptor;
   2767   ULONG Flags;
   2768 #define KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING	KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING
   2769 #define KSPIN_FLAG_CRITICAL_PROCESSING		KSFILTER_FLAG_CRITICAL_PROCESSING
   2770 #define KSPIN_FLAG_HYPERCRITICAL_PROCESSING	KSFILTER_FLAG_HYPERCRITICAL_PROCESSING
   2771 #define KSPIN_FLAG_ASYNCHRONOUS_PROCESSING			0x00000008
   2772 #define KSPIN_FLAG_DO_NOT_INITIATE_PROCESSING			0x00000010
   2773 #define KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL		0x00000020
   2774 #define KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING		0x00000040
   2775 #define KSPIN_FLAG_ENFORCE_FIFO					0x00000080
   2776 #define KSPIN_FLAG_GENERATE_MAPPINGS				0x00000100
   2777 #define KSPIN_FLAG_DISTINCT_TRAILING_EDGE			0x00000200
   2778 #define KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY			0x00010000
   2779 #define KSPIN_FLAG_SPLITTER					0x00020000
   2780 #define KSPIN_FLAG_USE_STANDARD_TRANSPORT			0x00040000
   2781 #define KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT		0x00080000
   2782 #define KSPIN_FLAG_FIXED_FORMAT					0x00100000
   2783 #define KSPIN_FLAG_GENERATE_EOS_EVENTS				0x00200000
   2784 #define KSPIN_FLAG_RENDERER			(KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY|KSPIN_FLAG_GENERATE_EOS_EVENTS)
   2785 #define KSPIN_FLAG_IMPLEMENT_CLOCK				0x00400000
   2786 #define KSPIN_FLAG_SOME_FRAMES_REQUIRED_FOR_PROCESSING		0x00800000
   2787 #define KSPIN_FLAG_PROCESS_IF_ANY_IN_RUN_STATE			0x01000000
   2788 #define KSPIN_FLAG_DENY_USERMODE_ACCESS				0x80000000
   2789   ULONG InstancesPossible;
   2790   ULONG InstancesNecessary;
   2791   const KSALLOCATOR_FRAMING_EX *AllocatorFraming;
   2792   PFNKSINTERSECTHANDLEREX IntersectHandler;
   2793 };
   2794 
   2795 #define DEFINE_KSPIN_DEFAULT_INTERFACES					\
   2796 	0,								\
   2797 	NULL
   2798 
   2799 #define DEFINE_KSPIN_DEFAULT_MEDIUMS					\
   2800 	0,								\
   2801 	NULL
   2802 
   2803 struct _KSNODE_DESCRIPTOR {
   2804   const KSAUTOMATION_TABLE *AutomationTable;
   2805   const GUID *Type;
   2806   const GUID *Name;
   2807 #ifndef _WIN64
   2808   PVOID Alignment;
   2809 #endif
   2810 };
   2811 
   2812 #ifndef _WIN64
   2813 #define DEFINE_NODE_DESCRIPTOR(automation,type,name)			\
   2814 	{ (automation), (type), (name), NULL }
   2815 #else
   2816 #define DEFINE_NODE_DESCRIPTOR(automation,type,name)			\
   2817 	{ (automation), (type), (name) }
   2818 #endif
   2819 
   2820 struct _KSDEVICE {
   2821   const KSDEVICE_DESCRIPTOR *Descriptor;
   2822   KSOBJECT_BAG Bag;
   2823   PVOID Context;
   2824   PDEVICE_OBJECT FunctionalDeviceObject;
   2825   PDEVICE_OBJECT PhysicalDeviceObject;
   2826   PDEVICE_OBJECT NextDeviceObject;
   2827   BOOLEAN Started;
   2828   SYSTEM_POWER_STATE SystemPowerState;
   2829   DEVICE_POWER_STATE DevicePowerState;
   2830 };
   2831 
   2832 struct _KSFILTERFACTORY {
   2833   const KSFILTER_DESCRIPTOR *FilterDescriptor;
   2834   KSOBJECT_BAG Bag;
   2835   PVOID Context;
   2836 };
   2837 
   2838 struct _KSFILTER {
   2839   const KSFILTER_DESCRIPTOR *Descriptor;
   2840   KSOBJECT_BAG Bag;
   2841   PVOID Context;
   2842 };
   2843 
   2844 struct _KSPIN {
   2845   const KSPIN_DESCRIPTOR_EX *Descriptor;
   2846   KSOBJECT_BAG Bag;
   2847   PVOID Context;
   2848   ULONG Id;
   2849   KSPIN_COMMUNICATION Communication;
   2850   BOOLEAN ConnectionIsExternal;
   2851   KSPIN_INTERFACE ConnectionInterface;
   2852   KSPIN_MEDIUM ConnectionMedium;
   2853   KSPRIORITY ConnectionPriority;
   2854   PKSDATAFORMAT ConnectionFormat;
   2855   PKSMULTIPLE_ITEM AttributeList;
   2856   ULONG StreamHeaderSize;
   2857   KSPIN_DATAFLOW DataFlow;
   2858   KSSTATE DeviceState;
   2859   KSRESET ResetState;
   2860   KSSTATE ClientState;
   2861 };
   2862 
   2863 struct _KSMAPPING {
   2864   PHYSICAL_ADDRESS PhysicalAddress;
   2865   ULONG ByteCount;
   2866   ULONG Alignment;
   2867 };
   2868 
   2869 struct _KSSTREAM_POINTER_OFFSET
   2870 {
   2871 #if defined(_NTDDK_)
   2872   __C89_NAMELESS union {
   2873     PUCHAR Data;
   2874     PKSMAPPING Mappings;
   2875   };
   2876 #else
   2877   PUCHAR Data;
   2878 #endif /* _NTDDK_ */
   2879 #ifndef _WIN64
   2880   PVOID Alignment;
   2881 #endif
   2882   ULONG Count;
   2883   ULONG Remaining;
   2884 };
   2885 
   2886 struct _KSSTREAM_POINTER
   2887 {
   2888   PVOID Context;
   2889   PKSPIN Pin;
   2890   PKSSTREAM_HEADER StreamHeader;
   2891   PKSSTREAM_POINTER_OFFSET Offset;
   2892   KSSTREAM_POINTER_OFFSET OffsetIn;
   2893   KSSTREAM_POINTER_OFFSET OffsetOut;
   2894 };
   2895 
   2896 struct _KSPROCESSPIN {
   2897   PKSPIN Pin;
   2898   PKSSTREAM_POINTER StreamPointer;
   2899   PKSPROCESSPIN InPlaceCounterpart;
   2900   PKSPROCESSPIN DelegateBranch;
   2901   PKSPROCESSPIN CopySource;
   2902   PVOID Data;
   2903   ULONG BytesAvailable;
   2904   ULONG BytesUsed;
   2905   ULONG Flags;
   2906   BOOLEAN Terminate;
   2907 };
   2908 
   2909 struct _KSPROCESSPIN_INDEXENTRY {
   2910   PKSPROCESSPIN *Pins;
   2911   ULONG Count;
   2912 };
   2913 
   2914 typedef enum {
   2915   KsObjectTypeDevice,
   2916   KsObjectTypeFilterFactory,
   2917   KsObjectTypeFilter,
   2918   KsObjectTypePin
   2919 } KSOBJECTTYPE;
   2920 
   2921 
   2922 typedef void (*PFNKSFREE)(PVOID Data);
   2923 
   2924 typedef void (*PFNKSPINFRAMERETURN)(PKSPIN Pin,PVOID Data,ULONG Size,PMDL Mdl,
   2925 				    PVOID Context,NTSTATUS Status);
   2926 
   2927 typedef void (*PFNKSPINIRPCOMPLETION)(PKSPIN Pin,PIRP Irp);
   2928 
   2929 
   2930 #if defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__)
   2931 #ifndef _IKsControl_
   2932 #define _IKsControl_
   2933 
   2934 typedef struct IKsControl *PIKSCONTROL;
   2935 
   2936 #ifndef DEFINE_ABSTRACT_UNKNOWN
   2937 #define DEFINE_ABSTRACT_UNKNOWN()					\
   2938 	STDMETHOD_(NTSTATUS,QueryInterface) (THIS_ 			\
   2939 						REFIID InterfaceId,	\
   2940 						PVOID *Interface	\
   2941 					    ) PURE;			\
   2942 	STDMETHOD_(ULONG,AddRef)(THIS) PURE;				\
   2943 	STDMETHOD_(ULONG,Release)(THIS) PURE;
   2944 #endif
   2945 
   2946 #undef INTERFACE
   2947 #define INTERFACE IKsControl
   2948 DECLARE_INTERFACE_(IKsControl,IUnknown)
   2949 {
   2950   DEFINE_ABSTRACT_UNKNOWN()
   2951   STDMETHOD_(NTSTATUS,KsProperty)(THIS_
   2952 					PKSPROPERTY Property,
   2953 					ULONG PropertyLength,
   2954 					PVOID PropertyData,
   2955 					ULONG DataLength,
   2956 					ULONG *BytesReturned
   2957 				 ) PURE;
   2958   STDMETHOD_(NTSTATUS,KsMethod)	(THIS_
   2959 					PKSMETHOD Method,
   2960 					ULONG MethodLength,
   2961 					PVOID MethodData,
   2962 					ULONG DataLength,
   2963 					ULONG *BytesReturned
   2964 				 ) PURE;
   2965   STDMETHOD_(NTSTATUS,KsEvent)	(THIS_
   2966 					PKSEVENT Event,
   2967 					ULONG EventLength,
   2968 					PVOID EventData,
   2969 					ULONG DataLength,
   2970 					ULONG *BytesReturned
   2971 				) PURE;
   2972 };
   2973 typedef struct IKsReferenceClock *PIKSREFERENCECLOCK;
   2974 
   2975 #undef INTERFACE
   2976 #define INTERFACE IKsReferenceClock
   2977 DECLARE_INTERFACE_(IKsReferenceClock,IUnknown)
   2978 {
   2979   DEFINE_ABSTRACT_UNKNOWN()
   2980   STDMETHOD_(LONGLONG,GetTime)		(THIS) PURE;
   2981   STDMETHOD_(LONGLONG,GetPhysicalTime)	(THIS) PURE;
   2982   STDMETHOD_(LONGLONG,GetCorrelatedTime)(THIS_
   2983   						PLONGLONG SystemTime
   2984   					) PURE;
   2985   STDMETHOD_(LONGLONG,GetCorrelatedPhysicalTime)(THIS_
   2986 						PLONGLONG SystemTime
   2987 					) PURE;
   2988   STDMETHOD_(NTSTATUS,GetResolution)	(THIS_
   2989 						PKSRESOLUTION Resolution
   2990 					) PURE;
   2991   STDMETHOD_(NTSTATUS,GetState)		(THIS_
   2992 						PKSSTATE State
   2993 					) PURE;
   2994 };
   2995 #undef INTERFACE
   2996 
   2997 #define INTERFACE IKsDeviceFunctions
   2998 DECLARE_INTERFACE_(IKsDeviceFunctions,IUnknown)
   2999 {
   3000   DEFINE_ABSTRACT_UNKNOWN()
   3001   STDMETHOD_(NTSTATUS,RegisterAdapterObjectEx)	(THIS_
   3002 						  PADAPTER_OBJECT AdapterObject,
   3003 						  PDEVICE_DESCRIPTION DeviceDescription,
   3004 						  ULONG NumberOfMapRegisters,
   3005 						  ULONG MaxMappingsByteCount,
   3006 						  ULONG MappingTableStride
   3007 						) PURE;
   3008 };
   3009 
   3010 #undef INTERFACE
   3011 #define STATIC_IID_IKsControl						\
   3012 	0x28F54685,0x06FD,0x11D2,0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96
   3013 DEFINE_GUID(IID_IKsControl,
   3014 	0x28F54685,0x06FD,0x11D2,0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96);
   3015 #define STATIC_IID_IKsFastClock						\
   3016 	0xc9902485,0xc180,0x11d2,0x84,0x73,0xd4,0x23,0x94,0x45,0x9e,0x5e
   3017 DEFINE_GUID(IID_IKsFastClock,
   3018 	0xc9902485,0xc180,0x11d2,0x84,0x73,0xd4,0x23,0x94,0x45,0x9e,0x5e);
   3019 #define STATIC_IID_IKsDeviceFunctions					\
   3020 	0xe234f2e2,0xbd69,0x4f8c,0xb3,0xf2,0x7c,0xd7,0x9e,0xd4,0x66,0xbd
   3021 DEFINE_GUID(IID_IKsDeviceFunctions,
   3022 	0xe234f2e2,0xbd69,0x4f8c,0xb3,0xf2,0x7c,0xd7,0x9e,0xd4,0x66,0xbd);
   3023 #endif /* _IKsControl_ */
   3024 #endif /* defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__) */
   3025 
   3026 #endif /* _NTDDK_ */
   3027 
   3028 
   3029 #ifdef __cplusplus
   3030 extern "C" {
   3031 #endif
   3032 
   3033 #ifdef _KSDDK_
   3034 #define KSDDKAPI
   3035 #else
   3036 #define KSDDKAPI DECLSPEC_IMPORT
   3037 #endif
   3038 
   3039 #if defined(_NTDDK_)
   3040 
   3041 KSDDKAPI NTSTATUS NTAPI KsEnableEvent
   3042 			(PIRP Irp, ULONG EventSetsCount, const KSEVENT_SET *EventSet,
   3043 			 PLIST_ENTRY EventsList, KSEVENTS_LOCKTYPE EventsFlags,
   3044 			 PVOID EventsLock);
   3045 
   3046 KSDDKAPI NTSTATUS NTAPI KsEnableEventWithAllocator
   3047 			(PIRP Irp, ULONG EventSetsCount, const KSEVENT_SET *EventSet,
   3048 			 PLIST_ENTRY EventsList, KSEVENTS_LOCKTYPE EventsFlags,
   3049 			 PVOID EventsLock, PFNKSALLOCATOR Allocator, ULONG EventItemSize);
   3050 
   3051 KSDDKAPI NTSTATUS NTAPI KsDisableEvent
   3052 			(PIRP Irp, PLIST_ENTRY EventsList, KSEVENTS_LOCKTYPE EventsFlags,
   3053 			 PVOID EventsLock);
   3054 
   3055 KSDDKAPI VOID NTAPI KsDiscardEvent (PKSEVENT_ENTRY EventEntry);
   3056 
   3057 KSDDKAPI VOID NTAPI KsFreeEventList
   3058 			(PFILE_OBJECT FileObject, PLIST_ENTRY EventsList,
   3059 			 KSEVENTS_LOCKTYPE EventsFlags, PVOID EventsLock);
   3060 
   3061 KSDDKAPI NTSTATUS NTAPI KsGenerateEvent (PKSEVENT_ENTRY EventEntry);
   3062 
   3063 KSDDKAPI NTSTATUS NTAPI KsGenerateDataEvent
   3064 			(PKSEVENT_ENTRY EventEntry, ULONG DataSize, PVOID Data);
   3065 
   3066 KSDDKAPI VOID NTAPI KsGenerateEventList
   3067 			(GUID *Set, ULONG EventId, PLIST_ENTRY EventsList,
   3068 			 KSEVENTS_LOCKTYPE EventsFlags, PVOID EventsLock);
   3069 
   3070 KSDDKAPI NTSTATUS NTAPI KsPropertyHandler
   3071 			(PIRP Irp, ULONG PropertySetsCount,
   3072 			 const KSPROPERTY_SET *PropertySet);
   3073 
   3074 KSDDKAPI NTSTATUS NTAPI KsPropertyHandlerWithAllocator
   3075 			(PIRP Irp, ULONG PropertySetsCount,
   3076 			 const KSPROPERTY_SET *PropertySet, PFNKSALLOCATOR Allocator,
   3077 			 ULONG PropertyItemSize);
   3078 
   3079 KSDDKAPI BOOLEAN NTAPI KsFastPropertyHandler
   3080 			(PFILE_OBJECT FileObject, PKSPROPERTY Property,
   3081 			 ULONG PropertyLength, PVOID Data, ULONG DataLength,
   3082 			 PIO_STATUS_BLOCK IoStatus, ULONG PropertySetsCount,
   3083 			 const KSPROPERTY_SET *PropertySet);
   3084 
   3085 KSDDKAPI NTSTATUS NTAPI KsMethodHandler
   3086 			(PIRP Irp, ULONG MethodSetsCount,
   3087 			 const KSMETHOD_SET *MethodSet);
   3088 
   3089 KSDDKAPI NTSTATUS NTAPI KsMethodHandlerWithAllocator
   3090 			(PIRP Irp, ULONG MethodSetsCount,
   3091 			 const KSMETHOD_SET *MethodSet, PFNKSALLOCATOR Allocator,
   3092 			 ULONG MethodItemSize);
   3093 
   3094 KSDDKAPI BOOLEAN NTAPI KsFastMethodHandler
   3095 			(PFILE_OBJECT FileObject, PKSMETHOD Method, ULONG MethodLength,
   3096 			 PVOID Data, ULONG DataLength, PIO_STATUS_BLOCK IoStatus,
   3097 			 ULONG MethodSetsCount, const KSMETHOD_SET *MethodSet);
   3098 
   3099 KSDDKAPI NTSTATUS NTAPI KsCreateDefaultAllocator (PIRP Irp);
   3100 
   3101 KSDDKAPI NTSTATUS NTAPI KsCreateDefaultAllocatorEx
   3102 			(PIRP Irp, PVOID InitializeContext,
   3103 			 PFNKSDEFAULTALLOCATE DefaultAllocate,
   3104 			 PFNKSDEFAULTFREE DefaultFree,
   3105 			 PFNKSINITIALIZEALLOCATOR InitializeAllocator,
   3106 			 PFNKSDELETEALLOCATOR DeleteAllocator);
   3107 
   3108 KSDDKAPI NTSTATUS NTAPI KsCreateAllocator
   3109 			(HANDLE ConnectionHandle, PKSALLOCATOR_FRAMING AllocatorFraming,
   3110 			 PHANDLE AllocatorHandle);
   3111 
   3112 KSDDKAPI NTSTATUS NTAPI KsValidateAllocatorCreateRequest
   3113 			(PIRP Irp, PKSALLOCATOR_FRAMING *AllocatorFraming);
   3114 
   3115 KSDDKAPI NTSTATUS NTAPI KsValidateAllocatorFramingEx
   3116 			(PKSALLOCATOR_FRAMING_EX Framing, ULONG BufferSize,
   3117 			 const KSALLOCATOR_FRAMING_EX *PinFraming);
   3118 
   3119 KSDDKAPI NTSTATUS NTAPI KsAllocateDefaultClock (PKSDEFAULTCLOCK *DefaultClock);
   3120 
   3121 KSDDKAPI NTSTATUS NTAPI KsAllocateDefaultClockEx
   3122 			(PKSDEFAULTCLOCK *DefaultClock, PVOID Context,
   3123 			 PFNKSSETTIMER SetTimer, PFNKSCANCELTIMER CancelTimer,
   3124 			 PFNKSCORRELATEDTIME CorrelatedTime,
   3125 			 const KSRESOLUTION *Resolution, ULONG Flags);
   3126 
   3127 KSDDKAPI VOID NTAPI KsFreeDefaultClock (PKSDEFAULTCLOCK DefaultClock);
   3128 KSDDKAPI NTSTATUS NTAPI KsCreateDefaultClock (PIRP Irp, PKSDEFAULTCLOCK DefaultClock);
   3129 
   3130 KSDDKAPI NTSTATUS NTAPI KsCreateClock
   3131 			(HANDLE ConnectionHandle, PKSCLOCK_CREATE ClockCreate,
   3132 			 PHANDLE ClockHandle);
   3133 
   3134 KSDDKAPI NTSTATUS NTAPI KsValidateClockCreateRequest
   3135 			(PIRP Irp, PKSCLOCK_CREATE *ClockCreate);
   3136 
   3137 KSDDKAPI KSSTATE NTAPI KsGetDefaultClockState (PKSDEFAULTCLOCK DefaultClock);
   3138 KSDDKAPI VOID NTAPI KsSetDefaultClockState(PKSDEFAULTCLOCK DefaultClock, KSSTATE State);
   3139 KSDDKAPI LONGLONG NTAPI KsGetDefaultClockTime (PKSDEFAULTCLOCK DefaultClock);
   3140 KSDDKAPI VOID NTAPI KsSetDefaultClockTime(PKSDEFAULTCLOCK DefaultClock, LONGLONG Time);
   3141 
   3142 KSDDKAPI NTSTATUS NTAPI KsCreatePin
   3143 			(HANDLE FilterHandle, PKSPIN_CONNECT Connect,
   3144 			 ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle);
   3145 
   3146 KSDDKAPI NTSTATUS NTAPI KsValidateConnectRequest
   3147 			(PIRP Irp, ULONG DescriptorsCount,
   3148 			 const KSPIN_DESCRIPTOR *Descriptor, PKSPIN_CONNECT *Connect);
   3149 
   3150 KSDDKAPI NTSTATUS NTAPI KsPinPropertyHandler
   3151 			(PIRP Irp, PKSPROPERTY Property, PVOID Data,
   3152 			 ULONG DescriptorsCount, const KSPIN_DESCRIPTOR *Descriptor);
   3153 
   3154 KSDDKAPI NTSTATUS NTAPI KsPinDataIntersection
   3155 			(PIRP Irp, PKSP_PIN Pin, PVOID Data, ULONG DescriptorsCount,
   3156 			 const KSPIN_DESCRIPTOR *Descriptor,
   3157 			 PFNKSINTERSECTHANDLER IntersectHandler);
   3158 
   3159 KSDDKAPI NTSTATUS NTAPI KsPinDataIntersectionEx
   3160 			(PIRP Irp, PKSP_PIN Pin, PVOID Data, ULONG DescriptorsCount,
   3161 			 const KSPIN_DESCRIPTOR *Descriptor, ULONG DescriptorSize,
   3162 			 PFNKSINTERSECTHANDLEREX IntersectHandler, PVOID HandlerContext);
   3163 
   3164 KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery
   3165 			(PIRP Irp, ULONG DataItemsCount, ULONG DataItemSize,
   3166 			 const VOID *DataItems);
   3167 
   3168 #ifndef MAKEINTRESOURCE
   3169 #define MAKEINTRESOURCE(r)		((ULONG_PTR) (USHORT) r)
   3170 #endif
   3171 #ifndef RT_STRING
   3172 #define RT_STRING			MAKEINTRESOURCE(6)
   3173 #define RT_RCDATA			MAKEINTRESOURCE(10)
   3174 #endif
   3175 
   3176 KSDDKAPI NTSTATUS NTAPI KsLoadResource
   3177 			(PVOID ImageBase, POOL_TYPE PoolType, ULONG_PTR ResourceName,
   3178 			 ULONG ResourceType, PVOID *Resource, PULONG ResourceSize);
   3179 
   3180 KSDDKAPI NTSTATUS NTAPI KsGetImageNameAndResourceId
   3181 			(HANDLE RegKey, PUNICODE_STRING ImageName, PULONG_PTR ResourceId,
   3182 			 PULONG ValueType);
   3183 
   3184 KSDDKAPI NTSTATUS NTAPI KsMapModuleName
   3185 			(PDEVICE_OBJECT PhysicalDeviceObject, PUNICODE_STRING ModuleName,
   3186 			 PUNICODE_STRING ImageName, PULONG_PTR ResourceId,
   3187 			 PULONG ValueType);
   3188 
   3189 KSDDKAPI NTSTATUS NTAPI KsReferenceBusObject (KSDEVICE_HEADER Header);
   3190 KSDDKAPI VOID NTAPI KsDereferenceBusObject (KSDEVICE_HEADER Header);
   3191 KSDDKAPI NTSTATUS NTAPI KsDispatchQuerySecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3192 KSDDKAPI NTSTATUS NTAPI KsDispatchSetSecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3193 KSDDKAPI NTSTATUS NTAPI KsDispatchSpecificProperty (PIRP Irp, PFNKSHANDLER Handler);
   3194 KSDDKAPI NTSTATUS NTAPI KsDispatchSpecificMethod (PIRP Irp, PFNKSHANDLER Handler);
   3195 
   3196 KSDDKAPI NTSTATUS NTAPI KsReadFile
   3197 			(PFILE_OBJECT FileObject, PKEVENT Event, PVOID PortContext,
   3198 			 PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length,
   3199 			 ULONG Key, KPROCESSOR_MODE RequestorMode);
   3200 
   3201 KSDDKAPI NTSTATUS NTAPI KsWriteFile
   3202 			(PFILE_OBJECT FileObject, PKEVENT Event, PVOID PortContext,
   3203 			 PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length,
   3204 			 ULONG Key, KPROCESSOR_MODE RequestorMode);
   3205 
   3206 KSDDKAPI NTSTATUS NTAPI KsQueryInformationFile
   3207 			(PFILE_OBJECT FileObject, PVOID FileInformation, ULONG Length,
   3208 			 FILE_INFORMATION_CLASS FileInformationClass);
   3209 
   3210 KSDDKAPI NTSTATUS NTAPI KsSetInformationFile
   3211 			(PFILE_OBJECT FileObject, PVOID FileInformation, ULONG Length,
   3212 			 FILE_INFORMATION_CLASS FileInformationClass);
   3213 
   3214 KSDDKAPI NTSTATUS NTAPI KsStreamIo
   3215 			(PFILE_OBJECT FileObject, PKEVENT Event, PVOID PortContext,
   3216 			 PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext,
   3217 			 KSCOMPLETION_INVOCATION CompletionInvocationFlags,
   3218 			 PIO_STATUS_BLOCK IoStatusBlock, PVOID StreamHeaders, ULONG Length,
   3219 			 ULONG Flags, KPROCESSOR_MODE RequestorMode);
   3220 
   3221 KSDDKAPI NTSTATUS NTAPI KsProbeStreamIrp(PIRP Irp, ULONG ProbeFlags, ULONG HeaderSize);
   3222 KSDDKAPI NTSTATUS NTAPI KsAllocateExtraData(PIRP Irp, ULONG ExtraSize, PVOID *ExtraBuffer);
   3223 KSDDKAPI VOID NTAPI KsNullDriverUnload (PDRIVER_OBJECT DriverObject);
   3224 
   3225 KSDDKAPI NTSTATUS NTAPI KsSetMajorFunctionHandler
   3226 			(PDRIVER_OBJECT DriverObject, ULONG MajorFunction);
   3227 
   3228 KSDDKAPI NTSTATUS NTAPI KsDispatchInvalidDeviceRequest
   3229 			(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3230 
   3231 KSDDKAPI NTSTATUS NTAPI KsDefaultDeviceIoCompletion
   3232 			(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3233 
   3234 KSDDKAPI NTSTATUS NTAPI KsDispatchIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3235 
   3236 KSDDKAPI BOOLEAN NTAPI KsDispatchFastIoDeviceControlFailure
   3237 			(PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer,
   3238 			 ULONG InputBufferLength, PVOID OutputBuffer,
   3239 			 ULONG OutputBufferLength, ULONG IoControlCode,
   3240 			 PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject);
   3241 
   3242 KSDDKAPI BOOLEAN NTAPI KsDispatchFastReadFailure
   3243 			(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset,
   3244 			 ULONG Length, BOOLEAN Wait, ULONG LockKey, PVOID Buffer,
   3245 			 PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject);
   3246 
   3247 #define KsDispatchFastWriteFailure		KsDispatchFastReadFailure
   3248 
   3249 KSDDKAPI VOID NTAPI KsCancelRoutine(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3250 KSDDKAPI VOID NTAPI KsCancelIo(PLIST_ENTRY QueueHead, PKSPIN_LOCK SpinLock);
   3251 KSDDKAPI VOID NTAPI KsReleaseIrpOnCancelableQueue(PIRP Irp, PDRIVER_CANCEL DriverCancel);
   3252 
   3253 KSDDKAPI PIRP NTAPI KsRemoveIrpFromCancelableQueue
   3254 			(PLIST_ENTRY QueueHead, PKSPIN_LOCK SpinLock,
   3255 			 KSLIST_ENTRY_LOCATION ListLocation,
   3256 			 KSIRP_REMOVAL_OPERATION RemovalOperation);
   3257 
   3258 KSDDKAPI NTSTATUS NTAPI KsMoveIrpsOnCancelableQueue
   3259 			(PLIST_ENTRY SourceList, PKSPIN_LOCK SourceLock,
   3260 			 PLIST_ENTRY DestinationList, PKSPIN_LOCK DestinationLock,
   3261 			 KSLIST_ENTRY_LOCATION ListLocation,
   3262 			 PFNKSIRPLISTCALLBACK ListCallback, PVOID Context);
   3263 
   3264 KSDDKAPI VOID NTAPI KsRemoveSpecificIrpFromCancelableQueue (PIRP Irp);
   3265 
   3266 KSDDKAPI VOID NTAPI KsAddIrpToCancelableQueue
   3267 			(PLIST_ENTRY QueueHead, PKSPIN_LOCK SpinLock, PIRP Irp,
   3268 			 KSLIST_ENTRY_LOCATION ListLocation, PDRIVER_CANCEL DriverCancel);
   3269 
   3270 KSDDKAPI NTSTATUS NTAPI KsAcquireResetValue(PIRP Irp, KSRESET *ResetValue);
   3271 
   3272 KSDDKAPI NTSTATUS NTAPI KsTopologyPropertyHandler
   3273 			(PIRP Irp, PKSPROPERTY Property, PVOID Data,
   3274 			 const KSTOPOLOGY *Topology);
   3275 
   3276 KSDDKAPI VOID NTAPI KsAcquireDeviceSecurityLock(KSDEVICE_HEADER Header, BOOLEAN Exclusive);
   3277 KSDDKAPI VOID NTAPI KsReleaseDeviceSecurityLock (KSDEVICE_HEADER Header);
   3278 KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPnp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3279 KSDDKAPI NTSTATUS NTAPI KsDefaultDispatchPower(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3280 KSDDKAPI NTSTATUS NTAPI KsDefaultForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
   3281 
   3282 KSDDKAPI VOID NTAPI KsSetDevicePnpAndBaseObject
   3283 			(KSDEVICE_HEADER Header, PDEVICE_OBJECT PnpDeviceObject,
   3284 			 PDEVICE_OBJECT BaseObject);
   3285 
   3286 KSDDKAPI PDEVICE_OBJECT NTAPI KsQueryDevicePnpObject (KSDEVICE_HEADER Header);
   3287 KSDDKAPI ACCESS_MASK NTAPI KsQueryObjectAccessMask (KSOBJECT_HEADER Header);
   3288 
   3289 KSDDKAPI VOID NTAPI KsRecalculateStackDepth
   3290 			(KSDEVICE_HEADER Header, BOOLEAN ReuseStackLocation);
   3291 
   3292 KSDDKAPI VOID NTAPI KsSetTargetState
   3293 			(KSOBJECT_HEADER Header, KSTARGET_STATE TargetState);
   3294 
   3295 KSDDKAPI VOID NTAPI KsSetTargetDeviceObject
   3296 			(KSOBJECT_HEADER Header, PDEVICE_OBJECT TargetDevice);
   3297 
   3298 KSDDKAPI VOID NTAPI KsSetPowerDispatch
   3299 			(KSOBJECT_HEADER Header, PFNKSCONTEXT_DISPATCH PowerDispatch,
   3300 			 PVOID PowerContext);
   3301 
   3302 KSDDKAPI PKSOBJECT_CREATE_ITEM NTAPI KsQueryObjectCreateItem (KSOBJECT_HEADER Header);
   3303 
   3304 KSDDKAPI NTSTATUS NTAPI KsAllocateDeviceHeader
   3305 			(KSDEVICE_HEADER *Header, ULONG ItemsCount,
   3306 			 PKSOBJECT_CREATE_ITEM ItemsList);
   3307 
   3308 KSDDKAPI VOID NTAPI KsFreeDeviceHeader (KSDEVICE_HEADER Header);
   3309 
   3310 KSDDKAPI NTSTATUS NTAPI KsAllocateObjectHeader
   3311 			(KSOBJECT_HEADER *Header, ULONG ItemsCount,
   3312 			 PKSOBJECT_CREATE_ITEM ItemsList, PIRP Irp,
   3313 			 const KSDISPATCH_TABLE *Table);
   3314 
   3315 KSDDKAPI VOID NTAPI KsFreeObjectHeader (KSOBJECT_HEADER Header);
   3316 
   3317 KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToDeviceHeader
   3318 			(KSDEVICE_HEADER Header, PDRIVER_DISPATCH Create, PVOID Context,
   3319 			 PWSTR ObjectClass, PSECURITY_DESCRIPTOR SecurityDescriptor);
   3320 
   3321 KSDDKAPI NTSTATUS NTAPI KsAddObjectCreateItemToObjectHeader
   3322 			(KSOBJECT_HEADER Header, PDRIVER_DISPATCH Create, PVOID Context,
   3323 			 PWSTR ObjectClass, PSECURITY_DESCRIPTOR SecurityDescriptor);
   3324 
   3325 KSDDKAPI NTSTATUS NTAPI KsAllocateObjectCreateItem
   3326 			(KSDEVICE_HEADER Header, PKSOBJECT_CREATE_ITEM CreateItem,
   3327 			 BOOLEAN AllocateEntry, PFNKSITEMFREECALLBACK ItemFreeCallback);
   3328 
   3329 KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItem
   3330 			(KSDEVICE_HEADER Header, PUNICODE_STRING CreateItem);
   3331 
   3332 KSDDKAPI NTSTATUS NTAPI KsFreeObjectCreateItemsByContext
   3333 			(KSDEVICE_HEADER Header, PVOID Context);
   3334 
   3335 KSDDKAPI NTSTATUS NTAPI KsCreateDefaultSecurity
   3336 			(PSECURITY_DESCRIPTOR ParentSecurity,
   3337 			 PSECURITY_DESCRIPTOR *DefaultSecurity);
   3338 
   3339 KSDDKAPI NTSTATUS NTAPI KsForwardIrp
   3340 			(PIRP Irp, PFILE_OBJECT FileObject, BOOLEAN ReuseStackLocation);
   3341 
   3342 KSDDKAPI NTSTATUS NTAPI KsForwardAndCatchIrp
   3343 			(PDEVICE_OBJECT DeviceObject, PIRP Irp, PFILE_OBJECT FileObject,
   3344 			 KSSTACK_USE StackUse);
   3345 
   3346 KSDDKAPI NTSTATUS NTAPI KsSynchronousIoControlDevice
   3347 			(PFILE_OBJECT FileObject, KPROCESSOR_MODE RequestorMode,
   3348 			 ULONG IoControl, PVOID InBuffer, ULONG InSize, PVOID OutBuffer,
   3349 			 ULONG OutSize, PULONG BytesReturned);
   3350 
   3351 KSDDKAPI NTSTATUS NTAPI KsUnserializeObjectPropertiesFromRegistry
   3352 			(PFILE_OBJECT FileObject, HANDLE ParentKey,
   3353 			 PUNICODE_STRING RegistryPath);
   3354 
   3355 KSDDKAPI NTSTATUS NTAPI KsCacheMedium
   3356 			(PUNICODE_STRING SymbolicLink, PKSPIN_MEDIUM Medium,
   3357 			 ULONG PinDirection);
   3358 
   3359 KSDDKAPI NTSTATUS NTAPI KsRegisterWorker
   3360 			(WORK_QUEUE_TYPE WorkQueueType, PKSWORKER *Worker);
   3361 
   3362 KSDDKAPI NTSTATUS NTAPI KsRegisterCountedWorker
   3363 			(WORK_QUEUE_TYPE WorkQueueType, PWORK_QUEUE_ITEM CountedWorkItem,
   3364 			 PKSWORKER *Worker);
   3365 
   3366 KSDDKAPI VOID NTAPI KsUnregisterWorker (PKSWORKER Worker);
   3367 KSDDKAPI NTSTATUS NTAPI KsQueueWorkItem(PKSWORKER Worker, PWORK_QUEUE_ITEM WorkItem);
   3368 KSDDKAPI ULONG NTAPI KsIncrementCountedWorker (PKSWORKER Worker);
   3369 KSDDKAPI ULONG NTAPI KsDecrementCountedWorker (PKSWORKER Worker);
   3370 
   3371 KSDDKAPI NTSTATUS NTAPI KsCreateTopologyNode
   3372 			(HANDLE ParentHandle, PKSNODE_CREATE NodeCreate,
   3373 			 ACCESS_MASK DesiredAccess, PHANDLE NodeHandle);
   3374 
   3375 KSDDKAPI NTSTATUS NTAPI KsValidateTopologyNodeCreateRequest
   3376 			(PIRP Irp, PKSTOPOLOGY Topology, PKSNODE_CREATE *NodeCreate);
   3377 
   3378 KSDDKAPI NTSTATUS NTAPI KsMergeAutomationTables
   3379 			(PKSAUTOMATION_TABLE *AutomationTableAB,
   3380 			 PKSAUTOMATION_TABLE AutomationTableA,
   3381 			 PKSAUTOMATION_TABLE AutomationTableB,
   3382 			 KSOBJECT_BAG Bag);
   3383 
   3384 KSDDKAPI NTSTATUS NTAPI KsInitializeDriver
   3385 			(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPathName,
   3386 			 const KSDEVICE_DESCRIPTOR *Descriptor);
   3387 
   3388 KSDDKAPI NTSTATUS NTAPI KsAddDevice
   3389 			(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject);
   3390 
   3391 KSDDKAPI NTSTATUS NTAPI KsCreateDevice
   3392 			(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject,
   3393 			 const KSDEVICE_DESCRIPTOR *Descriptor, ULONG ExtensionSize,
   3394 			 PKSDEVICE *Device);
   3395 
   3396 KSDDKAPI NTSTATUS NTAPI KsInitializeDevice
   3397 			(PDEVICE_OBJECT FunctionalDeviceObject,
   3398 			 PDEVICE_OBJECT PhysicalDeviceObject,
   3399 			 PDEVICE_OBJECT NextDeviceObject,
   3400 			 const KSDEVICE_DESCRIPTOR *Descriptor);
   3401 
   3402 KSDDKAPI void NTAPI KsTerminateDevice (PDEVICE_OBJECT DeviceObject);
   3403 KSDDKAPI PKSDEVICE NTAPI KsGetDeviceForDeviceObject (PDEVICE_OBJECT FunctionalDeviceObject);
   3404 KSDDKAPI void NTAPI KsAcquireDevice (PKSDEVICE Device);
   3405 KSDDKAPI void NTAPI KsReleaseDevice (PKSDEVICE Device);
   3406 
   3407 KSDDKAPI void NTAPI KsDeviceRegisterAdapterObject
   3408 			(PKSDEVICE Device, PADAPTER_OBJECT AdapterObject,
   3409 			 ULONG MaxMappingsByteCount, ULONG MappingTableStride);
   3410 
   3411 KSDDKAPI ULONG NTAPI KsDeviceGetBusData
   3412 			(PKSDEVICE Device, ULONG DataType, PVOID Buffer, ULONG Offset,
   3413 			 ULONG Length);
   3414 
   3415 KSDDKAPI ULONG NTAPI KsDeviceSetBusData
   3416 			(PKSDEVICE Device, ULONG DataType, PVOID Buffer, ULONG Offset,
   3417 			 ULONG Length);
   3418 
   3419 KSDDKAPI NTSTATUS NTAPI KsCreateFilterFactory
   3420 			(PDEVICE_OBJECT DeviceObject, const KSFILTER_DESCRIPTOR *Descriptor,
   3421 			 PWSTR RefString, PSECURITY_DESCRIPTOR SecurityDescriptor,
   3422 			 ULONG CreateItemFlags, PFNKSFILTERFACTORYPOWER SleepCallback,
   3423 			 PFNKSFILTERFACTORYPOWER WakeCallback,
   3424 			 PKSFILTERFACTORY *FilterFactory);
   3425 
   3426 #define KsDeleteFilterFactory(FilterFactory)												\
   3427 	KsFreeObjectCreateItemsByContext( *(KSDEVICE_HEADER *)(										\
   3428 						KsFilterFactoryGetParentDevice(FilterFactory)->FunctionalDeviceObject->DeviceExtension),\
   3429 					   FilterFactory)
   3430 
   3431 KSDDKAPI NTSTATUS NTAPI KsFilterFactoryUpdateCacheData
   3432 			(PKSFILTERFACTORY FilterFactory,
   3433 			 const KSFILTER_DESCRIPTOR *FilterDescriptor);
   3434 
   3435 KSDDKAPI NTSTATUS NTAPI KsFilterFactoryAddCreateItem
   3436 			(PKSFILTERFACTORY FilterFactory, PWSTR RefString,
   3437 			 PSECURITY_DESCRIPTOR SecurityDescriptor, ULONG CreateItemFlags);
   3438 
   3439 KSDDKAPI NTSTATUS NTAPI KsFilterFactorySetDeviceClassesState
   3440 			(PKSFILTERFACTORY FilterFactory, BOOLEAN NewState);
   3441 
   3442 KSDDKAPI PUNICODE_STRING NTAPI KsFilterFactoryGetSymbolicLink
   3443 			(PKSFILTERFACTORY FilterFactory);
   3444 
   3445 KSDDKAPI void NTAPI KsAddEvent(PVOID Object, PKSEVENT_ENTRY EventEntry);
   3446 
   3447 __forceinline void KsFilterAddEvent (PKSFILTER Filter, PKSEVENT_ENTRY EventEntry)
   3448 {
   3449 	KsAddEvent(Filter, EventEntry);
   3450 }
   3451 
   3452 __forceinline void KsPinAddEvent (PKSPIN Pin, PKSEVENT_ENTRY EventEntry)
   3453 {
   3454 	KsAddEvent(Pin, EventEntry);
   3455 }
   3456 
   3457 KSDDKAPI NTSTATUS NTAPI KsDefaultAddEventHandler
   3458 			(PIRP Irp, PKSEVENTDATA EventData, PKSEVENT_ENTRY EventEntry);
   3459 
   3460 KSDDKAPI void NTAPI KsGenerateEvents
   3461 			(PVOID Object, const GUID *EventSet, ULONG EventId,
   3462 			 ULONG DataSize, PVOID Data, PFNKSGENERATEEVENTCALLBACK CallBack,
   3463 			 PVOID CallBackContext);
   3464 
   3465 __forceinline void KsFilterGenerateEvents
   3466 			(PKSFILTER Filter, const GUID *EventSet, ULONG EventId,
   3467 			 ULONG DataSize, PVOID Data, PFNKSGENERATEEVENTCALLBACK CallBack,
   3468 			 PVOID CallBackContext)
   3469 {
   3470 	KsGenerateEvents(Filter, EventSet, EventId, DataSize, Data, CallBack,
   3471 			 CallBackContext);
   3472 }
   3473 
   3474 __forceinline void KsPinGenerateEvents
   3475 			(PKSPIN Pin, const GUID *EventSet, ULONG EventId,
   3476 			 ULONG DataSize, PVOID Data, PFNKSGENERATEEVENTCALLBACK CallBack,
   3477 			 PVOID CallBackContext)
   3478 {
   3479 	KsGenerateEvents(Pin, EventSet, EventId, DataSize, Data, CallBack,
   3480 			 CallBackContext);
   3481 }
   3482 
   3483 typedef enum {
   3484   KSSTREAM_POINTER_STATE_UNLOCKED = 0,
   3485   KSSTREAM_POINTER_STATE_LOCKED
   3486 } KSSTREAM_POINTER_STATE;
   3487 
   3488 KSDDKAPI NTSTATUS NTAPI KsPinGetAvailableByteCount
   3489 			(PKSPIN Pin, PLONG InputDataBytes, PLONG OutputBufferBytes);
   3490 
   3491 KSDDKAPI PKSSTREAM_POINTER NTAPI KsPinGetLeadingEdgeStreamPointer
   3492 			(PKSPIN Pin, KSSTREAM_POINTER_STATE State);
   3493 
   3494 KSDDKAPI PKSSTREAM_POINTER NTAPI KsPinGetTrailingEdgeStreamPointer
   3495 			(PKSPIN Pin, KSSTREAM_POINTER_STATE State);
   3496 
   3497 KSDDKAPI NTSTATUS NTAPI KsStreamPointerSetStatusCode
   3498 			(PKSSTREAM_POINTER StreamPointer, NTSTATUS Status);
   3499 
   3500 KSDDKAPI NTSTATUS NTAPI KsStreamPointerLock (PKSSTREAM_POINTER StreamPointer);
   3501 KSDDKAPI void NTAPI KsStreamPointerUnlock(PKSSTREAM_POINTER StreamPointer, BOOLEAN Eject);
   3502 
   3503 KSDDKAPI void NTAPI KsStreamPointerAdvanceOffsetsAndUnlock
   3504 			(PKSSTREAM_POINTER StreamPointer, ULONG InUsed, ULONG OutUsed,
   3505 			 BOOLEAN Eject);
   3506 
   3507 KSDDKAPI void NTAPI KsStreamPointerDelete (PKSSTREAM_POINTER StreamPointer);
   3508 
   3509 KSDDKAPI NTSTATUS NTAPI KsStreamPointerClone
   3510 			(PKSSTREAM_POINTER StreamPointer, PFNKSSTREAMPOINTER CancelCallback,
   3511 			 ULONG ContextSize, PKSSTREAM_POINTER *CloneStreamPointer);
   3512 
   3513 KSDDKAPI NTSTATUS NTAPI KsStreamPointerAdvanceOffsets
   3514 			(PKSSTREAM_POINTER StreamPointer, ULONG InUsed, ULONG OutUsed,
   3515 			 BOOLEAN Eject);
   3516 
   3517 KSDDKAPI NTSTATUS NTAPI KsStreamPointerAdvance (PKSSTREAM_POINTER StreamPointer);
   3518 KSDDKAPI PMDL NTAPI KsStreamPointerGetMdl (PKSSTREAM_POINTER StreamPointer);
   3519 
   3520 KSDDKAPI PIRP NTAPI KsStreamPointerGetIrp
   3521 			(PKSSTREAM_POINTER StreamPointer, PBOOLEAN FirstFrameInIrp,
   3522 			 PBOOLEAN LastFrameInIrp);
   3523 
   3524 KSDDKAPI void NTAPI KsStreamPointerScheduleTimeout
   3525 			(PKSSTREAM_POINTER StreamPointer, PFNKSSTREAMPOINTER Callback,
   3526 			 ULONGLONG Interval);
   3527 
   3528 KSDDKAPI void NTAPI KsStreamPointerCancelTimeout (PKSSTREAM_POINTER StreamPointer);
   3529 KSDDKAPI PKSSTREAM_POINTER NTAPI KsPinGetFirstCloneStreamPointer (PKSPIN Pin);
   3530 
   3531 KSDDKAPI PKSSTREAM_POINTER NTAPI KsStreamPointerGetNextClone
   3532 			(PKSSTREAM_POINTER StreamPointer);
   3533 
   3534 KSDDKAPI NTSTATUS NTAPI KsPinHandshake(PKSPIN Pin, PKSHANDSHAKE In, PKSHANDSHAKE Out);
   3535 KSDDKAPI void NTAPI KsCompletePendingRequest (PIRP Irp);
   3536 KSDDKAPI KSOBJECTTYPE NTAPI KsGetObjectTypeFromIrp (PIRP Irp);
   3537 KSDDKAPI PVOID NTAPI KsGetObjectFromFileObject (PFILE_OBJECT FileObject);
   3538 KSDDKAPI KSOBJECTTYPE NTAPI KsGetObjectTypeFromFileObject (PFILE_OBJECT FileObject);
   3539 
   3540 __forceinline PKSFILTER KsGetFilterFromFileObject (PFILE_OBJECT FileObject)
   3541 {
   3542 	return (PKSFILTER) KsGetObjectFromFileObject(FileObject);
   3543 }
   3544 
   3545 __forceinline PKSPIN KsGetPinFromFileObject (PFILE_OBJECT FileObject)
   3546 {
   3547 	return (PKSPIN) KsGetObjectFromFileObject(FileObject);
   3548 }
   3549 
   3550 KSDDKAPI PKSGATE NTAPI KsFilterGetAndGate (PKSFILTER Filter);
   3551 KSDDKAPI void NTAPI KsFilterAcquireProcessingMutex (PKSFILTER Filter);
   3552 KSDDKAPI void NTAPI KsFilterReleaseProcessingMutex (PKSFILTER Filter);
   3553 KSDDKAPI void NTAPI KsFilterAttemptProcessing(PKSFILTER Filter, BOOLEAN Asynchronous);
   3554 KSDDKAPI PKSGATE NTAPI KsPinGetAndGate(PKSPIN Pin);
   3555 KSDDKAPI void NTAPI KsPinAttachAndGate(PKSPIN Pin, PKSGATE AndGate);
   3556 KSDDKAPI void NTAPI KsPinAttachOrGate (PKSPIN Pin, PKSGATE OrGate);
   3557 KSDDKAPI void NTAPI KsPinAcquireProcessingMutex (PKSPIN Pin);
   3558 KSDDKAPI void NTAPI KsPinReleaseProcessingMutex (PKSPIN Pin);
   3559 KSDDKAPI BOOLEAN NTAPI KsProcessPinUpdate (PKSPROCESSPIN ProcessPin);
   3560 
   3561 KSDDKAPI void NTAPI KsPinGetCopyRelationships
   3562 			(PKSPIN Pin, PKSPIN *CopySource, PKSPIN *DelegateBranch);
   3563 
   3564 KSDDKAPI void NTAPI KsPinAttemptProcessing(PKSPIN Pin, BOOLEAN Asynchronous);
   3565 KSDDKAPI PVOID NTAPI KsGetParent (PVOID Object);
   3566 
   3567 __forceinline PKSDEVICE KsFilterFactoryGetParentDevice (PKSFILTERFACTORY FilterFactory)
   3568 {
   3569 	return (PKSDEVICE) KsGetParent((PVOID) FilterFactory);
   3570 }
   3571 
   3572 __forceinline PKSFILTERFACTORY KsFilterGetParentFilterFactory (PKSFILTER Filter)
   3573 {
   3574 	return (PKSFILTERFACTORY) KsGetParent((PVOID) Filter);
   3575 }
   3576 
   3577 KSDDKAPI PKSFILTER NTAPI KsPinGetParentFilter (PKSPIN Pin);
   3578 KSDDKAPI PVOID NTAPI KsGetFirstChild (PVOID Object);
   3579 
   3580 __forceinline PKSFILTERFACTORY KsDeviceGetFirstChildFilterFactory (PKSDEVICE Device)
   3581 {
   3582 	return (PKSFILTERFACTORY) KsGetFirstChild((PVOID) Device);
   3583 }
   3584 
   3585 __forceinline PKSFILTER KsFilterFactoryGetFirstChildFilter (PKSFILTERFACTORY FilterFactory)
   3586 {
   3587 	return (PKSFILTER) KsGetFirstChild((PVOID) FilterFactory);
   3588 }
   3589 
   3590 KSDDKAPI ULONG NTAPI KsFilterGetChildPinCount(PKSFILTER Filter, ULONG PinId);
   3591 KSDDKAPI PKSPIN NTAPI KsFilterGetFirstChildPin(PKSFILTER Filter, ULONG PinId);
   3592 KSDDKAPI PVOID NTAPI KsGetNextSibling (PVOID Object);
   3593 KSDDKAPI PKSPIN NTAPI KsPinGetNextSiblingPin (PKSPIN Pin);
   3594 
   3595 __forceinline PKSFILTERFACTORY KsFilterFactoryGetNextSiblingFilterFactory
   3596 			(PKSFILTERFACTORY FilterFactory)
   3597 {
   3598 	return (PKSFILTERFACTORY) KsGetNextSibling((PVOID) FilterFactory);
   3599 }
   3600 
   3601 __forceinline PKSFILTER KsFilterGetNextSiblingFilter (PKSFILTER Filter)
   3602 {
   3603 	return (PKSFILTER) KsGetNextSibling((PVOID) Filter);
   3604 }
   3605 
   3606 KSDDKAPI PKSDEVICE NTAPI KsGetDevice (PVOID Object);
   3607 
   3608 __forceinline PKSDEVICE KsFilterFactoryGetDevice (PKSFILTERFACTORY FilterFactory)
   3609 {
   3610 	return KsGetDevice((PVOID) FilterFactory);
   3611 }
   3612 
   3613 __forceinline PKSDEVICE KsFilterGetDevice (PKSFILTER Filter)
   3614 {
   3615 	return KsGetDevice((PVOID) Filter);
   3616 }
   3617 
   3618 __forceinline PKSDEVICE KsPinGetDevice (PKSPIN Pin)
   3619 {
   3620 	return KsGetDevice((PVOID) Pin);
   3621 }
   3622 
   3623 KSDDKAPI PKSFILTER NTAPI KsGetFilterFromIrp (PIRP Irp);
   3624 KSDDKAPI PKSPIN NTAPI KsGetPinFromIrp (PIRP Irp);
   3625 KSDDKAPI ULONG NTAPI KsGetNodeIdFromIrp (PIRP Irp);
   3626 KSDDKAPI void NTAPI KsAcquireControl (PVOID Object);
   3627 KSDDKAPI void NTAPI KsReleaseControl (PVOID Object);
   3628 
   3629 __forceinline void KsFilterAcquireControl (PKSFILTER Filter)
   3630 {
   3631 	KsAcquireControl((PVOID) Filter);
   3632 }
   3633 
   3634 __forceinline void KsFilterReleaseControl (PKSFILTER Filter)
   3635 {
   3636 	KsReleaseControl((PVOID) Filter);
   3637 }
   3638 
   3639 __forceinline void KsPinAcquireControl (PKSPIN Pin)
   3640 {
   3641 	KsAcquireControl((PVOID) Pin);
   3642 }
   3643 
   3644 __forceinline void KsPinReleaseControl (PKSPIN Pin)
   3645 {
   3646 	KsReleaseControl((PVOID) Pin);
   3647 }
   3648 
   3649 KSDDKAPI NTSTATUS NTAPI KsAddItemToObjectBag
   3650 			(KSOBJECT_BAG ObjectBag, PVOID Item, PFNKSFREE Free);
   3651 
   3652 KSDDKAPI ULONG NTAPI KsRemoveItemFromObjectBag
   3653 			(KSOBJECT_BAG ObjectBag, PVOID Item, BOOLEAN Free);
   3654 
   3655 #define KsDiscard(Object,Pointer)					\
   3656 	KsRemoveItemFromObjectBag((Object)->Bag, (PVOID)(Pointer), TRUE)
   3657 
   3658 KSDDKAPI NTSTATUS NTAPI KsAllocateObjectBag(PKSDEVICE Device, KSOBJECT_BAG *ObjectBag);
   3659 KSDDKAPI void NTAPI KsFreeObjectBag (KSOBJECT_BAG ObjectBag);
   3660 
   3661 KSDDKAPI NTSTATUS NTAPI KsCopyObjectBagItems
   3662 			(KSOBJECT_BAG ObjectBagDestination, KSOBJECT_BAG ObjectBagSource);
   3663 
   3664 KSDDKAPI NTSTATUS NTAPI _KsEdit
   3665 			(KSOBJECT_BAG ObjectBag, PVOID *PointerToPointerToItem,
   3666 			 ULONG NewSize, ULONG OldSize, ULONG Tag);
   3667 
   3668 #define KsEdit(Object, PointerToPointer, Tag)						\
   3669 	_KsEdit((Object)->Bag, (PVOID*)(PointerToPointer),				\
   3670 		sizeof(**(PointerToPointer)), sizeof(**(PointerToPointer)), (Tag))
   3671 
   3672 #define KsEditSized(Object, PointerToPointer, NewSize, OldSize, Tag)			\
   3673 	_KsEdit((Object)->Bag, (PVOID*)(PointerToPointer), (NewSize), (OldSize), (Tag))
   3674 
   3675 KSDDKAPI NTSTATUS NTAPI KsRegisterFilterWithNoKSPins
   3676 			(PDEVICE_OBJECT DeviceObject, const GUID *InterfaceClassGUID,
   3677 			 ULONG PinCount, WINBOOL *PinDirection, KSPIN_MEDIUM *MediumList,
   3678 			 GUID *CategoryList);
   3679 
   3680 KSDDKAPI NTSTATUS NTAPI KsFilterCreatePinFactory
   3681 			(PKSFILTER Filter, const KSPIN_DESCRIPTOR_EX *const PinDescriptor,
   3682 			 PULONG PinID);
   3683 
   3684 KSDDKAPI NTSTATUS NTAPI KsFilterCreateNode
   3685 			(PKSFILTER Filter, const KSNODE_DESCRIPTOR *const NodeDescriptor,
   3686 			 PULONG NodeID);
   3687 
   3688 KSDDKAPI NTSTATUS NTAPI KsFilterAddTopologyConnections
   3689 			(PKSFILTER Filter, ULONG NewConnectionsCount,
   3690 			 const KSTOPOLOGY_CONNECTION *const NewTopologyConnections);
   3691 
   3692 KSDDKAPI NTSTATUS NTAPI KsPinGetConnectedPinInterface
   3693 			(PKSPIN Pin, const GUID *InterfaceId, PVOID *Interface);
   3694 
   3695 KSDDKAPI PFILE_OBJECT NTAPI KsPinGetConnectedPinFileObject (PKSPIN Pin);
   3696 KSDDKAPI PDEVICE_OBJECT NTAPI KsPinGetConnectedPinDeviceObject (PKSPIN Pin);
   3697 
   3698 KSDDKAPI NTSTATUS NTAPI KsPinGetConnectedFilterInterface
   3699 			(PKSPIN Pin, const GUID *InterfaceId, PVOID *Interface);
   3700 
   3701 #if defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__)
   3702 KSDDKAPI NTSTATUS NTAPI KsPinGetReferenceClockInterface
   3703 			(PKSPIN Pin, PIKSREFERENCECLOCK *Interface);
   3704 #endif /* defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__) */
   3705 
   3706 KSDDKAPI VOID NTAPI KsPinSetPinClockTime(PKSPIN Pin, LONGLONG Time);
   3707 
   3708 KSDDKAPI NTSTATUS NTAPI KsPinSubmitFrame
   3709 			(PKSPIN Pin, PVOID Data, ULONG Size,
   3710 			 PKSSTREAM_HEADER StreamHeader, PVOID Context);
   3711 
   3712 KSDDKAPI NTSTATUS NTAPI KsPinSubmitFrameMdl
   3713 			(PKSPIN Pin, PMDL Mdl, PKSSTREAM_HEADER StreamHeader,
   3714 			 PVOID Context);
   3715 
   3716 KSDDKAPI void NTAPI KsPinRegisterFrameReturnCallback
   3717 			(PKSPIN Pin, PFNKSPINFRAMERETURN FrameReturn);
   3718 
   3719 KSDDKAPI void NTAPI KsPinRegisterIrpCompletionCallback
   3720 			(PKSPIN Pin, PFNKSPINIRPCOMPLETION IrpCompletion);
   3721 
   3722 KSDDKAPI void NTAPI KsPinRegisterHandshakeCallback
   3723 			(PKSPIN Pin, PFNKSPINHANDSHAKE Handshake);
   3724 
   3725 KSDDKAPI void NTAPI KsFilterRegisterPowerCallbacks
   3726 			(PKSFILTER Filter, PFNKSFILTERPOWER Sleep, PFNKSFILTERPOWER Wake);
   3727 
   3728 KSDDKAPI void NTAPI KsPinRegisterPowerCallbacks
   3729 			(PKSPIN Pin, PFNKSPINPOWER Sleep, PFNKSPINPOWER Wake);
   3730 
   3731 #if defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__)
   3732 KSDDKAPI PUNKNOWN NTAPI KsRegisterAggregatedClientUnknown
   3733 			(PVOID Object, PUNKNOWN ClientUnknown);
   3734 
   3735 KSDDKAPI PUNKNOWN NTAPI KsGetOuterUnknown (PVOID Object);
   3736 
   3737 __forceinline PUNKNOWN KsDeviceRegisterAggregatedClientUnknown
   3738 			(PKSDEVICE Device, PUNKNOWN ClientUnknown)
   3739 {
   3740 	return KsRegisterAggregatedClientUnknown((PVOID)Device, ClientUnknown);
   3741 }
   3742 
   3743 __forceinline PUNKNOWN KsDeviceGetOuterUnknown (PKSDEVICE Device)
   3744 {
   3745 	return KsGetOuterUnknown((PVOID) Device);
   3746 }
   3747 
   3748 __forceinline PUNKNOWN KsFilterFactoryRegisterAggregatedClientUnknown
   3749 			(PKSFILTERFACTORY FilterFactory, PUNKNOWN ClientUnknown)
   3750 {
   3751 	return KsRegisterAggregatedClientUnknown((PVOID)FilterFactory, ClientUnknown);
   3752 }
   3753 
   3754 __forceinline PUNKNOWN KsFilterFactoryGetOuterUnknown (PKSFILTERFACTORY FilterFactory)
   3755 {
   3756 	return KsGetOuterUnknown((PVOID)FilterFactory);
   3757 }
   3758 
   3759 __forceinline PUNKNOWN KsFilterRegisterAggregatedClientUnknown
   3760 			(PKSFILTER Filter, PUNKNOWN ClientUnknown)
   3761 {
   3762 	return KsRegisterAggregatedClientUnknown((PVOID)Filter, ClientUnknown);
   3763 }
   3764 
   3765 __forceinline PUNKNOWN KsFilterGetOuterUnknown (PKSFILTER Filter)
   3766 {
   3767 	return KsGetOuterUnknown((PVOID)Filter);
   3768 }
   3769 
   3770 __forceinline PUNKNOWN KsPinRegisterAggregatedClientUnknown
   3771 			(PKSPIN Pin, PUNKNOWN ClientUnknown)
   3772 {
   3773 	return KsRegisterAggregatedClientUnknown((PVOID)Pin, ClientUnknown);
   3774 }
   3775 
   3776 __forceinline PUNKNOWN KsPinGetOuterUnknown (PKSPIN Pin)
   3777 {
   3778 	return KsGetOuterUnknown((PVOID)Pin);
   3779 }
   3780 #endif /* defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__) */
   3781 
   3782 #else /* _NTDDK_ */
   3783 
   3784 #ifndef KS_NO_CREATE_FUNCTIONS
   3785 KSDDKAPI DWORD WINAPI KsCreateAllocator(HANDLE ConnectionHandle,PKSALLOCATOR_FRAMING AllocatorFraming,PHANDLE AllocatorHandle);
   3786 KSDDKAPI DWORD NTAPI KsCreateClock(HANDLE ConnectionHandle,PKSCLOCK_CREATE ClockCreate,PHANDLE ClockHandle);
   3787 KSDDKAPI DWORD WINAPI KsCreatePin(HANDLE FilterHandle,PKSPIN_CONNECT Connect,ACCESS_MASK DesiredAccess,PHANDLE ConnectionHandle);
   3788 KSDDKAPI DWORD WINAPI KsCreateTopologyNode(HANDLE ParentHandle,PKSNODE_CREATE NodeCreate,ACCESS_MASK DesiredAccess,PHANDLE NodeHandle);
   3789 #endif
   3790 
   3791 #endif /* _NTDDK_ */
   3792 
   3793 #ifdef __cplusplus
   3794 }
   3795 #endif
   3796 
   3797 #define DENY_USERMODE_ACCESS(pIrp,CompleteRequest)			\
   3798 	if(pIrp->RequestorMode!=KernelMode) {				\
   3799 		pIrp->IoStatus.Information = 0;				\
   3800 		pIrp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;	\
   3801 		if(CompleteRequest)					\
   3802 			IoCompleteRequest (pIrp,IO_NO_INCREMENT);	\
   3803 		return STATUS_INVALID_DEVICE_REQUEST;			\
   3804 	}
   3805 
   3806 #endif /* _KS_ */
   3807 
   3808