Ks.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:145k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4.     ks.h
  5. Abstract:
  6.     Windows Driver Model/Connection and Streaming Architecture (WDM-CSA)
  7.     core definitions.
  8. --*/
  9. #if !defined(_KS_)
  10. #define _KS_
  11. #if defined(__TCS__)
  12. #define _KS_NO_ANONYMOUS_STRUCTURES_ 1
  13. #endif
  14. #if !defined(_NTRTL_)
  15.     #ifndef DEFINE_GUIDEX
  16.         #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
  17.     #endif // !defined(DEFINE_GUIDEX)
  18.     #ifndef STATICGUIDOF
  19.         #define STATICGUIDOF(guid) STATIC_##guid
  20.     #endif // !defined(STATICGUIDOF)
  21. #endif // !defined(_NTRTL_)
  22. #ifndef SIZEOF_ARRAY
  23.     #define SIZEOF_ARRAY(ar)        (sizeof(ar)/sizeof((ar)[0]))
  24. #endif // !defined(SIZEOF_ARRAY)
  25. #if defined(__cplusplus) && _MSC_VER >= 1100
  26. #define DEFINE_GUIDSTRUCT(g, n) struct __declspec(uuid(g)) n
  27. #define DEFINE_GUIDNAMED(n) __uuidof(struct n)
  28. #else // !defined(__cplusplus)
  29. #define DEFINE_GUIDSTRUCT(g, n) DEFINE_GUIDEX(n)
  30. #define DEFINE_GUIDNAMED(n) n
  31. #endif // !defined(__cplusplus)
  32. //===========================================================================
  33. #define STATIC_GUID_NULL 
  34.     0x00000000L, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  35. DEFINE_GUIDSTRUCT("00000000-0000-0000-0000-000000000000", GUID_NULL);
  36. #define GUID_NULL DEFINE_GUIDNAMED(GUID_NULL)
  37. //===========================================================================
  38. #define IOCTL_KS_PROPERTY              CTL_CODE(FILE_DEVICE_KS, 0x000, METHOD_NEITHER, FILE_ANY_ACCESS)
  39. #define IOCTL_KS_ENABLE_EVENT          CTL_CODE(FILE_DEVICE_KS, 0x001, METHOD_NEITHER, FILE_ANY_ACCESS)
  40. #define IOCTL_KS_DISABLE_EVENT         CTL_CODE(FILE_DEVICE_KS, 0x002, METHOD_NEITHER, FILE_ANY_ACCESS)
  41. #define IOCTL_KS_METHOD                CTL_CODE(FILE_DEVICE_KS, 0x003, METHOD_NEITHER, FILE_ANY_ACCESS)
  42. #define IOCTL_KS_WRITE_STREAM          CTL_CODE(FILE_DEVICE_KS, 0x004, METHOD_NEITHER, FILE_WRITE_ACCESS)
  43. #define IOCTL_KS_READ_STREAM           CTL_CODE(FILE_DEVICE_KS, 0x005, METHOD_NEITHER, FILE_READ_ACCESS)
  44. #define IOCTL_KS_RESET_STATE           CTL_CODE(FILE_DEVICE_KS, 0x006, METHOD_NEITHER, FILE_ANY_ACCESS)
  45. //===========================================================================
  46. typedef enum {
  47.     KSRESET_BEGIN,
  48.     KSRESET_END
  49. } KSRESET;
  50. typedef enum {
  51.     KSSTATE_STOP,
  52.     KSSTATE_ACQUIRE,
  53.     KSSTATE_PAUSE,
  54.     KSSTATE_RUN
  55. } KSSTATE, *PKSSTATE;
  56. #define KSPRIORITY_LOW        0x00000001
  57. #define KSPRIORITY_NORMAL     0x40000000
  58. #define KSPRIORITY_HIGH       0x80000000
  59. #define KSPRIORITY_EXCLUSIVE  0xFFFFFFFF
  60. typedef struct {
  61.     ULONG   PriorityClass;
  62.     ULONG   PrioritySubClass;
  63. } KSPRIORITY, *PKSPRIORITY;
  64. typedef struct {
  65.     union {
  66. #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
  67.         struct _IDENTIFIER {
  68. #else        
  69.         struct {
  70. #endif        
  71.             GUID    Set;
  72.             ULONG   Id;
  73.             ULONG   Flags;
  74.         };
  75.         LONGLONG    Alignment;
  76.     };
  77. } KSIDENTIFIER, *PKSIDENTIFIER;
  78. typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY, KSMETHOD, *PKSMETHOD, KSEVENT, *PKSEVENT;
  79. #define KSMETHOD_TYPE_NONE                  0x00000000
  80. #define KSMETHOD_TYPE_READ                  0x00000001
  81. #define KSMETHOD_TYPE_WRITE                 0x00000002
  82. #define KSMETHOD_TYPE_MODIFY                0x00000003
  83. #define KSMETHOD_TYPE_SOURCE                0x00000004
  84. #define KSMETHOD_TYPE_SEND                  0x00000001
  85. #define KSMETHOD_TYPE_SETSUPPORT            0x00000100
  86. #define KSMETHOD_TYPE_BASICSUPPORT          0x00000200
  87. #define KSMETHOD_TYPE_TOPOLOGY 0x10000000
  88. #define KSPROPERTY_TYPE_GET                 0x00000001
  89. #define KSPROPERTY_TYPE_SET                 0x00000002
  90. #define KSPROPERTY_TYPE_SETSUPPORT          0x00000100
  91. #define KSPROPERTY_TYPE_BASICSUPPORT        0x00000200
  92. #define KSPROPERTY_TYPE_RELATIONS           0x00000400
  93. #define KSPROPERTY_TYPE_SERIALIZESET        0x00000800
  94. #define KSPROPERTY_TYPE_UNSERIALIZESET      0x00001000
  95. #define KSPROPERTY_TYPE_SERIALIZERAW        0x00002000
  96. #define KSPROPERTY_TYPE_UNSERIALIZERAW      0x00004000
  97. #define KSPROPERTY_TYPE_SERIALIZESIZE       0x00008000
  98. #define KSPROPERTY_TYPE_DEFAULTVALUES       0x00010000
  99. #define KSPROPERTY_TYPE_TOPOLOGY 0x10000000
  100. typedef struct {
  101.     KSPROPERTY      Property;
  102.     ULONG           NodeId;
  103.     ULONG           Reserved;
  104. } KSP_NODE, *PKSP_NODE;
  105. typedef struct {
  106.     KSMETHOD        Method;
  107.     ULONG           NodeId;
  108.     ULONG           Reserved;
  109. } KSM_NODE, *PKSM_NODE;
  110. typedef struct {
  111.     KSEVENT         Event;
  112.     ULONG           NodeId;
  113.     ULONG           Reserved;
  114. } KSE_NODE, *PKSE_NODE;
  115. #define STATIC_KSPROPTYPESETID_General 
  116.     0x97E99BA0L, 0xBDEA, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  117. DEFINE_GUIDSTRUCT("97E99BA0-BDEA-11CF-A5D6-28DB04C10000", KSPROPTYPESETID_General);
  118. #define KSPROPTYPESETID_General DEFINE_GUIDNAMED(KSPROPTYPESETID_General)
  119. #if defined(_NTDDK_) && !defined(__wtypes_h__)
  120. enum VARENUM {
  121.     VT_EMPTY = 0,
  122.     VT_NULL = 1,
  123.     VT_I2 = 2,
  124.     VT_I4 = 3,
  125.     VT_R4 = 4,
  126.     VT_R8 = 5,
  127.     VT_CY = 6,
  128.     VT_DATE = 7,
  129.     VT_BSTR = 8,
  130.     VT_DISPATCH = 9,
  131.     VT_ERROR = 10,
  132.     VT_BOOL = 11,
  133.     VT_VARIANT = 12,
  134.     VT_UNKNOWN = 13,
  135.     VT_DECIMAL = 14,
  136.     VT_I1 = 16,
  137.     VT_UI1 = 17,
  138.     VT_UI2 = 18,
  139.     VT_UI4 = 19,
  140.     VT_I8 = 20,
  141.     VT_UI8 = 21,
  142.     VT_INT = 22,
  143.     VT_UINT = 23,
  144.     VT_VOID = 24,
  145.     VT_HRESULT  = 25,
  146.     VT_PTR = 26,
  147.     VT_SAFEARRAY = 27,
  148.     VT_CARRAY = 28,
  149.     VT_USERDEFINED = 29,
  150.     VT_LPSTR = 30,
  151.     VT_LPWSTR = 31,
  152.     VT_FILETIME = 64,
  153.     VT_BLOB = 65,
  154.     VT_STREAM = 66,
  155.     VT_STORAGE = 67,
  156.     VT_STREAMED_OBJECT = 68,
  157.     VT_STORED_OBJECT = 69,
  158.     VT_BLOB_OBJECT = 70,
  159.     VT_CF = 71,
  160.     VT_CLSID = 72,
  161.     VT_VECTOR = 0x1000,
  162.     VT_ARRAY = 0x2000,
  163.     VT_BYREF = 0x4000,
  164.     VT_RESERVED = 0x8000,
  165.     VT_ILLEGAL = 0xffff,
  166.     VT_ILLEGALMASKED = 0xfff,
  167.     VT_TYPEMASK = 0xfff
  168. };
  169. #endif // _NTDDK_ && !__wtypes_h__
  170. typedef struct {
  171.     ULONG    Size;
  172.     ULONG    Count;
  173. } KSMULTIPLE_ITEM, *PKSMULTIPLE_ITEM;
  174. typedef struct {
  175.     ULONG           AccessFlags;
  176.     ULONG           DescriptionSize;
  177.     KSIDENTIFIER    PropTypeSet;
  178.     ULONG           MembersListCount;
  179.     ULONG           Reserved;
  180. } KSPROPERTY_DESCRIPTION, *PKSPROPERTY_DESCRIPTION;
  181. #define KSPROPERTY_MEMBER_RANGES            0x00000001
  182. #define KSPROPERTY_MEMBER_STEPPEDRANGES     0x00000002
  183. #define KSPROPERTY_MEMBER_VALUES            0x00000003
  184. #define KSPROPERTY_MEMBER_FLAG_DEFAULT                      0x00000001
  185. #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_MULTICHANNEL    0x00000002
  186. #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_UNIFORM         0x00000004
  187. typedef struct {
  188.     ULONG   MembersFlags;
  189.     ULONG   MembersSize;
  190.     ULONG   MembersCount;
  191.     ULONG   Flags;
  192. } KSPROPERTY_MEMBERSHEADER, *PKSPROPERTY_MEMBERSHEADER;
  193. typedef union {
  194. #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
  195.     struct _SIGNED {
  196. #else
  197.     struct {
  198. #endif    
  199.         LONG    SignedMinimum;
  200.         LONG    SignedMaximum;
  201.     };
  202. #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
  203.     struct _UNSIGNED {
  204. #else
  205.     struct {
  206. #endif    
  207.         ULONG   UnsignedMinimum;
  208.         ULONG   UnsignedMaximum;
  209.     };
  210. } KSPROPERTY_BOUNDS_LONG, *PKSPROPERTY_BOUNDS_LONG;
  211. typedef union {
  212. #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
  213.     struct _SIGNED64 {
  214. #else
  215.     struct {
  216. #endif    
  217.         LONGLONG    SignedMinimum;
  218.         LONGLONG    SignedMaximum;
  219.     };
  220. #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
  221.     struct _UNSIGNED64 {
  222. #else
  223.     struct {
  224. #endif    
  225. #if defined(_NTDDK_)
  226.         ULONGLONG   UnsignedMinimum;
  227.         ULONGLONG   UnsignedMaximum;
  228. #else // !_NTDDK_
  229.         DWORDLONG   UnsignedMinimum;
  230.         DWORDLONG   UnsignedMaximum;
  231. #endif // !_NTDDK_
  232.     };
  233. } KSPROPERTY_BOUNDS_LONGLONG, *PKSPROPERTY_BOUNDS_LONGLONG;
  234. typedef struct {
  235.     ULONG                       SteppingDelta;
  236.     ULONG                       Reserved;
  237.     KSPROPERTY_BOUNDS_LONG      Bounds;
  238. } KSPROPERTY_STEPPING_LONG, *PKSPROPERTY_STEPPING_LONG;
  239. typedef struct {
  240. #if defined(_NTDDK_)
  241.     ULONGLONG                   SteppingDelta;
  242. #else // !_NTDDK_
  243.     DWORDLONG                   SteppingDelta;
  244. #endif // !_NTDDK_
  245.     KSPROPERTY_BOUNDS_LONGLONG  Bounds;
  246. } KSPROPERTY_STEPPING_LONGLONG, *PKSPROPERTY_STEPPING_LONGLONG;
  247. //===========================================================================
  248. #if defined(_NTDDK_)
  249. //
  250. // Structure forward declarations.
  251. //
  252. typedef struct _KSDEVICE_DESCRIPTOR
  253. KSDEVICE_DESCRIPTOR, *PKSDEVICE_DESCRIPTOR;
  254. typedef struct _KSDEVICE_DISPATCH
  255. KSDEVICE_DISPATCH, *PKSDEVICE_DISPATCH;
  256. typedef struct _KSDEVICE 
  257. KSDEVICE, *PKSDEVICE;
  258. typedef struct _KSFILTERFACTORY 
  259. KSFILTERFACTORY, *PKSFILTERFACTORY;
  260. typedef struct _KSFILTER_DESCRIPTOR
  261. KSFILTER_DESCRIPTOR, *PKSFILTER_DESCRIPTOR;
  262. typedef struct _KSFILTER_DISPATCH
  263. KSFILTER_DISPATCH, *PKSFILTER_DISPATCH;
  264. typedef struct _KSFILTER 
  265. KSFILTER, *PKSFILTER;
  266. typedef struct _KSPIN_DESCRIPTOR_EX
  267. KSPIN_DESCRIPTOR_EX, *PKSPIN_DESCRIPTOR_EX;
  268. typedef struct _KSPIN_DISPATCH
  269. KSPIN_DISPATCH, *PKSPIN_DISPATCH;
  270. typedef struct _KSCLOCK_DISPATCH
  271. KSCLOCK_DISPATCH, *PKSCLOCK_DISPATCH;
  272. typedef struct _KSALLOCATOR_DISPATCH
  273. KSALLOCATOR_DISPATCH, *PKSALLOCATOR_DISPATCH;
  274. typedef struct _KSPIN 
  275. KSPIN, *PKSPIN;
  276. typedef struct _KSNODE_DESCRIPTOR
  277. KSNODE_DESCRIPTOR, *PKSNODE_DESCRIPTOR;
  278. typedef struct _KSSTREAM_POINTER_OFFSET
  279. KSSTREAM_POINTER_OFFSET, *PKSSTREAM_POINTER_OFFSET;
  280. typedef struct _KSSTREAM_POINTER
  281. KSSTREAM_POINTER, *PKSSTREAM_POINTER;
  282. typedef struct _KSMAPPING
  283. KSMAPPING, *PKSMAPPING;
  284. typedef struct _KSPROCESSPIN
  285. KSPROCESSPIN, *PKSPROCESSPIN;
  286. typedef struct _KSPROCESSPIN_INDEXENTRY
  287. KSPROCESSPIN_INDEXENTRY, *PKSPROCESSPIN_INDEXENTRY;
  288. #endif // _NTDDK_
  289. typedef PVOID PKSWORKER;
  290. typedef struct {
  291.     ULONG       NotificationType;
  292.     union {
  293.         struct {
  294.             HANDLE              Event;
  295.             ULONG_PTR           Reserved[2];
  296.         } EventHandle;
  297.         struct {
  298.             HANDLE              Semaphore;
  299.             ULONG               Reserved;
  300.             LONG                Adjustment;
  301.         } SemaphoreHandle;
  302. #if defined(_NTDDK_)
  303.         struct {
  304.             PVOID               Event;
  305.             KPRIORITY           Increment;
  306.             ULONG_PTR           Reserved;
  307.         } EventObject;
  308.         struct {
  309.             PVOID               Semaphore;
  310.             KPRIORITY           Increment;
  311.             LONG                Adjustment;
  312.         } SemaphoreObject;
  313.         struct {
  314.             PKDPC               Dpc;
  315.             ULONG               ReferenceCount;
  316.             ULONG_PTR           Reserved;
  317.         } Dpc;
  318.         struct {
  319.             PWORK_QUEUE_ITEM    WorkQueueItem;
  320.             WORK_QUEUE_TYPE     WorkQueueType;
  321.             ULONG_PTR           Reserved;
  322.         } WorkItem;
  323.         struct {
  324.             PWORK_QUEUE_ITEM    WorkQueueItem;
  325.             PKSWORKER           KsWorkerObject;
  326.             ULONG_PTR           Reserved;
  327.         } KsWorkItem;
  328. // @@BEGIN_DDKSPLIT
  329.         struct {
  330.             PKSFILTER           Filter;
  331.             ULONG_PTR           Reserved[2];
  332.         } KsFilterProcessing;
  333.         struct {
  334.             PKSPIN              Pin;
  335.             ULONG_PTR           Reserved[2];
  336.         } KsPinProcessing;
  337. // @@END_DDKSPLIT
  338. #endif // defined(_NTDDK_)
  339.         struct {
  340.             PVOID               Unused;
  341.             LONG_PTR            Alignment[2];
  342.         } Alignment;
  343.     };
  344. } KSEVENTDATA, *PKSEVENTDATA;
  345. #define KSEVENTF_EVENT_HANDLE       0x00000001
  346. #define KSEVENTF_SEMAPHORE_HANDLE   0x00000002
  347. #if defined(_NTDDK_)
  348. #define KSEVENTF_EVENT_OBJECT       0x00000004
  349. #define KSEVENTF_SEMAPHORE_OBJECT   0x00000008
  350. #define KSEVENTF_DPC                0x00000010
  351. #define KSEVENTF_WORKITEM           0x00000020
  352. #define KSEVENTF_KSWORKITEM         0x00000080
  353. // @@BEGIN_DDKSPLIT
  354. #define KSEVENTF_KSFILTERPROCESSING 0x00000100
  355. #define KSEVENTF_KSPINPROCESSING    0x00000200
  356. // @@END_DDKSPLIT
  357. #endif // defined(_NTDDK_)
  358. #define KSEVENT_TYPE_ENABLE         0x00000001
  359. #define KSEVENT_TYPE_ONESHOT        0x00000002
  360. #define KSEVENT_TYPE_ENABLEBUFFERED 0x00000004
  361. #define KSEVENT_TYPE_SETSUPPORT     0x00000100
  362. #define KSEVENT_TYPE_BASICSUPPORT   0x00000200
  363. #define KSEVENT_TYPE_QUERYBUFFER    0x00000400
  364. #define KSEVENT_TYPE_TOPOLOGY 0x10000000
  365. typedef struct {
  366.     KSEVENT         Event;
  367.     PKSEVENTDATA    EventData;
  368.     PVOID           Reserved;
  369. } KSQUERYBUFFER, *PKSQUERYBUFFER;
  370. typedef struct {
  371.     ULONG Size;
  372.     ULONG Flags;
  373.     union {
  374.         HANDLE ObjectHandle;
  375.         PVOID ObjectPointer;
  376.     };
  377.     PVOID Reserved;
  378.     KSEVENT Event;
  379.     KSEVENTDATA EventData;
  380. } KSRELATIVEEVENT;
  381. #define KSRELATIVEEVENT_FLAG_HANDLE 0x00000001
  382. #define KSRELATIVEEVENT_FLAG_POINTER 0x00000002
  383. //===========================================================================
  384. typedef struct {
  385.     KSEVENTDATA     EventData;
  386.     LONGLONG        MarkTime;
  387. } KSEVENT_TIME_MARK, *PKSEVENT_TIME_MARK;
  388. typedef struct {
  389.     KSEVENTDATA     EventData;
  390.     LONGLONG        TimeBase;
  391.     LONGLONG        Interval;
  392. } KSEVENT_TIME_INTERVAL, *PKSEVENT_TIME_INTERVAL;
  393. typedef struct {
  394.     LONGLONG        TimeBase;
  395.     LONGLONG        Interval;
  396. } KSINTERVAL, *PKSINTERVAL;
  397. //===========================================================================
  398. #define STATIC_KSPROPSETID_General
  399.     0x1464EDA5L, 0x6A8F, 0x11D1, 0x9A, 0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  400. DEFINE_GUIDSTRUCT("1464EDA5-6A8F-11D1-9AA7-00A0C9223196", KSPROPSETID_General);
  401. #define KSPROPSETID_General DEFINE_GUIDNAMED(KSPROPSETID_General)
  402. typedef enum {
  403.     KSPROPERTY_GENERAL_COMPONENTID
  404. } KSPROPERTY_GENERAL;
  405. typedef struct {
  406.     GUID    Manufacturer;
  407.     GUID    Product;
  408.     GUID    Component;
  409.     GUID    Name;
  410.     ULONG   Version;
  411.     ULONG   Revision;
  412. } KSCOMPONENTID, *PKSCOMPONENTID;
  413. #define DEFINE_KSPROPERTY_ITEM_GENERAL_COMPONENTID(Handler)
  414.     DEFINE_KSPROPERTY_ITEM(
  415.         KSPROPERTY_GENERAL_COMPONENTID,
  416.         (Handler),
  417.         sizeof(KSPROPERTY),
  418.         sizeof(KSCOMPONENTID),
  419.         NULL, NULL, 0, NULL, NULL, 0)
  420. #define STATIC_KSMETHODSETID_StreamIo
  421.     0x65D003CAL, 0x1523, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  422. DEFINE_GUIDSTRUCT("65D003CA-1523-11D2-B27A-00A0C9223196", KSMETHODSETID_StreamIo);
  423. #define KSMETHODSETID_StreamIo DEFINE_GUIDNAMED(KSMETHODSETID_StreamIo)
  424. typedef enum {
  425.     KSMETHOD_STREAMIO_READ,
  426.     KSMETHOD_STREAMIO_WRITE
  427. } KSMETHOD_STREAMIO;
  428. #define DEFINE_KSMETHOD_ITEM_STREAMIO_READ(Handler)
  429.     DEFINE_KSMETHOD_ITEM(
  430.         KSMETHOD_STREAMIO_READ,
  431.         KSMETHOD_TYPE_WRITE,
  432.         (Handler),
  433.         sizeof(KSMETHOD),
  434.         0,
  435.         NULL)
  436. #define DEFINE_KSMETHOD_ITEM_STREAMIO_WRITE(Handler)
  437.     DEFINE_KSMETHOD_ITEM(
  438.         KSMETHOD_STREAMIO_WRITE,
  439.         KSMETHOD_TYPE_READ,
  440.         (Handler),
  441.         sizeof(KSMETHOD),
  442.         0,
  443.         NULL)
  444. #define STATIC_KSPROPSETID_MediaSeeking
  445.     0xEE904F0CL, 0xD09B, 0x11D0, 0xAB, 0xE9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  446. DEFINE_GUIDSTRUCT("EE904F0C-D09B-11D0-ABE9-00A0C9223196", KSPROPSETID_MediaSeeking);
  447. #define KSPROPSETID_MediaSeeking DEFINE_GUIDNAMED(KSPROPSETID_MediaSeeking)
  448. typedef enum {
  449.     KSPROPERTY_MEDIASEEKING_CAPABILITIES,
  450.     KSPROPERTY_MEDIASEEKING_FORMATS,
  451.     KSPROPERTY_MEDIASEEKING_TIMEFORMAT,
  452.     KSPROPERTY_MEDIASEEKING_POSITION,
  453.     KSPROPERTY_MEDIASEEKING_STOPPOSITION,
  454.     KSPROPERTY_MEDIASEEKING_POSITIONS,
  455.     KSPROPERTY_MEDIASEEKING_DURATION,
  456.     KSPROPERTY_MEDIASEEKING_AVAILABLE,
  457.     KSPROPERTY_MEDIASEEKING_PREROLL,
  458.     KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT
  459. } KSPROPERTY_MEDIASEEKING;
  460. typedef enum {
  461.     KS_SEEKING_NoPositioning,
  462.     KS_SEEKING_AbsolutePositioning,
  463.     KS_SEEKING_RelativePositioning,
  464.     KS_SEEKING_IncrementalPositioning,
  465.     KS_SEEKING_PositioningBitsMask = 0x3,
  466.     KS_SEEKING_SeekToKeyFrame,
  467.     KS_SEEKING_ReturnTime = 0x8
  468. } KS_SEEKING_FLAGS;
  469. typedef enum {
  470.     KS_SEEKING_CanSeekAbsolute = 0x1,
  471.     KS_SEEKING_CanSeekForwards = 0x2,
  472.     KS_SEEKING_CanSeekBackwards = 0x4,
  473.     KS_SEEKING_CanGetCurrentPos = 0x8,
  474.     KS_SEEKING_CanGetStopPos = 0x10,
  475.     KS_SEEKING_CanGetDuration = 0x20,
  476.     KS_SEEKING_CanPlayBackwards = 0x40
  477. } KS_SEEKING_CAPABILITIES;
  478. typedef struct {
  479.     LONGLONG            Current;
  480.     LONGLONG            Stop;
  481.     KS_SEEKING_FLAGS    CurrentFlags;
  482.     KS_SEEKING_FLAGS    StopFlags;
  483. } KSPROPERTY_POSITIONS, *PKSPROPERTY_POSITIONS;
  484. typedef struct {
  485.     LONGLONG    Earliest;
  486.     LONGLONG    Latest;
  487. } KSPROPERTY_MEDIAAVAILABLE, *PKSPROPERTY_MEDIAAVAILABLE;
  488. typedef struct {
  489.     KSPROPERTY  Property;
  490.     GUID        SourceFormat;
  491.     GUID        TargetFormat;
  492.     LONGLONG    Time;
  493. } KSP_TIMEFORMAT, *PKSP_TIMEFORMAT;
  494. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CAPABILITIES(Handler)
  495.     DEFINE_KSPROPERTY_ITEM(
  496.         KSPROPERTY_MEDIASEEKING_CAPABILITIES,
  497.         (Handler),
  498.         sizeof(KSPROPERTY),
  499.         sizeof(KS_SEEKING_CAPABILITIES),
  500.         NULL, NULL, 0, NULL, NULL, 0)
  501. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_FORMATS(Handler)
  502.     DEFINE_KSPROPERTY_ITEM(
  503.         KSPROPERTY_MEDIASEEKING_FORMATS,
  504.         (Handler),
  505.         sizeof(KSPROPERTY),
  506.         0,
  507.         NULL, NULL, 0, NULL, NULL, 0)
  508. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_TIMEFORMAT(GetHandler, SetHandler)
  509.     DEFINE_KSPROPERTY_ITEM(
  510.         KSPROPERTY_MEDIASEEKING_TIMEFORMAT,
  511.         (GetHandler),
  512.         sizeof(KSPROPERTY),
  513.         sizeof(GUID),
  514.         (SetHandler),
  515.         NULL, 0, NULL, NULL, 0)
  516. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITION(Handler)
  517.     DEFINE_KSPROPERTY_ITEM(
  518.         KSPROPERTY_MEDIASEEKING_POSITION,
  519.         (Handler),
  520.         sizeof(KSPROPERTY),
  521.         sizeof(LONGLONG),
  522.         NULL, NULL, 0, NULL, NULL, 0)
  523. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_STOPPOSITION(Handler)
  524.     DEFINE_KSPROPERTY_ITEM(
  525.         KSPROPERTY_MEDIASEEKING_STOPPOSITION,
  526.         (Handler),
  527.         sizeof(KSPROPERTY),
  528.         sizeof(LONGLONG),
  529.         NULL, NULL, 0, NULL, NULL, 0)
  530. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITIONS(Handler)
  531.     DEFINE_KSPROPERTY_ITEM(
  532.         KSPROPERTY_MEDIASEEKING_POSITIONS,
  533.         NULL,
  534.         sizeof(KSPROPERTY),
  535.         sizeof(KSPROPERTY_POSITIONS),
  536.         (Handler),
  537.         NULL, 0, NULL, NULL, 0)
  538. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_DURATION(Handler)
  539.     DEFINE_KSPROPERTY_ITEM(
  540.         KSPROPERTY_MEDIASEEKING_DURATION,
  541.         (Handler),
  542.         sizeof(KSPROPERTY),
  543.         sizeof(LONGLONG),
  544.         NULL, NULL, 0, NULL, NULL, 0)
  545. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_AVAILABLE(Handler)
  546.     DEFINE_KSPROPERTY_ITEM(
  547.         KSPROPERTY_MEDIASEEKING_AVAILABLE,
  548.         (Handler),
  549.         sizeof(KSPROPERTY),
  550.         sizeof(KSPROPERTY_MEDIAAVAILABLE),
  551.         NULL, NULL, 0, NULL, NULL, 0)
  552. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_PREROLL(Handler)
  553.     DEFINE_KSPROPERTY_ITEM(
  554.         KSPROPERTY_MEDIASEEKING_PREROLL,
  555.         (Handler),
  556.         sizeof(KSPROPERTY),
  557.         sizeof(LONGLONG),
  558.         NULL, NULL, 0, NULL, NULL, 0)
  559. #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CONVERTTIMEFORMAT(Handler)
  560.     DEFINE_KSPROPERTY_ITEM(
  561.         KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT,
  562.         (Handler),
  563.         sizeof(KSP_TIMEFORMAT),
  564.         sizeof(LONGLONG),
  565.         NULL, NULL, 0, NULL, NULL, 0)
  566. //===========================================================================
  567. #define STATIC_KSPROPSETID_Topology
  568.     0x720D4AC0L, 0x7533, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  569. DEFINE_GUIDSTRUCT("720D4AC0-7533-11D0-A5D6-28DB04C10000", KSPROPSETID_Topology);
  570. #define KSPROPSETID_Topology DEFINE_GUIDNAMED(KSPROPSETID_Topology)
  571. typedef enum {
  572.     KSPROPERTY_TOPOLOGY_CATEGORIES,
  573.     KSPROPERTY_TOPOLOGY_NODES,
  574.     KSPROPERTY_TOPOLOGY_CONNECTIONS,
  575.     KSPROPERTY_TOPOLOGY_NAME
  576. } KSPROPERTY_TOPOLOGY;
  577. #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler)
  578.     DEFINE_KSPROPERTY_ITEM(
  579.         KSPROPERTY_TOPOLOGY_CATEGORIES,
  580.         (Handler),
  581.         sizeof(KSPROPERTY),
  582.         0,
  583.         NULL, NULL, 0, NULL, NULL, 0)
  584. #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler)
  585.     DEFINE_KSPROPERTY_ITEM(
  586.         KSPROPERTY_TOPOLOGY_NODES,
  587.         (Handler),
  588.         sizeof(KSPROPERTY),
  589.         0,
  590.         NULL, NULL, 0, NULL, NULL, 0)
  591. #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler)
  592.     DEFINE_KSPROPERTY_ITEM(
  593.         KSPROPERTY_TOPOLOGY_CONNECTIONS,
  594.         (Handler),
  595.         sizeof(KSPROPERTY),
  596.         0,
  597.         NULL, NULL, 0, NULL, NULL, 0)
  598. #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)
  599.     DEFINE_KSPROPERTY_ITEM(
  600.         KSPROPERTY_TOPOLOGY_NAME,
  601.         (Handler),
  602.         sizeof(KSP_NODE),
  603.         0,
  604.         NULL, NULL, 0, NULL, NULL, 0)
  605. #define DEFINE_KSPROPERTY_TOPOLOGYSET(TopologySet, Handler)
  606. DEFINE_KSPROPERTY_TABLE(TopologySet) {
  607.     DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler),
  608.     DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler),
  609.     DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler),
  610.     DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)
  611. }
  612. //=============================================================================
  613. //
  614. // properties used by graph manager to talk to particular filters
  615. //
  616. #if defined(_NTDDK_)
  617. #define STATIC_KSPROPSETID_GM 
  618.     0xAF627536L, 0xE719, 0x11D2, 0x8A, 0x1D, 0x00, 0x60, 0x97, 0xD2, 0xDF, 0x5D    
  619. DEFINE_GUIDSTRUCT("AF627536-E719-11D2-8A1D-006097D2DF5D", KSPROPSETID_GM);
  620. #define KSPROPSETID_GM DEFINE_GUIDNAMED(KSPROPSETID_GM)
  621. typedef VOID (*PFNKSGRAPHMANAGER_NOTIFY)(IN PFILE_OBJECT GraphManager,
  622.                                          IN ULONG EventId,
  623.                                          IN PVOID Filter,
  624.                                          IN PVOID Pin,
  625.                                          IN PVOID Frame,
  626.                                          IN ULONG Duration);
  627. typedef struct KSGRAPHMANAGER_FUNCTIONTABLE {
  628.     PFNKSGRAPHMANAGER_NOTIFY NotifyEvent;
  629. } KSGRAPHMANAGER_FUNCTIONTABLE, PKSGRAPHMANAGER_FUNCTIONTABLE;
  630. typedef struct _KSPROPERTY_GRAPHMANAGER_INTERFACE {
  631.     PFILE_OBJECT                 GraphManager;
  632.     KSGRAPHMANAGER_FUNCTIONTABLE FunctionTable;
  633. } KSPROPERTY_GRAPHMANAGER_INTERFACE, *PKSPROPERTY_GRAPHMANAGER_INTERFACE;
  634. //
  635. // Commands
  636. //
  637. typedef enum {
  638.     KSPROPERTY_GM_GRAPHMANAGER,    
  639.     KSPROPERTY_GM_TIMESTAMP_CLOCK, 
  640.     KSPROPERTY_GM_RATEMATCH,       
  641.     KSPROPERTY_GM_RENDER_CLOCK,    
  642. } KSPROPERTY_GM;
  643. #endif
  644. //===========================================================================
  645. #define STATIC_KSCATEGORY_BRIDGE 
  646.     0x085AFF00L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  647. DEFINE_GUIDSTRUCT("085AFF00-62CE-11CF-A5D6-28DB04C10000", KSCATEGORY_BRIDGE);
  648. #define KSCATEGORY_BRIDGE DEFINE_GUIDNAMED(KSCATEGORY_BRIDGE)
  649. #define STATIC_KSCATEGORY_CAPTURE 
  650.     0x65E8773DL, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  651. DEFINE_GUIDSTRUCT("65E8773D-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_CAPTURE);
  652. #define KSCATEGORY_CAPTURE DEFINE_GUIDNAMED(KSCATEGORY_CAPTURE)
  653. #define STATIC_KSCATEGORY_RENDER 
  654.     0x65E8773EL, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  655. DEFINE_GUIDSTRUCT("65E8773E-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_RENDER);
  656. #define KSCATEGORY_RENDER DEFINE_GUIDNAMED(KSCATEGORY_RENDER)
  657. #define STATIC_KSCATEGORY_MIXER 
  658.     0xAD809C00L, 0x7B88, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  659. DEFINE_GUIDSTRUCT("AD809C00-7B88-11D0-A5D6-28DB04C10000", KSCATEGORY_MIXER);
  660. #define KSCATEGORY_MIXER DEFINE_GUIDNAMED(KSCATEGORY_MIXER)
  661. #define STATIC_KSCATEGORY_SPLITTER 
  662.     0x0A4252A0L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  663. DEFINE_GUIDSTRUCT("0A4252A0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_SPLITTER);
  664. #define KSCATEGORY_SPLITTER DEFINE_GUIDNAMED(KSCATEGORY_SPLITTER)
  665. #define STATIC_KSCATEGORY_DATACOMPRESSOR 
  666.     0x1E84C900L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  667. DEFINE_GUIDSTRUCT("1E84C900-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATACOMPRESSOR);
  668. #define KSCATEGORY_DATACOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATACOMPRESSOR)
  669. #define STATIC_KSCATEGORY_DATADECOMPRESSOR 
  670.     0x2721AE20L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  671. DEFINE_GUIDSTRUCT("2721AE20-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATADECOMPRESSOR);
  672. #define KSCATEGORY_DATADECOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATADECOMPRESSOR)
  673. #define STATIC_KSCATEGORY_DATATRANSFORM 
  674.     0x2EB07EA0L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  675. DEFINE_GUIDSTRUCT("2EB07EA0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATATRANSFORM);
  676. #define KSCATEGORY_DATATRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_DATATRANSFORM)
  677. #define STATIC_KSCATEGORY_COMMUNICATIONSTRANSFORM 
  678.     0xCF1DDA2CL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  679. DEFINE_GUIDSTRUCT("CF1DDA2C-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_COMMUNICATIONSTRANSFORM);
  680. #define KSCATEGORY_COMMUNICATIONSTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_COMMUNICATIONSTRANSFORM)
  681. #define STATIC_KSCATEGORY_INTERFACETRANSFORM 
  682.     0xCF1DDA2DL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  683. DEFINE_GUIDSTRUCT("CF1DDA2D-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_INTERFACETRANSFORM);
  684. #define KSCATEGORY_INTERFACETRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_INTERFACETRANSFORM)
  685. #define STATIC_KSCATEGORY_MEDIUMTRANSFORM 
  686.     0xCF1DDA2EL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  687. DEFINE_GUIDSTRUCT("CF1DDA2E-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_MEDIUMTRANSFORM);
  688. #define KSCATEGORY_MEDIUMTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_MEDIUMTRANSFORM)
  689. #define STATIC_KSCATEGORY_FILESYSTEM 
  690.     0x760FED5EL, 0x9357, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  691. DEFINE_GUIDSTRUCT("760FED5E-9357-11D0-A3CC-00A0C9223196", KSCATEGORY_FILESYSTEM);
  692. #define KSCATEGORY_FILESYSTEM DEFINE_GUIDNAMED(KSCATEGORY_FILESYSTEM)
  693. // KSNAME_Clock
  694. #define STATIC_KSCATEGORY_CLOCK 
  695.     0x53172480L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  696. DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000", KSCATEGORY_CLOCK);
  697. #define KSCATEGORY_CLOCK DEFINE_GUIDNAMED(KSCATEGORY_CLOCK)
  698. #define STATIC_KSCATEGORY_PROXY 
  699.     0x97EBAACAL, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  700. DEFINE_GUIDSTRUCT("97EBAACA-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_PROXY);
  701. #define KSCATEGORY_PROXY DEFINE_GUIDNAMED(KSCATEGORY_PROXY)
  702. #define STATIC_KSCATEGORY_QUALITY 
  703.     0x97EBAACBL, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  704. DEFINE_GUIDSTRUCT("97EBAACB-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_QUALITY);
  705. #define KSCATEGORY_QUALITY DEFINE_GUIDNAMED(KSCATEGORY_QUALITY)
  706. typedef struct {
  707.     ULONG   FromNode;
  708.     ULONG   FromNodePin;
  709.     ULONG   ToNode;
  710.     ULONG   ToNodePin;
  711. } KSTOPOLOGY_CONNECTION, *PKSTOPOLOGY_CONNECTION;
  712. typedef struct {
  713.     ULONG                           CategoriesCount;
  714.     const GUID*                     Categories;
  715.     ULONG                           TopologyNodesCount;
  716.     const GUID*                     TopologyNodes;
  717.     ULONG                           TopologyConnectionsCount;
  718.     const KSTOPOLOGY_CONNECTION*    TopologyConnections;
  719.     const GUID*                     TopologyNodesNames;
  720.     ULONG                           Reserved;
  721. } KSTOPOLOGY, *PKSTOPOLOGY;
  722. #define KSFILTER_NODE   ((ULONG)-1)
  723. #define KSALL_NODES     ((ULONG)-1)
  724. typedef struct {
  725.     ULONG       CreateFlags;
  726.     ULONG       Node;
  727. } KSNODE_CREATE, *PKSNODE_CREATE;
  728. //===========================================================================
  729. // TIME_FORMAT_NONE
  730. #define STATIC_KSTIME_FORMAT_NONE       STATIC_GUID_NULL
  731. #define KSTIME_FORMAT_NONE              GUID_NULL
  732. // TIME_FORMAT_FRAME
  733. #define STATIC_KSTIME_FORMAT_FRAME
  734.     0x7b785570L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
  735. DEFINE_GUIDSTRUCT("7b785570-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_FRAME);
  736. #define KSTIME_FORMAT_FRAME DEFINE_GUIDNAMED(KSTIME_FORMAT_FRAME)
  737. // TIME_FORMAT_BYTE             
  738. #define STATIC_KSTIME_FORMAT_BYTE
  739.     0x7b785571L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
  740. DEFINE_GUIDSTRUCT("7b785571-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_BYTE);
  741. #define KSTIME_FORMAT_BYTE DEFINE_GUIDNAMED(KSTIME_FORMAT_BYTE)
  742. // TIME_FORMAT_SAMPLE
  743. #define STATIC_KSTIME_FORMAT_SAMPLE
  744.     0x7b785572L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
  745. DEFINE_GUIDSTRUCT("7b785572-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_SAMPLE);
  746. #define KSTIME_FORMAT_SAMPLE DEFINE_GUIDNAMED(KSTIME_FORMAT_SAMPLE)
  747. // TIME_FORMAT_FIELD
  748. #define STATIC_KSTIME_FORMAT_FIELD
  749.     0x7b785573L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
  750. DEFINE_GUIDSTRUCT("7b785573-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_FIELD);
  751. #define KSTIME_FORMAT_FIELD DEFINE_GUIDNAMED(KSTIME_FORMAT_FIELD)
  752. // TIME_FORMAT_MEDIA_TIME
  753. #define STATIC_KSTIME_FORMAT_MEDIA_TIME
  754.     0x7b785574L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
  755. DEFINE_GUIDSTRUCT("7b785574-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_MEDIA_TIME);
  756. #define KSTIME_FORMAT_MEDIA_TIME DEFINE_GUIDNAMED(KSTIME_FORMAT_MEDIA_TIME)
  757. //===========================================================================
  758. typedef KSIDENTIFIER KSPIN_INTERFACE, *PKSPIN_INTERFACE;
  759. #define STATIC_KSINTERFACESETID_Standard 
  760.     0x1A8766A0L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  761. DEFINE_GUIDSTRUCT("1A8766A0-62CE-11CF-A5D6-28DB04C10000", KSINTERFACESETID_Standard);
  762. #define KSINTERFACESETID_Standard DEFINE_GUIDNAMED(KSINTERFACESETID_Standard)
  763. typedef enum {
  764.     KSINTERFACE_STANDARD_STREAMING,
  765.     KSINTERFACE_STANDARD_LOOPED_STREAMING,
  766.     KSINTERFACE_STANDARD_CONTROL
  767. } KSINTERFACE_STANDARD;
  768. #define STATIC_KSINTERFACESETID_FileIo 
  769.     0x8C6F932CL, 0xE771, 0x11D0, 0xB8, 0xFF, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  770. DEFINE_GUIDSTRUCT("8C6F932C-E771-11D0-B8FF-00A0C9223196", KSINTERFACESETID_FileIo);
  771. #define KSINTERFACESETID_FileIo DEFINE_GUIDNAMED(KSINTERFACESETID_FileIo)
  772. typedef enum {
  773.     KSINTERFACE_FILEIO_STREAMING
  774. } KSINTERFACE_FILEIO;
  775. //===========================================================================
  776. #define KSMEDIUM_TYPE_ANYINSTANCE       0
  777. #define STATIC_KSMEDIUMSETID_Standard 
  778.     0x4747B320L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  779. DEFINE_GUIDSTRUCT("4747B320-62CE-11CF-A5D6-28DB04C10000", KSMEDIUMSETID_Standard);
  780. #define KSMEDIUMSETID_Standard DEFINE_GUIDNAMED(KSMEDIUMSETID_Standard)
  781. //For compatibility only
  782. #define KSMEDIUM_STANDARD_DEVIO     KSMEDIUM_TYPE_ANYINSTANCE
  783. //===========================================================================
  784. #define STATIC_KSPROPSETID_Pin
  785.     0x8C134960L, 0x51AD, 0x11CF, 0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00
  786. DEFINE_GUIDSTRUCT("8C134960-51AD-11CF-878A-94F801C10000", KSPROPSETID_Pin);
  787. #define KSPROPSETID_Pin DEFINE_GUIDNAMED(KSPROPSETID_Pin)
  788. typedef enum {
  789.     KSPROPERTY_PIN_CINSTANCES,
  790.     KSPROPERTY_PIN_CTYPES,
  791.     KSPROPERTY_PIN_DATAFLOW,
  792.     KSPROPERTY_PIN_DATARANGES,
  793.     KSPROPERTY_PIN_DATAINTERSECTION,
  794.     KSPROPERTY_PIN_INTERFACES,
  795.     KSPROPERTY_PIN_MEDIUMS,
  796.     KSPROPERTY_PIN_COMMUNICATION,
  797.     KSPROPERTY_PIN_GLOBALCINSTANCES,
  798.     KSPROPERTY_PIN_NECESSARYINSTANCES,
  799.     KSPROPERTY_PIN_PHYSICALCONNECTION,
  800.     KSPROPERTY_PIN_CATEGORY,
  801.     KSPROPERTY_PIN_NAME,
  802.     KSPROPERTY_PIN_CONSTRAINEDDATARANGES,
  803.     KSPROPERTY_PIN_PROPOSEDATAFORMAT
  804. } KSPROPERTY_PIN;
  805. typedef struct {
  806.     KSPROPERTY      Property;
  807.     ULONG           PinId;
  808.     ULONG           Reserved;
  809. } KSP_PIN, *PKSP_PIN;
  810. #define KSINSTANCE_INDETERMINATE    ((ULONG)-1)
  811. typedef struct {
  812.     ULONG  PossibleCount;
  813.     ULONG  CurrentCount;
  814. } KSPIN_CINSTANCES, *PKSPIN_CINSTANCES;
  815. typedef enum {
  816.     KSPIN_DATAFLOW_IN = 1,
  817.     KSPIN_DATAFLOW_OUT
  818. } KSPIN_DATAFLOW, *PKSPIN_DATAFLOW;
  819. #define KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION   0
  820. #define KSDATAFORMAT_TEMPORAL_COMPRESSION       (1 << KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION)
  821. #define KSDATAFORMAT_BIT_ATTRIBUTES 1
  822. #define KSDATAFORMAT_ATTRIBUTES (1 << KSDATAFORMAT_BIT_ATTRIBUTES)
  823. #define KSDATARANGE_BIT_ATTRIBUTES 1
  824. #define KSDATARANGE_ATTRIBUTES (1 << KSDATARANGE_BIT_ATTRIBUTES)
  825. #define KSDATARANGE_BIT_REQUIRED_ATTRIBUTES 2
  826. #define KSDATARANGE_REQUIRED_ATTRIBUTES (1 << KSDATARANGE_BIT_REQUIRED_ATTRIBUTES)
  827. #if !defined( _MSC_VER ) 
  828. typedef struct {
  829.     ULONG   FormatSize;
  830.     ULONG   Flags;
  831.     ULONG   SampleSize;
  832.     ULONG   Reserved;
  833.     GUID    MajorFormat;
  834.     GUID    SubFormat;
  835.     GUID    Specifier;
  836. } KSDATAFORMAT, *PKSDATAFORMAT, KSDATARANGE, *PKSDATARANGE;
  837. #else
  838. typedef union {
  839.     struct {
  840.         ULONG   FormatSize;
  841.         ULONG   Flags;
  842.         ULONG   SampleSize;
  843.         ULONG   Reserved;
  844.         GUID    MajorFormat;
  845.         GUID    SubFormat;
  846.         GUID    Specifier;
  847.     };
  848.     LONGLONG    Alignment;
  849. } KSDATAFORMAT, *PKSDATAFORMAT, KSDATARANGE, *PKSDATARANGE;
  850. #endif
  851. #define KSATTRIBUTE_REQUIRED 0x00000001
  852. typedef struct {
  853.     ULONG Size;
  854.     ULONG Flags;
  855.     GUID Attribute;
  856. } KSATTRIBUTE, *PKSATTRIBUTE;
  857. #if defined(_NTDDK_)
  858. typedef struct {
  859.     ULONG Count;
  860.     PKSATTRIBUTE* Attributes;
  861. } KSATTRIBUTE_LIST, *PKSATTRIBUTE_LIST;
  862. #endif // _NTDDK_
  863. typedef enum {
  864.     KSPIN_COMMUNICATION_NONE,
  865.     KSPIN_COMMUNICATION_SINK,
  866.     KSPIN_COMMUNICATION_SOURCE,
  867.     KSPIN_COMMUNICATION_BOTH,
  868.     KSPIN_COMMUNICATION_BRIDGE
  869. } KSPIN_COMMUNICATION, *PKSPIN_COMMUNICATION;
  870. typedef KSIDENTIFIER KSPIN_MEDIUM, *PKSPIN_MEDIUM;
  871. typedef struct {
  872.     KSPIN_INTERFACE Interface;
  873.     KSPIN_MEDIUM    Medium;
  874.     ULONG           PinId;
  875.     HANDLE          PinToHandle;
  876.     KSPRIORITY      Priority;
  877. } KSPIN_CONNECT, *PKSPIN_CONNECT;
  878. typedef struct {
  879.     ULONG   Size;
  880.     ULONG   Pin;
  881.     WCHAR   SymbolicLinkName[1];
  882. } KSPIN_PHYSICALCONNECTION, *PKSPIN_PHYSICALCONNECTION;
  883. #if defined(_NTDDK_)
  884. typedef
  885. NTSTATUS
  886. (*PFNKSINTERSECTHANDLER)(
  887.     IN PIRP Irp,
  888.     IN PKSP_PIN Pin,
  889.     IN PKSDATARANGE DataRange,
  890.     OUT PVOID Data OPTIONAL
  891.     );
  892. typedef
  893. NTSTATUS
  894. (*PFNKSINTERSECTHANDLEREX)(
  895.     IN PVOID Context,
  896.     IN PIRP Irp,
  897.     IN PKSP_PIN Pin,
  898.     IN PKSDATARANGE DataRange,
  899.     IN PKSDATARANGE MatchingDataRange,
  900.     IN ULONG DataBufferSize,
  901.     OUT PVOID Data OPTIONAL,
  902.     OUT PULONG DataSize
  903.     );
  904. #endif // _NTDDK_
  905. #define DEFINE_KSPIN_INTERFACE_TABLE(tablename)
  906.     const KSPIN_INTERFACE tablename[] =
  907. #define DEFINE_KSPIN_INTERFACE_ITEM(guid, interface)
  908.     {
  909.         STATICGUIDOF(guid),
  910.         (interface),
  911.         0
  912.     }
  913. #define DEFINE_KSPIN_MEDIUM_TABLE( tablename )
  914.     const KSPIN_MEDIUM tablename[] =
  915. #define DEFINE_KSPIN_MEDIUM_ITEM(guid, medium)
  916.     DEFINE_KSPIN_INTERFACE_ITEM(guid, medium)
  917. #define DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(Handler)
  918.     DEFINE_KSPROPERTY_ITEM(
  919.         KSPROPERTY_PIN_CINSTANCES,
  920.         (Handler),
  921.         sizeof(KSP_PIN),
  922.         sizeof(KSPIN_CINSTANCES),
  923.         NULL, NULL, 0, NULL, NULL, 0)
  924. #define DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(Handler)
  925.     DEFINE_KSPROPERTY_ITEM(
  926.         KSPROPERTY_PIN_CTYPES,
  927.         (Handler),
  928.         sizeof(KSPROPERTY),
  929.         sizeof(ULONG),
  930.         NULL, NULL, 0, NULL, NULL, 0)
  931. #define DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(Handler)
  932.     DEFINE_KSPROPERTY_ITEM(
  933.         KSPROPERTY_PIN_DATAFLOW,
  934.         (Handler),
  935.         sizeof(KSP_PIN),
  936.         sizeof(KSPIN_DATAFLOW),
  937.         NULL, NULL, 0, NULL, NULL, 0)
  938. #define DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(Handler)
  939.     DEFINE_KSPROPERTY_ITEM(
  940.         KSPROPERTY_PIN_DATARANGES,
  941.         (Handler),
  942.         sizeof(KSP_PIN),
  943.         0,
  944.         NULL, NULL, 0, NULL, NULL, 0)
  945. #define DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(Handler)
  946.     DEFINE_KSPROPERTY_ITEM(
  947.         KSPROPERTY_PIN_DATAINTERSECTION,
  948.         (Handler),
  949.         sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM),
  950.         0,
  951.         NULL, NULL, 0, NULL, NULL, 0)
  952. #define DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(Handler)
  953.     DEFINE_KSPROPERTY_ITEM(
  954.         KSPROPERTY_PIN_INTERFACES,
  955.         (Handler),
  956.         sizeof(KSP_PIN),
  957.         0,
  958.         NULL, NULL, 0, NULL, NULL, 0)
  959. #define DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(Handler)
  960.     DEFINE_KSPROPERTY_ITEM(
  961.         KSPROPERTY_PIN_MEDIUMS,
  962.         (Handler),
  963.         sizeof(KSP_PIN),
  964.         0,
  965.         NULL, NULL, 0, NULL, NULL, 0)
  966. #define DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(Handler)
  967.     DEFINE_KSPROPERTY_ITEM(
  968.         KSPROPERTY_PIN_COMMUNICATION,
  969.         (Handler),
  970.         sizeof(KSP_PIN),
  971.         sizeof(KSPIN_COMMUNICATION),
  972.         NULL, NULL, 0, NULL, NULL, 0)
  973. #define DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES(Handler)
  974.     DEFINE_KSPROPERTY_ITEM(
  975.         KSPROPERTY_PIN_GLOBALCINSTANCES,
  976.         (Handler),
  977.         sizeof(KSP_PIN),
  978.         sizeof(KSPIN_CINSTANCES),
  979.         NULL, NULL, 0, NULL, NULL, 0)
  980. #define DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES(Handler)
  981.     DEFINE_KSPROPERTY_ITEM(
  982.         KSPROPERTY_PIN_NECESSARYINSTANCES,
  983.         (Handler),
  984.         sizeof(KSP_PIN),
  985.         sizeof(ULONG),
  986.         NULL, NULL, 0, NULL, NULL, 0)
  987. #define DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION(Handler)
  988.     DEFINE_KSPROPERTY_ITEM(
  989.         KSPROPERTY_PIN_PHYSICALCONNECTION,
  990.         (Handler),
  991.         sizeof(KSP_PIN),
  992.         0,
  993.         NULL, NULL, 0, NULL, NULL, 0)
  994. #define DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(Handler)
  995.     DEFINE_KSPROPERTY_ITEM(
  996.         KSPROPERTY_PIN_CATEGORY,
  997.         (Handler),
  998.         sizeof(KSP_PIN),
  999.         sizeof(GUID),
  1000.         NULL, NULL, 0, NULL, NULL, 0)
  1001. #define DEFINE_KSPROPERTY_ITEM_PIN_NAME(Handler)
  1002.     DEFINE_KSPROPERTY_ITEM(
  1003.         KSPROPERTY_PIN_NAME,
  1004.         (Handler),
  1005.         sizeof(KSP_PIN),
  1006.         0,
  1007.         NULL, NULL, 0, NULL, NULL, 0)
  1008. #define DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(Handler)
  1009.     DEFINE_KSPROPERTY_ITEM(
  1010.         KSPROPERTY_PIN_CONSTRAINEDDATARANGES,
  1011.         (Handler),
  1012.         sizeof(KSP_PIN),
  1013.         0,
  1014.         NULL, NULL, 0, NULL, NULL, 0)
  1015. #define DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT(Handler)
  1016.     DEFINE_KSPROPERTY_ITEM(
  1017.         KSPROPERTY_PIN_PROPOSEDATAFORMAT,
  1018.         NULL,
  1019.         sizeof(KSP_PIN),
  1020.         sizeof(KSDATAFORMAT),
  1021.         (Handler), NULL, 0, NULL, NULL, 0)
  1022. #define DEFINE_KSPROPERTY_PINSET(PinSet,
  1023.     PropGeneral, PropInstances, PropIntersection)
  1024. DEFINE_KSPROPERTY_TABLE(PinSet) {
  1025.     DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),
  1026.     DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),
  1027.     DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),
  1028.     DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),
  1029.     DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),
  1030.     DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),
  1031.     DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),
  1032.     DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),
  1033.     DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),
  1034.     DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral)
  1035. }
  1036. #define DEFINE_KSPROPERTY_PINSETCONSTRAINED(PinSet,
  1037.     PropGeneral, PropInstances, PropIntersection)
  1038. DEFINE_KSPROPERTY_TABLE(PinSet) {
  1039.     DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),
  1040.     DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),
  1041.     DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),
  1042.     DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),
  1043.     DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),
  1044.     DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),
  1045.     DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),
  1046.     DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),
  1047.     DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),
  1048.     DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral),
  1049.     DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(PropGeneral)
  1050. }
  1051. #define STATIC_KSNAME_Filter
  1052.     0x9b365890L, 0x165f, 0x11d0, 0xa1, 0x95, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
  1053. DEFINE_GUIDSTRUCT("9b365890-165f-11d0-a195-0020afd156e4", KSNAME_Filter);
  1054. #define KSNAME_Filter DEFINE_GUIDNAMED(KSNAME_Filter)
  1055. #define KSSTRING_Filter L"{9B365890-165F-11D0-A195-0020AFD156E4}"
  1056. #define STATIC_KSNAME_Pin
  1057.     0x146F1A80L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1058. DEFINE_GUIDSTRUCT("146F1A80-4791-11D0-A5D6-28DB04C10000", KSNAME_Pin);
  1059. #define KSNAME_Pin DEFINE_GUIDNAMED(KSNAME_Pin)
  1060. #define KSSTRING_Pin L"{146F1A80-4791-11D0-A5D6-28DB04C10000}"
  1061. #define STATIC_KSNAME_Clock
  1062.     0x53172480L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1063. DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000", KSNAME_Clock);
  1064. #define KSNAME_Clock DEFINE_GUIDNAMED(KSNAME_Clock)
  1065. #define KSSTRING_Clock L"{53172480-4791-11D0-A5D6-28DB04C10000}"
  1066. #define STATIC_KSNAME_Allocator
  1067.     0x642F5D00L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1068. DEFINE_GUIDSTRUCT("642F5D00-4791-11D0-A5D6-28DB04C10000", KSNAME_Allocator);
  1069. #define KSNAME_Allocator DEFINE_GUIDNAMED(KSNAME_Allocator)
  1070. #define KSSTRING_Allocator L"{642F5D00-4791-11D0-A5D6-28DB04C10000}"
  1071. #define KSSTRING_AllocatorEx L"{091BB63B-603F-11D1-B067-00A0C9062802}"
  1072. #define STATIC_KSNAME_TopologyNode
  1073.     0x0621061AL, 0xEE75, 0x11D0, 0xB9, 0x15, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  1074. DEFINE_GUIDSTRUCT("0621061A-EE75-11D0-B915-00A0C9223196", KSNAME_TopologyNode);
  1075. #define KSNAME_TopologyNode DEFINE_GUIDNAMED(KSNAME_TopologyNode)
  1076. #define KSSTRING_TopologyNode L"{0621061A-EE75-11D0-B915-00A0C9223196}"
  1077. #if defined(_NTDDK_)
  1078. typedef struct {
  1079.     ULONG                   InterfacesCount;
  1080.     const KSPIN_INTERFACE*  Interfaces;
  1081.     ULONG                   MediumsCount;
  1082.     const KSPIN_MEDIUM*     Mediums;
  1083.     ULONG                   DataRangesCount;
  1084.     const PKSDATARANGE*     DataRanges;
  1085.     KSPIN_DATAFLOW          DataFlow;
  1086.     KSPIN_COMMUNICATION     Communication;
  1087.     const GUID*             Category;
  1088.     const GUID*             Name;
  1089.     union {
  1090.         LONGLONG            Reserved;
  1091.         struct {
  1092.             ULONG           ConstrainedDataRangesCount;
  1093.             PKSDATARANGE*   ConstrainedDataRanges;
  1094.         };
  1095.     };
  1096. } KSPIN_DESCRIPTOR, *PKSPIN_DESCRIPTOR;
  1097. typedef const KSPIN_DESCRIPTOR *PCKSPIN_DESCRIPTOR;
  1098. #define DEFINE_KSPIN_DESCRIPTOR_TABLE(tablename)
  1099.     const KSPIN_DESCRIPTOR tablename[] =
  1100. #define DEFINE_KSPIN_DESCRIPTOR_ITEM(
  1101.     InterfacesCount, Interfaces,
  1102.     MediumsCount, Mediums,
  1103.     DataRangesCount, DataRanges,
  1104.     DataFlow, Communication)
  1105. {
  1106.     InterfacesCount, Interfaces, MediumsCount, Mediums,
  1107.     DataRangesCount, DataRanges, DataFlow, Communication,
  1108.     NULL, NULL, 0
  1109. }
  1110. #define DEFINE_KSPIN_DESCRIPTOR_ITEMEX(
  1111.     InterfacesCount, Interfaces,
  1112.     MediumsCount, Mediums,
  1113.     DataRangesCount, DataRanges,
  1114.     DataFlow, Communication,
  1115.     Category, Name)
  1116. {
  1117.     InterfacesCount, Interfaces, MediumsCount, Mediums,
  1118.     DataRangesCount, DataRanges, DataFlow, Communication,
  1119.     Category, Name, 0
  1120. }
  1121. #endif // defined(_NTDDK_)
  1122. //===========================================================================
  1123. // MEDIATYPE_NULL
  1124. #define STATIC_KSDATAFORMAT_TYPE_WILDCARD       STATIC_GUID_NULL
  1125. #define KSDATAFORMAT_TYPE_WILDCARD              GUID_NULL
  1126. // MEDIASUBTYPE_NULL
  1127. #define STATIC_KSDATAFORMAT_SUBTYPE_WILDCARD    STATIC_GUID_NULL
  1128. #define KSDATAFORMAT_SUBTYPE_WILDCARD           GUID_NULL
  1129. // MEDIATYPE_Stream
  1130. #define STATIC_KSDATAFORMAT_TYPE_STREAM
  1131.     0xE436EB83L, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70
  1132. DEFINE_GUIDSTRUCT("E436EB83-524F-11CE-9F53-0020AF0BA770", KSDATAFORMAT_TYPE_STREAM);
  1133. #define KSDATAFORMAT_TYPE_STREAM DEFINE_GUIDNAMED(KSDATAFORMAT_TYPE_STREAM)
  1134. // MEDIASUBTYPE_None
  1135. #define STATIC_KSDATAFORMAT_SUBTYPE_NONE
  1136.     0xE436EB8EL, 0x524F, 0x11CE, 0x9F, 0x53, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70
  1137. DEFINE_GUIDSTRUCT("E436EB8E-524F-11CE-9F53-0020AF0BA770", KSDATAFORMAT_SUBTYPE_NONE);
  1138. #define KSDATAFORMAT_SUBTYPE_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_NONE)
  1139. #define STATIC_KSDATAFORMAT_SPECIFIER_WILDCARD  STATIC_GUID_NULL
  1140. #define KSDATAFORMAT_SPECIFIER_WILDCARD         GUID_NULL
  1141. #define STATIC_KSDATAFORMAT_SPECIFIER_FILENAME
  1142.     0xAA797B40L, 0xE974, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1143. DEFINE_GUIDSTRUCT("AA797B40-E974-11CF-A5D6-28DB04C10000", KSDATAFORMAT_SPECIFIER_FILENAME);
  1144. #define KSDATAFORMAT_SPECIFIER_FILENAME DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_FILENAME)
  1145. #define STATIC_KSDATAFORMAT_SPECIFIER_FILEHANDLE
  1146.     0x65E8773CL, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  1147. DEFINE_GUIDSTRUCT("65E8773C-8F56-11D0-A3B9-00A0C9223196", KSDATAFORMAT_SPECIFIER_FILEHANDLE);
  1148. #define KSDATAFORMAT_SPECIFIER_FILEHANDLE DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_FILEHANDLE)
  1149. // FORMAT_None
  1150. #define STATIC_KSDATAFORMAT_SPECIFIER_NONE
  1151.     0x0F6417D6L, 0xC318, 0x11D0, 0xA4, 0x3F, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  1152. DEFINE_GUIDSTRUCT("0F6417D6-C318-11D0-A43F-00A0C9223196", KSDATAFORMAT_SPECIFIER_NONE);
  1153. #define KSDATAFORMAT_SPECIFIER_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_NONE)
  1154. //===========================================================================
  1155. #define STATIC_KSPROPSETID_Quality 
  1156.     0xD16AD380L, 0xAC1A, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1157. DEFINE_GUIDSTRUCT("D16AD380-AC1A-11CF-A5D6-28DB04C10000", KSPROPSETID_Quality);
  1158. #define KSPROPSETID_Quality DEFINE_GUIDNAMED(KSPROPSETID_Quality)
  1159. typedef enum {
  1160.     KSPROPERTY_QUALITY_REPORT,
  1161.     KSPROPERTY_QUALITY_ERROR
  1162. } KSPROPERTY_QUALITY;
  1163. #define DEFINE_KSPROPERTY_ITEM_QUALITY_REPORT(GetHandler, SetHandler)
  1164.     DEFINE_KSPROPERTY_ITEM(
  1165.         KSPROPERTY_QUALITY_REPORT,
  1166.         (GetHandler),
  1167.         sizeof(KSPROPERTY),
  1168.         sizeof(KSQUALITY),
  1169.         (SetHandler),
  1170.         NULL, 0, NULL, NULL, 0)
  1171. #define DEFINE_KSPROPERTY_ITEM_QUALITY_ERROR(GetHandler, SetHandler)
  1172.     DEFINE_KSPROPERTY_ITEM(
  1173.         KSPROPERTY_QUALITY_ERROR,
  1174.         (GetHandler),
  1175.         sizeof(KSPROPERTY),
  1176.         sizeof(KSERROR),
  1177.         (SetHandler),
  1178.         NULL, 0, NULL, NULL, 0)
  1179. //===========================================================================
  1180. #define STATIC_KSPROPSETID_Connection 
  1181.     0x1D58C920L, 0xAC9B, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1182. DEFINE_GUIDSTRUCT("1D58C920-AC9B-11CF-A5D6-28DB04C10000", KSPROPSETID_Connection);
  1183. #define KSPROPSETID_Connection DEFINE_GUIDNAMED(KSPROPSETID_Connection)
  1184. typedef enum {
  1185.     KSPROPERTY_CONNECTION_STATE,
  1186.     KSPROPERTY_CONNECTION_PRIORITY,
  1187.     KSPROPERTY_CONNECTION_DATAFORMAT,
  1188.     KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
  1189.     KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,
  1190.     KSPROPERTY_CONNECTION_ACQUIREORDERING,
  1191.     KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,
  1192.     KSPROPERTY_CONNECTION_STARTAT
  1193. } KSPROPERTY_CONNECTION;
  1194. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE(GetHandler, SetHandler)
  1195.     DEFINE_KSPROPERTY_ITEM(
  1196.         KSPROPERTY_CONNECTION_STATE,
  1197.         (GetHandler),
  1198.         sizeof(KSPROPERTY),
  1199.         sizeof(KSSTATE),
  1200.         (SetHandler),
  1201.         NULL, 0, NULL, NULL, 0)
  1202. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PRIORITY(GetHandler, SetHandler)
  1203.     DEFINE_KSPROPERTY_ITEM(
  1204.         KSPROPERTY_CONNECTION_PRIORITY,
  1205.         (GetHandler),
  1206.         sizeof(KSPROPERTY),
  1207.         sizeof(KSPRIORITY),
  1208.         (SetHandler),
  1209.         NULL, 0, NULL, NULL, 0)
  1210. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT(GetHandler, SetHandler)
  1211.     DEFINE_KSPROPERTY_ITEM(
  1212.         KSPROPERTY_CONNECTION_DATAFORMAT,
  1213.         (GetHandler),
  1214.         sizeof(KSPROPERTY),
  1215.         0,
  1216.         (SetHandler),
  1217.         NULL, 0, NULL, NULL, 0)
  1218. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING(Handler)
  1219.     DEFINE_KSPROPERTY_ITEM(
  1220.         KSPROPERTY_CONNECTION_ALLOCATORFRAMING,
  1221.         (Handler),
  1222.         sizeof(KSPROPERTY),
  1223.         sizeof(KSALLOCATOR_FRAMING),
  1224.         NULL, NULL, 0, NULL, NULL, 0)
  1225.         
  1226. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING_EX(Handler)
  1227.     DEFINE_KSPROPERTY_ITEM(
  1228.         KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,
  1229.         (Handler),
  1230.         sizeof(KSPROPERTY),
  1231.         sizeof(KSALLOCATOR_FRAMING_EX),
  1232.         NULL, NULL, 0, NULL, NULL, 0)
  1233. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PROPOSEDATAFORMAT(Handler)
  1234.     DEFINE_KSPROPERTY_ITEM(
  1235.         KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,
  1236.         NULL,
  1237.         sizeof(KSPROPERTY),
  1238.         sizeof(KSDATAFORMAT),
  1239.         (Handler),
  1240.         NULL, 0, NULL, NULL, 0)
  1241. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ACQUIREORDERING(Handler)
  1242.     DEFINE_KSPROPERTY_ITEM(
  1243.         KSPROPERTY_CONNECTION_ACQUIREORDERING,
  1244.         (Handler),
  1245.         sizeof(KSPROPERTY),
  1246.         sizeof(int),
  1247.         NULL, NULL, 0, NULL, NULL, 0)
  1248. #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STARTAT(Handler)
  1249.     DEFINE_KSPROPERTY_ITEM(
  1250.         KSPROPERTY_CONNECTION_STARTAT,
  1251.         NULL,
  1252.         sizeof(KSPROPERTY),
  1253.         sizeof(KSRELATIVEEVENT),
  1254.         (Handler),
  1255.         NULL, 0, NULL, NULL, 0)
  1256. //===========================================================================
  1257. //
  1258. // pins flags
  1259. //
  1260. #define KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER   0x00000001
  1261. #define KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY      0x00000002
  1262. #define KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY    0x00000004
  1263. #define KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE      0x00000008
  1264. #define KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY   0x80000000
  1265. #define KSALLOCATOR_OPTIONF_COMPATIBLE              0x00000001
  1266. #define KSALLOCATOR_OPTIONF_SYSTEM_MEMORY           0x00000002
  1267. #define KSALLOCATOR_OPTIONF_VALID                   0x00000003
  1268. // 
  1269. // pins extended framing flags
  1270. //
  1271. #define KSALLOCATOR_FLAG_PARTIAL_READ_SUPPORT       0x00000010
  1272. #define KSALLOCATOR_FLAG_DEVICE_SPECIFIC            0x00000020
  1273. #define KSALLOCATOR_FLAG_CAN_ALLOCATE               0x00000040
  1274. #define KSALLOCATOR_FLAG_INSIST_ON_FRAMESIZE_RATIO  0x00000080
  1275. //
  1276. // allocator pipes flags
  1277. //
  1278. // there is at least one data modification in a pipe
  1279. #define KSALLOCATOR_FLAG_NO_FRAME_INTEGRITY         0x00000100
  1280. #define KSALLOCATOR_FLAG_MULTIPLE_OUTPUT            0x00000200
  1281. #define KSALLOCATOR_FLAG_CYCLE                      0x00000400
  1282. #define KSALLOCATOR_FLAG_ALLOCATOR_EXISTS           0x00000800
  1283. // there is no framing dependency between neighbouring pipes.
  1284. #define KSALLOCATOR_FLAG_INDEPENDENT_RANGES         0x00001000
  1285. #define KSALLOCATOR_FLAG_ATTENTION_STEPPING         0x00002000
  1286. //
  1287. // old Framing structure
  1288. //
  1289. typedef struct {
  1290.     union {
  1291.         ULONG       OptionsFlags;       // allocator options (create)
  1292.         ULONG       RequirementsFlags;  // allocation requirements (query)
  1293.     };
  1294. #if defined(_NTDDK_)
  1295.     POOL_TYPE   PoolType;
  1296. #else // !_NTDDK_
  1297.     ULONG       PoolType;
  1298. #endif // !_NTDDK_
  1299.     ULONG       Frames;     // total number of allowable outstanding frames
  1300.     ULONG       FrameSize;  // total size of frame
  1301.     ULONG       FileAlignment;
  1302.     ULONG       Reserved;
  1303. } KSALLOCATOR_FRAMING, *PKSALLOCATOR_FRAMING;
  1304. #if defined(_NTDDK_)
  1305. typedef
  1306. PVOID
  1307. (*PFNKSDEFAULTALLOCATE)(
  1308.     IN PVOID Context
  1309.     );
  1310. typedef
  1311. VOID
  1312. (*PFNKSDEFAULTFREE)(
  1313.     IN PVOID Context,
  1314.     IN PVOID Buffer
  1315.     );
  1316. typedef
  1317. NTSTATUS
  1318. (*PFNKSINITIALIZEALLOCATOR)(
  1319.     IN PVOID InitialContext,
  1320.     IN PKSALLOCATOR_FRAMING AllocatorFraming,
  1321.     OUT PVOID* Context
  1322.     );
  1323. typedef
  1324. VOID
  1325. (*PFNKSDELETEALLOCATOR)(
  1326.     IN PVOID Context
  1327.     );
  1328. #endif // !_NTDDK_
  1329. //
  1330. // new Framing structure, eventually will replace KSALLOCATOR_FRAMING.
  1331. // 
  1332. typedef struct {
  1333.     ULONG   MinFrameSize;
  1334.     ULONG   MaxFrameSize;
  1335.     ULONG   Stepping;
  1336. } KS_FRAMING_RANGE, *PKS_FRAMING_RANGE;
  1337. typedef struct {
  1338.     KS_FRAMING_RANGE  Range;
  1339.     ULONG             InPlaceWeight;
  1340.     ULONG             NotInPlaceWeight;
  1341. } KS_FRAMING_RANGE_WEIGHTED, *PKS_FRAMING_RANGE_WEIGHTED;
  1342. typedef struct {
  1343.     ULONG   RatioNumerator;      // compression/expansion ratio
  1344.     ULONG   RatioDenominator; 
  1345.     ULONG   RatioConstantMargin;
  1346. } KS_COMPRESSION, *PKS_COMPRESSION;
  1347. //
  1348. // Memory Types and Buses are repeated in each entry.
  1349. // Easiest to use but takes a little more memory than the varsize layout PinMemoriesBusesRanges.
  1350. //
  1351. typedef struct {
  1352.     GUID                        MemoryType;
  1353.     GUID                        BusType;
  1354.     ULONG                       MemoryFlags;
  1355.     ULONG                       BusFlags;   
  1356.     ULONG                       Flags;   
  1357.     ULONG                       Frames;              // total number of allowable outstanding frames
  1358.     ULONG                       FileAlignment;
  1359.     ULONG                       MemoryTypeWeight;    // this memory type Weight pin-wide
  1360.     KS_FRAMING_RANGE            PhysicalRange;
  1361.     KS_FRAMING_RANGE_WEIGHTED   FramingRange; 
  1362. } KS_FRAMING_ITEM, *PKS_FRAMING_ITEM;
  1363. typedef struct {
  1364.     ULONG               CountItems;         // count of FramingItem-s below.
  1365.     ULONG               PinFlags;
  1366.     KS_COMPRESSION      OutputCompression;
  1367.     ULONG               PinWeight;          // this pin framing's Weight graph-wide
  1368.     KS_FRAMING_ITEM     FramingItem[1]; 
  1369. } KSALLOCATOR_FRAMING_EX, *PKSALLOCATOR_FRAMING_EX;
  1370. //
  1371. // define memory type GUIDs
  1372. //
  1373. #define KSMEMORY_TYPE_WILDCARD          GUID_NULL
  1374. #define STATIC_KSMEMORY_TYPE_WILDCARD   STATIC_GUID_NULL
  1375. #define KSMEMORY_TYPE_DONT_CARE         GUID_NULL
  1376. #define STATIC_KSMEMORY_TYPE_DONT_CARE  STATIC_GUID_NULL
  1377. #define KS_TYPE_DONT_CARE           GUID_NULL
  1378. #define STATIC_KS_TYPE_DONT_CARE    STATIC_GUID_NULL
  1379.      
  1380. #define STATIC_KSMEMORY_TYPE_SYSTEM 
  1381.     0x091bb638L, 0x603f, 0x11d1, 0xb0, 0x67, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
  1382. DEFINE_GUIDSTRUCT("091bb638-603f-11d1-b067-00a0c9062802", KSMEMORY_TYPE_SYSTEM);
  1383. #define KSMEMORY_TYPE_SYSTEM  DEFINE_GUIDNAMED(KSMEMORY_TYPE_SYSTEM)
  1384. #define STATIC_KSMEMORY_TYPE_USER 
  1385.     0x8cb0fc28L, 0x7893, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
  1386. DEFINE_GUIDSTRUCT("8cb0fc28-7893-11d1-b069-00a0c9062802", KSMEMORY_TYPE_USER);
  1387. #define KSMEMORY_TYPE_USER  DEFINE_GUIDNAMED(KSMEMORY_TYPE_USER)
  1388. #define STATIC_KSMEMORY_TYPE_KERNEL_PAGED 
  1389.     0xd833f8f8L, 0x7894, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
  1390. DEFINE_GUIDSTRUCT("d833f8f8-7894-11d1-b069-00a0c9062802", KSMEMORY_TYPE_KERNEL_PAGED);
  1391. #define KSMEMORY_TYPE_KERNEL_PAGED  DEFINE_GUIDNAMED(KSMEMORY_TYPE_KERNEL_PAGED)
  1392. #define STATIC_KSMEMORY_TYPE_KERNEL_NONPAGED 
  1393.     0x4a6d5fc4L, 0x7895, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
  1394. DEFINE_GUIDSTRUCT("4a6d5fc4-7895-11d1-b069-00a0c9062802", KSMEMORY_TYPE_KERNEL_NONPAGED);
  1395. #define KSMEMORY_TYPE_KERNEL_NONPAGED  DEFINE_GUIDNAMED(KSMEMORY_TYPE_KERNEL_NONPAGED)
  1396. // old KS clients did not specify the device memory type
  1397. #define STATIC_KSMEMORY_TYPE_DEVICE_UNKNOWN 
  1398.     0x091bb639L, 0x603f, 0x11d1, 0xb0, 0x67, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
  1399. DEFINE_GUIDSTRUCT("091bb639-603f-11d1-b067-00a0c9062802", KSMEMORY_TYPE_DEVICE_UNKNOWN);
  1400. #define KSMEMORY_TYPE_DEVICE_UNKNOWN DEFINE_GUIDNAMED(KSMEMORY_TYPE_DEVICE_UNKNOWN)
  1401. //
  1402. // Helper framing macros.
  1403. //
  1404. #define DECLARE_SIMPLE_FRAMING_EX(FramingExName, MemoryType, Flags, Frames, Alignment, MinFrameSize, MaxFrameSize) 
  1405.     const KSALLOCATOR_FRAMING_EX FramingExName = 
  1406.     {
  1407.         1, 
  1408.         0, 
  1409.         {
  1410.             1, 
  1411.             1, 
  1412.             0 
  1413.         }, 
  1414.         0, 
  1415.         {
  1416.             {
  1417.                 MemoryType, 
  1418.                 STATIC_KS_TYPE_DONT_CARE, 
  1419.                 0, 
  1420.                 0, 
  1421.                 Flags, 
  1422.                 Frames, 
  1423.                 Alignment, 
  1424.                 0, 
  1425.                 {
  1426.                     0, 
  1427.                     (ULONG)-1, 
  1428.                     1 
  1429.                 }, 
  1430.                 {
  1431.                     {
  1432.                         MinFrameSize, 
  1433.                         MaxFrameSize, 
  1434.                         1 
  1435.                     }, 
  1436.                     0, 
  1437.                     0  
  1438.                 }
  1439.             }
  1440.         }
  1441.     }
  1442. #define SetDefaultKsCompression(KsCompressionPointer) 
  1443. {
  1444.     KsCompressionPointer->RatioNumerator = 1;
  1445.     KsCompressionPointer->RatioDenominator = 1;
  1446.     KsCompressionPointer->RatioConstantMargin = 0;
  1447. }
  1448. #define SetDontCareKsFramingRange(KsFramingRangePointer) 
  1449. {
  1450.     KsFramingRangePointer->MinFrameSize = 0;
  1451.     KsFramingRangePointer->MaxFrameSize = (ULONG) -1;
  1452.     KsFramingRangePointer->Stepping = 1;
  1453. }
  1454. #define SetKsFramingRange(KsFramingRangePointer, P_MinFrameSize, P_MaxFrameSize) 
  1455. {
  1456.     KsFramingRangePointer->MinFrameSize = P_MinFrameSize;
  1457.     KsFramingRangePointer->MaxFrameSize = P_MaxFrameSize;
  1458.     KsFramingRangePointer->Stepping = 1;
  1459. }
  1460. #define SetKsFramingRangeWeighted(KsFramingRangeWeightedPointer, P_MinFrameSize, P_MaxFrameSize) 
  1461. {
  1462.     KS_FRAMING_RANGE *KsFramingRange = &KsFramingRangeWeightedPointer->Range;
  1463.     SetKsFramingRange(KsFramingRange, P_MinFrameSize, P_MaxFrameSize);
  1464.     KsFramingRangeWeightedPointer->InPlaceWeight = 0;
  1465.     KsFramingRangeWeightedPointer->NotInPlaceWeight = 0;
  1466. }
  1467. #define INITIALIZE_SIMPLE_FRAMING_EX(FramingExPointer, P_MemoryType, P_Flags, P_Frames, P_Alignment, P_MinFrameSize, P_MaxFrameSize) 
  1468. {
  1469.     KS_COMPRESSION *KsCompression = &FramingExPointer->OutputCompression;
  1470.     KS_FRAMING_RANGE *KsFramingRange = &FramingExPointer->FramingItem[0].PhysicalRange;
  1471.     KS_FRAMING_RANGE_WEIGHTED *KsFramingRangeWeighted = &FramingExPointer->FramingItem[0].FramingRange;
  1472.     FramingExPointer->CountItems = 1;
  1473.     FramingExPointer->PinFlags = 0;
  1474.     SetDefaultKsCompression(KsCompression);
  1475.     FramingExPointer->PinWeight = 0;
  1476.     FramingExPointer->FramingItem[0].MemoryType = P_MemoryType;
  1477.     FramingExPointer->FramingItem[0].BusType = KS_TYPE_DONT_CARE;
  1478.     FramingExPointer->FramingItem[0].MemoryFlags = 0;
  1479.     FramingExPointer->FramingItem[0].BusFlags = 0;
  1480.     FramingExPointer->FramingItem[0].Flags = P_Flags;
  1481.     FramingExPointer->FramingItem[0].Frames = P_Frames;
  1482.     FramingExPointer->FramingItem[0].FileAlignment = P_Alignment;
  1483.     FramingExPointer->FramingItem[0].MemoryTypeWeight = 0;
  1484.     SetDontCareKsFramingRange(KsFramingRange);
  1485.     SetKsFramingRangeWeighted(KsFramingRangeWeighted, P_MinFrameSize, P_MaxFrameSize);
  1486. }
  1487. // KSEVENTSETID_StreamAllocator: {75D95571-073C-11d0-A161-0020AFD156E4}
  1488. #define STATIC_KSEVENTSETID_StreamAllocator
  1489.     0x75d95571L, 0x073c, 0x11d0, 0xa1, 0x61, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
  1490. DEFINE_GUIDSTRUCT("75d95571-073c-11d0-a161-0020afd156e4", KSEVENTSETID_StreamAllocator);
  1491. #define KSEVENTSETID_StreamAllocator DEFINE_GUIDNAMED(KSEVENTSETID_StreamAllocator)
  1492. typedef enum {
  1493.     KSEVENT_STREAMALLOCATOR_INTERNAL_FREEFRAME,
  1494.     KSEVENT_STREAMALLOCATOR_FREEFRAME
  1495. } KSEVENT_STREAMALLOCATOR;
  1496. #define STATIC_KSMETHODSETID_StreamAllocator
  1497.     0xcf6e4341L, 0xec87, 0x11cf, 0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
  1498. DEFINE_GUIDSTRUCT("cf6e4341-ec87-11cf-a130-0020afd156e4", KSMETHODSETID_StreamAllocator);
  1499. #define KSMETHODSETID_StreamAllocator DEFINE_GUIDNAMED(KSMETHODSETID_StreamAllocator)
  1500. typedef enum {
  1501.     KSMETHOD_STREAMALLOCATOR_ALLOC,
  1502.     KSMETHOD_STREAMALLOCATOR_FREE
  1503. } KSMETHOD_STREAMALLOCATOR;
  1504. #define DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_ALLOC(Handler)
  1505.     DEFINE_KSMETHOD_ITEM(
  1506.         KSMETHOD_STREAMALLOCATOR_ALLOC,
  1507.         KSMETHOD_TYPE_WRITE,
  1508.         (Handler),
  1509.         sizeof(KSMETHOD),
  1510.         sizeof(PVOID),
  1511.         NULL)
  1512. #define DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_FREE(Handler)
  1513.     DEFINE_KSMETHOD_ITEM(
  1514.         KSMETHOD_STREAMALLOCATOR_FREE,
  1515.         KSMETHOD_TYPE_READ,
  1516.         (Handler),
  1517.         sizeof(KSMETHOD),
  1518.         sizeof(PVOID),
  1519.         NULL)
  1520. #define DEFINE_KSMETHOD_ALLOCATORSET(AllocatorSet, MethodAlloc, MethodFree)
  1521. DEFINE_KSMETHOD_TABLE(AllocatorSet) {
  1522.     DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_ALLOC(MethodAlloc),
  1523.     DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_FREE(MethodFree)
  1524. }
  1525. #define STATIC_KSPROPSETID_StreamAllocator
  1526.     0xcf6e4342L, 0xec87, 0x11cf, 0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
  1527. DEFINE_GUIDSTRUCT("cf6e4342-ec87-11cf-a130-0020afd156e4", KSPROPSETID_StreamAllocator);
  1528. #define KSPROPSETID_StreamAllocator DEFINE_GUIDNAMED(KSPROPSETID_StreamAllocator)
  1529. #if defined(_NTDDK_)
  1530. typedef enum {
  1531.     KSPROPERTY_STREAMALLOCATOR_FUNCTIONTABLE,
  1532.     KSPROPERTY_STREAMALLOCATOR_STATUS
  1533. } KSPROPERTY_STREAMALLOCATOR;
  1534. #define DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_FUNCTIONTABLE(Handler)
  1535.     DEFINE_KSPROPERTY_ITEM(
  1536.         KSPROPERTY_STREAMALLOCATOR_FUNCTIONTABLE,
  1537.         (Handler),
  1538.         sizeof(KSPROPERTY),
  1539.         sizeof(KSSTREAMALLOCATOR_FUNCTIONTABLE),
  1540.         NULL, NULL, 0, NULL, NULL, 0)
  1541.         
  1542. #define DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_STATUS(Handler)
  1543.     DEFINE_KSPROPERTY_ITEM(
  1544.         KSPROPERTY_STREAMALLOCATOR_STATUS,
  1545.         (Handler),
  1546.         sizeof(KSPROPERTY),
  1547.         sizeof(KSSTREAMALLOCATOR_STATUS),
  1548.         NULL, NULL, 0, NULL, NULL, 0)
  1549. #define DEFINE_KSPROPERTY_ALLOCATORSET(AllocatorSet, PropFunctionTable, PropStatus)
  1550. DEFINE_KSPROPERTY_TABLE(AllocatorSet) {
  1551.     DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_STATUS(PropStatus),
  1552.     DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_FUNCTIONTABLE(PropFunctionTable)
  1553. }
  1554. typedef
  1555. NTSTATUS
  1556. (*PFNALLOCATOR_ALLOCATEFRAME)(
  1557.     IN PFILE_OBJECT FileObject,
  1558.     PVOID *Frame
  1559.     );
  1560. typedef
  1561. VOID
  1562. (*PFNALLOCATOR_FREEFRAME)(
  1563.     IN PFILE_OBJECT FileObject,
  1564.     IN PVOID Frame
  1565.     );
  1566. typedef struct {
  1567.     PFNALLOCATOR_ALLOCATEFRAME  AllocateFrame;
  1568.     PFNALLOCATOR_FREEFRAME      FreeFrame;
  1569. } KSSTREAMALLOCATOR_FUNCTIONTABLE, *PKSSTREAMALLOCATOR_FUNCTIONTABLE;
  1570. #endif // defined(_NTDDK_)
  1571. typedef struct {
  1572.     KSALLOCATOR_FRAMING Framing;
  1573.     ULONG               AllocatedFrames;
  1574.     ULONG               Reserved;
  1575. } KSSTREAMALLOCATOR_STATUS, *PKSSTREAMALLOCATOR_STATUS;
  1576. typedef struct {
  1577.     KSALLOCATOR_FRAMING_EX Framing;
  1578.     ULONG                  AllocatedFrames;
  1579.     ULONG                  Reserved;
  1580. } KSSTREAMALLOCATOR_STATUS_EX, *PKSSTREAMALLOCATOR_STATUS_EX;
  1581. #define KSSTREAM_HEADER_OPTIONSF_SPLICEPOINT        0x00000001
  1582. #define KSSTREAM_HEADER_OPTIONSF_PREROLL            0x00000002
  1583. #define KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY  0x00000004
  1584. #define KSSTREAM_HEADER_OPTIONSF_TYPECHANGED        0x00000008
  1585. #define KSSTREAM_HEADER_OPTIONSF_TIMEVALID          0x00000010
  1586. #define KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY  0x00000040
  1587. #define KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE       0x00000080
  1588. #define KSSTREAM_HEADER_OPTIONSF_DURATIONVALID      0x00000100
  1589. #define KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM        0x00000200
  1590. #define KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA         0x80000000
  1591. typedef struct {
  1592.     LONGLONG    Time;
  1593.     ULONG       Numerator;
  1594.     ULONG       Denominator;
  1595. } KSTIME, *PKSTIME;
  1596. typedef struct {
  1597.     ULONG       Size;
  1598.     ULONG       TypeSpecificFlags;
  1599.     KSTIME      PresentationTime;
  1600.     LONGLONG    Duration;
  1601.     ULONG       FrameExtent;
  1602.     ULONG       DataUsed;
  1603.     PVOID       Data;
  1604.     ULONG       OptionsFlags;
  1605. #if _WIN64
  1606.     ULONG       Reserved;
  1607. #endif
  1608. } KSSTREAM_HEADER, *PKSSTREAM_HEADER;
  1609. #define STATIC_KSPROPSETID_StreamInterface
  1610.     0x1fdd8ee1L, 0x9cd3, 0x11d0, 0x82, 0xaa, 0x00, 0x00, 0xf8, 0x22, 0xfe, 0x8a
  1611. DEFINE_GUIDSTRUCT("1fdd8ee1-9cd3-11d0-82aa-0000f822fe8a", KSPROPSETID_StreamInterface);
  1612. #define KSPROPSETID_StreamInterface DEFINE_GUIDNAMED(KSPROPSETID_StreamInterface)
  1613. typedef enum {
  1614.     KSPROPERTY_STREAMINTERFACE_HEADERSIZE
  1615. } KSPROPERTY_STREAMINTERFACE;
  1616. #define DEFINE_KSPROPERTY_ITEM_STREAMINTERFACE_HEADERSIZE( GetHandler )
  1617.     DEFINE_KSPROPERTY_ITEM(
  1618.         KSPROPERTY_STREAMINTERFACE_HEADERSIZE,
  1619.         (GetHandler),
  1620.         sizeof(KSPROPERTY),
  1621.         sizeof(ULONG),
  1622.         NULL, NULL, 0, NULL, NULL, 0)
  1623.         
  1624. #define DEFINE_KSPROPERTY_STREAMINTERFACESET(StreamInterfaceSet,
  1625.     HeaderSizeHandler)
  1626. DEFINE_KSPROPERTY_TABLE(StreamInterfaceSet) {
  1627.     DEFINE_KSPROPERTY_ITEM_STREAMINTERFACE_HEADERSIZE( HeaderSizeHandler )
  1628. }
  1629. #define STATIC_KSPROPSETID_Stream
  1630.     0x65aaba60L, 0x98ae, 0x11cf, 0xa1, 0x0d, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
  1631. DEFINE_GUIDSTRUCT("65aaba60-98ae-11cf-a10d-0020afd156e4", KSPROPSETID_Stream);
  1632. #define KSPROPSETID_Stream DEFINE_GUIDNAMED(KSPROPSETID_Stream)
  1633. typedef enum {
  1634.     KSPROPERTY_STREAM_ALLOCATOR,
  1635.     KSPROPERTY_STREAM_QUALITY,
  1636.     KSPROPERTY_STREAM_DEGRADATION,
  1637.     KSPROPERTY_STREAM_MASTERCLOCK,
  1638.     KSPROPERTY_STREAM_TIMEFORMAT,
  1639.     KSPROPERTY_STREAM_PRESENTATIONTIME,
  1640.     KSPROPERTY_STREAM_PRESENTATIONEXTENT,
  1641.     KSPROPERTY_STREAM_FRAMETIME,
  1642.     KSPROPERTY_STREAM_RATECAPABILITY,
  1643.     KSPROPERTY_STREAM_RATE,
  1644.     KSPROPERTY_STREAM_PIPE_ID
  1645. } KSPROPERTY_STREAM;
  1646. #define DEFINE_KSPROPERTY_ITEM_STREAM_ALLOCATOR(GetHandler, SetHandler)
  1647.     DEFINE_KSPROPERTY_ITEM(
  1648.         KSPROPERTY_STREAM_ALLOCATOR,
  1649.         (GetHandler),
  1650.         sizeof(KSPROPERTY),
  1651.         sizeof(HANDLE),
  1652.         (SetHandler),
  1653.         NULL, 0, NULL, NULL, 0)
  1654. #define DEFINE_KSPROPERTY_ITEM_STREAM_QUALITY(Handler)
  1655.     DEFINE_KSPROPERTY_ITEM(
  1656.         KSPROPERTY_STREAM_QUALITY,
  1657.         (Handler),
  1658.         sizeof(KSPROPERTY),
  1659.         sizeof(KSQUALITY_MANAGER),
  1660.         NULL, NULL, 0, NULL, NULL, 0)
  1661. #define DEFINE_KSPROPERTY_ITEM_STREAM_DEGRADATION(GetHandler, SetHandler)
  1662.     DEFINE_KSPROPERTY_ITEM(
  1663.         KSPROPERTY_STREAM_DEGRADATION,
  1664.         (GetHandler),
  1665.         sizeof(KSPROPERTY),
  1666.         0,
  1667.         (SetHandler),
  1668.         NULL, 0, NULL, NULL, 0)
  1669. #define DEFINE_KSPROPERTY_ITEM_STREAM_MASTERCLOCK(GetHandler, SetHandler)
  1670.     DEFINE_KSPROPERTY_ITEM(
  1671.         KSPROPERTY_STREAM_MASTERCLOCK,
  1672.         (GetHandler),
  1673.         sizeof(KSPROPERTY),
  1674.         sizeof(HANDLE),
  1675.         (SetHandler),
  1676.         NULL, 0, NULL, NULL, 0)
  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. #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONTIME(GetHandler, SetHandler)
  1685.     DEFINE_KSPROPERTY_ITEM(
  1686.         KSPROPERTY_STREAM_PRESENTATIONTIME,
  1687.         (GetHandler),
  1688.         sizeof(KSPROPERTY),
  1689.         sizeof(KSTIME),
  1690.         (SetHandler),
  1691.         NULL, 0, NULL, NULL, 0)
  1692. #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONEXTENT(Handler)
  1693.     DEFINE_KSPROPERTY_ITEM(
  1694.         KSPROPERTY_STREAM_PRESENTATIONEXTENT,
  1695.         (Handler),
  1696.         sizeof(KSPROPERTY),
  1697.         sizeof(LONGLONG),
  1698.         NULL, NULL, 0, NULL, NULL, 0)
  1699. #define DEFINE_KSPROPERTY_ITEM_STREAM_FRAMETIME(Handler)
  1700.     DEFINE_KSPROPERTY_ITEM(
  1701.         KSPROPERTY_STREAM_FRAMETIME,
  1702.         (Handler),
  1703.         sizeof(KSPROPERTY),
  1704.         sizeof(KSFRAMETIME),
  1705.         NULL, NULL, 0, NULL, NULL, 0)
  1706. #define DEFINE_KSPROPERTY_ITEM_STREAM_RATECAPABILITY(Handler)
  1707.     DEFINE_KSPROPERTY_ITEM(
  1708.         KSPROPERTY_STREAM_RATECAPABILITY,
  1709.         (Handler),
  1710.         sizeof(KSRATE_CAPABILITY),
  1711.         sizeof(KSRATE),
  1712.         NULL, NULL, 0, NULL, NULL, 0)
  1713. #define DEFINE_KSPROPERTY_ITEM_STREAM_RATE(GetHandler, SetHandler)
  1714.     DEFINE_KSPROPERTY_ITEM(
  1715.         KSPROPERTY_STREAM_RATE,
  1716.         (GetHandler),
  1717.         sizeof(KSPROPERTY),
  1718.         sizeof(KSRATE),
  1719.         (SetHandler),
  1720.         NULL, 0, NULL, NULL, 0)
  1721. #define DEFINE_KSPROPERTY_ITEM_STREAM_PIPE_ID(GetHandler, SetHandler)
  1722.     DEFINE_KSPROPERTY_ITEM(
  1723.         KSPROPERTY_STREAM_PIPE_ID,
  1724.         (GetHandler),
  1725.         sizeof(KSPROPERTY),
  1726.         sizeof(HANDLE),
  1727.         (SetHandler),
  1728.         NULL, 0, NULL, NULL, 0)
  1729. typedef struct {
  1730.     HANDLE      QualityManager;
  1731.     PVOID       Context;
  1732. } KSQUALITY_MANAGER, *PKSQUALITY_MANAGER;
  1733. typedef struct {
  1734.     LONGLONG    Duration;
  1735.     ULONG       FrameFlags;
  1736.     ULONG       Reserved;
  1737. } KSFRAMETIME, *PKSFRAMETIME;
  1738. #define KSFRAMETIME_VARIABLESIZE    0x00000001
  1739. typedef struct {
  1740.     LONGLONG        PresentationStart;
  1741.     LONGLONG        Duration;
  1742.     KSPIN_INTERFACE Interface;
  1743.     LONG            Rate;
  1744.     ULONG           Flags;
  1745. } KSRATE, *PKSRATE;
  1746. #define KSRATE_NOPRESENTATIONSTART      0x00000001
  1747. #define KSRATE_NOPRESENTATIONDURATION   0x00000002
  1748. typedef struct {
  1749.     KSPROPERTY      Property;
  1750.     KSRATE          Rate;
  1751. } KSRATE_CAPABILITY, *PKSRATE_CAPABILITY;
  1752. #define STATIC_KSPROPSETID_Clock 
  1753.     0xDF12A4C0L, 0xAC17, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1754. DEFINE_GUIDSTRUCT("DF12A4C0-AC17-11CF-A5D6-28DB04C10000", KSPROPSETID_Clock);
  1755. #define KSPROPSETID_Clock DEFINE_GUIDNAMED(KSPROPSETID_Clock)
  1756. //
  1757. // Performs a x*y/z operation on 64 bit quantities by splitting the operation. The equation
  1758. // is simplified with respect to adding in the remainder for the upper 32 bits.
  1759. //
  1760. // (xh * 10000000 / Frequency) * 2^32 + ((((xh * 10000000) % Frequency) * 2^32 + (xl * 10000000)) / Frequency)
  1761. //
  1762. #define NANOSECONDS 10000000
  1763. #define KSCONVERT_PERFORMANCE_TIME(Frequency, PerformanceTime) 
  1764.     ((((ULONGLONG)(ULONG)(PerformanceTime).HighPart * NANOSECONDS / (Frequency)) << 32) + 
  1765.     ((((((ULONGLONG)(ULONG)(PerformanceTime).HighPart * NANOSECONDS) % (Frequency)) << 32) + 
  1766.     ((ULONGLONG)(PerformanceTime).LowPart * NANOSECONDS)) / (Frequency)))
  1767. typedef struct {
  1768.     ULONG       CreateFlags;
  1769. } KSCLOCK_CREATE, *PKSCLOCK_CREATE;
  1770. typedef struct {
  1771.     LONGLONG    Time;
  1772.     LONGLONG    SystemTime;
  1773. } KSCORRELATED_TIME, *PKSCORRELATED_TIME;
  1774. typedef struct {
  1775.     LONGLONG    Granularity;
  1776.     LONGLONG    Error;
  1777. } KSRESOLUTION, *PKSRESOLUTION;
  1778. typedef enum {
  1779.     KSPROPERTY_CLOCK_TIME,
  1780.     KSPROPERTY_CLOCK_PHYSICALTIME,
  1781.     KSPROPERTY_CLOCK_CORRELATEDTIME,
  1782.     KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME,
  1783.     KSPROPERTY_CLOCK_RESOLUTION,
  1784.     KSPROPERTY_CLOCK_STATE,
  1785. #if defined(_NTDDK_)
  1786.     KSPROPERTY_CLOCK_FUNCTIONTABLE
  1787. #endif // defined(_NTDDK_)
  1788. } KSPROPERTY_CLOCK;
  1789. #if defined(_NTDDK_)
  1790. typedef
  1791. LONGLONG
  1792. (FASTCALL *PFNKSCLOCK_GETTIME)(
  1793.     IN PFILE_OBJECT FileObject
  1794.     );
  1795. typedef
  1796. LONGLONG
  1797. (FASTCALL *PFNKSCLOCK_CORRELATEDTIME)(
  1798.     IN PFILE_OBJECT FileObject,
  1799.     OUT PLONGLONG SystemTime);
  1800. typedef struct {
  1801.     PFNKSCLOCK_GETTIME GetTime;
  1802.     PFNKSCLOCK_GETTIME GetPhysicalTime;
  1803.     PFNKSCLOCK_CORRELATEDTIME GetCorrelatedTime;
  1804.     PFNKSCLOCK_CORRELATEDTIME GetCorrelatedPhysicalTime;
  1805. } KSCLOCK_FUNCTIONTABLE, *PKSCLOCK_FUNCTIONTABLE;
  1806. typedef
  1807. BOOLEAN
  1808. (*PFNKSSETTIMER)(
  1809.     IN PVOID Context,
  1810.     IN PKTIMER Timer,
  1811.     IN LARGE_INTEGER DueTime,
  1812.     IN PKDPC Dpc
  1813.     );
  1814. typedef
  1815. BOOLEAN
  1816. (*PFNKSCANCELTIMER)(
  1817.     IN PVOID Context,
  1818.     IN PKTIMER Timer
  1819.     );
  1820. typedef
  1821. LONGLONG
  1822. (FASTCALL *PFNKSCORRELATEDTIME)(
  1823.     IN PVOID Context,
  1824.     OUT PLONGLONG SystemTime);
  1825. typedef PVOID   PKSDEFAULTCLOCK;
  1826. #define DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(Handler)
  1827.     DEFINE_KSPROPERTY_ITEM(
  1828.         KSPROPERTY_CLOCK_TIME,
  1829.         (Handler),
  1830.         sizeof(KSPROPERTY),
  1831.         sizeof(LONGLONG),
  1832.         NULL, NULL, 0, NULL, NULL, 0)
  1833. #define DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(Handler)
  1834.     DEFINE_KSPROPERTY_ITEM(
  1835.         KSPROPERTY_CLOCK_PHYSICALTIME,
  1836.         (Handler),
  1837.         sizeof(KSPROPERTY),
  1838.         sizeof(LONGLONG),
  1839.         NULL, NULL, 0, NULL, NULL, 0)
  1840. #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(Handler)
  1841.     DEFINE_KSPROPERTY_ITEM(
  1842.         KSPROPERTY_CLOCK_CORRELATEDTIME,
  1843.         (Handler),
  1844.         sizeof(KSPROPERTY),
  1845.         sizeof(KSCORRELATED_TIME),
  1846.         NULL, NULL, 0, NULL, NULL, 0)
  1847. #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(Handler)
  1848.     DEFINE_KSPROPERTY_ITEM(
  1849.         KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME,
  1850.         (Handler),
  1851.         sizeof(KSPROPERTY),
  1852.         sizeof(KSCORRELATED_TIME),
  1853.         NULL, NULL, 0, NULL, NULL, 0)
  1854. #define DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(Handler)
  1855.     DEFINE_KSPROPERTY_ITEM(
  1856.         KSPROPERTY_CLOCK_RESOLUTION,
  1857.         (Handler),
  1858.         sizeof(KSPROPERTY),
  1859.         sizeof(KSRESOLUTION),
  1860.         NULL, NULL, 0, NULL, NULL, 0)
  1861. #define DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(Handler)
  1862.     DEFINE_KSPROPERTY_ITEM(
  1863.         KSPROPERTY_CLOCK_STATE,
  1864.         (Handler),
  1865.         sizeof(KSPROPERTY),
  1866.         sizeof(KSSTATE),
  1867.         NULL, NULL, 0, NULL, NULL, 0)
  1868. #define DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(Handler)
  1869.     DEFINE_KSPROPERTY_ITEM(
  1870.         KSPROPERTY_CLOCK_FUNCTIONTABLE,
  1871.         (Handler),
  1872.         sizeof(KSPROPERTY),
  1873.         sizeof(KSCLOCK_FUNCTIONTABLE),
  1874.         NULL, NULL, 0, NULL, NULL, 0)
  1875. #define DEFINE_KSPROPERTY_CLOCKSET(ClockSet,
  1876.     PropTime, PropPhysicalTime,
  1877.     PropCorrelatedTime, PropCorrelatedPhysicalTime,
  1878.     PropResolution, PropState, PropFunctionTable)
  1879. DEFINE_KSPROPERTY_TABLE(ClockSet) {
  1880.     DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(PropTime),
  1881.     DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(PropPhysicalTime),
  1882.     DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(PropCorrelatedTime),
  1883.     DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(PropCorrelatedPhysicalTime),
  1884.     DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(PropResolution),
  1885.     DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(PropState),
  1886.     DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(PropFunctionTable),
  1887. }
  1888. #endif // defined(_NTDDK_)
  1889. #define STATIC_KSEVENTSETID_Clock 
  1890.     0x364D8E20L, 0x62C7, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1891. DEFINE_GUIDSTRUCT("364D8E20-62C7-11CF-A5D6-28DB04C10000", KSEVENTSETID_Clock);
  1892. #define KSEVENTSETID_Clock DEFINE_GUIDNAMED(KSEVENTSETID_Clock)
  1893. typedef enum {
  1894.     KSEVENT_CLOCK_INTERVAL_MARK,
  1895.     KSEVENT_CLOCK_POSITION_MARK
  1896. } KSEVENT_CLOCK_POSITION;
  1897. #define STATIC_KSEVENTSETID_Connection
  1898.     0x7f4bcbe0L, 0x9ea5, 0x11cf, 0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00
  1899. DEFINE_GUIDSTRUCT("7f4bcbe0-9ea5-11cf-a5d6-28db04c10000", KSEVENTSETID_Connection);
  1900. #define KSEVENTSETID_Connection DEFINE_GUIDNAMED(KSEVENTSETID_Connection)
  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. typedef struct {
  1909.     PVOID       Context;
  1910.     ULONG       Proportion;
  1911.     LONGLONG    DeltaTime;
  1912. } KSQUALITY, *PKSQUALITY;
  1913. typedef struct {
  1914.     PVOID       Context;
  1915.     ULONG       Status;
  1916. } KSERROR, *PKSERROR;
  1917. typedef KSIDENTIFIER KSDEGRADE, *PKSDEGRADE;
  1918. #define STATIC_KSDEGRADESETID_Standard
  1919.     0x9F564180L, 0x704C, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
  1920. DEFINE_GUIDSTRUCT("9F564180-704C-11D0-A5D6-28DB04C10000", KSDEGRADESETID_Standard);
  1921. #define KSDEGRADESETID_Standard DEFINE_GUIDNAMED(KSDEGRADESETID_Standard)
  1922. typedef enum {
  1923.     KSDEGRADE_STANDARD_SAMPLE,
  1924.     KSDEGRADE_STANDARD_QUALITY,
  1925.     KSDEGRADE_STANDARD_COMPUTATION,
  1926.     KSDEGRADE_STANDARD_SKIP
  1927. } KSDEGRADE_STANDARD;
  1928. #if defined(_NTDDK_)
  1929. #define KSPROBE_STREAMREAD      0x00000000
  1930. #define KSPROBE_STREAMWRITE     0x00000001
  1931. #define KSPROBE_ALLOCATEMDL     0x00000010
  1932. #define KSPROBE_PROBEANDLOCK    0x00000020
  1933. #define KSPROBE_SYSTEMADDRESS   0x00000040
  1934. #define KSPROBE_MODIFY          0x00000200
  1935. #define KSPROBE_STREAMWRITEMODIFY (KSPROBE_MODIFY | KSPROBE_STREAMWRITE)
  1936. #define KSPROBE_ALLOWFORMATCHANGE   0x00000080
  1937. #define KSSTREAM_READ           KSPROBE_STREAMREAD
  1938. #define KSSTREAM_WRITE          KSPROBE_STREAMWRITE
  1939. #define KSSTREAM_PAGED_DATA     0x00000000
  1940. #define KSSTREAM_NONPAGED_DATA  0x00000100
  1941. #define KSSTREAM_SYNCHRONOUS    0x00001000
  1942. #define KSSTREAM_FAILUREEXCEPTION 0x00002000
  1943. typedef
  1944. NTSTATUS
  1945. (*PFNKSCONTEXT_DISPATCH)(
  1946.     IN PVOID Context,
  1947.     IN PIRP Irp
  1948.     );
  1949. typedef
  1950. NTSTATUS
  1951. (*PFNKSHANDLER)(
  1952.     IN PIRP Irp,
  1953.     IN PKSIDENTIFIER Request,
  1954.     IN OUT PVOID Data
  1955.     );
  1956. typedef
  1957. BOOLEAN
  1958. (*PFNKSFASTHANDLER)(
  1959.     IN PFILE_OBJECT FileObject,
  1960.     IN PKSIDENTIFIER Request,
  1961.     IN ULONG RequestLength,
  1962.     IN OUT PVOID Data,
  1963.     IN ULONG DataLength,
  1964.     OUT PIO_STATUS_BLOCK IoStatus
  1965.     );
  1966. typedef
  1967. NTSTATUS
  1968. (*PFNKSALLOCATOR)(
  1969.     IN PIRP Irp,
  1970.     IN ULONG BufferSize,
  1971.     IN BOOLEAN InputOperation
  1972.     );
  1973. typedef struct {
  1974.     KSPROPERTY_MEMBERSHEADER    MembersHeader;
  1975.     const VOID*                 Members;
  1976. } KSPROPERTY_MEMBERSLIST, *PKSPROPERTY_MEMBERSLIST;
  1977. typedef struct {
  1978.     KSIDENTIFIER                    PropTypeSet;
  1979.     ULONG                           MembersListCount;
  1980.     const KSPROPERTY_MEMBERSLIST*   MembersList;
  1981. } KSPROPERTY_VALUES, *PKSPROPERTY_VALUES;
  1982. #define DEFINE_KSPROPERTY_TABLE(tablename)
  1983.     const KSPROPERTY_ITEM tablename[] =
  1984. #define DEFINE_KSPROPERTY_ITEM(PropertyId, GetHandler,
  1985.                                MinProperty,
  1986.                                MinData,
  1987.                                SetHandler,
  1988.                                Values, RelationsCount, Relations, SupportHandler,
  1989.                                SerializedSize)
  1990. {
  1991.     PropertyId, (PFNKSHANDLER)GetHandler, MinProperty, MinData,
  1992.     (PFNKSHANDLER)SetHandler,
  1993.     (PKSPROPERTY_VALUES)Values, RelationsCount, (PKSPROPERTY)Relations,
  1994.     (PFNKSHANDLER)SupportHandler, (ULONG)SerializedSize
  1995. }
  1996. typedef struct {
  1997.     ULONG                   PropertyId;
  1998.     union {
  1999.         PFNKSHANDLER            GetPropertyHandler;
  2000.         BOOLEAN                 GetSupported;
  2001.     };
  2002.     ULONG                   MinProperty;
  2003.     ULONG                   MinData;
  2004.     union {
  2005.         PFNKSHANDLER            SetPropertyHandler;
  2006.         BOOLEAN                 SetSupported;
  2007.     };
  2008.     const KSPROPERTY_VALUES*Values;
  2009.     ULONG                   RelationsCount;
  2010.     const KSPROPERTY*       Relations;
  2011.     PFNKSHANDLER            SupportHandler;
  2012.     ULONG                   SerializedSize;
  2013. } KSPROPERTY_ITEM, *PKSPROPERTY_ITEM;
  2014. #define DEFINE_KSFASTPROPERTY_ITEM(PropertyId, GetHandler, SetHandler)
  2015. {
  2016.     PropertyId, (PFNKSFASTHANDLER)GetHandler, (PFNKSFASTHANDLER)SetHandler, 0
  2017. }
  2018. typedef struct {
  2019.     ULONG                       PropertyId;
  2020.     union {
  2021.         PFNKSFASTHANDLER            GetPropertyHandler;
  2022.         BOOLEAN                     GetSupported;
  2023.     };
  2024.     union {
  2025.         PFNKSFASTHANDLER            SetPropertyHandler;
  2026.         BOOLEAN                     SetSupported;
  2027.     };
  2028.     ULONG                       Reserved;
  2029. } KSFASTPROPERTY_ITEM, *PKSFASTPROPERTY_ITEM;
  2030. #define DEFINE_KSPROPERTY_SET(Set,
  2031.                               PropertiesCount,
  2032.                               PropertyItem,
  2033.                               FastIoCount,
  2034.                               FastIoTable)
  2035. {
  2036.     Set,
  2037.     PropertiesCount,
  2038.     PropertyItem,
  2039.     FastIoCount,
  2040.     FastIoTable
  2041. }
  2042. #define DEFINE_KSPROPERTY_SET_TABLE(tablename)
  2043.     const KSPROPERTY_SET tablename[] =
  2044. typedef struct {
  2045.     const GUID*                 Set;
  2046.     ULONG                       PropertiesCount;
  2047.     const KSPROPERTY_ITEM*      PropertyItem;
  2048.     ULONG                       FastIoCount;
  2049.     const KSFASTPROPERTY_ITEM*  FastIoTable;
  2050. } KSPROPERTY_SET, *PKSPROPERTY_SET;
  2051. #define DEFINE_KSMETHOD_TABLE(tablename)
  2052.     const KSMETHOD_ITEM tablename[] =
  2053. #define DEFINE_KSMETHOD_ITEM(MethodId, Flags,
  2054.                              MethodHandler,
  2055.                              MinMethod, MinData, SupportHandler)
  2056. {
  2057.     MethodId, (PFNKSHANDLER)MethodHandler, MinMethod, MinData,
  2058.     SupportHandler, Flags
  2059. }
  2060. typedef struct {
  2061.     ULONG                   MethodId;
  2062.     union {
  2063.         PFNKSHANDLER            MethodHandler;
  2064.         BOOLEAN                 MethodSupported;
  2065.     };
  2066.     ULONG                   MinMethod;
  2067.     ULONG                   MinData;
  2068.     PFNKSHANDLER            SupportHandler;
  2069.     ULONG                   Flags;
  2070. } KSMETHOD_ITEM, *PKSMETHOD_ITEM;
  2071. #define DEFINE_KSFASTMETHOD_ITEM(MethodId, MethodHandler)
  2072. {
  2073.     MethodId, (PFNKSFASTHANDLER)MethodHandler
  2074. }
  2075. typedef struct {
  2076.     ULONG                   MethodId;
  2077.     union {
  2078.         PFNKSFASTHANDLER        MethodHandler;
  2079.         BOOLEAN                 MethodSupported;
  2080.     };
  2081. } KSFASTMETHOD_ITEM, *PKSFASTMETHOD_ITEM;
  2082. #define DEFINE_KSMETHOD_SET(Set,
  2083.                             MethodsCount,
  2084.                             MethodItem,
  2085.                             FastIoCount,
  2086.                             FastIoTable)
  2087. {
  2088.     Set,
  2089.     MethodsCount,
  2090.     MethodItem,
  2091.     FastIoCount,
  2092.     FastIoTable
  2093. }
  2094. #define DEFINE_KSMETHOD_SET_TABLE(tablename)
  2095.     const KSMETHOD_SET tablename[] =
  2096. typedef struct {
  2097.     const GUID*             Set;
  2098.     ULONG                   MethodsCount;
  2099.     const KSMETHOD_ITEM*    MethodItem;
  2100.     ULONG                   FastIoCount;
  2101.     const KSFASTMETHOD_ITEM*FastIoTable;
  2102. } KSMETHOD_SET, *PKSMETHOD_SET;
  2103. typedef struct _KSEVENT_ENTRY
  2104. KSEVENT_ENTRY, *PKSEVENT_ENTRY;
  2105. typedef
  2106. NTSTATUS
  2107. (*PFNKSADDEVENT)(
  2108.     IN PIRP Irp,
  2109.     IN PKSEVENTDATA EventData,
  2110.     IN struct _KSEVENT_ENTRY* EventEntry
  2111.     );
  2112. typedef
  2113. VOID
  2114. (*PFNKSREMOVEEVENT)(
  2115.     IN PFILE_OBJECT FileObject,
  2116.     IN struct _KSEVENT_ENTRY* EventEntry
  2117.     );
  2118.     
  2119. #define DEFINE_KSEVENT_TABLE(tablename)
  2120.     const KSEVENT_ITEM tablename[] =
  2121. #define DEFINE_KSEVENT_ITEM(EventId, DataInput, ExtraEntryData,
  2122.                             AddHandler, RemoveHandler, SupportHandler)
  2123. {
  2124.     EventId,
  2125.     DataInput,
  2126.     ExtraEntryData,
  2127.     AddHandler,
  2128.     RemoveHandler,
  2129.     SupportHandler
  2130. }
  2131. typedef struct {
  2132.     ULONG               EventId;
  2133.     ULONG               DataInput;
  2134.     ULONG               ExtraEntryData;
  2135.     PFNKSADDEVENT       AddHandler;
  2136.     PFNKSREMOVEEVENT    RemoveHandler;
  2137.     PFNKSHANDLER        SupportHandler;
  2138. } KSEVENT_ITEM, *PKSEVENT_ITEM;
  2139. #define DEFINE_KSEVENT_SET(Set,
  2140.                            EventsCount,
  2141.                            EventItem)
  2142. {
  2143.     Set, EventsCount, EventItem
  2144. }
  2145. #define DEFINE_KSEVENT_SET_TABLE(tablename)
  2146.     const KSEVENT_SET tablename[] =
  2147. typedef struct {
  2148.     const GUID*         Set;
  2149.     ULONG               EventsCount;
  2150.     const KSEVENT_ITEM* EventItem;
  2151. } KSEVENT_SET, *PKSEVENT_SET;
  2152. typedef struct {
  2153.     KDPC            Dpc;
  2154.     ULONG           ReferenceCount;
  2155.     KSPIN_LOCK      AccessLock;
  2156. } KSDPC_ITEM, *PKSDPC_ITEM;
  2157. typedef struct {
  2158.     KSDPC_ITEM          DpcItem;
  2159.     LIST_ENTRY          BufferList;
  2160. } KSBUFFER_ITEM, *PKSBUFFER_ITEM;
  2161. #define KSEVENT_ENTRY_DELETED   1
  2162. #define KSEVENT_ENTRY_ONESHOT   2
  2163. #define KSEVENT_ENTRY_BUFFERED  4
  2164. struct _KSEVENT_ENTRY {
  2165.     LIST_ENTRY      ListEntry;
  2166.     PVOID           Object;
  2167.     union {
  2168.         PKSDPC_ITEM         DpcItem;
  2169.         PKSBUFFER_ITEM      BufferItem;
  2170.     };
  2171.     PKSEVENTDATA        EventData;
  2172.     ULONG               NotificationType;
  2173.     const KSEVENT_SET*  EventSet;
  2174.     const KSEVENT_ITEM* EventItem;
  2175.     PFILE_OBJECT        FileObject;
  2176.     ULONG               SemaphoreAdjustment;
  2177.     ULONG               Reserved;
  2178.     ULONG               Flags;
  2179. };
  2180. typedef enum {
  2181.     KSEVENTS_NONE,
  2182.     KSEVENTS_SPINLOCK,
  2183.     KSEVENTS_MUTEX,
  2184.     KSEVENTS_FMUTEX,
  2185.     KSEVENTS_FMUTEXUNSAFE,
  2186.     KSEVENTS_INTERRUPT,
  2187.     KSEVENTS_ERESOURCE
  2188. } KSEVENTS_LOCKTYPE;
  2189. #define KSDISPATCH_FASTIO       0x80000000
  2190. typedef struct {
  2191.     PDRIVER_DISPATCH        Create;
  2192.     PVOID                   Context;
  2193.     UNICODE_STRING          ObjectClass;
  2194.     PSECURITY_DESCRIPTOR    SecurityDescriptor;
  2195.     ULONG                   Flags;
  2196. } KSOBJECT_CREATE_ITEM, *PKSOBJECT_CREATE_ITEM;
  2197. typedef
  2198. VOID
  2199. (*PFNKSITEMFREECALLBACK)(
  2200.     IN PKSOBJECT_CREATE_ITEM CreateItem
  2201.     );
  2202. #define KSCREATE_ITEM_SECURITYCHANGED       0x00000001
  2203. #define KSCREATE_ITEM_WILDCARD              0x00000002
  2204. #define KSCREATE_ITEM_NOPARAMETERS          0x00000004
  2205. #define KSCREATE_ITEM_FREEONSTOP            0x00000008
  2206. #define DEFINE_KSCREATE_DISPATCH_TABLE( tablename )
  2207.     KSOBJECT_CREATE_ITEM tablename[] =
  2208. #define DEFINE_KSCREATE_ITEM(DispatchCreate, TypeName, Context)
  2209. {
  2210.     (DispatchCreate),
  2211.     (PVOID)(Context),
  2212.     {
  2213.         sizeof(TypeName) - sizeof(UNICODE_NULL),
  2214.         sizeof(TypeName),
  2215.         (PWCHAR)(TypeName)
  2216.     },
  2217.     NULL, 0
  2218. }
  2219. #define DEFINE_KSCREATE_ITEMEX(DispatchCreate, TypeName, Context, Flags)
  2220. {
  2221.     (DispatchCreate),
  2222.     (PVOID)(Context),
  2223.     {
  2224.         sizeof(TypeName) - sizeof(UNICODE_NULL),
  2225.         sizeof(TypeName),
  2226.         (PWCHAR)(TypeName)
  2227.     },
  2228.     NULL, (Flags)
  2229. }
  2230. #define DEFINE_KSCREATE_ITEMNULL( DispatchCreate, Context )
  2231. {
  2232.     DispatchCreate,
  2233.     Context,
  2234.     {
  2235.         0,
  2236.         0,
  2237.         NULL,
  2238.     },
  2239.     NULL, 0
  2240. }
  2241. typedef struct {
  2242.     ULONG                    CreateItemsCount;
  2243.     PKSOBJECT_CREATE_ITEM    CreateItemsList;
  2244. } KSOBJECT_CREATE, *PKSOBJECT_CREATE;
  2245. typedef struct {
  2246.     PDRIVER_DISPATCH        DeviceIoControl;
  2247.     PDRIVER_DISPATCH        Read;
  2248.     PDRIVER_DISPATCH        Write;
  2249.     PDRIVER_DISPATCH        Flush;
  2250.     PDRIVER_DISPATCH        Close;
  2251.     PDRIVER_DISPATCH        QuerySecurity;
  2252.     PDRIVER_DISPATCH        SetSecurity;
  2253.     PFAST_IO_DEVICE_CONTROL FastDeviceIoControl;
  2254.     PFAST_IO_READ           FastRead;
  2255.     PFAST_IO_WRITE          FastWrite;
  2256. } KSDISPATCH_TABLE, *PKSDISPATCH_TABLE;
  2257. #define DEFINE_KSDISPATCH_TABLE( tablename, DeviceIoControl, Read, Write,
  2258.                                  Flush, Close, QuerySecurity, SetSecurity,
  2259.                                  FastDeviceIoControl, FastRead, FastWrite  )
  2260.     const KSDISPATCH_TABLE tablename = 
  2261.     {
  2262.         DeviceIoControl,        
  2263.         Read,                   
  2264.         Write,                  
  2265.         Flush,                  
  2266.         Close,                  
  2267.         QuerySecurity,          
  2268.         SetSecurity,            
  2269.         FastDeviceIoControl,    
  2270.         FastRead,               
  2271.         FastWrite,              
  2272.     }
  2273. #define KSCREATE_ITEM_IRP_STORAGE(Irp)      (*(PKSOBJECT_CREATE_ITEM*)&(Irp)->Tail.Overlay.DriverContext[0])
  2274. #define KSEVENT_SET_IRP_STORAGE(Irp)        (*(const KSEVENT_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
  2275. #define KSEVENT_ITEM_IRP_STORAGE(Irp)       (*(const KSEVENT_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
  2276. #define KSEVENT_ENTRY_IRP_STORAGE(Irp)      (*(PKSEVENT_ENTRY*)&(Irp)->Tail.Overlay.DriverContext[0])
  2277. #define KSMETHOD_SET_IRP_STORAGE(Irp)       (*(const KSMETHOD_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
  2278. #define KSMETHOD_ITEM_IRP_STORAGE(Irp)      (*(const KSMETHOD_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
  2279. #define KSMETHOD_TYPE_IRP_STORAGE(Irp)      (*(ULONG_PTR*)(&(Irp)->Tail.Overlay.DriverContext[2]))
  2280. #define KSQUEUE_SPINLOCK_IRP_STORAGE(Irp)   (*(PKSPIN_LOCK*)&(Irp)->Tail.Overlay.DriverContext[1])
  2281. #define KSPROPERTY_SET_IRP_STORAGE(Irp)     (*(const KSPROPERTY_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
  2282. #define KSPROPERTY_ITEM_IRP_STORAGE(Irp)    (*(const KSPROPERTY_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
  2283. #define KSPROPERTY_ATTRIBUTES_IRP_STORAGE(Irp) (*(PKSATTRIBUTE_LIST*)&(Irp)->Tail.Overlay.DriverContext[2])
  2284. typedef PVOID   KSDEVICE_HEADER, KSOBJECT_HEADER;
  2285. typedef enum {
  2286.     KsInvokeOnSuccess = 1,
  2287.     KsInvokeOnError = 2,
  2288.     KsInvokeOnCancel = 4
  2289. } KSCOMPLETION_INVOCATION;
  2290. typedef enum {
  2291.     KsListEntryTail,
  2292.     KsListEntryHead
  2293. } KSLIST_ENTRY_LOCATION;
  2294. typedef enum {
  2295.     KsAcquireOnly,
  2296.     KsAcquireAndRemove,
  2297.     KsAcquireOnlySingleItem,
  2298.     KsAcquireAndRemoveOnlySingleItem
  2299. } KSIRP_REMOVAL_OPERATION;
  2300. typedef enum {
  2301.     KsStackCopyToNewLocation,
  2302.     KsStackReuseCurrentLocation,
  2303.     KsStackUseNewLocation
  2304. } KSSTACK_USE;
  2305. typedef enum {
  2306.     KSTARGET_STATE_DISABLED,
  2307.     KSTARGET_STATE_ENABLED
  2308. } KSTARGET_STATE;
  2309. typedef
  2310. NTSTATUS
  2311. (*PFNKSIRPLISTCALLBACK)(
  2312.     IN PIRP Irp,
  2313.     IN PVOID Context
  2314.     );
  2315. typedef 
  2316. VOID 
  2317. (*PFNREFERENCEDEVICEOBJECT)( 
  2318.     IN PVOID Context
  2319.     );
  2320.     
  2321. typedef 
  2322. VOID 
  2323. (*PFNDEREFERENCEDEVICEOBJECT)( 
  2324.     IN PVOID Context
  2325.     );
  2326.     
  2327. typedef
  2328. NTSTATUS
  2329. (*PFNQUERYREFERENCESTRING)( 
  2330.     IN PVOID Context,
  2331.     IN OUT PWCHAR *String
  2332.     );
  2333. #define BUS_INTERFACE_REFERENCE_VERSION    0x100
  2334.     
  2335. typedef struct {
  2336.     //
  2337.     // Standard interface header
  2338.     //
  2339.     
  2340.     INTERFACE                   Interface;
  2341.     
  2342.     //
  2343.     // Standard bus interfaces
  2344.     //
  2345.     
  2346.     PFNREFERENCEDEVICEOBJECT    ReferenceDeviceObject;
  2347.     PFNDEREFERENCEDEVICEOBJECT  DereferenceDeviceObject;
  2348.     PFNQUERYREFERENCESTRING     QueryReferenceString;
  2349.     
  2350. } BUS_INTERFACE_REFERENCE, *PBUS_INTERFACE_REFERENCE;
  2351. #define STATIC_REFERENCE_BUS_INTERFACE STATIC_KSMEDIUMSETID_Standard
  2352. #define REFERENCE_BUS_INTERFACE KSMEDIUMSETID_Standard
  2353. typedef
  2354. NTSTATUS
  2355. (*PFNQUERYMEDIUMSLIST)( 
  2356.     IN PVOID Context,
  2357.     OUT ULONG* MediumsCount,
  2358.     OUT PKSPIN_MEDIUM* MediumList
  2359.     );
  2360. typedef struct {
  2361.     //
  2362.     // Standard interface header
  2363.     //
  2364.     
  2365.     INTERFACE                   Interface;
  2366.     
  2367.     //
  2368.     // Interface definition
  2369.     //
  2370.     
  2371.     PFNQUERYMEDIUMSLIST         QueryMediumsList;
  2372.     
  2373. } BUS_INTERFACE_MEDIUMS, *PBUS_INTERFACE_MEDIUMS;
  2374. #define STATIC_GUID_BUS_INTERFACE_MEDIUMS 
  2375.     0x4EC35C3EL, 0x201B, 0x11D2, 0x87, 0x45, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
  2376. DEFINE_GUIDSTRUCT("4EC35C3E-201B-11D2-8745-00A0C9223196", GUID_BUS_INTERFACE_MEDIUMS);
  2377. #define GUID_BUS_INTERFACE_MEDIUMS DEFINE_GUIDNAMED(GUID_BUS_INTERFACE_MEDIUMS)
  2378. #endif // defined(_NTDDK_)
  2379. #if !defined( PACK_PRAGMAS_NOT_SUPPORTED )
  2380. #include <pshpack1.h>
  2381. #endif
  2382. typedef struct {
  2383.     GUID            PropertySet;
  2384.     ULONG           Count;
  2385. } KSPROPERTY_SERIALHDR, *PKSPROPERTY_SERIALHDR;
  2386. #if !defined( PACK_PRAGMAS_NOT_SUPPORTED )
  2387. #include <poppack.h>
  2388. #endif
  2389. typedef struct {
  2390.     KSIDENTIFIER    PropTypeSet;
  2391.     ULONG           Id;
  2392.     ULONG           PropertyLength;
  2393. } KSPROPERTY_SERIAL, *PKSPROPERTY_SERIAL;
  2394. #if defined(_NTDDK_)
  2395. #define IOCTL_KS_HANDSHAKE             CTL_CODE(FILE_DEVICE_KS, 0x007, METHOD_NEITHER, FILE_ANY_ACCESS)
  2396. typedef struct {
  2397.     GUID ProtocolId;
  2398.     PVOID Argument1;
  2399.     PVOID Argument2;
  2400. } KSHANDSHAKE, *PKSHANDSHAKE;
  2401. typedef struct _KSGATE
  2402. KSGATE, *PKSGATE;
  2403. struct _KSGATE {
  2404.     LONG Count;
  2405.     PKSGATE NextGate;
  2406. };
  2407. #ifndef _NTOS_
  2408. void __inline
  2409. KsGateTurnInputOn(
  2410.     IN PKSGATE Gate OPTIONAL
  2411.     )
  2412. {
  2413.     while (Gate && (InterlockedIncrement(&Gate->Count) == 1)) {
  2414.         Gate = Gate->NextGate;
  2415.     }
  2416. }
  2417. void __inline
  2418. KsGateTurnInputOff(
  2419.     IN PKSGATE Gate OPTIONAL
  2420.     )
  2421. {
  2422.     while (Gate && (InterlockedDecrement(&Gate->Count) == 0)) {
  2423.         Gate = Gate->NextGate;
  2424.     }
  2425. }
  2426. BOOLEAN __inline
  2427. KsGateGetStateUnsafe(
  2428.     IN PKSGATE Gate
  2429.     )
  2430. {
  2431.     ASSERT(Gate);
  2432.     return Gate->Count > 0;
  2433. }
  2434. BOOLEAN __inline
  2435. KsGateCaptureThreshold(
  2436.     IN PKSGATE Gate
  2437.     )
  2438. {
  2439.     BOOLEAN captured;
  2440.     ASSERT(Gate);