ReactOS  0.4.13-dev-257-gfabbd7c
ks.h
Go to the documentation of this file.
1 /*
2  ReactOS
3  Kernel Streaming API
4 
5  by Andrew Greenwood
6 
7  NOTES:
8  This is a basic stubbing of the Kernel Streaming API header. It is
9  very incomplete - a lot of the #defines are not set to any value at all.
10 
11  Some of the structs/funcs may be incorrectly grouped.
12 
13  GUIDs need to be defined properly.
14 
15  AVStream functionality (XP and above, DirectX 8.0 and above) will NOT
16  implemented for a while.
17 
18  Some example code for interaction from usermode:
19  DeviceIoControl(
20  FilterHandle,
21  IOCTL_KS_PROPERTY,
22  &Property,
23  sizeof(KSPROPERTY),
24  &SeekingCapabilities,
25  sizeof(KS_SEEKING_CAPABILITIES),
26  &BytesReturned,
27  &Overlapped);
28 */
29 
30 #ifndef _KS_
31 #define _KS_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #ifdef BUILDING_KS
38  #define KSDDKAPI
39 #else
40  #define KSDDKAPI //DECLSPEC_IMPORT /* TODO */
41 #endif
42 
43 
44 #define KSFILTER_NODE ((ULONG)-1)
45 #define KSALL_NODES ((ULONG)-1)
46 
47 #define KSSTRING_Filter L"{9B365890-165F-11D0-A195-0020AFD156E4}"
48 #define KSSTRING_Pin L"{146F1A80-4791-11D0-A5D6-28DB04C10000}"
49 #define KSSTRING_Clock L"{53172480-4791-11D0-A5D6-28DB04C10000}"
50 #define KSSTRING_Allocator L"{642F5D00-4791-11D0-A5D6-28DB04C10000}"
51 #define KSSTRING_AllocatorEx L"{091BB63B-603F-11D1-B067-00A0C9062802}"
52 #define KSSTRING_TopologyNode L"{0621061A-EE75-11D0-B915-00A0C9223196}"
53 
54 #define KSDATAFORMAT_BIT_ATTRIBUTES 1
55 #define KSDATAFORMAT_ATTRIBUTES (1 << KSDATAFORMAT_BIT_ATTRIBUTES)
56 
57 #if defined(_NTDDK_)
58 typedef PVOID PKSWORKER;
59 #endif
60 
61 #ifndef SIZEOF_ARRAY
62 #define SIZEOF_ARRAY(a) (sizeof(a)/sizeof((a)[0]))
63 #endif
64 
65 /* ===============================================================
66  GUID definition helpers
67 */
68 
69 #ifndef _NTRTL_
70 
71 #ifndef DEFINE_GUIDEX
72 #ifdef _MSC_VER
73 #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name
74 #else
75 #define DEFINE_GUIDEX(name) EXTERN_C const GUID name
76 #endif
77 #endif /* !DEFINE_GUIDEX */
78 
79 #ifndef STATICGUIDOF
80 #define STATICGUIDOF(guid) STATIC_##guid
81 #endif
82 
83 #endif /* !_NTRTL_ */
84 
85 #if defined(__cplusplus)
86 
87 #if _MSC_VER >= 1100
88 #define DEFINE_GUIDSTRUCT(guid, name) struct __declspec(uuid(guid)) name
89 #define DEFINE_GUIDNAMED(name) __uuidof(struct name)
90 #else
91 #define DEFINE_GUIDSTRUCT(guid, name) \
92  extern const DECLSPEC_SELECTANY GUID __uuid__##name={STATIC_##name};
93 #define DEFINE_GUIDNAMED(name) __uuid__##name
94 #endif
95 
96 #else /* __cplusplus */
97 
98 #define DEFINE_GUIDSTRUCT(guid, name) DEFINE_GUIDEX(name)
99 #define DEFINE_GUIDNAMED(name) name
100 
101 #endif /* __cplusplus */
102 
103 #define STATIC_GUID_NULL \
104  0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
105 DEFINE_GUIDSTRUCT("00000000-0000-0000-0000-000000000000", GUID_NULL);
106 #define GUID_NULL DEFINE_GUIDNAMED(GUID_NULL)
107 
108 #define STATIC_KSNAME_Filter\
109  0x9b365890L, 0x165f, 0x11d0, {0xa1, 0x95, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4}
110 DEFINE_GUIDSTRUCT("9b365890-165f-11d0-a195-0020afd156e4", KSNAME_Filter);
111 #define KSNAME_Filter DEFINE_GUIDNAMED(KSNAME_Filter)
112 
113 #define STATIC_KSMEMORY_TYPE_KERNEL_PAGED \
114  0xd833f8f8L, 0x7894, 0x11d1, {0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02}
115 DEFINE_GUIDSTRUCT("d833f8f8-7894-11d1-b069-00a0c9062802", KSMEMORY_TYPE_KERNEL_PAGED);
116 #define KSMEMORY_TYPE_KERNEL_PAGED DEFINE_GUIDNAMED(KSMEMORY_TYPE_KERNEL_PAGED)
117 
118 #define STATIC_KSDATAFORMAT_SUBTYPE_NONE \
119  0xe436eb8eL, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}
120 DEFINE_GUIDSTRUCT("e436eb8e-524f-11ce-9f53-0020af0ba770", KSDATAFORMAT_SUBTYPE_NONE);
121 #define KSDATAFORMAT_SUBTYPE_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SUBTYPE_NONE)
122 
123 /* ===============================================================
124  I/O Control Codes
125 */
126 
127 #define IOCTL_KS_DISABLE_EVENT \
128  CTL_CODE( \
129  FILE_DEVICE_KS, \
130  0x000, \
131  METHOD_NEITHER, \
132  FILE_ANY_ACCESS)
133 
134 #define IOCTL_KS_ENABLE_EVENT \
135  CTL_CODE( \
136  FILE_DEVICE_KS, \
137  0x001, \
138  METHOD_NEITHER, \
139  FILE_ANY_ACCESS)
140 
141 // WAS 2
142 #define IOCTL_KS_METHOD \
143  CTL_CODE( \
144  FILE_DEVICE_KS, \
145  0x003, \
146  METHOD_NEITHER, \
147  FILE_ANY_ACCESS)
148 
149 // WAS 3
150 #define IOCTL_KS_PROPERTY \
151  CTL_CODE( \
152  FILE_DEVICE_KS, \
153  0x000, \
154  METHOD_NEITHER, \
155  FILE_ANY_ACCESS)
156 
157 #define IOCTL_KS_WRITE_STREAM \
158  CTL_CODE( \
159  FILE_DEVICE_KS, \
160  0x004, \
161  METHOD_NEITHER, \
162  FILE_WRITE_ACCESS)
163 
164 #define IOCTL_KS_READ_STREAM \
165  CTL_CODE( \
166  FILE_DEVICE_KS, \
167  0x005, \
168  METHOD_NEITHER, \
169  FILE_READ_ACCESS)
170 
171 #define IOCTL_KS_RESET_STATE \
172  CTL_CODE( \
173  FILE_DEVICE_KS, \
174  0x006, \
175  METHOD_NEITHER, \
176  FILE_ANY_ACCESS)
177 
178 /* ===============================================================
179  Categories
180 */
181 
182 #define STATIC_KSCATEGORY_BRIDGE \
183  0x085AFF00L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
184 DEFINE_GUIDSTRUCT("085AFF00-62CE-11CF-A5D6-28DB04C10000", KSCATEGORY_BRIDGE);
185 #define KSCATEGORY_BRIDGE DEFINE_GUIDNAMED(KSCATEGORY_BRIDGE)
186 
187 #define STATIC_KSCATEGORY_CAPTURE \
188  0x65E8773DL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
189 DEFINE_GUIDSTRUCT("65E8773D-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_CAPTURE);
190 #define KSCATEGORY_CAPTURE DEFINE_GUIDNAMED(KSCATEGORY_CAPTURE)
191 
192 #define STATIC_KSCATEGORY_RENDER \
193  0x65E8773EL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
194 DEFINE_GUIDSTRUCT("65E8773E-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_RENDER);
195 #define KSCATEGORY_RENDER DEFINE_GUIDNAMED(KSCATEGORY_RENDER)
196 
197 #define STATIC_KSCATEGORY_MIXER \
198  0xAD809C00L, 0x7B88, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
199 DEFINE_GUIDSTRUCT("AD809C00-7B88-11D0-A5D6-28DB04C10000", KSCATEGORY_MIXER);
200 #define KSCATEGORY_MIXER DEFINE_GUIDNAMED(KSCATEGORY_MIXER)
201 
202 #define STATIC_KSCATEGORY_SPLITTER \
203  0x0A4252A0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
204 DEFINE_GUIDSTRUCT("0A4252A0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_SPLITTER);
205 #define KSCATEGORY_SPLITTER DEFINE_GUIDNAMED(KSCATEGORY_SPLITTER)
206 
207 #define STATIC_KSCATEGORY_DATACOMPRESSOR \
208  0x1E84C900L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
209 DEFINE_GUIDSTRUCT("1E84C900-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATACOMPRESSOR);
210 #define KSCATEGORY_DATACOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATACOMPRESSOR)
211 
212 #define STATIC_KSCATEGORY_DATADECOMPRESSOR \
213  0x2721AE20L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
214 DEFINE_GUIDSTRUCT("2721AE20-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATADECOMPRESSOR);
215 #define KSCATEGORY_DATADECOMPRESSOR DEFINE_GUIDNAMED(KSCATEGORY_DATADECOMPRESSOR)
216 
217 #define STATIC_KSCATEGORY_DATATRANSFORM \
218  0x2EB07EA0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
219 DEFINE_GUIDSTRUCT("2EB07EA0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATATRANSFORM);
220 #define KSCATEGORY_DATATRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_DATATRANSFORM)
221 
222 #define STATIC_KSCATEGORY_COMMUNICATIONSTRANSFORM \
223  0xCF1DDA2CL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
224 DEFINE_GUIDSTRUCT("CF1DDA2C-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_COMMUNICATIONSTRANSFORM);
225 #define KSCATEGORY_COMMUNICATIONSTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_COMMUNICATIONSTRANSFORM)
226 
227 #define STATIC_KSCATEGORY_INTERFACETRANSFORM \
228  0xCF1DDA2DL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
229 DEFINE_GUIDSTRUCT("CF1DDA2D-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_INTERFACETRANSFORM);
230 #define KSCATEGORY_INTERFACETRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_INTERFACETRANSFORM)
231 
232 #define STATIC_KSCATEGORY_MEDIUMTRANSFORM \
233  0xCF1DDA2EL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
234 DEFINE_GUIDSTRUCT("CF1DDA2E-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_MEDIUMTRANSFORM);
235 #define KSCATEGORY_MEDIUMTRANSFORM DEFINE_GUIDNAMED(KSCATEGORY_MEDIUMTRANSFORM)
236 
237 #define STATIC_KSCATEGORY_FILESYSTEM \
238  0x760FED5EL, 0x9357, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
239 DEFINE_GUIDSTRUCT("760FED5E-9357-11D0-A3CC-00A0C9223196", KSCATEGORY_FILESYSTEM);
240 #define KSCATEGORY_FILESYSTEM DEFINE_GUIDNAMED(KSCATEGORY_FILESYSTEM)
241 
242 #define STATIC_KSCATEGORY_CLOCK \
243  0x53172480L, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
244 DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000", KSCATEGORY_CLOCK);
245 #define KSCATEGORY_CLOCK DEFINE_GUIDNAMED(KSCATEGORY_CLOCK)
246 
247 #define STATIC_KSCATEGORY_PROXY \
248  0x97EBAACAL, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
249 DEFINE_GUIDSTRUCT("97EBAACA-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_PROXY);
250 #define KSCATEGORY_PROXY DEFINE_GUIDNAMED(KSCATEGORY_PROXY)
251 
252 #define STATIC_KSCATEGORY_QUALITY \
253  0x97EBAACBL, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
254 DEFINE_GUIDSTRUCT("97EBAACB-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_QUALITY);
255 #define KSCATEGORY_QUALITY DEFINE_GUIDNAMED(KSCATEGORY_QUALITY)
256 
257 /* ===============================================================
258  Common
259 */
260 
261 typedef struct {
262  GUID Set;
263  ULONG Id;
264  ULONG Flags;
266 
270 
272 
275 
276 typedef union {
277  struct {
278  ULONG FormatSize;
279  ULONG Flags;
280  ULONG SampleSize;
281  ULONG Reserved;
282  GUID MajorFormat;
283  GUID SubFormat;
284  GUID Specifier;
285  };
288 
289 typedef struct {
294 
295 
296 /* ===============================================================
297  Interface Sets - TODO
298 */
299 
300 #if 0
301 #define KSINTERFACESETID_Media
302 #define KSINTERFACE_STANDARD_STREAMING
303 #define KSINTERFACE_STANDARD_LOOPED_STREAMING
304 #define KSINTERFACE_STANDARD_CONTROL
305 #endif
306 
307 #define STATIC_KSINTERFACESETID_Standard \
308  0x1A8766A0L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
309 DEFINE_GUIDSTRUCT("1A8766A0-62CE-11CF-A5D6-28DB04C10000", KSINTERFACESETID_Standard);
310 #define KSINTERFACESETID_Standard DEFINE_GUIDNAMED(KSINTERFACESETID_Standard)
311 
312 typedef enum {
317 
318 #define STATIC_KSINTERFACESETID_FileIo \
319  0x8C6F932CL, 0xE771, 0x11D0, {0xB8, 0xFF, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
320 DEFINE_GUIDSTRUCT("8C6F932C-E771-11D0-B8FF-00A0C9223196", KSINTERFACESETID_FileIo);
321 #define KSINTERFACESETID_FileIo DEFINE_GUIDNAMED(KSINTERFACESETID_FileIo)
322 
323 /* ===============================================================
324  Mediums
325 */
326 
327 typedef enum {
330 
331 #define KSMEDIUM_TYPE_ANYINSTANCE 0
332 
333 #define STATIC_KSMEDIUMSETID_Standard \
334  0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
335 DEFINE_GUIDSTRUCT("4747B320-62CE-11CF-A5D6-28DB04C10000", KSMEDIUMSETID_Standard);
336 #define KSMEDIUMSETID_Standard DEFINE_GUIDNAMED(KSMEDIUMSETID_Standard)
337 
338 /* ===============================================================
339  Clock Properties/Methods/Events
340 */
341 
342 #define STATIC_KSPROPSETID_Clock \
343  0xDF12A4C0L, 0xAC17, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
344 DEFINE_GUIDSTRUCT("DF12A4C0-AC17-11CF-A5D6-28DB04C10000", KSPROPSETID_Clock);
345 #define KSPROPSETID_Clock DEFINE_GUIDNAMED(KSPROPSETID_Clock)
346 
347 typedef enum {
354 #if defined(_NTDDK_)
355  KSPROPERTY_CLOCK_FUNCTIONTABLE
356 #endif // defined(_NTDDK_)
358 
359 #define STATIC_KSEVENTSETID_Clock \
360  0x364D8E20L, 0x62C7, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
361 DEFINE_GUIDSTRUCT("364D8E20-62C7-11CF-A5D6-28DB04C10000", KSEVENTSETID_Clock);
362 #define KSEVENTSETID_Clock DEFINE_GUIDNAMED(KSEVENTSETID_Clock)
363 
364 typedef enum {
368 
369 /* ===============================================================
370  Connection Properties/Methods/Events
371 */
372 
373 #define STATIC_KSPROPSETID_Connection \
374  0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
375 DEFINE_GUIDSTRUCT("1D58C920-AC9B-11CF-A5D6-28DB04C10000", KSPROPSETID_Connection);
376 #define KSPROPSETID_Connection DEFINE_GUIDNAMED(KSPROPSETID_Connection)
377 
378 typedef enum {
388 
389 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE(GetHandler, SetHandler)\
390  DEFINE_KSPROPERTY_ITEM(\
391  KSPROPERTY_CONNECTION_STATE,\
392  (GetHandler),\
393  sizeof(KSPROPERTY),\
394  sizeof(KSSTATE),\
395  (SetHandler),\
396  NULL, 0, NULL, NULL, 0)
397 
398 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PRIORITY(GetHandler, SetHandler)\
399  DEFINE_KSPROPERTY_ITEM(\
400  KSPROPERTY_CONNECTION_PRIORITY,\
401  (GetHandler),\
402  sizeof(KSPROPERTY),\
403  sizeof(KSPRIORITY),\
404  (SetHandler),\
405  NULL, 0, NULL, NULL, 0)
406 
407 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT(GetHandler, SetHandler)\
408  DEFINE_KSPROPERTY_ITEM(\
409  KSPROPERTY_CONNECTION_DATAFORMAT,\
410  (GetHandler),\
411  sizeof(KSPROPERTY),\
412  0,\
413  (SetHandler),\
414  NULL, 0, NULL, NULL, 0)
415 
416 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING(Handler)\
417  DEFINE_KSPROPERTY_ITEM(\
418  KSPROPERTY_CONNECTION_ALLOCATORFRAMING,\
419  (Handler),\
420  sizeof(KSPROPERTY),\
421  sizeof(KSALLOCATOR_FRAMING),\
422  NULL, NULL, 0, NULL, NULL, 0)
423 
424 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING_EX(Handler)\
425  DEFINE_KSPROPERTY_ITEM(\
426  KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX,\
427  (Handler),\
428  sizeof(KSPROPERTY),\
429  0,\
430  NULL, NULL, 0, NULL, NULL, 0)
431 
432 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_PROPOSEDATAFORMAT(Handler)\
433  DEFINE_KSPROPERTY_ITEM(\
434  KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT,\
435  NULL,\
436  sizeof(KSPROPERTY),\
437  sizeof(KSDATAFORMAT),\
438  (Handler),\
439  NULL, 0, NULL, NULL, 0)
440 
441 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_ACQUIREORDERING(Handler)\
442  DEFINE_KSPROPERTY_ITEM(\
443  KSPROPERTY_CONNECTION_ACQUIREORDERING,\
444  (Handler),\
445  sizeof(KSPROPERTY),\
446  sizeof(int),\
447  NULL, NULL, 0, NULL, NULL, 0)
448 
449 #define DEFINE_KSPROPERTY_ITEM_CONNECTION_STARTAT(Handler)\
450  DEFINE_KSPROPERTY_ITEM(\
451  KSPROPERTY_CONNECTION_STARTAT,\
452  NULL,\
453  sizeof(KSPROPERTY),\
454  sizeof(KSRELATIVEEVENT),\
455  (Handler),\
456  NULL, 0, NULL, NULL, 0)
457 
458 typedef enum {
465 
466 /* ===============================================================
467  General
468  Properties/Methods/Events
469 */
470 
471 #define STATIC_KSPROPSETID_General\
472  0x1464EDA5L, 0x6A8F, 0x11D1, {0x9A, 0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
473 DEFINE_GUIDSTRUCT("1464EDA5-6A8F-11D1-9AA7-00A0C9223196", KSPROPSETID_General);
474 #define KSPROPSETID_General DEFINE_GUIDNAMED(KSPROPSETID_General)
475 
476 typedef enum {
479 
480 /* ===============================================================
481  Graph Manager
482  Properties/Methods/Events
483 */
484 
485 #define KSPROPSETID_GM \
486  0xAF627536L, 0xE719, 0x11D2, {0x8A, 0x1D, 0x00, 0x60, 0x97, 0xD2, 0xDF, 0x5D}
487 
488 typedef enum {
493 } KSPROPERTY_GM;
494 
495 /* ===============================================================
496  Media Seeking
497  Properties/Methods/Events
498 */
499 
500 #define STATIC_KSPROPSETID_MediaSeeking\
501  0xEE904F0CL, 0xD09B, 0x11D0, {0xAB, 0xE9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
502 DEFINE_GUIDSTRUCT("EE904F0C-D09B-11D0-ABE9-00A0C9223196", KSPROPSETID_MediaSeeking);
503 #define KSPROPSETID_MediaSeeking DEFINE_GUIDNAMED(KSPROPSETID_MediaSeeking)
504 
505 typedef enum {
517 
518 typedef enum {
527 
528 typedef enum {
537 
538 typedef struct {
544 
545 typedef struct {
549 
550 typedef struct {
556 
557 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CAPABILITIES(Handler)\
558  DEFINE_KSPROPERTY_ITEM(\
559  KSPROPERTY_MEDIASEEKING_CAPABILITIES,\
560  (Handler),\
561  sizeof(KSPROPERTY),\
562  sizeof(KS_SEEKING_CAPABILITIES),\
563  NULL, NULL, 0, NULL, NULL, 0)
564 
565 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_FORMATS(Handler)\
566  DEFINE_KSPROPERTY_ITEM(\
567  KSPROPERTY_MEDIASEEKING_FORMATS,\
568  (Handler),\
569  sizeof(KSPROPERTY),\
570  0,\
571  NULL, NULL, 0, NULL, NULL, 0)
572 
573 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_TIMEFORMAT(GetHandler, SetHandler)\
574  DEFINE_KSPROPERTY_ITEM(\
575  KSPROPERTY_MEDIASEEKING_TIMEFORMAT,\
576  (GetHandler),\
577  sizeof(KSPROPERTY),\
578  sizeof(GUID),\
579  (SetHandler),\
580  NULL, 0, NULL, NULL, 0)
581 
582 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITION(Handler)\
583  DEFINE_KSPROPERTY_ITEM(\
584  KSPROPERTY_MEDIASEEKING_POSITION,\
585  (Handler),\
586  sizeof(KSPROPERTY),\
587  sizeof(LONGLONG),\
588  NULL, NULL, 0, NULL, NULL, 0)
589 
590 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_STOPPOSITION(Handler)\
591  DEFINE_KSPROPERTY_ITEM(\
592  KSPROPERTY_MEDIASEEKING_STOPPOSITION,\
593  (Handler),\
594  sizeof(KSPROPERTY),\
595  sizeof(LONGLONG),\
596  NULL, NULL, 0, NULL, NULL, 0)
597 
598 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITIONS(Handler)\
599  DEFINE_KSPROPERTY_ITEM(\
600  KSPROPERTY_MEDIASEEKING_POSITIONS,\
601  NULL,\
602  sizeof(KSPROPERTY),\
603  sizeof(KSPROPERTY_POSITIONS),\
604  (Handler),\
605  NULL, 0, NULL, NULL, 0)
606 
607 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_DURATION(Handler)\
608  DEFINE_KSPROPERTY_ITEM(\
609  KSPROPERTY_MEDIASEEKING_DURATION,\
610  (Handler),\
611  sizeof(KSPROPERTY),\
612  sizeof(LONGLONG),\
613  NULL, NULL, 0, NULL, NULL, 0)
614 
615 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_AVAILABLE(Handler)\
616  DEFINE_KSPROPERTY_ITEM(\
617  KSPROPERTY_MEDIASEEKING_AVAILABLE,\
618  (Handler),\
619  sizeof(KSPROPERTY),\
620  sizeof(KSPROPERTY_MEDIAAVAILABLE),\
621  NULL, NULL, 0, NULL, NULL, 0)
622 
623 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_PREROLL(Handler)\
624  DEFINE_KSPROPERTY_ITEM(\
625  KSPROPERTY_MEDIASEEKING_PREROLL,\
626  (Handler),\
627  sizeof(KSPROPERTY),\
628  sizeof(LONGLONG),\
629  NULL, NULL, 0, NULL, NULL, 0)
630 
631 #define DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CONVERTTIMEFORMAT(Handler)\
632  DEFINE_KSPROPERTY_ITEM(\
633  KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT,\
634  (Handler),\
635  sizeof(KSP_TIMEFORMAT),\
636  sizeof(LONGLONG),\
637  NULL, NULL, 0, NULL, NULL, 0)
638 
639 /* ===============================================================
640  Pin
641  Properties/Methods/Events
642 */
643 
644 #define STATIC_KSPROPSETID_Pin\
645  0x8C134960L, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}
646 DEFINE_GUIDSTRUCT("8C134960-51AD-11CF-878A-94F801C10000", KSPROPSETID_Pin);
647 #define KSPROPSETID_Pin DEFINE_GUIDNAMED(KSPROPSETID_Pin)
648 
649 #define STATIC_KSNAME_Pin\
650  0x146F1A80L, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
651 DEFINE_GUIDSTRUCT("146F1A80-4791-11D0-A5D6-28DB04C10000", KSNAME_Pin);
652 #define KSNAME_Pin DEFINE_GUIDNAMED(KSNAME_Pin)
653 
654 typedef enum {
671 
672 typedef struct {
676 } KSP_PIN, *PKSP_PIN;
677 
678 #define KSINSTANCE_INDETERMINATE ((ULONG)-1)
679 
680 typedef struct {
684 
685 typedef struct {
688  WCHAR SymbolicLinkName[1];
690 
691 /* ===============================================================
692  Quality
693  Properties/Methods/Events
694 */
695 
696 #define KSPROPSETID_Quality \
697  0xD16AD380L, 0xAC1A, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
698 
699 typedef enum {
703 
704 /* ===============================================================
705  Stream
706  Properties/Methods/Events
707 */
708 
709 #define STATIC_KSPROPSETID_Stream\
710  0x65aaba60L, 0x98ae, 0x11cf, {0xa1, 0x0d, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4}
711 DEFINE_GUIDSTRUCT("65aaba60-98ae-11cf-a10d-0020afd156e4", KSPROPSETID_Stream);
712 #define KSPROPSETID_Stream DEFINE_GUIDNAMED(KSPROPSETID_Stream)
713 
714 typedef enum {
727 
728 #define DEFINE_KSPROPERTY_ITEM_STREAM_ALLOCATOR(GetHandler, SetHandler)\
729  DEFINE_KSPROPERTY_ITEM(\
730  KSPROPERTY_STREAM_ALLOCATOR,\
731  (GetHandler),\
732  sizeof(KSPROPERTY),\
733  sizeof(HANDLE),\
734  (SetHandler),\
735  NULL, 0, NULL, NULL, 0)
736 
737 #define DEFINE_KSPROPERTY_ITEM_STREAM_QUALITY(Handler)\
738  DEFINE_KSPROPERTY_ITEM(\
739  KSPROPERTY_STREAM_QUALITY,\
740  (Handler),\
741  sizeof(KSPROPERTY),\
742  sizeof(KSQUALITY_MANAGER),\
743  NULL, NULL, 0, NULL, NULL, 0)
744 
745 #define DEFINE_KSPROPERTY_ITEM_STREAM_DEGRADATION(GetHandler, SetHandler)\
746  DEFINE_KSPROPERTY_ITEM(\
747  KSPROPERTY_STREAM_DEGRADATION,\
748  (GetHandler),\
749  sizeof(KSPROPERTY),\
750  0,\
751  (SetHandler),\
752  NULL, 0, NULL, NULL, 0)
753 
754 #define DEFINE_KSPROPERTY_ITEM_STREAM_MASTERCLOCK(GetHandler, SetHandler)\
755  DEFINE_KSPROPERTY_ITEM(\
756  KSPROPERTY_STREAM_MASTERCLOCK,\
757  (GetHandler),\
758  sizeof(KSPROPERTY),\
759  sizeof(HANDLE),\
760  (SetHandler),\
761  NULL, 0, NULL, NULL, 0)
762 
763 #define DEFINE_KSPROPERTY_ITEM_STREAM_TIMEFORMAT(Handler)\
764  DEFINE_KSPROPERTY_ITEM(\
765  KSPROPERTY_STREAM_TIMEFORMAT,\
766  (Handler),\
767  sizeof(KSPROPERTY),\
768  sizeof(GUID),\
769  NULL, NULL, 0, NULL, NULL, 0)
770 
771 #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONTIME(GetHandler, SetHandler)\
772  DEFINE_KSPROPERTY_ITEM(\
773  KSPROPERTY_STREAM_PRESENTATIONTIME,\
774  (GetHandler),\
775  sizeof(KSPROPERTY),\
776  sizeof(KSTIME),\
777  (SetHandler),\
778  NULL, 0, NULL, NULL, 0)
779 
780 #define DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONEXTENT(Handler)\
781  DEFINE_KSPROPERTY_ITEM(\
782  KSPROPERTY_STREAM_PRESENTATIONEXTENT,\
783  (Handler),\
784  sizeof(KSPROPERTY),\
785  sizeof(LONGLONG),\
786  NULL, NULL, 0, NULL, NULL, 0)
787 
788 #define DEFINE_KSPROPERTY_ITEM_STREAM_FRAMETIME(Handler)\
789  DEFINE_KSPROPERTY_ITEM(\
790  KSPROPERTY_STREAM_FRAMETIME,\
791  (Handler),\
792  sizeof(KSPROPERTY),\
793  sizeof(KSFRAMETIME),\
794  NULL, NULL, 0, NULL, NULL, 0)
795 
796 #define DEFINE_KSPROPERTY_ITEM_STREAM_RATECAPABILITY(Handler)\
797  DEFINE_KSPROPERTY_ITEM(\
798  KSPROPERTY_STREAM_RATECAPABILITY,\
799  (Handler),\
800  sizeof(KSRATE_CAPABILITY),\
801  sizeof(KSRATE),\
802  NULL, NULL, 0, NULL, NULL, 0)
803 
804 #define DEFINE_KSPROPERTY_ITEM_STREAM_RATE(GetHandler, SetHandler)\
805  DEFINE_KSPROPERTY_ITEM(\
806  KSPROPERTY_STREAM_RATE,\
807  (GetHandler),\
808  sizeof(KSPROPERTY),\
809  sizeof(KSRATE),\
810  (SetHandler),\
811  NULL, 0, NULL, NULL, 0)
812 
813 #define DEFINE_KSPROPERTY_ITEM_STREAM_PIPE_ID(GetHandler, SetHandler)\
814  DEFINE_KSPROPERTY_ITEM(\
815  KSPROPERTY_STREAM_PIPE_ID,\
816  (GetHandler),\
817  sizeof(KSPROPERTY),\
818  sizeof(HANDLE),\
819  (SetHandler),\
820  NULL, 0, NULL, NULL, 0)
821 
822 /* ===============================================================
823  StreamAllocator
824  Properties/Methods/Events
825 */
826 
827 #define STATIC_KSPROPSETID_StreamAllocator\
828  0xcf6e4342L, 0xec87, 0x11cf, {0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4}
829 DEFINE_GUIDSTRUCT("cf6e4342-ec87-11cf-a130-0020afd156e4", KSPROPSETID_StreamAllocator);
830 #define KSPROPSETID_StreamAllocator DEFINE_GUIDNAMED(KSPROPSETID_StreamAllocator)
831 
832 typedef enum {
836 
837 #define KSMETHODSETID_StreamAllocator \
838  0xcf6e4341L, 0xec87, 0x11cf, {0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4}
839 
840 typedef enum {
844 
845 #define KSEVENTSETID_StreamAllocator
846 
847 typedef enum {
851 
852 /* ===============================================================
853  StreamInterface
854  Properties/Methods/Events
855 */
856 
857 #define KSPROPSETID_StreamInterface \
858  0x1fdd8ee1L, 0x9cd3, 0x11d0, 0x82, 0xaa, 0x00, 0x00, 0xf8, 0x22, 0xfe, 0x8a
859 
860 typedef enum {
863 
864 /* ===============================================================
865  Topology
866  Properties/Methods/Events
867 */
868 
869 #define STATIC_KSPROPSETID_Topology\
870  0x720D4AC0L, 0x7533, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
871 DEFINE_GUIDSTRUCT("720D4AC0-7533-11D0-A5D6-28DB04C10000", KSPROPSETID_Topology);
872 #define KSPROPSETID_Topology DEFINE_GUIDNAMED(KSPROPSETID_Topology)
873 
874 typedef enum {
880 
881 /* ===============================================================
882  Property Sets for audio drivers - TODO
883 */
884 
885 #define STATIC_KSPROPTYPESETID_General \
886  0x97E99BA0L, 0xBDEA, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}
887 DEFINE_GUIDSTRUCT("97E99BA0-BDEA-11CF-A5D6-28DB04C10000", KSPROPTYPESETID_General);
888 #define KSPROPTYPESETID_General DEFINE_GUIDNAMED(KSPROPTYPESETID_General)
889 
890 /*
891  KSPROPERTY_AC3_ALTERNATE_AUDIO
892  KSPROPERTY_AC3_BIT_STREAM_MODE
893  KSPROPERTY_AC3_DIALOGUE_LEVEL
894  KSPROPERTY_AC3_DOWNMIX
895  KSPROPERTY_AC3_ERROR_CONCEALMENT
896  KSPROPERTY_AC3_LANGUAGE_CODE
897  KSPROPERTY_AC3_ROOM_TYPE
898 */
899 
900 #define KSPROPSETID_Acoustic_Echo_Cancel
901 /*
902  KSPROPERTY_AEC_MODE
903  KSPROPERTY_AEC_NOISE_FILL_ENABLE
904  KSPROPERTY_AEC_STATUS
905 */
906 
907 /*
908  KSPROPERTY_AUDIO_3D_INTERFACE
909  KSPROPERTY_AUDIO_AGC
910  KSPROPERTY_AUDIO_ALGORITHM_INSTANCE
911  KSPROPERTY_AUDIO_BASS
912  KSPROPERTY_AUDIO_BASS_BOOST
913  KSPROPERTY_AUDIO_CHANNEL_CONFIG
914  KSPROPERTY_AUDIO_CHORUS_LEVEL
915  KSPROPERTY_AUDIO_COPY_PROTECTION
916  KSPROPERTY_AUDIO_CPU_RESOURCES
917  KSPROPERTY_AUDIO_DELAY
918  KSPROPERTY_AUDIO_DEMUX_DEST
919  KSPROPERTY_AUDIO_DEV_SPECIFIC
920  KSPROPERTY_AUDIO_DYNAMIC_RANGE
921  KSPROPERTY_AUDIO_DYNAMIC_SAMPLING_RATE
922  KSPROPERTY_AUDIO_EQ_BANDS
923  KSPROPERTY_AUDIO_EQ_LEVEL
924  KSPROPERTY_AUDIO_FILTER_STATE
925  KSPROPERTY_AUDIO_LATENCY
926  KSPROPERTY_AUDIO_LOUDNESS
927  KSPROPERTY_AUDIO_MANUFACTURE_GUID
928  KSPROPERTY_AUDIO_MID
929  KSPROPERTY_AUDIO_MIX_LEVEL_CAPS
930  KSPROPERTY_AUDIO_MIX_LEVEL_TABLE
931  KSPROPERTY_AUDIO_MUTE
932  KSPROPERTY_AUDIO_MUX_SOURCE
933  KSPROPERTY_AUDIO_NUM_EQ_BANDS
934  KSPROPERTY_AUDIO_PEAKMETER
935  KSPROPERTY_AUDIO_POSITION
936  KSPROPERTY_AUDIO_PREFERRED_STATUS
937  KSPROPERTY_AUDIO_PRODUCT_GUID
938  KSPROPERTY_AUDIO_QUALITY
939  KSPROPERTY_AUDIO_REVERB_LEVEL
940  KSPROPERTY_AUDIO_SAMPLING_RATE
941  KSPROPERTY_AUDIO_STEREO_ENHANCE
942  KSPROPERTY_AUDIO_STEREO_SPEAKER_GEOMETRY
943  KSPROPERTY_AUDIO_SURROUND_ENCODE
944  KSPROPERTY_AUDIO_TREBLE
945  KSPROPERTY_AUDIO_VOLUMELEVEL
946  KSPROPERTY_AUDIO_WIDE_MODE
947  KSPROPERTY_AUDIO_WIDENESS
948 */
949 
950 #define KSPROPSETID_AudioGfx
951 /*
952  KSPROPERTY_AUDIOGFX_CAPTURETARGETDEVICEID
953  KSPROPERTY_AUDIOGFX_RENDERTARGETDEVICEID
954 */
955 
956 #define KSPROPSETID_DirectSound3DBuffer
957 /*
958  KSPROPERTY_DIRECTSOUND3DBUFFER_ALL
959  KSPROPERTY_DIRECTSOUND3DBUFFER_CONEANGLES
960  KSPROPERTY_DIRECTSOUND3DBUFFER_CONEORIENTATION
961  KSPROPERTY_DIRECTSOUND3DBUFFER_CONEOUTSIDEVOLUME
962  KSPROPERTY_DIRECTSOUND3DBUFFER_MAXDISTANCE
963  KSPROPERTY_DIRECTSOUND3DBUFFER_MINDISTANCE
964  KSPROPERTY_DIRECTSOUND3DBUFFER_MODE
965  KSPROPERTY_DIRECTSOUND3DBUFFER_POSITION
966  KSPROPERTY_DIRECTSOUND3DBUFFER_VELOCITY
967 */
968 
969 #define KSPROPSETID_DirectSound3DListener
970 /*
971  KSPROPERTY_DIRECTSOUND3DLISTENER_ALL
972  KSPROPERTY_DIRECTSOUND3DLISTENER_ALLOCATION
973  KSPROPERTY_DIRECTSOUND3DLISTENER_BATCH
974  KSPROPERTY_DIRECTSOUND3DLISTENER_DISTANCEFACTOR
975  KSPROPERTY_DIRECTSOUND3DLISTENER_DOPPLERFACTOR
976  KSPROPERTY_DIRECTSOUND3DLISTENER_ORIENTATION
977  KSPROPERTY_DIRECTSOUND3DLISTENER_POSITION
978  KSPROPERTY_DIRECTSOUND3DLISTENER_ROLLOFFFACTOR
979  KSPROPERTY_DIRECTSOUND3DLISTENER_VELOCITY
980 */
981 
982 #define KSPROPSETID_Hrtf3d
983 /*
984  KSPROPERTY_HRTF3D_FILTER_FORMAT
985  KSPROPERTY_HRTF3D_INITIALIZE
986  KSPROPERTY_HRTF3D_PARAMS
987 */
988 
989 #define KSPROPSETID_Itd3d
990 /*
991  KSPROPERTY_ITD3D_PARAMS
992 */
993 
994 #define KSPROPSETID_TopologyNode
995 /*
996  KSPROPERTY_TOPOLOGYNODE_ENABLE
997  KSPROPERTY_TOPOLOGYNODE_RESET
998 */
999 
1000 
1001 /* ===============================================================
1002  Node Types
1003 */
1004 /*
1005  KSNODETYPE_3D_EFFECTS
1006  KSNODETYPE_ACOUSTIC_ECHO_CANCEL
1007  KSNODETYPE_ADC
1008  KSNODETYPE_AGC
1009  KSNODETYPE_CHORUS
1010  KSNODETYPE_DAC
1011  KSNODETYPE_DELAY
1012  KSNODETYPE_DEMUX
1013  KSNODETYPE_DEV_SPECIFIC
1014  KSNODETYPE_DMSYNTH
1015  KSNODETYPE_DMSYNTH_CAPS
1016  KSNODETYPE_DRM_DESCRAMBLE
1017  KSNODETYPE_EQUALIZER
1018  KSNODETYPE_LOUDNESS
1019  KSNODETYPE_MUTE
1020  KSNODETYPE_MUX
1021  KSNODETYPE_PEAKMETER
1022  KSNODETYPE_PROLOGIC_DECODER
1023  KSNODETYPE_PROLOGIC_ENCODER
1024  KSNODETYPE_REVERB
1025  KSNODETYPE_SRC
1026  KSNODETYPE_STEREO_ENHANCE
1027  KSNODETYPE_STEREO_WIDE
1028  KSNODETYPE_SUM
1029  KSNODETYPE_SUPERMIX
1030  KSNODETYPE_SWMIDI
1031  KSNODETYPE_SWSYNTH
1032  KSNODETYPE_SYNTHESIZER
1033  KSNODETYPE_TONE
1034  KSNODETYPE_VOLUME
1035 */
1036 
1038 
1039 /* ===============================================================
1040  Method Types
1041 */
1042 
1043 #define KSMETHOD_TYPE_NONE 0x00000000
1044 #define KSMETHOD_TYPE_READ 0x00000001
1045 #define KSMETHOD_TYPE_WRITE 0x00000002
1046 #define KSMETHOD_TYPE_MODIFY 0x00000003
1047 #define KSMETHOD_TYPE_SOURCE 0x00000004
1048 #define KSMETHOD_TYPE_SEND 0x00000001
1049 #define KSMETHOD_TYPE_SETSUPPORT 0x00000100
1050 #define KSMETHOD_TYPE_BASICSUPPORT 0x00000200
1051 
1052 /* ===============================================================
1053  Property Types
1054 */
1055 
1056 #define KSPROPERTY_TYPE_GET 0x00000001
1057 #define KSPROPERTY_TYPE_SET 0x00000002
1058 #define KSPROPERTY_TYPE_SETSUPPORT 0x00000100
1059 #define KSPROPERTY_TYPE_BASICSUPPORT 0x00000200
1060 #define KSPROPERTY_TYPE_RELATIONS 0x00000400
1061 #define KSPROPERTY_TYPE_SERIALIZESET 0x00000800
1062 #define KSPROPERTY_TYPE_UNSERIALIZESET 0x00001000
1063 #define KSPROPERTY_TYPE_SERIALIZERAW 0x00002000
1064 #define KSPROPERTY_TYPE_UNSERIALIZERAW 0x00004000
1065 #define KSPROPERTY_TYPE_SERIALIZESIZE 0x00008000
1066 #define KSPROPERTY_TYPE_DEFAULT_VALUES 0x00010000
1067 
1068 /* ===============================================================
1069  Topology Methods/Properties
1070 */
1071 
1072 #define KSMETHOD_TYPE_TOPOLOGY 0x10000000
1073 #define KSPROPERTY_TYPE_TOPOLOGY 0x10000000
1074 
1075 /*
1076 #define DEFINE_KS_GUID(GA,GB,GC,GD,GE,GF,GG,GH,GI,GJ,GK) \
1077  DEFINE_GUID(??, 0x#GA#L, 0xGB, 0xGC, 0xGD, 0xGE, 0xGF, 0xGG, 0xGH, 0xGI, 0xGJ, 0xGK) \
1078  "GA-GB-GC-GDGE-GFGGGHGIGJGK"
1079 */
1080 
1081 /* ===============================================================
1082  KS Category GUIDs
1083 
1084  BRIDGE - 0x085AFF00L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1085  CAPTURE - 0x65E8773DL, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1086  RENDER - 0x65E8773EL, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1087  MIXER - 0xAD809C00L, 0x7B88, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1088  SPLITTER - 0x0A4252A0L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1089  DATACOMPRESSOR - 0x1E84C900L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1090  DATADECOMPRESSOR - 0x2721AE20L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1091  DATATRANSFORM - 0x2EB07EA0L, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1092  COMMUNICATIONSTRANSFORM - 0xCF1DDA2CL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1093  INTERFACETRANSFORM - 0xCF1DDA2DL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1094  MEDIUMTRANSFORM - 0xCF1DDA2EL, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1095  FILESYSTEM - 0x760FED5EL, 0x9357, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1096  CLOCK - 0x53172480L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1097  PROXY - 0x97EBAACAL, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1098  QUALITY - 0x97EBAACBL, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1099 */
1100 
1101 /* ===============================================================
1102  KSNAME GUIDs (defined also as KSSTRING_Xxx L"{...}"
1103 
1104  Filter - 0x9b365890L, 0x165f, 0x11d0, 0xa1, 0x95, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
1105  Pin - 0x146F1A80L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1106  Clock - 0x53172480L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1107  Allocator - 0x642F5D00L, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1108  TopologyNode - 0x0621061AL, 0xEE75, 0x11D0, 0xB9, 0x15, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1109 */
1110 
1111 /* ===============================================================
1112  Interface GUIDs
1113 
1114  Standard - 0x1A8766A0L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1115  FileIo - 0x8C6F932CL, 0xE771, 0x11D0, 0xB8, 0xFF, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1116 */
1117 
1118 /* ===============================================================
1119  Medium Type GUIDs
1120 
1121  Standard - 0x4747B320L, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1122 */
1123 
1124 /* ===============================================================
1125  Property Set GUIDs
1126 
1127  General - 0x1464EDA5L, 0x6A8F, 0x11D1, 0x9A, 0xA7, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1128  StreamIo - 0x65D003CAL, 0x1523, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1129  MediaSeeking - 0xEE904F0CL, 0xD09B, 0x11D0, 0xAB, 0xE9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96
1130  Topology - 0x720D4AC0L, 0x7533, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1131  GM - 0xAF627536L, 0xE719, 0x11D2, 0x8A, 0x1D, 0x00, 0x60, 0x97, 0xD2, 0xDF, 0x5D
1132  Quality - 0xD16AD380L, 0xAC1A, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1133  Connection - 0x1D58C920L, 0xAC9B, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1134 */
1135 
1136 /* ===============================================================
1137  StreamAllocator Sets
1138 
1139  Event set - 0x75d95571L, 0x073c, 0x11d0, 0xa1, 0x61, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
1140  Method set - 0xcf6e4341L, 0xec87, 0x11cf, 0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
1141  Property set - 0xcf6e4342L, 0xec87, 0x11cf, 0xa1, 0x30, 0x00, 0x20, 0xaf, 0xd1, 0x56, 0xe4
1142 */
1143 
1144 /* ===============================================================
1145  StreamInterface Sets
1146 
1147  Property set - 0x1fdd8ee1L, 0x9cd3, 0x11d0, 0x82, 0xaa, 0x00, 0x00, 0xf8, 0x22, 0xfe, 0x8a
1148 */
1149 
1150 /* ===============================================================
1151  Clock Sets
1152 
1153  Property set - 0xDF12A4C0L, 0xAC17, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1154  Event sets - 0x364D8E20L, 0x62C7, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
1155 */
1156 
1157 /* ===============================================================
1158  Connection Sets
1159 
1160  Event set - 0x7f4bcbe0L, 0x9ea5, 0x11cf, 0xa5, 0xd6, 0x28, 0xdb, 0x04, 0xc1, 0x00, 0x00
1161 */
1162 
1163 /* ===============================================================
1164  Time Format GUIDs
1165 
1166  KSTIME_FORMAT_NONE (null guid)
1167  FRAME - 0x7b785570L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
1168  BYTE - 0x7b785571L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
1169  SAMPLE - 0x7b785572L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
1170  FIELD - 0x7b785573L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
1171  MEDIA_TIME - 0x7b785574L, 0x8c82, 0x11cf, 0xbc, 0x0c, 0x00, 0xaa, 0x00, 0xac, 0x74, 0xf6
1172 */
1173 
1174 /* ===============================================================
1175  Media Type GUIDs
1176 
1177  NULL
1178  Stream -
1179  None -
1180 
1181  TODO ...
1182 */
1183 
1184 #define STATIC_KSDATAFORMAT_SPECIFIER_NONE\
1185  0x0F6417D6L, 0xC318, 0x11D0, {0xA4, 0x3F, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
1186 DEFINE_GUIDSTRUCT("0F6417D6-C318-11D0-A43F-00A0C9223196", KSDATAFORMAT_SPECIFIER_NONE);
1187 #define KSDATAFORMAT_SPECIFIER_NONE DEFINE_GUIDNAMED(KSDATAFORMAT_SPECIFIER_NONE)
1188 
1189 /* ===============================================================
1190  KSMEMORY_TYPE_xxx
1191 
1192  WILDCARD, DONT_CARE = NULL
1193  SYSTEM - 0x091bb638L, 0x603f, 0x11d1, 0xb0, 0x67, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
1194  USER - 0x8cb0fc28L, 0x7893, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
1195  KERNEL_PAGED - 0xd833f8f8L, 0x7894, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
1196  KERNEL_NONPAGED - 0x4a6d5fc4L, 0x7895, 0x11d1, 0xb0, 0x69, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
1197  DEVICE_UNKNOWN - 0x091bb639L, 0x603f, 0x11d1, 0xb0, 0x67, 0x00, 0xa0, 0xc9, 0x06, 0x28, 0x02
1198 */
1199 
1200 /* ===============================================================
1201  Enums
1202  (values have been checked)
1203 */
1204 
1205 #ifndef _MSC_VER
1206 
1207 #define DEFINE_KSPROPERTY_ITEM(PropertyId, GetHandler,\
1208  MinProperty,\
1209  MinData,\
1210  SetHandler,\
1211  Values, RelationsCount, Relations, SupportHandler,\
1212  SerializedSize)\
1213 {\
1214  PropertyId, {(PFNKSHANDLER)GetHandler}, MinProperty, MinData,\
1215  {(PFNKSHANDLER)SetHandler},\
1216  (PKSPROPERTY_VALUES)Values, RelationsCount, (PKSPROPERTY)Relations,\
1217  (PFNKSHANDLER)SupportHandler, (ULONG)SerializedSize\
1218 }
1219 
1220 #else
1221 
1222 #define DEFINE_KSPROPERTY_ITEM(PropertyId, GetHandler,\
1223  MinProperty,\
1224  MinData,\
1225  SetHandler,\
1226  Values, RelationsCount, Relations, SupportHandler,\
1227  SerializedSize)\
1228 {\
1229  PropertyId, (PFNKSHANDLER)GetHandler, MinProperty, MinData,\
1230  (PFNKSHANDLER)SetHandler,\
1231  (PKSPROPERTY_VALUES)Values, RelationsCount, (PKSPROPERTY)Relations,\
1232  (PFNKSHANDLER)SupportHandler, (ULONG)SerializedSize\
1233 }
1234 
1235 #endif
1236 
1237 typedef enum {
1242 } KSOBJECTTYPE;
1243 
1244 typedef enum {
1249 } KSSTATE, *PKSSTATE;
1250 
1251 typedef enum {
1254 } KSTARGET_STATE;
1255 
1256 typedef enum {
1259 } KSRESET;
1260 
1261 typedef enum {
1270 
1271 typedef enum {
1277 
1278 typedef enum {
1282 
1283 typedef enum {
1290 
1291 typedef enum {
1295 
1296 typedef enum {
1300 } KSSTACK_USE;
1301 
1302 typedef enum {
1308 
1309 typedef enum {
1314 
1315 #if defined(_NTDDK_) && !defined(__wtypes_h__)
1316 enum VARENUM {
1317  VT_EMPTY = 0,
1318  VT_NULL = 1,
1319  VT_I2 = 2,
1320  VT_I4 = 3,
1321  VT_R4 = 4,
1322  VT_R8 = 5,
1323  VT_CY = 6,
1324  VT_DATE = 7,
1325  VT_BSTR = 8,
1326  VT_DISPATCH = 9,
1327  VT_ERROR = 10,
1328  VT_BOOL = 11,
1329  VT_VARIANT = 12,
1330  VT_UNKNOWN = 13,
1331  VT_DECIMAL = 14,
1332  VT_I1 = 16,
1333  VT_UI1 = 17,
1334  VT_UI2 = 18,
1335  VT_UI4 = 19,
1336  VT_I8 = 20,
1337  VT_UI8 = 21,
1338  VT_INT = 22,
1339  VT_UINT = 23,
1340  VT_VOID = 24,
1341  VT_HRESULT = 25,
1342  VT_PTR = 26,
1343  VT_SAFEARRAY = 27,
1344  VT_CARRAY = 28,
1345  VT_USERDEFINED = 29,
1346  VT_LPSTR = 30,
1347  VT_LPWSTR = 31,
1348  VT_FILETIME = 64,
1349  VT_BLOB = 65,
1350  VT_STREAM = 66,
1351  VT_STORAGE = 67,
1352  VT_STREAMED_OBJECT = 68,
1353  VT_STORED_OBJECT = 69,
1354  VT_BLOB_OBJECT = 70,
1355  VT_CF = 71,
1356  VT_CLSID = 72,
1357  VT_VECTOR = 0x1000,
1358  VT_ARRAY = 0x2000,
1359  VT_BYREF = 0x4000,
1360  VT_RESERVED = 0x8000,
1361  VT_ILLEGAL = 0xffff,
1362  VT_ILLEGALMASKED = 0xfff,
1363  VT_TYPEMASK = 0xfff
1364 };
1365 #endif
1366 
1367 #define STATIC_KSDATAFORMAT_TYPE_WILDCARD STATIC_GUID_NULL
1368 #define KSDATAFORMAT_TYPE_WILDCARD GUID_NULL
1369 
1370 #define STATIC_KSDATAFORMAT_SUBTYPE_WILDCARD STATIC_GUID_NULL
1371 #define KSDATAFORMAT_SUBTYPE_WILDCARD GUID_NULL
1372 
1373 #define STATIC_KSDATAFORMAT_SPECIFIER_WILDCARD STATIC_GUID_NULL
1374 #define KSDATAFORMAT_SPECIFIER_WILDCARD GUID_NULL
1375 
1376 /* ===============================================================
1377  Framing
1378 */
1379 
1380 typedef struct {
1385 
1386 typedef struct {
1391 
1392 typedef struct {
1404 
1405 typedef struct {
1410 
1411 /* ===============================================================
1412  Priorities
1413 */
1414 
1415 #define KSPRIORITY_LOW 0x00000001
1416 #define KSPRIORITY_NORMAL 0x40000000
1417 #define KSPRIORITY_HIGH 0x80000000
1418 #define KSPRIORITY_EXCLUSIVE 0xFFFFFFFF
1419 
1420 typedef struct {
1424 
1425 /* ===============================================================
1426  Dispatch Table
1427  http://www.osronline.com/DDKx/stream/ks-struct_494j.htm
1428 */
1429 
1430 #if defined(_NTDDK_)
1431 
1432 typedef struct {
1438  PDRIVER_DISPATCH QuerySecurity;
1439  PDRIVER_DISPATCH SetSecurity;
1440  PFAST_IO_DEVICE_CONTROL FastDeviceIoControl;
1441  PFAST_IO_READ FastRead;
1442  PFAST_IO_WRITE FastWrite;
1443 } KSDISPATCH_TABLE, *PKSDISPATCH_TABLE;
1444 
1445 #define KSCREATE_ITEM_IRP_STORAGE(Irp) (*(PKSOBJECT_CREATE_ITEM*)&(Irp)->Tail.Overlay.DriverContext[0])
1446 #define KSEVENT_SET_IRP_STORAGE(Irp) (*(const KSEVENT_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
1447 #define KSEVENT_ITEM_IRP_STORAGE(Irp) (*(const KSEVENT_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
1448 #define KSEVENT_ENTRY_IRP_STORAGE(Irp) (*(PKSEVENT_ENTRY*)&(Irp)->Tail.Overlay.DriverContext[0])
1449 #define KSMETHOD_SET_IRP_STORAGE(Irp) (*(const KSMETHOD_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
1450 #define KSMETHOD_ITEM_IRP_STORAGE(Irp) (*(const KSMETHOD_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
1451 #define KSMETHOD_TYPE_IRP_STORAGE(Irp) (*(ULONG_PTR*)(&(Irp)->Tail.Overlay.DriverContext[2]))
1452 #define KSQUEUE_SPINLOCK_IRP_STORAGE(Irp) (*(PKSPIN_LOCK*)&(Irp)->Tail.Overlay.DriverContext[1])
1453 #define KSPROPERTY_SET_IRP_STORAGE(Irp) (*(const KSPROPERTY_SET**)&(Irp)->Tail.Overlay.DriverContext[0])
1454 #define KSPROPERTY_ITEM_IRP_STORAGE(Irp) (*(const KSPROPERTY_ITEM**)&(Irp)->Tail.Overlay.DriverContext[3])
1455 #define KSPROPERTY_ATTRIBUTES_IRP_STORAGE(Irp) (*(PKSATTRIBUTE_LIST*)&(Irp)->Tail.Overlay.DriverContext[2])
1456 
1458 typedef VOID
1459 (NTAPI *PFNREFERENCEDEVICEOBJECT)(
1460  _In_ PVOID Context);
1461 
1463 typedef VOID
1464 (NTAPI *PFNDEREFERENCEDEVICEOBJECT)(
1465  _In_ PVOID Context);
1466 
1468 typedef NTSTATUS
1469 (NTAPI *PFNQUERYREFERENCESTRING)(
1470  _In_ PVOID Context,
1471  _Inout_ PWCHAR *String);
1472 
1473 typedef struct {
1475  PFNREFERENCEDEVICEOBJECT ReferenceDeviceObject;
1476  PFNDEREFERENCEDEVICEOBJECT DereferenceDeviceObject;
1477  PFNQUERYREFERENCESTRING QueryReferenceString;
1478 } BUS_INTERFACE_REFERENCE, *PBUS_INTERFACE_REFERENCE;
1479 
1480 typedef struct {
1481  KDPC Dpc;
1482  ULONG ReferenceCount;
1483  KSPIN_LOCK AccessLock;
1484 } KSDPC_ITEM, *PKSDPC_ITEM;
1485 
1486 typedef struct {
1487  KSDPC_ITEM DpcItem;
1488  LIST_ENTRY BufferList;
1489 } KSBUFFER_ITEM, *PKSBUFFER_ITEM;
1490 
1491 #endif /* _NTDDK_ */
1492 
1493 typedef struct {
1501 
1502 #define DEFINE_KSPROPERTY_ITEM_GENERAL_COMPONENTID(Handler)\
1503  DEFINE_KSPROPERTY_ITEM(\
1504  KSPROPERTY_GENERAL_COMPONENTID,\
1505  (Handler),\
1506  sizeof(KSPROPERTY),\
1507  sizeof(KSCOMPONENTID),\
1508  NULL, NULL, 0, NULL, NULL, 0)
1509 
1510 /* ===============================================================
1511  Properties
1512 */
1513 
1514 typedef struct {
1518 
1519 typedef struct {
1524 
1525 typedef union {
1526  struct {
1529 #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
1530  } _SIGNED;
1531 #else
1532  };
1533 #endif
1534  struct {
1537 #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
1538  } _UNSIGNED;
1539 #else
1540  };
1541 #endif
1543 
1544 typedef union {
1545  struct {
1548 #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
1549  } _SIGNED64;
1550 #else
1551  };
1552 #endif
1553  struct {
1554 #if defined(_NTDDK_)
1555  ULONGLONG UnsignedMinimum;
1556  ULONGLONG UnsignedMaximum;
1557 #else
1560 #endif
1561 #if defined( _KS_NO_ANONYMOUS_STRUCTURES_ )
1562  } _UNSIGNED64;
1563 #else
1564  };
1565 #endif
1567 
1568 typedef struct {
1575 
1576 typedef struct {
1582 
1583 typedef struct {
1585  const VOID *Members;
1587 
1588 #define KSPROPERTY_MEMBER_RANGES 0x00000001
1589 #define KSPROPERTY_MEMBER_STEPPEDRANGES 0x00000002
1590 #define KSPROPERTY_MEMBER_VALUES 0x00000003
1591 
1592 #define KSPROPERTY_MEMBER_FLAG_DEFAULT 0x00000001
1593 #if (NTDDI_VERSION >= NTDDI_WINXP)
1594 #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_MULTICHANNEL 0x00000002
1595 #define KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_UNIFORM 0x00000004
1596 #endif
1597 
1598 typedef struct {
1601  _Field_size_(MembersListCount) const KSPROPERTY_MEMBERSLIST *MembersList;
1603 
1604 #if defined(_NTDDK_)
1605 
1607 typedef NTSTATUS
1608 (NTAPI *PFNKSCONTEXT_DISPATCH)(
1609  _In_ PVOID Context,
1610  _In_ PIRP Irp);
1611 
1613 typedef NTSTATUS
1614 (NTAPI *PFNKSHANDLER)(
1615  _In_ PIRP Irp,
1617  _Inout_ PVOID Data);
1618 
1619 typedef struct {
1620  ULONG PropertyId;
1621  union {
1622  PFNKSHANDLER GetPropertyHandler;
1623  BOOLEAN GetSupported;
1624  };
1625  ULONG MinProperty;
1626  ULONG MinData;
1627  union {
1628  PFNKSHANDLER SetPropertyHandler;
1629  BOOLEAN SetSupported;
1630  };
1631  const KSPROPERTY_VALUES *Values;
1632  ULONG RelationsCount;
1633  _Field_size_(RelationsCount) const KSPROPERTY *Relations;
1634  PFNKSHANDLER SupportHandler;
1635  ULONG SerializedSize;
1636 } KSPROPERTY_ITEM, *PKSPROPERTY_ITEM;
1637 
1639 typedef BOOLEAN
1640 (NTAPI *PFNKSFASTHANDLER)(
1642  _In_reads_bytes_(RequestLength) PKSIDENTIFIER Request,
1643  _In_ ULONG RequestLength,
1647 
1648 typedef struct {
1649  ULONG PropertyId;
1650  union {
1651  PFNKSFASTHANDLER GetPropertyHandler;
1652  BOOLEAN GetSupported;
1653  };
1654  union {
1655  PFNKSFASTHANDLER SetPropertyHandler;
1656  BOOLEAN SetSupported;
1657  };
1658  ULONG Reserved;
1659 } KSFASTPROPERTY_ITEM, *PKSFASTPROPERTY_ITEM;
1660 
1661 typedef struct {
1662  const GUID *Set;
1663  ULONG PropertiesCount;
1664  _Field_size_(PropertiesCount) const KSPROPERTY_ITEM *PropertyItem;
1665  ULONG FastIoCount;
1666  const KSFASTPROPERTY_ITEM *FastIoTable;
1667 } KSPROPERTY_SET, *PKSPROPERTY_SET;
1668 
1669 #endif /* _NTDDK_ */
1670 
1671 typedef struct {
1676 
1677 typedef struct {
1678 #if defined(_NTDDK_)
1679  ULONGLONG SteppingDelta;
1680 #else
1682 #endif
1685 
1686 /* ===============================================================
1687  Allocator Framing
1688 */
1689 
1690 typedef struct {
1691  union {
1694  };
1695 #if defined(_NTDDK_)
1697 #else
1699 #endif
1705 
1706 typedef struct {
1711  KS_FRAMING_ITEM FramingItem[1];
1713 
1714 #define KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER 0x00000001
1715 #define KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY 0x00000002
1716 #define KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY 0x00000004
1717 #define KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE 0x00000008
1718 #define KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY 0x80000000
1719 
1720 #define KSALLOCATOR_OPTIONF_COMPATIBLE 0x00000001
1721 #define KSALLOCATOR_OPTIONF_SYSTEM_MEMORY 0x00000002
1722 #define KSALLOCATOR_OPTIONF_VALID 0x00000003
1723 
1724 #define KSALLOCATOR_FLAG_PARTIAL_READ_SUPPORT 0x00000010
1725 #define KSALLOCATOR_FLAG_DEVICE_SPECIFIC 0x00000020
1726 #define KSALLOCATOR_FLAG_CAN_ALLOCATE 0x00000040
1727 #define KSALLOCATOR_FLAG_INSIST_ON_FRAMESIZE_RATIO 0x00000080
1728 
1729 /* ===============================================================
1730  Quality
1731 */
1732 
1733 typedef struct {
1737 } KSQUALITY, *PKSQUALITY;
1738 
1739 typedef struct {
1743 
1744 typedef struct {
1750 } KSRATE, *PKSRATE;
1751 
1752 typedef struct {
1756 
1757 typedef struct {
1761 
1762 typedef struct {
1764  union {
1765  struct {
1768  } EventHandle;
1769  struct {
1773  } SemaphoreHandle;
1774 #if defined(_NTDDK_)
1775  struct {
1776  PVOID Event;
1779  } EventObject;
1780  struct {
1781  PVOID Semaphore;
1783  LONG Adjustment;
1784  } SemaphoreObject;
1785  struct {
1786  PKDPC Dpc;
1787  ULONG ReferenceCount;
1789  } Dpc;
1790  struct {
1791  PWORK_QUEUE_ITEM WorkQueueItem;
1792  WORK_QUEUE_TYPE WorkQueueType;
1794  } WorkItem;
1795  struct {
1796  PWORK_QUEUE_ITEM WorkQueueItem;
1797  PKSWORKER KsWorkerObject;
1799  } KsWorkItem;
1800 #endif
1801  struct {
1804  } Alignment;
1805  };
1807 
1808 #define KSEVENTF_EVENT_HANDLE 0x00000001
1809 #define KSEVENTF_SEMAPHORE_HANDLE 0x00000002
1810 #if defined(_NTDDK_)
1811 #define KSEVENTF_EVENT_OBJECT 0x00000004
1812 #define KSEVENTF_SEMAPHORE_OBJECT 0x00000008
1813 #define KSEVENTF_DPC 0x00000010
1814 #define KSEVENTF_WORKITEM 0x00000020
1815 #define KSEVENTF_KSWORKITEM 0x00000080
1816 #endif
1817 
1818 
1819 #define KSEVENT_TYPE_ENABLE 0x00000001
1820 #define KSEVENT_TYPE_ONESHOT 0x00000002
1821 #define KSEVENT_TYPE_ENABLEBUFFERED 0x00000004
1822 #define KSEVENT_TYPE_SETSUPPORT 0x00000100
1823 #define KSEVENT_TYPE_BASICSUPPORT 0x00000200
1824 #define KSEVENT_TYPE_QUERYBUFFER 0x00000400
1825 
1826 #define KSEVENT_TYPE_TOPOLOGY 0x10000000
1827 
1828 typedef struct {
1831  union {
1834  };
1839 
1840 #define KSRELATIVEEVENT_FLAG_HANDLE 0x00000001
1841 #define KSRELATIVEEVENT_FLAG_POINTER 0x00000002
1842 
1843 /* ===============================================================
1844  Timing
1845 */
1846 
1847 typedef struct {
1851 
1852 typedef struct {
1857 
1858 typedef struct {
1862 
1863 typedef struct {
1867 } KSTIME, *PKSTIME;
1868 
1869 typedef struct {
1873 
1874 typedef struct {
1879 
1880 /* ===============================================================
1881  Clocks
1882 */
1883 
1885 
1886 typedef struct {
1889 
1890 #if defined(_NTDDK_)
1891 
1893 typedef LONGLONG
1894 (FASTCALL *PFNKSCLOCK_GETTIME)(
1896 
1898 typedef LONGLONG
1899 (FASTCALL *PFNKSCLOCK_CORRELATEDTIME)(
1901  _Out_ PLONGLONG SystemTime);
1902 
1903 typedef struct {
1904  PFNKSCLOCK_GETTIME GetTime;
1905  PFNKSCLOCK_GETTIME GetPhysicalTime;
1906  PFNKSCLOCK_CORRELATEDTIME GetCorrelatedTime;
1907  PFNKSCLOCK_CORRELATEDTIME GetCorrelatedPhysicalTime;
1908 } KSCLOCK_FUNCTIONTABLE, *PKSCLOCK_FUNCTIONTABLE;
1909 
1910 #define DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(Handler)\
1911  DEFINE_KSPROPERTY_ITEM(\
1912  KSPROPERTY_CLOCK_TIME,\
1913  (Handler),\
1914  sizeof(KSPROPERTY),\
1915  sizeof(LONGLONG),\
1916  NULL, NULL, 0, NULL, NULL, 0)
1917 
1918 #define DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(Handler)\
1919  DEFINE_KSPROPERTY_ITEM(\
1920  KSPROPERTY_CLOCK_PHYSICALTIME,\
1921  (Handler),\
1922  sizeof(KSPROPERTY),\
1923  sizeof(LONGLONG),\
1924  NULL, NULL, 0, NULL, NULL, 0)
1925 
1926 #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(Handler)\
1927  DEFINE_KSPROPERTY_ITEM(\
1928  KSPROPERTY_CLOCK_CORRELATEDTIME,\
1929  (Handler),\
1930  sizeof(KSPROPERTY),\
1931  sizeof(KSCORRELATED_TIME),\
1932  NULL, NULL, 0, NULL, NULL, 0)
1933 
1934 #define DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(Handler)\
1935  DEFINE_KSPROPERTY_ITEM(\
1936  KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME,\
1937  (Handler),\
1938  sizeof(KSPROPERTY),\
1939  sizeof(KSCORRELATED_TIME),\
1940  NULL, NULL, 0, NULL, NULL, 0)
1941 
1942 #define DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(Handler)\
1943  DEFINE_KSPROPERTY_ITEM(\
1944  KSPROPERTY_CLOCK_RESOLUTION,\
1945  (Handler),\
1946  sizeof(KSPROPERTY),\
1947  sizeof(KSRESOLUTION),\
1948  NULL, NULL, 0, NULL, NULL, 0)
1949 
1950 #define DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(Handler)\
1951  DEFINE_KSPROPERTY_ITEM(\
1952  KSPROPERTY_CLOCK_STATE,\
1953  (Handler),\
1954  sizeof(KSPROPERTY),\
1955  sizeof(KSSTATE),\
1956  NULL, NULL, 0, NULL, NULL, 0)
1957 
1958 #define DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(Handler)\
1959  DEFINE_KSPROPERTY_ITEM(\
1960  KSPROPERTY_CLOCK_FUNCTIONTABLE,\
1961  (Handler),\
1962  sizeof(KSPROPERTY),\
1963  sizeof(KSCLOCK_FUNCTIONTABLE),\
1964  NULL, NULL, 0, NULL, NULL, 0)
1965 
1966 #define DEFINE_KSPROPERTY_CLOCKSET(ClockSet,\
1967  PropTime, PropPhysicalTime,\
1968  PropCorrelatedTime, PropCorrelatedPhysicalTime,\
1969  PropResolution, PropState, PropFunctionTable)\
1970 DEFINE_KSPROPERTY_TABLE(ClockSet) {\
1971  DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(PropTime),\
1972  DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(PropPhysicalTime),\
1973  DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(PropCorrelatedTime),\
1974  DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(PropCorrelatedPhysicalTime),\
1975  DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(PropResolution),\
1976  DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(PropState),\
1977  DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(PropFunctionTable)\
1978 }
1979 
1980 /* ===============================================================
1981  Objects ??? SORT ME!
1982 */
1983 
1984 #define KSCREATE_ITEM_SECURITYCHANGED 0x1
1985 #define KSCREATE_ITEM_WILDCARD 0x2
1986 #define KSCREATE_ITEM_NOPARAMETERS 0x4
1987 #define KSCREATE_ITEM_FREEONSTOP 0x8
1988 
1989 typedef struct {
1991  PVOID Context;
1992  UNICODE_STRING ObjectClass;
1994  ULONG Flags;
1995 } KSOBJECT_CREATE_ITEM, *PKSOBJECT_CREATE_ITEM;
1996 
1997 typedef struct {
1998  ULONG CreateItemsCount;
1999  _Field_size_(CreateItemsCount) PKSOBJECT_CREATE_ITEM CreateItemsList;
2000 } KSOBJECT_CREATE, *PKSOBJECT_CREATE;
2001 
2002 typedef VOID
2003 (NTAPI *PFNKSITEMFREECALLBACK)(
2004  _In_ PKSOBJECT_CREATE_ITEM CreateItem);
2005 
2006 #endif /* _NTDDK_ */
2007 
2008 typedef struct {
2012 
2013 typedef struct {
2018 
2019 typedef struct {
2022 } KSERROR, *PKSERROR;
2023 
2024 /* ===============================================================
2025  Methods
2026 */
2027 
2028 #if defined(_NTDDK_)
2029 
2030 typedef struct {
2031  ULONG MethodId;
2032  union {
2033  PFNKSHANDLER MethodHandler;
2034  BOOLEAN MethodSupported;
2035  };
2036  ULONG MinMethod;
2037  ULONG MinData;
2038  PFNKSHANDLER SupportHandler;
2039  ULONG Flags;
2040 } KSMETHOD_ITEM, *PKSMETHOD_ITEM;
2041 
2042 #ifndef _MSC_VER
2043 
2044 #define DEFINE_KSMETHOD_ITEM(MethodId, Flags,\
2045  MethodHandler,\
2046  MinMethod, MinData, SupportHandler)\
2047 {\
2048  MethodId, {(PFNKSHANDLER)MethodHandler}, MinMethod, MinData,\
2049  SupportHandler, Flags\
2050 }
2051 
2052 #else
2053 
2054 #define DEFINE_KSMETHOD_ITEM(MethodId, Flags,\
2055  MethodHandler,\
2056  MinMethod, MinData, SupportHandler)\
2057 {\
2058  MethodId, (PFNKSHANDLER)MethodHandler, MinMethod, MinData,\
2059  SupportHandler, Flags\
2060 }
2061 
2062 #endif
2063 
2064 typedef struct {
2065  ULONG MethodId;
2066  union {
2067  PFNKSFASTHANDLER MethodHandler;
2068  BOOLEAN MethodSupported;
2069  };
2070 } KSFASTMETHOD_ITEM, *PKSFASTMETHOD_ITEM;
2071 
2072 #define DEFINE_KSFASTMETHOD_ITEM(MethodId, MethodHandler)\
2073 {\
2074  MethodId, (PFNKSFASTHANDLER)MethodHandler\
2075 }
2076 
2077 typedef struct {
2078  const GUID *Set;
2079  ULONG MethodsCount;
2080  _Field_size_(MethodsCount) const KSMETHOD_ITEM *MethodItem;
2081  ULONG FastIoCount;
2082  _Field_size_(FastIoCount) const KSFASTMETHOD_ITEM *FastIoTable;
2083 } KSMETHOD_SET, *PKSMETHOD_SET;
2084 
2085 #define DEFINE_KSMETHOD_SET(Set,\
2086  MethodsCount,\
2087  MethodItem,\
2088  FastIoCount,\
2089  FastIoTable)\
2090 {\
2091  Set,\
2092  MethodsCount,\
2093  MethodItem,\
2094  FastIoCount,\
2095  FastIoTable\
2096 }
2097 
2098 #endif /* _NTDDK_ */
2099 
2100 /* ===============================================================
2101  Nodes
2102 */
2103 
2104 typedef struct {
2108 } KSP_NODE, *PKSP_NODE;
2109 
2110 typedef struct {
2114 } KSM_NODE, *PKSM_NODE;
2115 
2116 typedef struct {
2120 } KSE_NODE, *PKSE_NODE;
2121 
2122 typedef struct {
2126 
2127 /* ===============================================================
2128  Events
2129 */
2130 
2131 typedef struct _KSEVENT_ENTRY KSEVENT_ENTRY, *PKSEVENT_ENTRY;
2132 
2133 #if defined(_NTDDK_)
2134 
2135 typedef NTSTATUS
2136 (NTAPI *PFNKSADDEVENT)(
2137  _In_ PIRP Irp,
2138  _In_ PKSEVENTDATA EventData,
2139  _In_ struct _KSEVENT_ENTRY *EventEntry);
2140 
2141 typedef VOID
2142 (NTAPI *PFNKSREMOVEEVENT)(
2144  _In_ struct _KSEVENT_ENTRY *EventEntry);
2145 
2146 typedef struct {
2147  ULONG EventId;
2148  ULONG DataInput;
2149  ULONG ExtraEntryData;
2150  PFNKSADDEVENT AddHandler;
2151  PFNKSREMOVEEVENT RemoveHandler;
2152  PFNKSHANDLER SupportHandler;
2153 } KSEVENT_ITEM, *PKSEVENT_ITEM;
2154 
2155 typedef struct {
2156  const GUID *Set;
2157  ULONG EventsCount;
2158  _Field_size_(EventsCount) const KSEVENT_ITEM *EventItem;
2159 } KSEVENT_SET, *PKSEVENT_SET;
2160 
2161 struct _KSEVENT_ENTRY {
2162  LIST_ENTRY ListEntry;
2163  PVOID Object;
2164  union {
2165  PKSDPC_ITEM DpcItem;
2166  PKSBUFFER_ITEM BufferItem;
2167  };
2168  PKSEVENTDATA EventData;
2169  ULONG NotificationType;
2170  const KSEVENT_SET *EventSet;
2171  const KSEVENT_ITEM *EventItem;
2173  ULONG SemaphoreAdjustment;
2174  ULONG Reserved;
2175  ULONG Flags;
2176 };
2177 
2178 #endif /* _NTDDK_ */
2179 
2180 /* ===============================================================
2181  Pins
2182 */
2183 
2184 #if defined(_NTDDK_)
2185 
2186 typedef struct _KSPIN KSPIN, *PKSPIN;
2187 typedef struct _KSSTREAM_POINTER KSSTREAM_POINTER, *PKSSTREAM_POINTER;
2188 typedef struct _KSSTREAM_POINTER_OFFSET KSSTREAM_POINTER_OFFSET, *PKSSTREAM_POINTER_OFFSET;
2189 typedef struct _KSMAPPING KSMAPPING, *PKSMAPPING;
2190 typedef struct _KSPROCESSPIN KSPROCESSPIN, *PKSPROCESSPIN;
2191 
2192 #define IOCTL_KS_HANDSHAKE CTL_CODE(FILE_DEVICE_KS, 0x007, METHOD_NEITHER, FILE_ANY_ACCESS)
2193 
2194 typedef struct {
2195  GUID ProtocolId;
2196  PVOID Argument1;
2197  PVOID Argument2;
2198 } KSHANDSHAKE, *PKSHANDSHAKE;
2199 
2201 typedef NTSTATUS
2202 (NTAPI *PFNKSPINHANDSHAKE)(
2203  _In_ PKSPIN Pin,
2204  _In_ PKSHANDSHAKE In,
2205  _In_ PKSHANDSHAKE Out);
2206 
2208 typedef void
2209 (NTAPI *PFNKSPINPOWER)(
2210  _In_ PKSPIN Pin,
2212 
2213 typedef void
2214 (NTAPI *PFNKSPINFRAMERETURN)(
2215  _In_ PKSPIN Pin,
2218  _In_opt_ PMDL Mdl,
2220  _In_ NTSTATUS Status);
2221 
2223 typedef void
2224 (NTAPI *PFNKSPINIRPCOMPLETION)(
2225  _In_ PKSPIN Pin,
2226  _In_ PIRP Irp);
2227 
2229 typedef NTSTATUS
2230 (NTAPI *PFNKSPINIRP)(
2231  _In_ PKSPIN Pin,
2232  _In_ PIRP Irp);
2233 
2234 typedef NTSTATUS
2235 (NTAPI *PFNKSPIN)(
2236  _In_ PKSPIN Pin);
2237 
2239 typedef void
2240 (NTAPI *PFNKSPINVOID)(
2241  _In_ PKSPIN Pin);
2242 
2244 typedef void
2245 (NTAPI *PFNKSSTREAMPOINTER)(
2246  _In_ PKSSTREAM_POINTER StreamPointer);
2247 
2248 typedef struct {
2249  ULONG Count;
2251 } KSATTRIBUTE_LIST, *PKSATTRIBUTE_LIST;
2252 
2254 typedef NTSTATUS
2255 (NTAPI *PFNKSPINSETDATAFORMAT)(
2256  _In_ PKSPIN Pin,
2257  _In_opt_ PKSDATAFORMAT OldFormat,
2258  _In_opt_ PKSMULTIPLE_ITEM OldAttributeList,
2259  _In_ const KSDATARANGE* DataRange,
2260  _In_opt_ const KSATTRIBUTE_LIST* AttributeRange);
2261 
2263 typedef NTSTATUS
2264 (NTAPI *PFNKSPINSETDEVICESTATE)(
2265  _In_ PKSPIN Pin,
2266  _In_ KSSTATE ToState,
2267  _In_ KSSTATE FromState);
2268 
2269 typedef struct _KSCLOCK_DISPATCH KSCLOCK_DISPATCH, *PKSCLOCK_DISPATCH;
2270 typedef struct _KSALLOCATOR_DISPATCH KSALLOCATOR_DISPATCH, *PKSALLOCATOR_DISPATCH;
2271 
2272 typedef struct {
2273  PFNKSPINIRP Create;
2274  PFNKSPINIRP Close;
2275  PFNKSPIN Process;
2276  PFNKSPINVOID Reset;
2277  PFNKSPINSETDATAFORMAT SetDataFormat;
2278  PFNKSPINSETDEVICESTATE SetDeviceState;
2279  PFNKSPIN Connect;
2280  PFNKSPINVOID Disconnect;
2281  const KSCLOCK_DISPATCH* Clock;
2282  const KSALLOCATOR_DISPATCH* Allocator;
2283 } KSPIN_DISPATCH, *PKSPIN_DISPATCH;
2284 
2286 typedef BOOLEAN
2287 (NTAPI *PFNKSPINSETTIMER)(
2288  _In_ PKSPIN Pin,
2289  _In_ PKTIMER Timer,
2291  _In_ PKDPC Dpc);
2292 
2294 typedef BOOLEAN
2295 (NTAPI *PFNKSPINCANCELTIMER)(
2296  _In_ PKSPIN Pin,
2297  _In_ PKTIMER Timer);
2298 
2300 typedef LONGLONG
2301 (FASTCALL *PFNKSPINCORRELATEDTIME)(
2302  _In_ PKSPIN Pin,
2303  _Out_ PLONGLONG SystemTime);
2304 
2306 typedef void
2307 (NTAPI *PFNKSPINRESOLUTION)(
2308  _In_ PKSPIN Pin,
2310 
2311 struct _KSCLOCK_DISPATCH {
2312  PFNKSPINSETTIMER SetTimer;
2313  PFNKSPINCANCELTIMER CancelTimer;
2314  PFNKSPINCORRELATEDTIME CorrelatedTime;
2315  PFNKSPINRESOLUTION Resolution;
2316 };
2317 
2319 typedef NTSTATUS
2320 (NTAPI *PFNKSPININITIALIZEALLOCATOR)(
2321  _In_ PKSPIN Pin,
2323  _Out_ PVOID *Context);
2324 
2325 typedef PVOID
2326 (NTAPI *PFNKSDELETEALLOCATOR)(
2327  _In_ PVOID Context);
2328 
2329 typedef PVOID
2330 (NTAPI *PFNKSDEFAULTALLOCATE)(
2331  _In_ PVOID Context);
2332 
2333 typedef PVOID
2334 (NTAPI *PFNKSDEFAULTFREE)(
2335  _In_ PVOID Context,
2336  _In_ PVOID Buffer);
2337 
2338 struct _KSALLOCATOR_DISPATCH {
2339  PFNKSPININITIALIZEALLOCATOR InitializeAllocator;
2340  PFNKSDELETEALLOCATOR DeleteAllocator;
2341  PFNKSDEFAULTALLOCATE Allocate;
2342  PFNKSDEFAULTFREE Free;
2343 };
2344 
2345 typedef struct KSAUTOMATION_TABLE_ {
2346  ULONG PropertySetsCount;
2347  ULONG PropertyItemSize;
2348  _Field_size_bytes_(PropertySetsCount * PropertyItemSize) const KSPROPERTY_SET *PropertySets;
2349  ULONG MethodSetsCount;
2350  ULONG MethodItemSize;
2351  _Field_size_bytes_(MethodSetsCount * MethodItemSize) const KSMETHOD_SET *MethodSets;
2352  ULONG EventSetsCount;
2353  ULONG EventItemSize;
2354  _Field_size_bytes_(EventSetsCount * EventItemSize) const KSEVENT_SET *EventSets;
2355 #if !defined(_WIN64)
2356  PVOID Alignment;
2357 #endif
2358 } KSAUTOMATION_TABLE, *PKSAUTOMATION_TABLE;
2359 
2360 typedef struct {
2361  ULONG InterfacesCount;
2362  _Field_size_(InterfacesCount) const KSPIN_INTERFACE *Interfaces;
2363  ULONG MediumsCount;
2364  _Field_size_(MediumsCount) const KSPIN_MEDIUM *Mediums;
2365  ULONG DataRangesCount;
2366  _Field_size_(DataRangesCount) const PKSDATARANGE *DataRanges;
2368  KSPIN_COMMUNICATION Communication;
2369  const GUID *Category;
2370  const GUID *Name;
2371  union {
2373  struct {
2374  ULONG ConstrainedDataRangesCount;
2375  _Field_size_(ConstrainedDataRangesCount) PKSDATARANGE *ConstrainedDataRanges;
2376  };
2377  };
2378 } KSPIN_DESCRIPTOR, *PKSPIN_DESCRIPTOR;
2379 
2382 typedef NTSTATUS
2383 (NTAPI *PFNKSINTERSECTHANDLER)(
2384  _In_ PIRP Irp,
2385  _In_ PKSP_PIN Pin,
2386  _In_ PKSDATARANGE DataRange,
2387  _Out_opt_ PVOID Data);
2388 
2391 typedef NTSTATUS
2392 (NTAPI *PFNKSINTERSECTHANDLEREX)(
2393  _In_ PVOID Context,
2394  _In_ PIRP Irp,
2395  _In_ PKSP_PIN Pin,
2396  _In_ PKSDATARANGE DataRange,
2397  _In_ PKSDATARANGE MatchingDataRange,
2398  _In_ ULONG DataBufferSize,
2399  _Out_writes_bytes_to_opt_(DataBufferSize, *DataSize) PVOID Data,
2401 
2402 typedef struct {
2403  const KSPIN_DISPATCH* Dispatch;
2404  const KSAUTOMATION_TABLE* AutomationTable;
2405  KSPIN_DESCRIPTOR PinDescriptor;
2406  ULONG Flags;
2407  ULONG InstancesPossible;
2408  ULONG InstancesNecessary;
2410  PFNKSINTERSECTHANDLEREX IntersectHandler;
2411 } KSPIN_DESCRIPTOR_EX, *PKSPIN_DESCRIPTOR_EX;
2412 
2413 #define KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING 0x00000001
2414 #define KSFILTER_FLAG_CRITICAL_PROCESSING 0x00000002
2415 #define KSFILTER_FLAG_HYPERCRITICAL_PROCESSING 0x00000004
2416 #define KSFILTER_FLAG_RECEIVE_ZERO_LENGTH_SAMPLES 0x00000008
2417 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
2418 #define KSFILTER_FLAG_DENY_USERMODE_ACCESS 0x80000000
2419 #endif
2420 
2421 #define KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING
2422 #define KSPIN_FLAG_CRITICAL_PROCESSING KSFILTER_FLAG_CRITICAL_PROCESSING
2423 #define KSPIN_FLAG_HYPERCRITICAL_PROCESSING KSFILTER_FLAG_HYPERCRITICAL_PROCESSING
2424 
2425 #define KSPIN_FLAG_ASYNCHRONOUS_PROCESSING 0x00000008
2426 #define KSPIN_FLAG_DO_NOT_INITIATE_PROCESSING 0x00000010
2427 #define KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL 0x00000020
2428 #define KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING 0x00000040
2429 #define KSPIN_FLAG_ENFORCE_FIFO 0x00000080
2430 
2431 #define KSPIN_FLAG_GENERATE_MAPPINGS 0x00000100
2432 #define KSPIN_FLAG_DISTINCT_TRAILING_EDGE 0x00000200
2433 
2434 #define KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY 0x00010000
2435 #define KSPIN_FLAG_SPLITTER 0x00020000
2436 #define KSPIN_FLAG_USE_STANDARD_TRANSPORT 0x00040000
2437 #define KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT 0x00080000
2438 #define KSPIN_FLAG_FIXED_FORMAT 0x00100000
2439 #define KSPIN_FLAG_GENERATE_EOS_EVENTS 0x00200000
2440 
2441 #define KSPIN_FLAG_RENDERER (KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY|KSPIN_FLAG_GENERATE_EOS_EVENTS)
2442 
2443 #define KSPIN_FLAG_IMPLEMENT_CLOCK 0x00400000
2444 #define KSPIN_FLAG_SOME_FRAMES_REQUIRED_FOR_PROCESSING 0x00800000
2445 #define KSPIN_FLAG_PROCESS_IF_ANY_IN_RUN_STATE 0x01000000
2446 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
2447 #define KSPIN_FLAG_DENY_USERMODE_ACCESS 0x80000000
2448 #endif
2449 
2450 struct _KSPIN {
2451  const KSPIN_DESCRIPTOR_EX *Descriptor;
2452  KSOBJECT_BAG Bag;
2453  PVOID Context;
2454  ULONG Id;
2455  KSPIN_COMMUNICATION Communication;
2456  BOOLEAN ConnectionIsExternal;
2457  KSPIN_INTERFACE ConnectionInterface;
2458  KSPIN_MEDIUM ConnectionMedium;
2459  KSPRIORITY ConnectionPriority;
2460  PKSDATAFORMAT ConnectionFormat;
2461  PKSMULTIPLE_ITEM AttributeList;
2462  ULONG StreamHeaderSize;
2464  KSSTATE DeviceState;
2466  KSSTATE ClientState;
2467 };
2468 
2469 #define DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(Handler)\
2470  DEFINE_KSPROPERTY_ITEM(\
2471  KSPROPERTY_PIN_CINSTANCES,\
2472  (Handler),\
2473  sizeof(KSP_PIN),\
2474  sizeof(KSPIN_CINSTANCES),\
2475  NULL, NULL, 0, NULL, NULL, 0)
2476 
2477 #define DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(Handler)\
2478  DEFINE_KSPROPERTY_ITEM(\
2479  KSPROPERTY_PIN_CTYPES,\
2480  (Handler),\
2481  sizeof(KSPROPERTY),\
2482  sizeof(ULONG),\
2483  NULL, NULL, 0, NULL, NULL, 0)
2484 
2485 #define DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(Handler)\
2486  DEFINE_KSPROPERTY_ITEM(\
2487  KSPROPERTY_PIN_DATAFLOW,\
2488  (Handler),\
2489  sizeof(KSP_PIN),\
2490  sizeof(KSPIN_DATAFLOW),\
2491  NULL, NULL, 0, NULL, NULL, 0)
2492 
2493 #define DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(Handler)\
2494  DEFINE_KSPROPERTY_ITEM(\
2495  KSPROPERTY_PIN_DATARANGES,\
2496  (Handler),\
2497  sizeof(KSP_PIN),\
2498  0,\
2499  NULL, NULL, 0, NULL, NULL, 0)
2500 
2501 #define DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(Handler)\
2502  DEFINE_KSPROPERTY_ITEM(\
2503  KSPROPERTY_PIN_DATAINTERSECTION,\
2504  (Handler),\
2505  sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM),\
2506  0,\
2507  NULL, NULL, 0, NULL, NULL, 0)
2508 
2509 #define DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(Handler)\
2510  DEFINE_KSPROPERTY_ITEM(\
2511  KSPROPERTY_PIN_INTERFACES,\
2512  (Handler),\
2513  sizeof(KSP_PIN),\
2514  0,\
2515  NULL, NULL, 0, NULL, NULL, 0)
2516 
2517 #define DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(Handler)\
2518  DEFINE_KSPROPERTY_ITEM(\
2519  KSPROPERTY_PIN_MEDIUMS,\
2520  (Handler),\
2521  sizeof(KSP_PIN),\
2522  0,\
2523  NULL, NULL, 0, NULL, NULL, 0)
2524 
2525 #define DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(Handler)\
2526  DEFINE_KSPROPERTY_ITEM(\
2527  KSPROPERTY_PIN_COMMUNICATION,\
2528  (Handler),\
2529  sizeof(KSP_PIN),\
2530  sizeof(KSPIN_COMMUNICATION),\
2531  NULL, NULL, 0, NULL, NULL, 0)
2532 
2533 #define DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES(Handler)\
2534  DEFINE_KSPROPERTY_ITEM(\
2535  KSPROPERTY_PIN_GLOBALCINSTANCES,\
2536  (Handler),\
2537  sizeof(KSP_PIN),\
2538  sizeof(KSPIN_CINSTANCES),\
2539  NULL, NULL, 0, NULL, NULL, 0)
2540 
2541 #define DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES(Handler)\
2542  DEFINE_KSPROPERTY_ITEM(\
2543  KSPROPERTY_PIN_NECESSARYINSTANCES,\
2544  (Handler),\
2545  sizeof(KSP_PIN),\
2546  sizeof(ULONG),\
2547  NULL, NULL, 0, NULL, NULL, 0)
2548 
2549 #define DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION(Handler)\
2550  DEFINE_KSPROPERTY_ITEM(\
2551  KSPROPERTY_PIN_PHYSICALCONNECTION,\
2552  (Handler),\
2553  sizeof(KSP_PIN),\
2554  0,\
2555  NULL, NULL, 0, NULL, NULL, 0)
2556 
2557 #define DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(Handler)\
2558  DEFINE_KSPROPERTY_ITEM(\
2559  KSPROPERTY_PIN_CATEGORY,\
2560  (Handler),\
2561  sizeof(KSP_PIN),\
2562  sizeof(GUID),\
2563  NULL, NULL, 0, NULL, NULL, 0)
2564 
2565 #define DEFINE_KSPROPERTY_ITEM_PIN_NAME(Handler)\
2566  DEFINE_KSPROPERTY_ITEM(\
2567  KSPROPERTY_PIN_NAME,\
2568  (Handler),\
2569  sizeof(KSP_PIN),\
2570  0,\
2571  NULL, NULL, 0, NULL, NULL, 0)
2572 
2573 #define DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(Handler)\
2574  DEFINE_KSPROPERTY_ITEM(\
2575  KSPROPERTY_PIN_CONSTRAINEDDATARANGES,\
2576  (Handler),\
2577  sizeof(KSP_PIN),\
2578  0,\
2579  NULL, NULL, 0, NULL, NULL, 0)
2580 
2581 #define DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT(Handler)\
2582  DEFINE_KSPROPERTY_ITEM(\
2583  KSPROPERTY_PIN_PROPOSEDATAFORMAT,\
2584  NULL,\
2585  sizeof(KSP_PIN),\
2586  sizeof(KSDATAFORMAT),\
2587  (Handler), NULL, 0, NULL, NULL, 0)
2588 
2589 #define DEFINE_KSPROPERTY_PINSET(PinSet,\
2590  PropGeneral, PropInstances, PropIntersection)\
2591 DEFINE_KSPROPERTY_TABLE(PinSet) {\
2592  DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),\
2593  DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),\
2594  DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),\
2595  DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),\
2596  DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),\
2597  DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),\
2598  DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),\
2599  DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),\
2600  DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),\
2601  DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral)\
2602 }
2603 
2604 #define DEFINE_KSPROPERTY_PINSETCONSTRAINED(PinSet,\
2605  PropGeneral, PropInstances, PropIntersection)\
2606 DEFINE_KSPROPERTY_TABLE(PinSet) {\
2607  DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),\
2608  DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),\
2609  DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),\
2610  DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),\
2611  DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),\
2612  DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),\
2613  DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),\
2614  DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),\
2615  DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),\
2616  DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral),\
2617  DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(PropGeneral)\
2618 }
2619 
2620 typedef void
2621 (NTAPI *PFNKSFREE)(
2622  _In_ PVOID Data);
2623 
2624 #define DEFINE_KSPROPERTY_TABLE(tablename) \
2625  const KSPROPERTY_ITEM tablename[] =
2626 
2627 #endif /* _NTDDK_ */
2628 
2629 typedef struct {
2636 
2637 /* ===============================================================
2638  Topology
2639 */
2640 
2641 typedef struct {
2642  ULONG FromNode;
2643  ULONG FromNodePin;
2644  ULONG ToNode;
2645  ULONG ToNodePin;
2647 
2648 typedef struct {
2650  _Field_size_(CategoriesCount) const GUID *Categories;
2652  _Field_size_(TopologyNodesCount) const GUID *TopologyNodes;
2654  _Field_size_(TopologyConnectionsCount) const KSTOPOLOGY_CONNECTION *TopologyConnections;
2655  _Field_size_(TopologyNodesCount) const GUID *TopologyNodesNames;
2658 
2659 
2660 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler)\
2661  DEFINE_KSPROPERTY_ITEM(\
2662  KSPROPERTY_TOPOLOGY_CATEGORIES,\
2663  (Handler),\
2664  sizeof(KSPROPERTY),\
2665  0,\
2666  NULL, NULL, 0, NULL, NULL, 0)
2667 
2668 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler)\
2669  DEFINE_KSPROPERTY_ITEM(\
2670  KSPROPERTY_TOPOLOGY_NODES,\
2671  (Handler),\
2672  sizeof(KSPROPERTY),\
2673  0,\
2674  NULL, NULL, 0, NULL, NULL, 0)
2675 
2676 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler)\
2677  DEFINE_KSPROPERTY_ITEM(\
2678  KSPROPERTY_TOPOLOGY_CONNECTIONS,\
2679  (Handler),\
2680  sizeof(KSPROPERTY),\
2681  0,\
2682  NULL, NULL, 0, NULL, NULL, 0)
2683 
2684 #define DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)\
2685  DEFINE_KSPROPERTY_ITEM(\
2686  KSPROPERTY_TOPOLOGY_NAME,\
2687  (Handler),\
2688  sizeof(KSP_NODE),\
2689  0,\
2690  NULL, NULL, 0, NULL, NULL, 0)
2691 
2692 #define DEFINE_KSPROPERTY_TOPOLOGYSET(TopologySet, Handler)\
2693 DEFINE_KSPROPERTY_TABLE(TopologySet) {\
2694  DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES(Handler),\
2695  DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES(Handler),\
2696  DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS(Handler),\
2697  DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME(Handler)\
2698 }
2699 
2700 /* ===============================================================
2701  ??? SORT ME
2702 */
2703 
2704 /* TODO */
2705 typedef void* UNKNOWN;
2706 
2707 typedef PVOID
2709  _In_ PVOID InitialContext,
2712 
2713 #if defined(_NTDDK_)
2714 
2716 typedef NTSTATUS
2717 (NTAPI *PFNKSALLOCATOR)(
2718  _In_ PIRP Irp,
2720  _In_ BOOLEAN InputOperation);
2721 
2724 typedef NTSTATUS
2725 (NTAPI *PFNKINTERSECTHANDLEREX)(
2726  _In_ PVOID Context,
2727  _In_ PIRP Irp,
2728  _In_ PKSP_PIN Pin,
2729  _In_ PKSDATARANGE DataRange,
2730  _In_ PKSDATARANGE MatchingDataRange,
2731  _In_ ULONG DataBufferSize,
2732  _Out_writes_bytes_to_opt_(DataBufferSize, *DataSize) PVOID Data,
2734 
2735 typedef NTSTATUS
2736 (NTAPI *PFNALLOCATOR_ALLOCATEFRAME)(
2738  _Outptr_ PVOID *Frame);
2739 
2740 typedef VOID
2741 (NTAPI *PFNALLOCATOR_FREEFRAME)(
2743  _In_ PVOID Frame);
2744 
2745 typedef struct {
2746  PFNALLOCATOR_ALLOCATEFRAME AllocateFrame;
2747  PFNALLOCATOR_FREEFRAME FreeFrame;
2748 } KSSTREAMALLOCATOR_FUNCTIONTABLE, *PKSSTREAMALLOCATOR_FUNCTIONTABLE;
2749 
2750 #endif /* _NTDDK_ */
2751 
2752 typedef struct {
2757 
2758 typedef struct {
2763 
2764 typedef struct {
2773 #ifdef _WIN64
2774  ULONG Reserved;
2775 #endif
2777 
2778 #define KSSTREAM_HEADER_OPTIONSF_SPLICEPOINT 0x00000001
2779 #define KSSTREAM_HEADER_OPTIONSF_PREROLL 0x00000002
2780 #define KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY 0x00000004
2781 #define KSSTREAM_HEADER_OPTIONSF_TYPECHANGED 0x00000008
2782 #define KSSTREAM_HEADER_OPTIONSF_TIMEVALID 0x00000010
2783 #define KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY 0x00000040
2784 #define KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE 0x00000080
2785 #define KSSTREAM_HEADER_OPTIONSF_DURATIONVALID 0x00000100
2786 #define KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM 0x00000200
2787 #define KSSTREAM_HEADER_OPTIONSF_BUFFEREDTRANSFER 0x00000400
2788 #define KSSTREAM_HEADER_OPTIONSF_VRAM_DATA_TRANSFER 0x00000800
2789 #define KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA 0x80000000
2790 
2791 /* ===============================================================
2792  XP / DX8
2793 */
2794 
2795 #if defined(_NTDDK_)
2796 
2797 typedef struct _KSGATE KSGATE, *PKSGATE;
2798 
2799 struct _KSGATE {
2800  LONG Count;
2801  PKSGATE NextGate;
2802 };
2803 
2804 #ifndef _NTOS_
2805 
2807 KSDDKAPI
2808 PKSGATE
2809 NTAPI
2811  _In_ PKSPIN Pin);
2812 
2814 static
2815 __inline
2816 void
2817 KsGateTurnInputOn(
2818  _In_opt_ PKSGATE Gate)
2819 {
2820  while (Gate && (InterlockedIncrement(&Gate->Count) == 1))
2821  {
2822  Gate = Gate->NextGate;
2823  }
2824 }
2825 
2827 static
2828 __inline
2829 void
2830 KsGateTurnInputOff(
2831  _In_opt_ PKSGATE Gate)
2832 {
2833  while (Gate && (InterlockedDecrement(&Gate->Count) == 0))
2834  {
2835  Gate = Gate->NextGate;
2836  }
2837 }
2838 
2840 static
2841 __inline
2842 BOOLEAN
2843 KsGateGetStateUnsafe(
2844  _In_ PKSGATE Gate)
2845 {
2846  ASSERT(Gate);
2847  return((BOOLEAN)(Gate->Count > 0));
2848 }
2849 
2851 static
2852 __inline
2853 BOOLEAN
2854 KsGateCaptureThreshold(
2855  _In_ PKSGATE Gate)
2856 {
2857  BOOLEAN captured;
2858 
2859  ASSERT(Gate);
2860 
2861  captured = (BOOLEAN)(InterlockedCompareExchange(&Gate->Count,0,1) == 1);
2862 
2863  if (captured)
2864  {
2865  KsGateTurnInputOff(Gate->NextGate);
2866  }
2867 
2868  return captured;
2869 }
2870 
2872 static
2873 __inline
2874 void
2875 KsGateInitialize(
2876  _In_ PKSGATE Gate,
2877  _In_ LONG InitialCount,
2878  _In_opt_ PKSGATE NextGate,
2879  _In_ BOOLEAN StateToPropagate)
2880 {
2881  ASSERT(Gate);
2882  Gate->Count = InitialCount;
2883  Gate->NextGate = NextGate;
2884 
2885  if (NextGate)
2886  {
2887  if (InitialCount > 0)
2888  {
2889  if (StateToPropagate)
2890  {
2891  KsGateTurnInputOn(NextGate);
2892  }
2893  }
2894  else
2895  {
2896  if (!StateToPropagate)
2897  {
2898  KsGateTurnInputOff(NextGate);
2899  }
2900  }
2901  }
2902 }
2903 
2905 static
2906 __inline
2907 void
2908 KsGateInitializeAnd(
2909  _In_ PKSGATE AndGate,
2910  _In_opt_ PKSGATE NextOrGate)
2911 {
2912  KsGateInitialize(AndGate,1,NextOrGate,TRUE);
2913 }
2914 
2916 static
2917 __inline
2918 void
2919 KsGateInitializeOr(
2920  _In_ PKSGATE OrGate,
2921  _In_opt_ PKSGATE NextAndGate)
2922 {
2923  KsGateInitialize(OrGate,0,NextAndGate,FALSE);
2924 }
2925 
2927 static
2928 __inline
2929 void
2930 KsGateAddOnInputToAnd(
2931  _In_ PKSGATE AndGate)
2932 {
2933  UNREFERENCED_PARAMETER (AndGate);
2934 }
2935 
2937 static
2938 __inline
2939 void
2940 KsGateAddOffInputToAnd(
2941  _In_ PKSGATE AndGate)
2942 {
2943  KsGateTurnInputOff(AndGate);
2944 }
2945 
2947 static
2948 __inline
2949 void
2950 KsGateRemoveOnInputFromAnd(
2951  _In_ PKSGATE AndGate)
2952 {
2953  UNREFERENCED_PARAMETER (AndGate);
2954 }
2955 
2957 static
2958 __inline
2959 void
2960 KsGateRemoveOffInputFromAnd(
2961  _In_ PKSGATE AndGate)
2962 {
2963  KsGateTurnInputOn(AndGate);
2964 }
2965 
2967 static
2968 __inline
2969 void
2970 KsGateAddOnInputToOr(
2971  _In_ PKSGATE OrGate)
2972 {
2973  KsGateTurnInputOn(OrGate);
2974 }
2975 
2977 static
2978 __inline
2979 void
2980 KsGateAddOffInputToOr(
2981  _In_ PKSGATE OrGate)
2982 {
2983  UNREFERENCED_PARAMETER (OrGate);
2984 }
2985 
2987 static
2988 __inline
2989 void
2990 KsGateRemoveOnInputFromOr(
2991  _In_ PKSGATE OrGate)
2992 {
2993  KsGateTurnInputOff(OrGate);
2994 }
2995 
2997 static
2998 __inline
2999 void
3000 KsGateRemoveOffInputFromOr(
3001  _In_ PKSGATE OrGate)
3002 {
3003  UNREFERENCED_PARAMETER (OrGate);
3004 }
3005 
3007 static
3008 __inline
3009 void
3010 KsGateTerminateAnd(
3011  _In_ PKSGATE AndGate)
3012 {
3013  ASSERT(AndGate);
3014  if (KsGateGetStateUnsafe(AndGate))
3015  {
3016  KsGateRemoveOnInputFromOr(AndGate->NextGate);
3017  }
3018  else
3019  {
3020  KsGateRemoveOffInputFromOr(AndGate->NextGate);
3021  }
3022 }
3023 
3025 static
3026 __inline
3027 void
3028 KsGateTerminateOr(
3029  _In_ PKSGATE OrGate)
3030 {
3031  ASSERT(OrGate);
3032  if (KsGateGetStateUnsafe(OrGate))
3033  {
3034  KsGateRemoveOnInputFromAnd(OrGate->NextGate);
3035  }
3036  else
3037  {
3038  KsGateRemoveOffInputFromAnd(OrGate->NextGate);
3039  }
3040 }
3041 
3042 #endif /* !_NTOS_ */
3043 
3044 struct _KSMAPPING {
3046  ULONG ByteCount;
3047  ULONG Alignment;
3048 };
3049 
3050 #endif /* _NTDDK_ */
3051 
3052 typedef enum {
3056 
3057 typedef struct _KSPROCESSPIN_INDEXENTRY KSPROCESSPIN_INDEXENTRY, *PKSPROCESSPIN_INDEXENTRY;
3058 
3060 #if defined(_NTDDK_)
3061  union {
3062  PUCHAR Data;
3063  PKSMAPPING Mappings;
3064  };
3065 #else
3067 #endif
3068 #if !defined(_WIN64)
3070 #endif
3073 };
3074 
3075 #if defined(_NTDDK_)
3076 
3077 struct _KSSTREAM_POINTER {
3078  PVOID Context;
3079  PKSPIN Pin;
3080  PKSSTREAM_HEADER StreamHeader;
3081  PKSSTREAM_POINTER_OFFSET Offset;
3082  KSSTREAM_POINTER_OFFSET OffsetIn;
3083  KSSTREAM_POINTER_OFFSET OffsetOut;
3084 };
3085 
3086 struct _KSPROCESSPIN {
3087  PKSPIN Pin;
3088  PKSSTREAM_POINTER StreamPointer;
3089  PKSPROCESSPIN InPlaceCounterpart;
3090  PKSPROCESSPIN DelegateBranch;
3091  PKSPROCESSPIN CopySource;
3092  _Field_size_bytes_(BytesAvailable) PVOID Data;
3093  ULONG BytesAvailable;
3094  ULONG BytesUsed;
3095  ULONG Flags;
3096  BOOLEAN Terminate;
3097 };
3098 
3099 struct _KSPROCESSPIN_INDEXENTRY {
3100  _Field_size_(Count) PKSPROCESSPIN *Pins;
3101  ULONG Count;
3102 };
3103 
3104 #endif /* _NTDDK_ */
3105 
3106 /* ===============================================================
3107  Device Dispatch
3108 */
3109 
3110 #if defined(_NTDDK_)
3111 
3112 typedef struct _KSFILTER_DISPATCH KSFILTER_DISPATCH, *PKSFILTER_DISPATCH;
3113 typedef struct _KSDEVICE KSDEVICE, *PKSDEVICE;
3114 typedef struct _KSFILTER KSFILTER, *PKSFILTER;
3115 typedef struct _KSNODE_DESCRIPTOR KSNODE_DESCRIPTOR, *PKSNODE_DESCRIPTOR;
3116 typedef struct _KSFILTER_DESCRIPTOR KSFILTER_DESCRIPTOR, *PKSFILTER_DESCRIPTOR;
3117 typedef struct _KSDEVICE_DESCRIPTOR KSDEVICE_DESCRIPTOR, *PKSDEVICE_DESCRIPTOR;
3118 
3120 typedef NTSTATUS
3121 (NTAPI *PFNKSDEVICECREATE)(
3122  _In_ PKSDEVICE Device);
3123 
3125 typedef NTSTATUS
3126 (NTAPI *PFNKSDEVICEPNPSTART)(
3127  _In_ PKSDEVICE Device,
3128  _In_ PIRP Irp,
3129  _In_opt_ PCM_RESOURCE_LIST TranslatedResourceList,
3130  _In_opt_ PCM_RESOURCE_LIST UntranslatedResourceList);
3131 
3133 typedef NTSTATUS
3134 (NTAPI *PFNKSDEVICE)(
3135  _In_ PKSDEVICE Device);
3136 
3138 typedef NTSTATUS
3139 (NTAPI *PFNKSDEVICEIRP)(
3140  _In_ PKSDEVICE Device,
3141  _In_ PIRP Irp);
3142 
3144 typedef VOID
3145 (NTAPI *PFNKSDEVICEIRPVOID)(
3146  _In_ PKSDEVICE Device,
3147  _In_ PIRP Irp);
3148 
3150 typedef NTSTATUS
3151 (NTAPI *PFNKSDEVICEQUERYCAPABILITIES)(
3152  _In_ PKSDEVICE Device,
3153  _In_ PIRP Irp,
3155 
3157 typedef NTSTATUS
3158 (NTAPI *PFNKSDEVICEQUERYPOWER)(
3159  _In_ PKSDEVICE Device,
3160  _In_ PIRP Irp,
3161  _In_ DEVICE_POWER_STATE DeviceTo,
3162  _In_ DEVICE_POWER_STATE DeviceFrom,
3163  _In_ SYSTEM_POWER_STATE SystemTo,
3164  _In_ SYSTEM_POWER_STATE SystemFrom,
3166 
3168 typedef VOID
3169 (NTAPI *PFNKSDEVICESETPOWER)(
3170  _In_ PKSDEVICE Device,
3171  _In_ PIRP Irp,
3173  _In_ DEVICE_POWER_STATE From);
3174 
3175 typedef struct _KSDEVICE_DISPATCH {
3176  PFNKSDEVICECREATE Add;
3177  PFNKSDEVICEPNPSTART Start;
3178  PFNKSDEVICE PostStart;
3179  PFNKSDEVICEIRP QueryStop;
3180  PFNKSDEVICEIRPVOID CancelStop;
3181  PFNKSDEVICEIRPVOID Stop;
3182  PFNKSDEVICEIRP QueryRemove;
3183  PFNKSDEVICEIRPVOID CancelRemove;
3184  PFNKSDEVICEIRPVOID Remove;
3185  PFNKSDEVICEQUERYCAPABILITIES QueryCapabilities;
3186  PFNKSDEVICEIRPVOID SurpriseRemoval;
3187  PFNKSDEVICEQUERYPOWER QueryPower;
3188  PFNKSDEVICESETPOWER SetPower;
3189  PFNKSDEVICEIRP QueryInterface;
3190 } KSDEVICE_DISPATCH, *PKSDEVICE_DISPATCH;
3191 
3192 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
3193 #define KSDEVICE_DESCRIPTOR_VERSION_2 (0x110)
3194 #define MIN_DEV_VER_FOR_FLAGS (0x110)
3195 #endif
3196 
3197 struct _KSDEVICE {
3198  const KSDEVICE_DESCRIPTOR* Descriptor;
3199  KSOBJECT_BAG Bag;
3200  PVOID Context;
3204  BOOLEAN Started;
3207 };
3208 
3209 #endif /* _NTDDK_ */
3210 
3211 /* ===============================================================
3212  Filter Dispatch
3213 */
3214 
3215 #if defined(_NTDDK_)
3216 
3217 struct _KSFILTER {
3218  const KSFILTER_DESCRIPTOR* Descriptor;
3219  KSOBJECT_BAG Bag;
3220  PVOID Context;
3221 };
3222 
3224 typedef void
3225 (NTAPI *PFNKSFILTERPOWER)(
3226  _In_ PKSFILTER Filter,
3228 
3230 typedef NTSTATUS
3231 (NTAPI *PFNKSFILTERIRP)(
3232  _In_ PKSFILTER Filter,
3233  _In_ PIRP Irp);
3234 
3235 typedef NTSTATUS
3236 (NTAPI *PFNKSFILTERPROCESS)(
3237  _In_ PKSFILTER Filter,
3238  _In_ PKSPROCESSPIN_INDEXENTRY ProcessPinsIndex);
3239 
3241 typedef NTSTATUS
3242 (NTAPI *PFNKSFILTERVOID)(
3243  _In_ PKSFILTER Filter);
3244 
3245 struct _KSFILTER_DISPATCH {
3246  PFNKSFILTERIRP Create;
3247  PFNKSFILTERIRP Close;
3248  PFNKSFILTERPROCESS Process;
3249  PFNKSFILTERVOID Reset;
3250 };
3251 
3252 struct _KSNODE_DESCRIPTOR {
3253  const KSAUTOMATION_TABLE *AutomationTable;
3254  const GUID *Type;
3255  const GUID *Name;
3256 #if !defined(_WIN64)
3257  PVOID Alignment;
3258 #endif
3259 };
3260 
3261 struct _KSFILTER_DESCRIPTOR {
3262  const KSFILTER_DISPATCH *Dispatch;
3263  const KSAUTOMATION_TABLE *AutomationTable;
3264  ULONG Version;
3265  ULONG Flags;
3266  const GUID *ReferenceGuid;
3267  ULONG PinDescriptorsCount;
3268  ULONG PinDescriptorSize;
3269  _Field_size_bytes_(PinDescriptorsCount * PinDescriptorSize) const KSPIN_DESCRIPTOR_EX *PinDescriptors;
3270  ULONG CategoriesCount;
3271  _Field_size_(CategoriesCount) const GUID *Categories;
3272  ULONG NodeDescriptorsCount;
3273  ULONG NodeDescriptorSize;
3274  _Field_size_bytes_(NodeDescriptorsCount * NodeDescriptorSize) const KSNODE_DESCRIPTOR *NodeDescriptors;
3275  ULONG ConnectionsCount;
3276  _Field_size_(ConnectionsCount) const KSTOPOLOGY_CONNECTION *Connections;
3277  const KSCOMPONENTID *ComponentId;
3278 };
3279 
3280 #define KSFILTER_DESCRIPTOR_VERSION ((ULONG)-1)
3281 
3282 struct _KSDEVICE_DESCRIPTOR {
3283  const KSDEVICE_DISPATCH *Dispatch;
3284  ULONG FilterDescriptorsCount;
3285  _Field_size_(FilterDescriptorsCount) const KSFILTER_DESCRIPTOR * const *FilterDescriptors;
3286  ULONG Version;
3287  ULONG Flags;
3288 };
3289 
3290 struct _KSFILTERFACTORY {
3291  const KSFILTER_DESCRIPTOR* FilterDescriptor;
3292  KSOBJECT_BAG Bag;
3293  PVOID Context;
3294 };
3295 
3296 #define DEFINE_KSFILTER_DESCRIPTOR(descriptor)\
3297  const KSFILTER_DESCRIPTOR descriptor =
3298 
3299 #define DEFINE_KSFILTER_PIN_DESCRIPTORS(table)\
3300  SIZEOF_ARRAY(table),\
3301  sizeof(table[0]),\
3302  table
3303 
3304 #define DEFINE_KSFILTER_CATEGORIES(table)\
3305  SIZEOF_ARRAY(table),\
3306  table
3307 
3308 #define DEFINE_KSFILTER_CATEGORY(category)\
3309  1,\
3310  &(category)
3311 
3312 #define DEFINE_KSFILTER_CATEGORIES_NULL\
3313  0,\
3314  NULL
3315 
3316 #define DEFINE_KSFILTER_NODE_DESCRIPTORS(table)\
3317  SIZEOF_ARRAY(table),\
3318  sizeof(table[0]),\
3319  table
3320 
3321 #define DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL\
3322  0,\
3323  sizeof(KSNODE_DESCRIPTOR),\
3324  NULL
3325 
3326 #define DEFINE_KSFILTER_CONNECTIONS(table)\
3327  SIZEOF_ARRAY(table),\
3328  table
3329 
3330 #define DEFINE_KSFILTER_DEFAULT_CONNECTIONS\
3331  0,\
3332  NULL
3333 
3334 #endif /* _NTDDK_ */
3335 
3336 /* ===============================================================
3337  Minidriver Callbacks
3338 */
3339 
3340 #if defined(_NTDDK_)
3341 
3342 typedef NTSTATUS
3343 (NTAPI *KStrMethodHandler)(
3344  IN PIRP Irp,
3346  IN OUT PVOID Data);
3347 
3348 typedef NTSTATUS
3349 (NTAPI *KStrSupportHandler)(
3350  IN PIRP Irp,
3352  IN OUT PVOID Data);
3353 
3354 #endif
3355 
3356 /* ===============================================================
3357  Allocator Functions
3358 */
3359 
3360 #if defined(_NTDDK_)
3361 
3363 KSDDKAPI
3364 NTSTATUS
3365 NTAPI
3370 
3372 KSDDKAPI
3373 NTSTATUS
3374 NTAPI
3376  _In_ PIRP Irp);
3377 
3379 KSDDKAPI
3380 NTSTATUS
3381 NTAPI
3383  _In_ PIRP Irp,
3385 
3387 KSDDKAPI
3388 NTSTATUS
3389 NTAPI
3391  _In_ PIRP Irp,
3393  _In_opt_ PFNKSDEFAULTALLOCATE DefaultAllocate,
3394  _In_opt_ PFNKSDEFAULTFREE DefaultFree,
3395  _In_opt_ PFNKSINITIALIZEALLOCATOR InitializeAllocator,
3396  _In_opt_ PFNKSDELETEALLOCATOR DeleteAllocator);
3397 
3399 KSDDKAPI
3400 NTSTATUS
3401 NTAPI
3403  _In_ PKSALLOCATOR_FRAMING_EX Framing,
3405  _In_ const KSALLOCATOR_FRAMING_EX *PinFraming);
3406 
3407 #endif /* _NTDDK_ */
3408 
3409 /* ===============================================================
3410  Clock Functions
3411 */
3412 
3413 #if defined(_NTDDK_)
3414 
3416 typedef BOOLEAN
3417 (NTAPI *PFNKSSETTIMER)(
3418  _In_ PVOID Context,
3419  _In_ PKTIMER Timer,
3421  _In_ PKDPC Dpc);
3422 
3424 typedef BOOLEAN
3425 (NTAPI *PFNKSCANCELTIMER)(
3426  _In_ PVOID Context,
3427  _In_ PKTIMER Timer);
3428 
3429 typedef LONGLONG
3430 (FASTCALL *PFNKSCORRELATEDTIME)(
3431  _In_ PVOID Context,
3432  _Out_ PLONGLONG SystemTime);
3433 
3435 KSDDKAPI
3436 NTSTATUS
3437 NTAPI
3442 
3444 KSDDKAPI
3445 NTSTATUS
3446 NTAPI
3448  _In_ PIRP Irp,
3449  _In_ PKSDEFAULTCLOCK DefaultClock);
3450 
3452 KSDDKAPI
3453 NTSTATUS
3454 NTAPI
3456  _Out_ PKSDEFAULTCLOCK *DefaultClock);
3457 
3459 KSDDKAPI
3460 NTSTATUS
3461 NTAPI
3463  _Out_ PKSDEFAULTCLOCK *DefaultClock,
3465  _In_opt_ PFNKSSETTIMER SetTimer,
3466  _In_opt_ PFNKSCANCELTIMER CancelTimer,
3467  _In_opt_ PFNKSCORRELATEDTIME CorrelatedTime,
3469  _In_ ULONG Flags);
3470 
3472 KSDDKAPI
3473 VOID
3474 NTAPI
3476  _In_ PKSDEFAULTCLOCK DefaultClock);
3477 
3479 KSDDKAPI
3480 NTSTATUS
3481 NTAPI
3483  _In_ PIRP Irp,
3485 
3487 KSDDKAPI
3488 KSSTATE
3489 NTAPI
3491  _In_ PKSDEFAULTCLOCK DefaultClock);
3492 
3494 KSDDKAPI
3495 VOID
3496 NTAPI
3498  _In_ PKSDEFAULTCLOCK DefaultClock,
3499  _In_ KSSTATE State);
3500 
3502 KSDDKAPI
3503 LONGLONG
3504 NTAPI
3506  _In_ PKSDEFAULTCLOCK DefaultClock);
3507 
3509 KSDDKAPI
3510 VOID
3511 NTAPI
3513  _In_ PKSDEFAULTCLOCK DefaultClock,
3514  _In_ LONGLONG Time);
3515 
3516 #endif /* _NTDDK_ */
3517 
3518 /* ===============================================================
3519  Method Functions
3520 */
3521 
3522 /* Method sets - TODO: Make into macros! */
3523 #if defined(_NTDDK_)
3524 
3525 #if 0
3526 
3527 VOID
3528 KSMETHOD_SET_IRP_STORAGE(
3529  IN IRP Irp);
3530 
3531 VOID
3532 KSMETHOD_ITEM_IRP_STORAGE(
3533  IN IRP Irp);
3534 
3535 VOID
3536 KSMETHOD_TYPE_IRP_STORAGE(
3537  IN IRP Irp);
3538 
3539 #endif
3540 
3542 KSDDKAPI
3543 NTSTATUS
3544 NTAPI
3545 KsMethodHandler(
3546  _In_ PIRP Irp,
3547  _In_ ULONG MethodSetsCount,
3548  _In_reads_(MethodSetsCount) const KSMETHOD_SET* MethodSet);
3549 
3551 KSDDKAPI
3552 NTSTATUS
3553 NTAPI
3554 KsMethodHandlerWithAllocator(
3555  _In_ PIRP Irp,
3556  _In_ ULONG MethodSetsCount,
3557  _In_reads_(MethodSetsCount) const KSMETHOD_SET* MethodSet,
3558  _In_opt_ PFNKSALLOCATOR Allocator,
3559  _In_opt_ ULONG MethodItemSize);
3560 
3562 KSDDKAPI
3563 BOOLEAN
3564 NTAPI
3567  _In_reads_bytes_(MethodLength) PKSMETHOD UNALIGNED Method,
3568  _In_ ULONG MethodLength,
3572  _In_ ULONG MethodSetsCount,
3573  _In_reads_(MethodSetsCount) const KSMETHOD_SET *MethodSet);
3574 
3575 #endif /* _NTDDK_ */
3576 
3577 /* ===============================================================
3578  Property Functions
3579 */
3580 
3581 #if defined(_NTDDK_)
3582 
3584 KSDDKAPI
3585 NTSTATUS
3586 NTAPI
3588  _In_ PIRP Irp,
3589  _In_ ULONG PropertySetsCount,
3590  _In_reads_(PropertySetsCount) const KSPROPERTY_SET *PropertySet);
3591 
3593 KSDDKAPI
3594 NTSTATUS
3595 NTAPI
3596 KsPropertyHandlerWithAllocator(
3597  _In_ PIRP Irp,
3598  _In_ ULONG PropertySetsCount,
3599  _In_reads_(PropertySetsCount) const KSPROPERTY_SET* PropertySet,
3600  _In_opt_ PFNKSALLOCATOR Allocator,
3601  _In_opt_ ULONG PropertyItemSize);
3602 
3604 KSDDKAPI
3605 NTSTATUS
3606 NTAPI
3609  _In_opt_ HANDLE ParentKey,
3611 
3613 KSDDKAPI
3614 BOOLEAN
3615 NTAPI
3619  _In_ ULONG PropertyLength,
3623  _In_ ULONG PropertySetsCount,
3624  _In_reads_(PropertySetsCount) const KSPROPERTY_SET *PropertySet);
3625 
3626 #endif /* _NTDDK_ */
3627 
3628 /* ===============================================================
3629  Event Functions
3630 */
3631 
3632 #if defined(_NTDDK_)
3633 
3634 #define KSPROBE_STREAMREAD 0x00000000
3635 #define KSPROBE_STREAMWRITE 0x00000001
3636 #define KSPROBE_ALLOCATEMDL 0x00000010
3637 #define KSPROBE_PROBEANDLOCK 0x00000020
3638 #define KSPROBE_SYSTEMADDRESS 0x00000040
3639 #define KSPROBE_MODIFY 0x00000200
3640 #define KSPROBE_STREAMWRITEMODIFY (KSPROBE_MODIFY | KSPROBE_STREAMWRITE)
3641 #define KSPROBE_ALLOWFORMATCHANGE 0x00000080
3642 
3643 #define KSSTREAM_READ KSPROBE_STREAMREAD
3644 #define KSSTREAM_WRITE KSPROBE_STREAMWRITE
3645 #define KSSTREAM_PAGED_DATA 0x00000000
3646 #define KSSTREAM_NONPAGED_DATA 0x00000100
3647 #define KSSTREAM_SYNCHRONOUS 0x00001000
3648 #define KSSTREAM_FAILUREEXCEPTION 0x00002000
3649 
3651 typedef BOOLEAN
3652 (NTAPI *PFNKSGENERATEEVENTCALLBACK)(
3653  _In_ PVOID Context,
3654  _In_ PKSEVENT_ENTRY EventEntry);
3655 
3656 KSDDKAPI
3657 NTSTATUS
3658 NTAPI
3660  _In_ PKSEVENT_ENTRY EntryEvent);
3661 
3663 KSDDKAPI
3664 void
3665 NTAPI
3667  _In_ PVOID Object,
3668  _In_opt_ const GUID *EventSet,
3669  _In_ ULONG EventId,
3672  _In_opt_ PFNKSGENERATEEVENTCALLBACK CallBack,
3674 
3676 KSDDKAPI
3677 NTSTATUS
3678 NTAPI
3679 KsEnableEventWithAllocator(
3680  _In_ PIRP Irp,
3681  _In_ ULONG EventSetsCount,
3682  _In_reads_(EventSetsCount) const KSEVENT_SET* EventSet,
3683  _Inout_opt_ PLIST_ENTRY EventsList,
3684  _In_opt_ KSEVENTS_LOCKTYPE EventsFlags,
3685  _In_opt_ PVOID EventsLock,
3686  _In_opt_ PFNKSALLOCATOR Allocator,
3687  _In_opt_ ULONG EventItemSize);
3688 
3689 KSDDKAPI
3690 NTSTATUS
3691 NTAPI
3693  _In_ PKSEVENT_ENTRY EventEntry,
3696 
3698 KSDDKAPI
3699 NTSTATUS
3700 NTAPI
3702  _In_ PIRP Irp,
3703  _In_ ULONG EventSetsCount,
3704  _In_reads_(EventSetsCount) KSEVENT_SET *EventSet,
3705  _Inout_opt_ PLIST_ENTRY EventsList,
3706  _In_opt_ KSEVENTS_LOCKTYPE EventsFlags,
3707  _In_opt_ PVOID EventsLock);
3708 
3710 KSDDKAPI
3711 VOID
3712 NTAPI
3714  _In_ PKSEVENT_ENTRY EventEntry);
3715 
3717 KSDDKAPI
3718 NTSTATUS
3719 NTAPI
3721  _In_ PIRP Irp,
3722  _Inout_ PLIST_ENTRY EventsList,
3723  _In_ KSEVENTS_LOCKTYPE EventsFlags,
3724  _In_ PVOID EventsLock);
3725 
3727 KSDDKAPI
3728 VOID
3729 NTAPI
3732  _Inout_ PLIST_ENTRY EventsList,
3733  _In_ KSEVENTS_LOCKTYPE EventsFlags,
3734  _In_ PVOID EventsLock);
3735 
3736 /* ===============================================================
3737  Topology Functions
3738 */
3739 
3741 KSDDKAPI
3742 NTSTATUS
3743 NTAPI
3745  _In_ PIRP Irp,
3746  _In_ PKSTOPOLOGY Topology,
3748 
3750 KSDDKAPI
3751 NTSTATUS
3752 NTAPI
3754  _In_ HANDLE ParentHandle,
3758 
3760 KSDDKAPI
3761 NTSTATUS
3762 NTAPI
3764  _In_ PIRP Irp,
3766  _Inout_ PVOID Data,
3767  _In_ const KSTOPOLOGY *Topology);
3768 
3769 /* ===============================================================
3770  Connectivity Functions
3771 */
3772 
3774 KSDDKAPI
3775 NTSTATUS
3776 NTAPI
3777 KsCreatePin(
3778  _In_ HANDLE FilterHandle,
3782 
3784 KSDDKAPI
3785 NTSTATUS
3786 NTAPI
3788  _In_ PIRP Irp,
3789  _In_ ULONG DescriptorsCount,
3790  _In_reads_(DescriptorsCount) KSPIN_DESCRIPTOR *Descriptor,
3792 
3794 KSDDKAPI
3795 NTSTATUS
3796 NTAPI
3798  _In_ PIRP Irp,
3800  _Inout_ PVOID Data,
3801  _In_ ULONG DescriptorsCount,
3802  _In_reads_(DescriptorsCount) const KSPIN_DESCRIPTOR *Descriptor);
3803 
3806 KSDDKAPI
3807 NTSTATUS
3808 NTAPI
3810  _In_ PIRP Irp,
3811  _In_ PKSP_PIN Pin,
3813  _In_ ULONG DescriptorsCount,
3814  _In_reads_(DescriptorsCount) const KSPIN_DESCRIPTOR *Descriptor,
3815  _In_ PFNKSINTERSECTHANDLER IntersectHandler);
3816 
3819 KSDDKAPI
3820 NTSTATUS
3821 NTAPI
3823  _In_ PIRP Irp,
3824  _In_ PKSP_PIN Pin,
3825  _Out_ PVOID Data,
3826  _In_ ULONG DescriptorsCount,
3827  _In_reads_bytes_(DescriptorsCount * DescriptorSize) const KSPIN_DESCRIPTOR *Descriptor,
3828  _In_ ULONG DescriptorSize,
3829  _In_opt_ PFNKSINTERSECTHANDLEREX IntersectHandler,
3830  _In_opt_ PVOID HandlerContext);
3831 
3833 KSDDKAPI
3834 PKSFILTER
3835 NTAPI
3837  _In_ PKSPIN Pin);
3838 
3840 KSDDKAPI
3841 PKSPIN
3842 NTAPI
3844  _In_ PKSPIN Pin);
3845 
3847 KSDDKAPI
3848 PKSSTREAM_POINTER
3849 NTAPI
3851  _In_ PKSPIN Pin,
3853 
3855 KSDDKAPI
3856 NTSTATUS
3857 NTAPI
3859  _In_ PKSSTREAM_POINTER StreamPointer,
3861 );
3862 
3864 KSDDKAPI
3865 void
3866 NTAPI
3868  _In_ PKSSTREAM_POINTER StreamPointer
3869 );
3870 
3872 KSDDKAPI
3873 NTSTATUS
3874 NTAPI
3876  _In_ PKSSTREAM_POINTER StreamPointer,
3877  _In_opt_ PFNKSSTREAMPOINTER CancelCallback,
3879  _Out_ PKSSTREAM_POINTER* CloneStreamPointer
3880 );
3881 
3882 
3883 /* Does this belong here? */
3884 
3886 KSDDKAPI
3887 NTSTATUS
3888 NTAPI
3890  _In_ PIRP Irp,
3891  _In_ ULONG DataItemsCount,
3892  _In_ ULONG DataItemSize,
3893  _In_reads_bytes_(DataItemsCount * DataItemSize) const VOID *DataItems);
3894 
3895 /* ===============================================================
3896  IRP Helper Functions
3897 */
3898 
3900 typedef NTSTATUS
3901 (NTAPI *PFNKSIRPLISTCALLBACK)(
3902  _In_ PIRP Irp,
3903  _In_ PVOID Context);
3904 
3906 KSDDKAPI
3907 NTSTATUS
3908 NTAPI
3910  _In_ PIRP Irp,
3911  _Out_ KSRESET *ResetValue);
3912 
3914 KSDDKAPI
3915 VOID
3916 NTAPI
3918  _Inout_ PLIST_ENTRY QueueHead,
3920  _In_ PIRP Irp,
3921  _In_ KSLIST_ENTRY_LOCATION ListLocation,
3922  _In_opt_ PDRIVER_CANCEL DriverCancel);
3923 
3925 KSDDKAPI
3926 NTSTATUS
3927 NTAPI
3931  _In_ PVOID Context,
3932  _In_ PWSTR ObjectClass,
3934 
3936 KSDDKAPI
3937 NTSTATUS
3938 NTAPI
3942  _In_ PVOID Context,
3943  _In_ PWSTR ObjectClass,
3945 
3947 KSDDKAPI
3948 NTSTATUS
3949 NTAPI
3952  _In_ ULONG ItemsCount,
3953  _In_reads_opt_(ItemsCount) PKSOBJECT_CREATE_ITEM ItemsList);
3954 
3956 KSDDKAPI
3957 NTSTATUS
3958 NTAPI
3960  _Inout_ PIRP Irp,
3961  _In_ ULONG ExtraSize,
3962  _Out_ PVOID *ExtraBuffer);
3963 
3965 KSDDKAPI
3966 NTSTATUS
3967 NTAPI
3970  _In_ PKSOBJECT_CREATE_ITEM CreateItem,
3971  _In_ BOOLEAN AllocateEntry,
3972  _In_opt_ PFNKSITEMFREECALLBACK ItemFreeCallback);
3973 
3975 KSDDKAPI
3976 NTSTATUS
3977 NTAPI
3980  _In_ ULONG ItemsCount,
3981  _In_reads_opt_(ItemsCount) PKSOBJECT_CREATE_ITEM ItemsList,
3982  _In_ PIRP Irp,
3983  _In_ KSDISPATCH_TABLE *Table);
3984 
3986 KSDDKAPI
3987 VOID
3988 NTAPI
3989 KsCancelIo(
3990  _Inout_ PLIST_ENTRY QueueHead,
3992 
3994 KSDDKAPI
3995 VOID
3996 NTAPI
3999  _In_ PIRP Irp);
4000 
4002 KSDDKAPI
4003 NTSTATUS
4004 NTAPI
4007  _In_ PIRP Irp);
4008 
4010 KSDDKAPI
4011 BOOLEAN
4012 NTAPI
4015  _In_ BOOLEAN Wait,
4022  _In_ PDEVICE_OBJECT DeviceObject); /* always return false */
4023 
4025 KSDDKAPI
4026 BOOLEAN
4027 NTAPI
4031  _In_ ULONG Length,
4032  _In_ BOOLEAN Wait,
4033  _In_ ULONG LockKey,
4034  _Out_ PVOID Buffer,
4036  _In_ PDEVICE_OBJECT DeviceObject); /* always return false */
4037 
4038 /* This function does the same as the above */
4039 #define KsDispatchFastWriteFailure KsDispatchFastReadFailure
4040 
4042 KSDDKAPI
4043 NTSTATUS
4044 NTAPI
4047  _In_ PIRP Irp);
4048 
4050 KSDDKAPI
4051 NTSTATUS
4052 NTAPI
4055  _In_ PIRP Irp);
4056 
4058 KSDDKAPI
4059 NTSTATUS
4060 NTAPI
4062  _In_ PIRP Irp,
4063  _In_ PFNKSHANDLER Handler);
4064 
4066 KSDDKAPI
4067 NTSTATUS
4068 NTAPI
4070  _In_ PIRP Irp,
4071  _In_ PFNKSHANDLER Handler);
4072 
4074 KSDDKAPI
4075 NTSTATUS
4076 NTAPI
4079  _In_ PIRP Irp,
4081  _In_ KSSTACK_USE StackUse);
4082 
4084 KSDDKAPI
4085 NTSTATUS
4086 NTAPI
4087 KsForwardIrp(
4088  _In_ PIRP Irp,
4090  _In_ BOOLEAN ReuseStackLocation);
4091 
4093 KSDDKAPI
4094 VOID
4095 NTAPI
4098 
4100 KSDDKAPI
4101 VOID
4102 NTAPI
4104  _In_ PVOID Header);
4105 
4106 KSDDKAPI
4107 NTSTATUS
4108 NTAPI
4109 KsGetChildCreateParameter(
4110  _In_ PIRP Irp,
4111  _Out_ PVOID *CreateParameter);
4112 
4114 KSDDKAPI
4115 NTSTATUS
4116 NTAPI
4119  _In_ PKSPIN_LOCK SourceLock,
4120  _Inout_ PLIST_ENTRY DestinationList,
4121  _In_opt_ PKSPIN_LOCK DestinationLock,
4122  _In_ KSLIST_ENTRY_LOCATION ListLocation,
4123  _In_ PFNKSIRPLISTCALLBACK ListCallback,
4124  _In_ PVOID Context);
4125 
4127 KSDDKAPI
4128 NTSTATUS
4129 NTAPI
4131  _Inout_ PIRP Irp,
4132  _In_ ULONG ProbeFlags,
4133  _In_ ULONG HeaderSize);
4134 
4136 KSDDKAPI
4137 NTSTATUS
4138 NTAPI
4142  _In_ ULONG Length,
4144 
4146 KSDDKAPI
4148 NTAPI
4151 
4153 KSDDKAPI
4154 PKSOBJECT_CREATE_ITEM
4155 NTAPI
4158 
4160 KSDDKAPI
4161 NTSTATUS
4162 NTAPI
4163 KsReadFile(
4166  _In_opt_ PVOID PortContext,
4169  _In_ ULONG Length,
4170  _In_opt_ ULONG Key,
4171  _In_ KPROCESSOR_MODE RequestorMode);
4172 
4174 KSDDKAPI
4175 VOID
4176 NTAPI
4178  _In_ PKSDEVICE);
4179 
4181 KSDDKAPI
4182 VOID
4183 NTAPI
4185  _In_ PIRP Irp,
4186  _In_opt_ PDRIVER_CANCEL DriverCancel);
4187 
4189 KSDDKAPI
4190 PIRP
4191 NTAPI
4193  _Inout_ PLIST_ENTRY QueueHead,
4195  _In_ KSLIST_ENTRY_LOCATION ListLocation,
4196  _In_ KSIRP_REMOVAL_OPERATION RemovalOperation);
4197 
4199 KSDDKAPI
4200 VOID
4201 NTAPI
4203  _In_ PIRP Irp);
4204 
4206 KSDDKAPI
4207 NTSTATUS
4208 NTAPI
4212  _In_ ULONG Length,
4214 
4216 KSDDKAPI
4217 NTSTATUS
4218 NTAPI
4221  _In_ ULONG MajorFunction);
4222 
4225 KSDDKAPI
4226 NTSTATUS
4227 NTAPI
4228 KsStreamIo(
4231  _In_opt_ PVOID PortContext,
4234  _In_opt_ KSCOMPLETION_INVOCATION CompletionInvocationFlags,
4236  _Inout_updates_bytes_(Length) PVOID StreamHeaders,
4237  _In_ ULONG Length,
4238  _In_ ULONG Flags,
4239  _In_ KPROCESSOR_MODE RequestorMode);
4240 
4242 KSDDKAPI
4243 VOID
4244 NTAPI
4246  _In_ PKSSTREAM_POINTER StreamPointer,
4247  _In_ BOOLEAN Eject);
4248 
4250 KSDDKAPI
4251 NTSTATUS
4252 NTAPI
4254  _In_ PKSSTREAM_POINTER StreamPointer,
4255  _In_ ULONG InUsed,
4256  _In_ ULONG OutUsed,
4257  _In_ BOOLEAN Eject);
4258 
4261 KSDDKAPI
4262 NTSTATUS
4263 NTAPI
4265  _In_ PKSSTREAM_POINTER StreamPointer);
4266 
4268 KSDDKAPI
4269 VOID
4270 NTAPI
4272  _In_ PKSSTREAM_POINTER StreamPointer,
4273  _In_ ULONG InUsed,
4274  _In_ ULONG OutUsed,
4275  _In_ BOOLEAN Eject
4276  );
4277 
4278 
4280 KSDDKAPI
4281 NTSTATUS
4282 NTAPI
4283 KsWriteFile(
4286  _In_opt_ PVOID PortContext,
4289  _In_ ULONG Length,
4290  _In_opt_ ULONG Key,
4291  _In_ KPROCESSOR_MODE RequestorMode);
4292 
4293 KSDDKAPI
4294 NTSTATUS
4295 NTAPI
4298  _In_ PIRP Irp);
4299 
4300 /* ===============================================================
4301  Worker Management Functions
4302 */
4303 
4305 KSDDKAPI
4306 NTSTATUS
4307 NTAPI
4309  _In_ WORK_QUEUE_TYPE WorkQueueType,
4310  _Out_ PKSWORKER* Worker);
4311 
4313 KSDDKAPI
4314 VOID
4315 NTAPI
4317  _In_ PKSWORKER Worker);
4318 
4320 KSDDKAPI
4321 NTSTATUS
4322 NTAPI
4324  _In_ WORK_QUEUE_TYPE WorkQueueType,
4325  _In_ PWORK_QUEUE_ITEM CountedWorkItem,
4326  _Out_ PKSWORKER *Worker);
4327 
4329 KSDDKAPI
4330 ULONG
4331 NTAPI
4333  _In_ PKSWORKER Worker);
4334 
4336 KSDDKAPI
4337 ULONG
4338 NTAPI
4340  _In_ PKSWORKER Worker);
4341 
4343 KSDDKAPI
4344 NTSTATUS
4345 NTAPI
4347  _In_ PKSWORKER Worker,
4348  _In_ PWORK_QUEUE_ITEM WorkItem);
4349 
4350 /* ===============================================================
4351  Resources / Images
4352 */
4353 
4355 KSDDKAPI
4356 NTSTATUS
4357 NTAPI
4359  _In_ PVOID ImageBase,
4361  _In_ ULONG_PTR ResourceName,
4362  _In_ ULONG ResourceType,
4363  _Outptr_result_bytebuffer_(*ResourceSize) PVOID *Resource,
4364  _Out_opt_ PULONG ResourceSize);
4365 
4367 KSDDKAPI
4368 NTSTATUS
4369 NTAPI
4371  _In_ HANDLE RegKey,
4373  _Out_ PULONG_PTR ResourceId,
4375 
4377 KSDDKAPI
4378 NTSTATUS
4379 NTAPI
4384  _Out_ PULONG_PTR ResourceId,
4386 
4387 /* ===============================================================
4388  Misc. Helper Functions
4389 */
4390 
4392 KSDDKAPI
4393 PVOID
4394 NTAPI
4396  _In_ PVOID Object);
4397 
4399 KSDDKAPI
4400 NTSTATUS
4401 NTAPI
4404  _In_ PKSPIN_MEDIUM Medium,
4405  _In_ ULONG PinDirection);
4406 
4407 KSDDKAPI
4408 NTSTATUS
4409 NTAPI
4412  _In_ PIRP Irp);
4413 
4415 KSDDKAPI
4416 VOID
4417 NTAPI
4420  _In_ PDEVICE_OBJECT PnpDeviceObject,
4421  _In_ PDEVICE_OBJECT BaseDevice);
4422 
4423 KSDDKAPI
4424 NTSTATUS
4425 NTAPI
4428  _In_ PIRP Irp);
4429 
4431 KSDDKAPI
4432 VOID
4433 NTAPI
4436  _In_opt_ PFNKSCONTEXT_DISPATCH PowerDispatch,
4437  _In_opt_ PVOID PowerContext);
4438 
4440 KSDDKAPI
4441 NTSTATUS
4442 NTAPI
4445 
4447 KSDDKAPI
4448 VOID
4449 NTAPI
4452 
4454 KSDDKAPI
4455 NTSTATUS
4456 NTAPI
4459  _In_ PUNICODE_STRING CreateItem);
4460 
4462 KSDDKAPI
4463 NTSTATUS
4464 NTAPI
4467  _In_ PVOID Context);
4468 
4470 KSDDKAPI
4471 VOID
4472 NTAPI
4475 
4477 KSDDKAPI
4479 NTAPI
4482 
4484 KSDDKAPI
4485 VOID
4486 NTAPI
4489  _In_ BOOLEAN ReuseStackLocation);
4490 
4492 KSDDKAPI
4493 VOID
4494 NTAPI
4498 
4500 KSDDKAPI
4501 VOID
4502 NTAPI
4505  _In_ KSTARGET_STATE TargetState);
4506 
4509 KSDDKAPI
4510 NTSTATUS
4511 NTAPI
4514  _In_ KPROCESSOR_MODE RequestorMode,
4515  _In_ ULONG IoControl,
4516  _In_reads_bytes_(InSize) PVOID InBuffer,
4517  _In_ ULONG InSize,
4518  _Out_writes_bytes_to_(OutSize, *BytesReturned) PVOID OutBuffer,
4519  _In_ ULONG OutSize,
4521 
4523 KSDDKAPI
4524 PKSPIN
4525 NTAPI
4527  _In_ PKSFILTER Filter,
4528  _In_ ULONG PinId);
4529 
4531 KSDDKAPI
4533 NTAPI
4535  _In_ PKSPIN Pin);
4536 
4537 #else /* _NTDDK_ */
4538 
4539 #if !defined( KS_NO_CREATE_FUNCTIONS )
4540 
4542 KSDDKAPI
4543 DWORD
4544 WINAPI
4549 
4551 KSDDKAPI
4552 DWORD
4553 NTAPI
4558 
4560 KSDDKAPI
4561 DWORD
4562 WINAPI
4563 KsCreatePin(
4564  _In_ HANDLE FilterHandle,
4568 
4570 KSDDKAPI
4571 DWORD
4572 WINAPI
4574  _In_ HANDLE ParentHandle,
4578 
4579 #endif
4580 
4581 #endif /* _NTDDK_ */
4582 
4583 /* ===============================================================
4584  AVStream Functions (XP / DirectX 8)
4585  NOT IMPLEMENTED YET
4586  http://www.osronline.com/ddkx/stream/avstream_5q9f.htm
4587 */
4588 
4589 #if defined(_NTDDK_)
4590 
4592 KSDDKAPI
4593 NTSTATUS
4594 NTAPI
4596  _Out_ PKSAUTOMATION_TABLE *AutomationTableAB,
4597  _In_opt_ PKSAUTOMATION_TABLE AutomationTableA,
4598  _In_opt_ PKSAUTOMATION_TABLE AutomationTableB,
4599  _In_opt_ KSOBJECT_BAG Bag);
4600 
4603 KSDDKAPI
4604 NTSTATUS
4605 NTAPI
4609  _In_opt_ const KSDEVICE_DESCRIPTOR *Descriptor);
4610 
4611 typedef struct _KSFILTERFACTORY KSFILTERFACTORY, *PKSFILTERFACTORY; //FIXME
4612 
4614 KSDDKAPI
4615 NTSTATUS
4616 NTAPI
4621  _In_opt_ const KSDEVICE_DESCRIPTOR *Descriptor);
4622 
4624 typedef void
4625 (NTAPI *PFNKSFILTERFACTORYPOWER)(
4626  _In_ PKSFILTERFACTORY FilterFactory,
4628 
4631 KSDDKAPI
4632 NTSTATUS
4633 NTAPI
4634 _KsEdit(
4635  _In_ KSOBJECT_BAG ObjectBag,
4636  _Inout_ PVOID *PointerToPointerToItem,
4637  _In_ ULONG NewSize,
4638  _In_ ULONG OldSize,
4639  _In_ ULONG Tag);
4640 
4642 KSDDKAPI
4643 VOID
4644 NTAPI
4646  _In_ PVOID Object);
4647 
4649 KSDDKAPI
4650 VOID
4651 NTAPI
4653  _In_ PKSDEVICE Device);
4654 
4656 KSDDKAPI
4657 NTSTATUS
4658 NTAPI
4659 KsAddDevice(
4662 
4664 KSDDKAPI
4665 VOID
4666 NTAPI
4667 KsAddEvent(
4668  _In_ PVOID Object,
4669  _In_ PKSEVENT_ENTRY EventEntry);
4670 
4673 KSDDKAPI
4674 NTSTATUS
4675 NTAPI
4677  _In_ KSOBJECT_BAG ObjectBag,
4679  _In_opt_ PFNKSFREE Free);
4680 
4682 KSDDKAPI
4683 ULONG
4684 NTAPI
4686  _In_ KSOBJECT_BAG ObjectBag,
4687  _In_ PVOID Item,
4688  _In_ BOOLEAN Free);
4689 
4691 KSDDKAPI
4692 NTSTATUS
4693 NTAPI
4695  _In_ PKSDEVICE Device,
4696  _Out_ KSOBJECT_BAG *ObjectBag);
4697 
4699 KSDDKAPI
4700 VOID
4701 NTAPI
4703  _In_ KSOBJECT_BAG ObjectBag);
4704 
4706 KSDDKAPI
4707 VOID
4708 NTAPI
4710  _In_ PIRP Irp);
4711 
4713 KSDDKAPI
4714 NTSTATUS
4715 NTAPI
4717  _In_ KSOBJECT_BAG ObjectBagDestination,
4718  _In_ KSOBJECT_BAG ObjectBagSource);
4719 
4721 KSDDKAPI
4722 NTSTATUS
4723 NTAPI
4727  _In_opt_ const KSDEVICE_DESCRIPTOR *Descriptor,
4728  _In_ ULONG ExtensionSize,
4729  _Out_opt_ PKSDEVICE *Device);
4730 
4733 KSDDKAPI
4734 NTSTATUS
4735 NTAPI
4738  _In_ const KSFILTER_DESCRIPTOR *Descriptor,
4739  _In_opt_ PWSTR RefString,
4741  _In_ ULONG CreateItemFlags,
4742  _In_opt_ PFNKSFILTERFACTORYPOWER SleepCallback,
4743  _In_opt_ PFNKSFILTERFACTORYPOWER WakeCallback,
4744  _Out_opt_ PKSFILTERFACTORY *FilterFactory);
4745 
4747 KSDDKAPI
4748 NTSTATUS
4749 NTAPI
4751  _In_ PKSFILTERFACTORY FilterFactory,
4752  _In_ BOOLEAN NewState);
4753 
4756 KSDDKAPI
4757 NTSTATUS
4758 NTAPI
4760  _In_ PKSFILTERFACTORY FilterFactory,
4761  _In_opt_ const KSFILTER_DESCRIPTOR *FilterDescriptor);
4762 
4764 KSDDKAPI
4765 PKSPIN
4766 NTAPI
4768  _In_ PIRP Irp);
4769 
4771 KSDDKAPI
4772 PKSFILTER
4773 NTAPI
4775  _In_ PIRP Irp);
4776 
4778 KSDDKAPI
4779 NTSTATUS
4780 NTAPI
4782  _In_ PIRP Irp,
4783  _In_ PKSEVENTDATA EventData,
4784  _Inout_ PKSEVENT_ENTRY EventEntry);
4785 
4787 KSDDKAPI
4788 NTSTATUS
4789 NTAPI
4792  _In_ PIRP Irp);
4793 
4795 KSDDKAPI
4796 NTSTATUS
4797 NTAPI
4800  _In_ PIRP Irp);
4801 
4803 KSDDKAPI
4804 VOID
4805 NTAPI
4807  _In_ PKSPIN Pin,
4809 
4811 KSDDKAPI
4812 VOID
4813 NTAPI
4815  _In_ PKSPIN Pin);
4816 
4818 KSDDKAPI
4819 VOID
4820 NTAPI
4822  _In_ PKSPIN Pin);
4823 
4825 KSDDKAPI
4826 PVOID
4827 NTAPI
4828 KsGetParent(
4829  _In_ PVOID Object);
4830 
4832 static
4833 __inline
4834 PKSFILTERFACTORY
4835 KsFilterGetParentFilterFactory(
4836  _In_ PKSFILTER Filter)
4837 {
4838  return (PKSFILTERFACTORY) KsGetParent((PVOID) Filter);
4839 }
4840 
4842 static
4843 __inline
4844 PKSDEVICE
4845 KsFilterFactoryGetParentDevice(
4846  _In_ PKSFILTERFACTORY FilterFactory)
4847 {
4848  return (PKSDEVICE) KsGetParent((PVOID) FilterFactory);
4849 }
4850 
4851 #define KsDeleteFilterFactory(FilterFactory) \
4852  KsFreeObjectCreateItemsByContext( \
4853  *(KSDEVICE_HEADER *)( \
4854  KsFilterFactoryGetParentDevice(FilterFactory)->FunctionalDeviceObject-> \
4855  DeviceExtension), \
4856  FilterFactory)
4857 
4859 KSDDKAPI
4860 ULONG
4861 NTAPI
4863  _In_ PKSDEVICE Device,
4866  _In_ ULONG Offset,
4867  _In_ ULONG Length);
4868 
4870 KSDDKAPI
4871 PVOID
4872 NTAPI
4874  _In_ PVOID Object);
4875 
4877 KSDDKAPI
4878 PKSFILTERFACTORY
4879 NTAPI
4880 KsDeviceGetFirstChildFilterFactory(
4881  _In_ PKSDEVICE Device);
4882 
4883 #if defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__)
4884 
4886 KSDDKAPI
4887 PUNKNOWN
4888 NTAPI
4890  _In_ PVOID Object);
4891 
4893 static
4894 __inline
4895 PUNKNOWN
4896 KsDeviceGetOuterUnknown(
4897  _In_ PKSDEVICE Device)
4898 {
4899  return KsGetOuterUnknown((PVOID) Device);
4900 }
4901 
4903 KSDDKAPI
4904 PUNKNOWN
4905 NTAPI
4906 KsDeviceRegisterAggregatedClientUnknown(
4907  _In_ PKSDEVICE Device,
4908  _In_ PUNKNOWN ClientUnknown);
4909 
4910 #endif
4911 
4912 #if defined(_UNKNOWN_H_) || defined(__IUnknown_INTERFACE_DEFINED__)
4913 
4914 typedef interface IKsReferenceClock* PIKSREFERENCECLOCK;
4915 
4916 #undef INTERFACE
4917 #define INTERFACE IKsReferenceClock
4918 DECLARE_INTERFACE_(IKsReferenceClock,IUnknown)
4919 {
4920  DEFINE_ABSTRACT_UNKNOWN() // For C
4921 
4923  ) PURE;
4924  STDMETHOD_(LONGLONG,GetPhysicalTime)(THIS
4925  ) PURE;
4926  STDMETHOD_(LONGLONG,GetCorrelatedTime)(THIS_
4927  _Out_ PLONGLONG SystemTime
4928  ) PURE;
4929  STDMETHOD_(LONGLONG,GetCorrelatedPhysicalTime)(THIS_
4930  _Out_ PLONGLONG SystemTime
4931  ) PURE;
4932  STDMETHOD_(NTSTATUS, GetResolution)(THIS_
4934  ) PURE;
4935  STDMETHOD_(NTSTATUS, GetState)(THIS_
4937  ) PURE;
4938 };
4939 
4940 #undef INTERFACE
4941 #define INTERFACE IKsControl
4942 
4943 DEFINE_GUID(IID_IKsControl, 0x28F54685L, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96);
4944 
4946 {
4948  REFIID InterfaceId,
4949  PVOID* Interface)PURE;
4950 
4952 
4954 
4955  STDMETHOD_(NTSTATUS, KsProperty)(THIS_
4956  _In_reads_bytes_(PropertyLength) PKSPROPERTY Property,
4957  _In_ ULONG PropertyLength,
4958  _Inout_updates_bytes_(DataLength) PVOID PropertyData,
4961  ) PURE;
4962  STDMETHOD_(NTSTATUS, KsMethod)(THIS_
4963  _In_reads_bytes_(MethodLength) PKSMETHOD Method,
4964  _In_ ULONG MethodLength,
4968  ) PURE;
4969  STDMETHOD_(NTSTATUS, KsEvent)(THIS_
4970  _In_reads_bytes_opt_(EventLength) PKSEVENT Event,
4971  _In_ ULONG EventLength,
4975  ) PURE;
4976 };
4977 
4978 #undef INTERFACE
4979 typedef IKsControl* PIKSCONTROL;
4980 
4981 #endif
4982 
4984 KSDDKAPI
4985 VOID
4986 NTAPI
4988  _In_ PKSDEVICE Device,
4989  _In_ PADAPTER_OBJECT AdapterObject,
4990  _In_ ULONG MaxMappingByteCount,
4991  _In_ ULONG MappingTableStride);
4992 
4994 KSDDKAPI
4995 ULONG
4996 NTAPI
4998  _In_ PKSDEVICE Device,
5001  _In_ ULONG Offset,
5002  _In_ ULONG Length);
5003 
5005 KSDDKAPI
5006 VOID
5007 NTAPI
5009  _In_ PVOID Object);
5010 
5011 #define KsDiscard(object, pointer) \
5012  KsRemoveItemFromObjectBag(object->Bag, pointer, TRUE)
5013 
5014 #define KsFilterAcquireControl(Filter) \
5015  KsAcquireControl((PVOID) Filter);
5016 
5017 #define KsFilterReleaseControl(Filter) \
5018  KsReleaseControl((PVOID) Filter);
5019 
5020 #define KsFilterAddEvent(Filter, EventEntry) \
5021  KsAddEvent(Filter,EventEntry);
5022 
5024 KSDDKAPI
5025 VOID
5026 NTAPI
5028  _In_ PKSFILTER Filter);
5029 
5031 KSDDKAPI
5032 NTSTATUS
5033 NTAPI
5035  _In_ PKSFILTER Filter,
5036  _In_ ULONG NewConnectionsCount,
5037  _In_reads_(NewConnectionsCount) const KSTOPOLOGY_CONNECTION *const NewTopologyConnections);
5038 
5040 KSDDKAPI
5041 VOID
5042 NTAPI
5044  _In_ PKSFILTER Filter,
5046 
5048 KSDDKAPI
5049 NTSTATUS
5050 NTAPI
5052  _In_ PKSFILTER Filter,
5053  _In_ const KSNODE_DESCRIPTOR *const NodeDescriptor,
5054  _Out_ PULONG NodeID);
5055 
5057 KSDDKAPI
5058 NTSTATUS
5059 NTAPI
5061  _In_ PKSFILTER Filter,
5062  _In_ const KSPIN_DESCRIPTOR_EX *const PinDescriptor,
5063  _Out_ PULONG PinID);
5064 
5066 KSDDKAPI
5067 PKSDEVICE
5068 NTAPI
5069 KsGetDevice(
5070  _In_ PVOID Object);
5071 
5073 static
5074 __inline
5075 PKSDEVICE
5076 KsFilterFactoryGetDevice(
5077  _In_ PKSFILTERFACTORY FilterFactory)
5078 {
5079  return KsGetDevice((PVOID)FilterFactory);
5080 }
5081 
5082 /* etc. */
5083 #endif /* avstream */
5084 
5085 #ifdef __cplusplus
5086 }
5087 #endif
5088 
5089 #endif /* _KS_ */
#define KSNAME_Filter
Definition: ks.h:111