ifndef _KS_
define _KS_

ifdef __TCS__
_KS_NO_ANONYMOUS_STRUCTURES_ equ 1
endif

ifndef _NTRTL_
ifndef DEFINE_GUIDEX
DEFINE_GUIDEX macro name
	exitm<externdef name:GUID>
	endm
endif
ifndef STATICGUIDOF
STATICGUIDOF macro guid
	exitm<_&guid&>
	endm
endif
endif

ifndef SIZEOF_ARRAY
SIZEOF_ARRAY macro ar
	exitm<lengthof(ar)>
	endm
endif

DEFINE_GUIDSTRUCT macro g, n
	exitm<DEFINE_GUIDS(n, g)>
	endm
DEFINE_GUIDNAMED macro n
	exitm<n>
	endm

STATIC_GUID_NULL	equ <{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}>
DEFINE_GUIDSTRUCT("00000000-0000-0000-0000-000000000000", GUID_NULL)


IOCTL_KS_PROPERTY	equ CTL_CODE(FILE_DEVICE_KS, 0x000, METHOD_NEITHER, FILE_ANY_ACCESS)
IOCTL_KS_ENABLE_EVENT	equ CTL_CODE(FILE_DEVICE_KS, 0x001, METHOD_NEITHER, FILE_ANY_ACCESS)
IOCTL_KS_DISABLE_EVENT	equ CTL_CODE(FILE_DEVICE_KS, 0x002, METHOD_NEITHER, FILE_ANY_ACCESS)
IOCTL_KS_METHOD		equ CTL_CODE(FILE_DEVICE_KS, 0x003, METHOD_NEITHER, FILE_ANY_ACCESS)
IOCTL_KS_WRITE_STREAM	equ CTL_CODE(FILE_DEVICE_KS, 0x004, METHOD_NEITHER, FILE_WRITE_ACCESS)
IOCTL_KS_READ_STREAM	equ CTL_CODE(FILE_DEVICE_KS, 0x005, METHOD_NEITHER, FILE_READ_ACCESS)
IOCTL_KS_RESET_STATE	equ CTL_CODE(FILE_DEVICE_KS, 0x006, METHOD_NEITHER, FILE_ANY_ACCESS)


KSRESET_BEGIN		equ 0
KSRESET_END		equ 1

KSSTATE_STOP		equ 0
KSSTATE_ACQUIRE		equ 1
KSSTATE_PAUSE		equ 2
KSSTATE_RUN		equ 3

KSPRIORITY_LOW		equ 0x00000001
KSPRIORITY_NORMAL	equ 0x40000000
KSPRIORITY_HIGH		equ 0x80000000
KSPRIORITY_EXCLUSIVE	equ 0xFFFFFFFF

KSPRIORITY		STRUC
PriorityClass		ULONG ?
PrioritySubClass	ULONG ?
KSPRIORITY		ENDS
PKSPRIORITY		typedef ptr KSPRIORITY

KSIDENTIFIER		STRUC
UNION
 STRUC
  Set			GUID <>
  Id			ULONG ?
  Flags			ULONG ?
 ENDS ;
 Alignment		LONGLONG ?
ENDS
KSIDENTIFIER		ENDS
PKSIDENTIFIER		typedef ptr KSIDENTIFIER

KSEVENT			typedef KSIDENTIFIER
KSMETHOD		typedef KSIDENTIFIER
KSPROPERTY		typedef KSIDENTIFIER
PKSEVENT		typedef ptr KSIDENTIFIER
PKSMETHOD		typedef ptr KSIDENTIFIER
PKSPROPERTY		typedef ptr KSIDENTIFIER

KSMETHOD_TYPE_NONE	equ 0x00000000
KSMETHOD_TYPE_READ	equ 0x00000001
KSMETHOD_TYPE_WRITE	equ 0x00000002
KSMETHOD_TYPE_MODIFY	equ 0x00000003
KSMETHOD_TYPE_SOURCE	equ 0x00000004

KSMETHOD_TYPE_SEND	equ 0x00000001
KSMETHOD_TYPE_SETSUPPORT equ 0x00000100
KSMETHOD_TYPE_BASICSUPPORT equ 0x00000200

KSMETHOD_TYPE_TOPOLOGY	equ 0x10000000

KSPROPERTY_TYPE_GET	equ 0x00000001
KSPROPERTY_TYPE_SET	equ 0x00000002
KSPROPERTY_TYPE_SETSUPPORT equ 0x00000100
KSPROPERTY_TYPE_BASICSUPPORT equ 0x00000200
KSPROPERTY_TYPE_RELATIONS equ 0x00000400
KSPROPERTY_TYPE_SERIALIZESET equ 0x00000800
KSPROPERTY_TYPE_UNSERIALIZESET equ 0x00001000
KSPROPERTY_TYPE_SERIALIZERAW equ 0x00002000
KSPROPERTY_TYPE_UNSERIALIZERAW equ 0x00004000
KSPROPERTY_TYPE_SERIALIZESIZE equ 0x00008000
KSPROPERTY_TYPE_DEFAULTVALUES equ 0x00010000

KSPROPERTY_TYPE_TOPOLOGY equ 0x10000000

KSP_NODE		STRUC
Property		KSPROPERTY <>
NodeId			ULONG ?
Reserved		ULONG ?
KSP_NODE		ENDS
PKSP_NODE		typedef ptr KSP_NODE

KSM_NODE		STRUC
Method			KSMETHOD <>
NodeId			ULONG ?
Reserved		ULONG ?
KSM_NODE		ENDS
PKSM_NODE		typedef ptr KSM_NODE

KSE_NODE		STRUC
Event			KSEVENT <>
NodeId			ULONG ?
Reserved		ULONG ?
KSE_NODE		ENDS
PKSE_NODE		typedef ptr KSE_NODE

STATIC_KSPROPTYPESETID_General equ <{0x97E99BA0,0xBDEA,0x11CF,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("97E99BA0-BDEA-11CF-A5D6-28DB04C10000", KSPROPTYPESETID_General)

ifdef _NTDDK_
ifndef __wtypes_h__
VARENUM			typedef SDWORD
VT_EMPTY		equ 0
VT_NULL			equ 1
VT_I2			equ 2
VT_I4			equ 3
VT_R4			equ 4
VT_R8			equ 5
VT_CY			equ 6
VT_DATE			equ 7
VT_BSTR			equ 8
VT_DISPATCH		equ 9
VT_ERROR		equ 10
VT_BOOL			equ 11
VT_VARIANT		equ 12
VT_UNKNOWN		equ 13
VT_DECIMAL		equ 14
VT_I1			equ 16
VT_UI1			equ 17
VT_UI2			equ 18
VT_UI4			equ 19
VT_I8			equ 20
VT_UI8			equ 21
VT_INT			equ 22
VT_UINT			equ 23
VT_VOID			equ 24
VT_HRESULT		equ 25
VT_PTR			equ 26
VT_SAFEARRAY		equ 27
VT_CARRAY		equ 28
VT_USERDEFINED		equ 29
VT_LPSTR		equ 30
VT_LPWSTR		equ 31
VT_FILETIME		equ 64
VT_BLOB			equ 65
VT_STREAM		equ 66
VT_STORAGE		equ 67
VT_STREAMED_OBJECT	equ 68
VT_STORED_OBJECT	equ 69
VT_BLOB_OBJECT		equ 70
VT_CF			equ 71
VT_CLSID		equ 72
VT_VECTOR		equ 0x1000
VT_ARRAY		equ 0x2000
VT_BYREF		equ 0x4000
VT_RESERVED		equ 0x8000
VT_ILLEGAL		equ 0xffff
VT_ILLEGALMASKED	equ 0xfff
VT_TYPEMASK		equ 0xfff
endif
endif

KSMULTIPLE_ITEM		STRUC
Size			ULONG ?
Count			ULONG ?
KSMULTIPLE_ITEM		ENDS
PKSMULTIPLE_ITEM	typedef ptr KSMULTIPLE_ITEM

KSPROPERTY_DESCRIPTION	STRUC
AccessFlags		ULONG ?
DescriptionSize		ULONG ?
PropTypeSet		KSIDENTIFIER <>
MembersListCount	ULONG ?
Reserved		ULONG ?
KSPROPERTY_DESCRIPTION	ENDS
PKSPROPERTY_DESCRIPTION typedef ptr KSPROPERTY_DESCRIPTION

KSPROPERTY_MEMBER_RANGES equ 0x00000001
KSPROPERTY_MEMBER_STEPPEDRANGES equ 0x00000002
KSPROPERTY_MEMBER_VALUES equ 0x00000003

KSPROPERTY_MEMBER_FLAG_DEFAULT equ 0x00000001
if (NTDDI_VERSION GE NTDDI_WINXP)
KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_MULTICHANNEL equ 0x00000002
KSPROPERTY_MEMBER_FLAG_BASICSUPPORT_UNIFORM equ 0x00000004
endif

KSPROPERTY_MEMBERSHEADER STRUC
MembersFlags		ULONG ?
MembersSize		ULONG ?
MembersCount		ULONG ?
Flags			ULONG ?
KSPROPERTY_MEMBERSHEADER ENDS
PKSPROPERTY_MEMBERSHEADER typedef ptr KSPROPERTY_MEMBERSHEADER

KSPROPERTY_BOUNDS_LONG	UNION
STRUC
 SignedMinimum		LONG ?
 SignedMaximum		LONG ?
ENDS
STRUC
 UnsignedMinimum	ULONG ?
 UnsignedMaximum	ULONG ?
ENDS
KSPROPERTY_BOUNDS_LONG	ENDS
PKSPROPERTY_BOUNDS_LONG typedef ptr KSPROPERTY_BOUNDS_LONG

KSPROPERTY_BOUNDS_LONGLONG UNION
STRUC
 SignedMinimum		LONGLONG ?
 SignedMaximum		LONGLONG ?
ENDS
STRUC
ifdef _NTDDK_
 UnsignedMinimum	ULONGLONG ?
 UnsignedMaximum	ULONGLONG ?
else
 UnsignedMinimum	dd ?
 UnsignedMaximum	dd ?
endif
ENDS
KSPROPERTY_BOUNDS_LONGLONG ENDS
PKSPROPERTY_BOUNDS_LONGLONG typedef ptr KSPROPERTY_BOUNDS_LONGLONG

KSPROPERTY_STEPPING_LONG STRUC
SteppingDelta		ULONG ?
Reserved		ULONG ?
Bounds			KSPROPERTY_BOUNDS_LONG <>
KSPROPERTY_STEPPING_LONG ENDS
PKSPROPERTY_STEPPING_LONG typedef ptr KSPROPERTY_STEPPING_LONG

KSPROPERTY_STEPPING_LONGLONG STRUC
ifdef _NTDDK_
 SteppingDelta		ULONGLONG ?
else
 SteppingDelta		dd ?
endif
Bounds			KSPROPERTY_BOUNDS_LONGLONG <>
KSPROPERTY_STEPPING_LONGLONG ENDS
PKSPROPERTY_STEPPING_LONGLONG typedef ptr KSPROPERTY_STEPPING_LONGLONG

if (NTDDI_VERSION GE NTDDI_WINXP)
ifdef _NTDDK_
PKSDEVICE_DESCRIPTOR	 typedef ptr KSDEVICE_DESCRIPTOR
PKSDEVICE_DISPATCH	 typedef ptr KSDEVICE_DISPATCH
PKSDEVICE		 typedef ptr KSDEVICE
PKSFILTERFACTORY	 typedef ptr KSFILTERFACTORY
PKSFILTER_DESCRIPTOR	 typedef ptr KSFILTER_DESCRIPTOR
PKSFILTER_DISPATCH	 typedef ptr KSFILTER_DISPATCH
PKSFILTER		 typedef ptr KSFILTER
PKSPIN_DESCRIPTOR_EX	 typedef ptr KSPIN_DESCRIPTOR_EX
PKSPIN_DISPATCH		 typedef ptr KSPIN_DISPATCH
PKSCLOCK_DISPATCH	 typedef ptr KSCLOCK_DISPATCH
PKSALLOCATOR_DISPATCH	 typedef ptr KSALLOCATOR_DISPATCH
PKSPIN			 typedef ptr KSPIN
PKSNODE_DESCRIPTOR	 typedef ptr KSNODE_DESCRIPTOR
PKSSTREAM_POINTER_OFFSET typedef ptr KSSTREAM_POINTER_OFFSET
PKSSTREAM_POINTER	 typedef ptr KSSTREAM_POINTER
PKSMAPPING		 typedef ptr KSMAPPING
PKSPROCESSPIN		 typedef ptr KSPROCESSPIN
PKSPROCESSPIN_INDEXENTRY typedef ptr KSPROCESSPIN_INDEXENTRY
endif
endif

PKSWORKER		typedef PVOID

KSEVENTDATA		STRUC
NotificationType	ULONG ?
UNION
 STRUC EventHandle
  Event			HANDLE ?
  Reserved		ULONG_PTR 2 dup(?)
 ENDS
 STRUC SemaphoreHandle
  Semaphore		HANDLE ?
  Reserved		ULONG ?
  Adjustment		LONG ?
 ENDS
ifdef _NTDDK_
 STRUC EventObject
  Event			PVOID ?
  Increment		KPRIORITY ?
  Reserved		ULONG_PTR ?
 ENDS
 STRUC SemaphoreObject
  Semaphore		PVOID ?
  Increment		KPRIORITY ?
  Adjustment		LONG ?
 ENDS
 STRUC Dpc
  Dpc			PKDPC ?
  ReferenceCount	ULONG ?
  Reserved		ULONG_PTR ?
 ENDS
 STRUC WorkItem
  WorkQueueItem		PWORK_QUEUE_ITEM ?
  WorkQueueType		WORK_QUEUE_TYPE ?
  Reserved		ULONG_PTR ?
 ENDS
 STRUC KsWorkItem
  WorkQueueItem		PWORK_QUEUE_ITEM ?
  KsWorkerObject	PKSWORKER ?
  Reserved		ULONG_PTR ?
 ENDS
endif
 STRUC Alignment
  Unused		PVOID ?
  Alignment		LONG_PTR 2 dup(?)
 ENDS
ENDS
KSEVENTDATA		ENDS
PKSEVENTDATA		typedef ptr KSEVENTDATA

KSEVENTF_EVENT_HANDLE	equ 0x00000001
KSEVENTF_SEMAPHORE_HANDLE equ 0x00000002
ifdef _NTDDK_
KSEVENTF_EVENT_OBJECT	equ 0x00000004
KSEVENTF_SEMAPHORE_OBJECT equ 0x00000008
KSEVENTF_DPC		equ 0x00000010
KSEVENTF_WORKITEM	equ 0x00000020
KSEVENTF_KSWORKITEM	equ 0x00000080
endif

KSEVENT_TYPE_ENABLE	equ 0x00000001
KSEVENT_TYPE_ONESHOT	equ 0x00000002
KSEVENT_TYPE_ENABLEBUFFERED equ 0x00000004
KSEVENT_TYPE_SETSUPPORT equ 0x00000100
KSEVENT_TYPE_BASICSUPPORT equ 0x00000200
KSEVENT_TYPE_QUERYBUFFER equ 0x00000400

KSEVENT_TYPE_TOPOLOGY	equ 0x10000000

KSQUERYBUFFER		STRUC
Event			KSEVENT <>
EventData		PKSEVENTDATA ?
Reserved		PVOID ?
KSQUERYBUFFER		ENDS
PKSQUERYBUFFER		typedef ptr KSQUERYBUFFER

KSRELATIVEEVENT		STRUC
Size			ULONG ?
Flags			ULONG ?
UNION
 ObjectHandle		HANDLE ?
 ObjectPointer		PVOID ?
ENDS
Reserved		PVOID ?
Event			KSEVENT <>
EventData		KSEVENTDATA <>
KSRELATIVEEVENT		ENDS

KSRELATIVEEVENT_FLAG_HANDLE equ 0x00000001
KSRELATIVEEVENT_FLAG_POINTER equ 0x00000002


KSEVENT_TIME_MARK	STRUC
EventData		KSEVENTDATA <>
MarkTime		LONGLONG ?
KSEVENT_TIME_MARK	ENDS
PKSEVENT_TIME_MARK	typedef ptr KSEVENT_TIME_MARK

KSEVENT_TIME_INTERVAL	STRUC
EventData		KSEVENTDATA <>
TimeBase		LONGLONG ?
Interval		LONGLONG ?
KSEVENT_TIME_INTERVAL	ENDS
PKSEVENT_TIME_INTERVAL	typedef ptr KSEVENT_TIME_INTERVAL

KSINTERVAL		STRUC
TimeBase		LONGLONG ?
Interval		LONGLONG ?
KSINTERVAL		ENDS
PKSINTERVAL		typedef ptr KSINTERVAL

STATIC_KSPROPSETID_General equ <{0x1464EDA5,0x6A8F,0x11D1,{0x9A,0xA7,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("1464EDA5-6A8F-11D1-9AA7-00A0C9223196", KSPROPSETID_General)

KSPROPERTY_GENERAL_COMPONENTID equ 0

KSCOMPONENTID		STRUC
Manufacturer		GUID <>
Product			GUID <>
Component		GUID <>
Name			GUID <>
Version			ULONG ?
Revision		ULONG ?
KSCOMPONENTID		ENDS
PKSCOMPONENTID		typedef ptr KSCOMPONENTID

DEFINE_KSPROPERTY_ITEM_GENERAL_COMPONENTID macro Handler
    DEFINE_KSPROPERTY_ITEM(KSPROPERTY_GENERAL_COMPONENTID,Handler, KSPROPERTY, KSCOMPONENTID, NULL, NULL, 0, NULL, NULL, 0)
    endm

STATIC_KSMETHODSETID_StreamIo equ <{0x65D003CA,0x1523,0x11D2,{0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("65D003CA-1523-11D2-B27A-00A0C9223196", KSMETHODSETID_StreamIo)

KSMETHOD_STREAMIO_READ	equ 0
KSMETHOD_STREAMIO_WRITE equ 1

DEFINE_KSMETHOD_ITEM_STREAMIO_READ macro Handler
    DEFINE_KSMETHOD_ITEM(KSMETHOD_STREAMIO_READ,KSMETHOD_TYPE_WRITE,Handler,KSMETHOD, 0, NULL)
    endm

DEFINE_KSMETHOD_ITEM_STREAMIO_WRITE macro Handler
    DEFINE_KSMETHOD_ITEM(KSMETHOD_STREAMIO_WRITE,KSMETHOD_TYPE_READ,Handler,KSMETHOD, 0, NULL)
    endm

STATIC_KSPROPSETID_MediaSeeking equ <{0xEE904F0C,0xD09B,0x11D0,{0xAB,0xE9,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("EE904F0C-D09B-11D0-ABE9-00A0C9223196", KSPROPSETID_MediaSeeking)

KSPROPERTY_MEDIASEEKING typedef SDWORD
KSPROPERTY_MEDIASEEKING_CAPABILITIES equ 0
KSPROPERTY_MEDIASEEKING_FORMATS equ 1
KSPROPERTY_MEDIASEEKING_TIMEFORMAT equ 2
KSPROPERTY_MEDIASEEKING_POSITION equ 3
KSPROPERTY_MEDIASEEKING_STOPPOSITION equ 4
KSPROPERTY_MEDIASEEKING_POSITIONS equ 5
KSPROPERTY_MEDIASEEKING_DURATION equ 6
KSPROPERTY_MEDIASEEKING_AVAILABLE equ 7
KSPROPERTY_MEDIASEEKING_PREROLL equ 8
KSPROPERTY_MEDIASEEKING_CONVERTTIMEFORMAT equ 9

KS_SEEKING_FLAGS		typedef SDWORD
KS_SEEKING_NoPositioning	equ 0
KS_SEEKING_AbsolutePositioning	equ 1
KS_SEEKING_RelativePositioning	equ 2
KS_SEEKING_IncrementalPositioning equ 3
KS_SEEKING_PositioningBitsMask	equ 0x3
KS_SEEKING_SeekToKeyFrame	equ 5
KS_SEEKING_ReturnTime		equ 0x8

KS_SEEKING_CAPABILITIES		typedef SDWORD
KS_SEEKING_CanSeekAbsolute	equ 0x1
KS_SEEKING_CanSeekForwards	equ 0x2
KS_SEEKING_CanSeekBackwards	equ 0x4
KS_SEEKING_CanGetCurrentPos	equ 0x8
KS_SEEKING_CanGetStopPos	equ 0x10
KS_SEEKING_CanGetDuration	equ 0x20
KS_SEEKING_CanPlayBackwards	equ 0x40

KSPROPERTY_POSITIONS	STRUC
Current			LONGLONG ?
Stop			LONGLONG ?
CurrentFlags		KS_SEEKING_FLAGS ?
StopFlags		KS_SEEKING_FLAGS ?
KSPROPERTY_POSITIONS	ENDS
PKSPROPERTY_POSITIONS	typedef ptr KSPROPERTY_POSITIONS

KSPROPERTY_MEDIAAVAILABLE STRUC
Earliest		LONGLONG ?
Latest			LONGLONG ?
KSPROPERTY_MEDIAAVAILABLE ENDS
PKSPROPERTY_MEDIAAVAILABLE typedef ptr KSPROPERTY_MEDIAAVAILABLE

KSP_TIMEFORMAT		STRUC
Property		KSPROPERTY <>
SourceFormat		GUID <>
TargetFormat		GUID <>
Time			LONGLONG ?
KSP_TIMEFORMAT		ENDS
PKSP_TIMEFORMAT		typedef ptr KSP_TIMEFORMAT

DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CAPABILITIES macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_FORMATS macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_TIMEFORMAT macro GetHandler, SetHandler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITION macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_STOPPOSITION macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_POSITIONS macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_DURATION macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_AVAILABLE macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_PREROLL macro Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_ITEM_MEDIASEEKING_CONVERTTIMEFORMAT macro Handler
	exitm<>
	endm


STATIC_KSPROPSETID_Topology equ <{0x720D4AC0,0x7533,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("720D4AC0-7533-11D0-A5D6-28DB04C10000", KSPROPSETID_Topology)

KSPROPERTY_TOPOLOGY_CATEGORIES equ 0
KSPROPERTY_TOPOLOGY_NODES equ 1
KSPROPERTY_TOPOLOGY_CONNECTIONS equ 2
KSPROPERTY_TOPOLOGY_NAME equ 3

DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CATEGORIES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NODES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_TOPOLOGY_CONNECTIONS macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_TOPOLOGY_NAME macro Handler
	endm
DEFINE_KSPROPERTY_TOPOLOGYSET macro TopologySet, Handler
	exitm<>
	endm
DEFINE_KSPROPERTY_TABLE macro TopologySet
	endm


ifdef _NTDDK_

STATIC_KSPROPSETID_GM	equ <{0xAF627536,0xE719,0x11D2,{0x8A,0x1D,0x00,0x60,0x97,0xD2,0xDF,0x5D}}>
DEFINE_GUIDSTRUCT("AF627536-E719-11D2-8A1D-006097D2DF5D", KSPROPSETID_GM)

CALLBACK(PFNKSGRAPHMANAGER_NOTIFY, :PFILE_OBJECT, :ULONG, :ptr, :ptr, :ptr, :ULONG)

KSGRAPHMANAGER_FUNCTIONTABLE  STRUC
NotifyEvent		PFNKSGRAPHMANAGER_NOTIFY ?
KSGRAPHMANAGER_FUNCTIONTABLE ENDS
PKSGRAPHMANAGER_FUNCTIONTABLE typedef KSGRAPHMANAGER_FUNCTIONTABLE

KSPROPERTY_GRAPHMANAGER_INTERFACE  STRUC
GraphManager		PFILE_OBJECT ?
FunctionTable		KSGRAPHMANAGER_FUNCTIONTABLE ?
KSPROPERTY_GRAPHMANAGER_INTERFACE ENDS
PKSPROPERTY_GRAPHMANAGER_INTERFACE typedef ptr KSPROPERTY_GRAPHMANAGER_INTERFACE


KSPROPERTY_GM_GRAPHMANAGER equ 0
KSPROPERTY_GM_TIMESTAMP_CLOCK equ 1
KSPROPERTY_GM_RATEMATCH equ 2
KSPROPERTY_GM_RENDER_CLOCK equ 3

endif



STATIC_KSCATEGORY_BRIDGE equ <{0x085AFF00,0x62CE,0x11CF,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("085AFF00-62CE-11CF-A5D6-28DB04C10000", KSCATEGORY_BRIDGE)

STATIC_KSCATEGORY_CAPTURE equ <{0x65E8773D,0x8F56,0x11D0,{0xA3,0xB9,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("65E8773D-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_CAPTURE)

STATIC_KSCATEGORY_RENDER equ <{0x65E8773E,0x8F56,0x11D0,{0xA3,0xB9,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("65E8773E-8F56-11D0-A3B9-00A0C9223196", KSCATEGORY_RENDER)

STATIC_KSCATEGORY_MIXER equ <{0xAD809C00,0x7B88,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("AD809C00-7B88-11D0-A5D6-28DB04C10000", KSCATEGORY_MIXER)

STATIC_KSCATEGORY_SPLITTER equ <{0x0A4252A0,0x7E70,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("0A4252A0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_SPLITTER)

STATIC_KSCATEGORY_DATACOMPRESSOR equ <{0x1E84C900,0x7E70,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("1E84C900-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATACOMPRESSOR)

STATIC_KSCATEGORY_DATADECOMPRESSOR equ <{0x2721AE20,0x7E70,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("2721AE20-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATADECOMPRESSOR)

STATIC_KSCATEGORY_DATATRANSFORM equ <{0x2EB07EA0,0x7E70,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("2EB07EA0-7E70-11D0-A5D6-28DB04C10000", KSCATEGORY_DATATRANSFORM)

STATIC_KSMFT_CATEGORY_VIDEO_DECODER equ <{0xd6c02d4b,0x6833,0x45b4,{0x97,0x1a,0x05,0xa4,0xb0,0x4b,0xab,0x91}}>
DEFINE_GUIDSTRUCT("d6c02d4b-6833-45b4-971a-05a4b04bab91", KSMFT_CATEGORY_VIDEO_DECODER)

STATIC_KSMFT_CATEGORY_VIDEO_ENCODER equ <{0xf79eac7d,0xe545,0x4387,{0xbd,0xee,0xd6,0x47,0xd7,0xbd,0xe4,0x2a}}>
DEFINE_GUIDSTRUCT("f79eac7d-e545-4387-bdee-d647d7bde42a", KSMFT_CATEGORY_VIDEO_ENCODER)

STATIC_KSMFT_CATEGORY_VIDEO_EFFECT equ <{0x12e17c21,0x532c,0x4a6e,{0x8a,0x1c,0x40,0x82,0x5a,0x73,0x63,0x97}}>
DEFINE_GUIDSTRUCT("12e17c21-532c-4a6e-8a1c-40825a736397", KSMFT_CATEGORY_VIDEO_EFFECT)

STATIC_KSMFT_CATEGORY_MULTIPLEXER equ <{0x059c561e,0x05ae,0x4b61,{0xb6,0x9d,0x55,0xb6,0x1e,0xe5,0x4a,0x7b}}>
DEFINE_GUIDSTRUCT("059c561e-05ae-4b61-b69d-55b61ee54a7b", KSMFT_CATEGORY_MULTIPLEXER)

STATIC_KSMFT_CATEGORY_DEMULTIPLEXER equ <{0xa8700a7a,0x939b,0x44c5,{0x99,0xd7,0x76,0x22,0x6b,0x23,0xb3,0xf1}}>
DEFINE_GUIDSTRUCT("a8700a7a-939b-44c5-99d7-76226b23b3f1", KSMFT_CATEGORY_DEMULTIPLEXER);

STATIC_KSMFT_CATEGORY_AUDIO_DECODER equ <{0x9ea73fb4,0xef7a,0x4559,{0x8d,0x5d,0x71,0x9d,0x8f,0x04,0x26,0xc7}}>
DEFINE_GUIDSTRUCT("9ea73fb4-ef7a-4559-8d5d-719d8f0426c7", KSMFT_CATEGORY_AUDIO_DECODER);

STATIC_KSMFT_CATEGORY_AUDIO_ENCODER equ <{0x91c64bd0,0xf91e,0x4d8c,{0x92,0x76,0xdb,0x24,0x82,0x79,0xd9,0x75}}>
DEFINE_GUIDSTRUCT("91c64bd0-f91e-4d8c-9276-db248279d975", KSMFT_CATEGORY_AUDIO_ENCODER);

STATIC_KSMFT_CATEGORY_AUDIO_EFFECT equ <{0x11064c48,0x3648,0x4ed0,{0x93,0x2e,0x05,0xce,0x8a,0xc8,0x11,0xb7}}>
DEFINE_GUIDSTRUCT("11064c48-3648-4ed0-932e-05ce8ac811b7", KSMFT_CATEGORY_AUDIO_EFFECT);

STATIC_KSMFT_CATEGORY_VIDEO_PROCESSOR equ <{0x302ea3fc,0xaa5f,0x47f9,{0x9f,0x7a,0xc2,0x18,0x8b,0xb1,0x63,0x2}}>
DEFINE_GUIDSTRUCT("302ea3fc-aa5f-47f9-9f7a-c2188bb16302", KSMFT_CATEGORY_VIDEO_PROCESSOR);

STATIC_KSMFT_CATEGORY_OTHER equ <{0x90175d57,0xb7ea,0x4901,{0xae,0xb3,0x93,0x3a,0x87,0x47,0x75,0x6f}}>
DEFINE_GUIDSTRUCT("90175d57-b7ea-4901-aeb3-933a8747756f", KSMFT_CATEGORY_OTHER);

STATIC_KSCATEGORY_COMMUNICATIONSTRANSFORM equ <{0xCF1DDA2C,0x9743,0x11D0,{0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("CF1DDA2C-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_COMMUNICATIONSTRANSFORM)

STATIC_KSCATEGORY_INTERFACETRANSFORM equ <{0xCF1DDA2D,0x9743,0x11D0,{0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("CF1DDA2D-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_INTERFACETRANSFORM)

STATIC_KSCATEGORY_MEDIUMTRANSFORM equ <{0xCF1DDA2E,0x9743,0x11D0,{0xA3,0xEE,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("CF1DDA2E-9743-11D0-A3EE-00A0C9223196", KSCATEGORY_MEDIUMTRANSFORM)

STATIC_KSCATEGORY_FILESYSTEM equ <{0x760FED5E,0x9357,0x11D0,{0xA3,0xCC,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("760FED5E-9357-11D0-A3CC-00A0C9223196", KSCATEGORY_FILESYSTEM)

STATIC_KSCATEGORY_CLOCK equ <{0x53172480,0x4791,0x11D0,{0xA5,0xD6,0x28,0xDB,0x04,0xC1,0x00,0x00}}>
DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000", KSCATEGORY_CLOCK)

STATIC_KSCATEGORY_PROXY equ <{0x97EBAACA,0x95BD,0x11D0,{0xA3,0xEA,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("97EBAACA-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_PROXY)

STATIC_KSCATEGORY_QUALITY equ <{0x97EBAACB,0x95BD,0x11D0,{0xA3,0xEA,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUIDSTRUCT("97EBAACB-95BD-11D0-A3EA-00A0C9223196", KSCATEGORY_QUALITY)

KSTOPOLOGY_CONNECTION	STRUC
FromNode		ULONG ?
FromNodePin		ULONG ?
ToNode			ULONG ?
ToNodePin		ULONG ?
KSTOPOLOGY_CONNECTION	ENDS
PKSTOPOLOGY_CONNECTION	typedef ptr KSTOPOLOGY_CONNECTION

KSTOPOLOGY		STRUC
CategoriesCount		ULONG ?
Categories		LPGUID ?
TopologyNodesCount	ULONG ?
TopologyNodes		LPGUID ?
TopologyConnectionsCount ULONG ?
TopologyConnections	PKSTOPOLOGY_CONNECTION ?
TopologyNodesNames	LPGUID ?
Reserved		ULONG ?
KSTOPOLOGY		ENDS
PKSTOPOLOGY		typedef ptr KSTOPOLOGY

KSFILTER_NODE		equ (-1)
KSALL_NODES		equ (-1)

KSNODE_CREATE		STRUC
CreateFlags		ULONG ?
Node			ULONG ?
KSNODE_CREATE		ENDS
PKSNODE_CREATE		typedef ptr KSNODE_CREATE


;STATIC_KSTIME_FORMAT_NONE equ STATIC_GUID_NULL
;KSTIME_FORMAT_NONE	equ GUID_NULL

DEFINE_GUIDSTRUCT("7b785570-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_FRAME)
DEFINE_GUIDSTRUCT("7b785571-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_BYTE)
DEFINE_GUIDSTRUCT("7b785572-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_SAMPLE)
DEFINE_GUIDSTRUCT("7b785573-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_FIELD)
DEFINE_GUIDSTRUCT("7b785574-8c82-11cf-bc0c-00aa00ac74f6", KSTIME_FORMAT_MEDIA_TIME)

KSPIN_INTERFACE		typedef KSIDENTIFIER
PKSPIN_INTERFACE	typedef ptr KSIDENTIFIER

DEFINE_GUIDSTRUCT("1A8766A0-62CE-11CF-A5D6-28DB04C10000", KSINTERFACESETID_Standard)

KSINTERFACE_STANDARD_STREAMING equ 0
KSINTERFACE_STANDARD_LOOPED_STREAMING equ 1
KSINTERFACE_STANDARD_CONTROL equ 2

DEFINE_GUIDSTRUCT("8C6F932C-E771-11D0-B8FF-00A0C9223196", KSINTERFACESETID_FileIo)

KSINTERFACE_FILEIO_STREAMING equ 0

KSMEDIUM_TYPE_ANYINSTANCE equ 0
DEFINE_GUIDSTRUCT("4747B320-62CE-11CF-A5D6-28DB04C10000", KSMEDIUMSETID_Standard)

KSMEDIUM_STANDARD_DEVIO equ KSMEDIUM_TYPE_ANYINSTANCE
DEFINE_GUIDSTRUCT("8C134960-51AD-11CF-878A-94F801C10000", KSPROPSETID_Pin)

KSPROPERTY_PIN_CINSTANCES equ 0
KSPROPERTY_PIN_CTYPES	equ 1
KSPROPERTY_PIN_DATAFLOW equ 2
KSPROPERTY_PIN_DATARANGES equ 3
KSPROPERTY_PIN_DATAINTERSECTION equ 4
KSPROPERTY_PIN_INTERFACES equ 5
KSPROPERTY_PIN_MEDIUMS	equ 6
KSPROPERTY_PIN_COMMUNICATION equ 7
KSPROPERTY_PIN_GLOBALCINSTANCES equ 8
KSPROPERTY_PIN_NECESSARYINSTANCES equ 9
KSPROPERTY_PIN_PHYSICALCONNECTION equ 10
KSPROPERTY_PIN_CATEGORY equ 11
KSPROPERTY_PIN_NAME	equ 12
KSPROPERTY_PIN_CONSTRAINEDDATARANGES equ 13
KSPROPERTY_PIN_PROPOSEDATAFORMAT equ 14

KSP_PIN			STRUC
Property		KSPROPERTY <>
PinId			ULONG ?
Reserved		ULONG ?
KSP_PIN			ENDS
PKSP_PIN		typedef ptr KSP_PIN

KSE_PIN			STRUC
Event			KSEVENT <>
PinId			ULONG ?
Reserved		ULONG ?
KSE_PIN			ENDS
PKSE_PIN		typedef ptr KSE_PIN

KSINSTANCE_INDETERMINATE equ (-1)

KSPIN_CINSTANCES	STRUC
PossibleCount		ULONG ?
CurrentCount		ULONG ?
KSPIN_CINSTANCES	ENDS
PKSPIN_CINSTANCES	typedef ptr KSPIN_CINSTANCES

KSPIN_DATAFLOW_IN	equ 1
KSPIN_DATAFLOW_OUT	equ 2
KSPIN_DATAFLOW		typedef SDWORD

KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION equ 0
KSDATAFORMAT_TEMPORAL_COMPRESSION equ (1 SHL KSDATAFORMAT_BIT_TEMPORAL_COMPRESSION)
KSDATAFORMAT_BIT_ATTRIBUTES equ 1
KSDATAFORMAT_ATTRIBUTES equ (1 SHL KSDATAFORMAT_BIT_ATTRIBUTES)

KSDATARANGE_BIT_ATTRIBUTES equ 1
KSDATARANGE_ATTRIBUTES	equ (1 SHL KSDATARANGE_BIT_ATTRIBUTES)
KSDATARANGE_BIT_REQUIRED_ATTRIBUTES equ 2
KSDATARANGE_REQUIRED_ATTRIBUTES equ (1 SHL KSDATARANGE_BIT_REQUIRED_ATTRIBUTES)

ifndef _MSC_VER
KSDATAFORMAT		STRUC
FormatSize		ULONG ?
Flags			ULONG ?
SampleSize		ULONG ?
Reserved		ULONG ?
MajorFormat		GUID <>
SubFormat		GUID <>
Specifier		GUID <>
KSDATAFORMAT		ENDS
PKSDATAFORMAT		typedef ptr KSDATAFORMAT
KSDATARANGE		typedef KSDATAFORMAT
PKSDATARANGE		typedef ptr KSDATAFORMAT
else
KSDATAFORMAT		UNION
STRUC
 FormatSize		ULONG ?
 Flags			ULONG ?
 SampleSize		ULONG ?
 Reserved		ULONG ?
 MajorFormat		GUID <>
 SubFormat		GUID <>
 Specifier		GUID <>
ENDS
Alignment		LONGLONG ?
KSDATAFORMAT		ENDS
PKSDATAFORMAT		typedef ptr KSDATAFORMAT
KSDATARANGE		typedef KSDATAFORMAT
PKSDATARANGE		typedef ptr KSDATAFORMAT
endif

KSATTRIBUTE_REQUIRED	equ 0x00000001

KSATTRIBUTE		STRUC
Size			ULONG ?
Flags			ULONG ?
Attribute		GUID <>
KSATTRIBUTE		ENDS
PKSATTRIBUTE		typedef ptr KSATTRIBUTE

ifdef _NTDDK_
KSATTRIBUTE_LIST	STRUC
Count			ULONG ?
Attributes		PKSATTRIBUTE ?
KSATTRIBUTE_LIST	ENDS
PKSATTRIBUTE_LIST	typedef ptr KSATTRIBUTE_LIST
endif

KSPIN_COMMUNICATION_NONE equ 0
KSPIN_COMMUNICATION_SINK equ 1
KSPIN_COMMUNICATION_SOURCE equ 2
KSPIN_COMMUNICATION_BOTH equ 3
KSPIN_COMMUNICATION_BRIDGE equ 4

KSPIN_MEDIUM		typedef KSIDENTIFIER
PKSPIN_MEDIUM		typedef ptr KSIDENTIFIER

KSPIN_CONNECT		STRUC
Interface		KSPIN_INTERFACE <>
Medium			KSPIN_MEDIUM <>
PinId			ULONG ?
PinToHandle		HANDLE ?
Priority		KSPRIORITY <>
KSPIN_CONNECT		ENDS
PKSPIN_CONNECT		typedef ptr KSPIN_CONNECT

KSPIN_PHYSICALCONNECTION STRUC
Size			ULONG ?
Pin			ULONG ?
SymbolicLinkName	WCHAR 1 dup(?)
KSPIN_PHYSICALCONNECTION ENDS
PKSPIN_PHYSICALCONNECTION typedef ptr KSPIN_PHYSICALCONNECTION

ifdef _NTDDK_
CALLBACK(PFNKSINTERSECTHANDLER, :PIRP, :PKSP_PIN, :PKSDATARANGE, :ptr)
CALLBACK(PFNKSINTERSECTHANDLEREX, :ptr, :PIRP, :PKSP_PIN, :PKSDATARANGE, :PKSDATARANGE, :ULONG, :ptr, :PULONG)
endif

DEFINE_KSPIN_INTERFACE_TABLE macro tablename
tablename label KSPIN_INTERFACE
	endm

DEFINE_KSPIN_INTERFACE_ITEM macro guid, interface
	STATICGUIDOF(guid)
	interface
	0
	endm

DEFINE_KSPIN_MEDIUM_TABLE macro tablename
tablename label KSPIN_MEDIUM
	endm

DEFINE_KSPIN_MEDIUM_ITEM macro guid, medium
	exitm<DEFINE_KSPIN_INTERFACE_ITEM(guid, medium)>
	endm

DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_CTYPES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_NAME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT macro Handler
	endm

DEFINE_KSPROPERTY_PINSET macro PinSet
	endm
DEFINE_KSPROPERTY_TABLE macro PinSet
	endm
DEFINE_KSPROPERTY_PINSETCONSTRAINED macro PinSet
	endm
DEFINE_KSPROPERTY_TABLE macro PinSet
	endm

DEFINE_GUIDSTRUCT("DD4F192E-3B78-49AD-A534-2C315B822000", KSEVENTSETID_PinCapsChange)

KSEVENT_PINCAPS_FORMATCHANGE equ 0
KSEVENT_PINCAPS_JACKINFOCHANGE equ 1

DEFINE_GUIDSTRUCT("9b365890-165f-11d0-a195-0020afd156e4", KSNAME_Filter)
KSSTRING_Filter		equ <L"{9B365890-165F-11D0-A195-0020AFD156E4}">

DEFINE_GUIDSTRUCT("146F1A80-4791-11D0-A5D6-28DB04C10000", KSNAME_Pin)
KSSTRING_Pin		equ <L"{146F1A80-4791-11D0-A5D6-28DB04C10000}">

DEFINE_GUIDSTRUCT("53172480-4791-11D0-A5D6-28DB04C10000", KSNAME_Clock)
KSSTRING_Clock		equ <L"{53172480-4791-11D0-A5D6-28DB04C10000}">

DEFINE_GUIDSTRUCT("642F5D00-4791-11D0-A5D6-28DB04C10000", KSNAME_Allocator)
KSSTRING_Allocator	equ <L"{642F5D00-4791-11D0-A5D6-28DB04C10000}">
KSSTRING_AllocatorEx	equ <L"{091BB63B-603F-11D1-B067-00A0C9062802}">

DEFINE_GUIDSTRUCT("0621061A-EE75-11D0-B915-00A0C9223196", KSNAME_TopologyNode)
KSSTRING_TopologyNode	equ <L"{0621061A-EE75-11D0-B915-00A0C9223196}">

ifdef _NTDDK_

KSPIN_DESCRIPTOR	STRUC
InterfacesCount		ULONG ?
Interfaces		PKSPIN_INTERFACE ?
MediumsCount		ULONG ?
Mediums			PKSPIN_MEDIUM ?
DataRangesCount		ULONG ?
DataRanges		PKSDATARANGE ?
DataFlow		KSPIN_DATAFLOW ?
Communication		KSPIN_COMMUNICATION ?
Category		LPGUID ?
Name			LPGUID ?
UNION
 Reserved		LONGLONG ?
 STRUC
  ConstrainedDataRangesCount ULONG ?
  ConstrainedDataRanges PKSDATARANGE ?
 ENDS
ENDS
KSPIN_DESCRIPTOR	ENDS
PKSPIN_DESCRIPTOR	typedef ptr KSPIN_DESCRIPTOR
PCKSPIN_DESCRIPTOR	typedef ptr KSPIN_DESCRIPTOR

DEFINE_KSPIN_DESCRIPTOR_TABLE macro tablename
tablename label KSPIN_DESCRIPTOR
	endm

DEFINE_KSPIN_DESCRIPTOR_ITEM macro InterfacesCount, Interfaces, MediumsCount, Mediums, DataRangesCount, DataRanges, DataFlow, Communication
    InterfacesCount, Interfaces, MediumsCount, Mediums
    DataRangesCount, DataRanges, DataFlow, Communication
    NULL, NULL, 0
    endm

endif


;STATIC_KSDATAFORMAT_TYPE_WILDCARD equ STATIC_GUID_NULL
;KSDATAFORMAT_TYPE_WILDCARD equ GUID_NULL

;STATIC_KSDATAFORMAT_SUBTYPE_WILDCARD equ STATIC_GUID_NULL
;KSDATAFORMAT_SUBTYPE_WILDCARD equ GUID_NULL

DEFINE_GUIDSTRUCT("E436EB83-524F-11CE-9F53-0020AF0BA770", KSDATAFORMAT_TYPE_STREAM)
DEFINE_GUIDSTRUCT("E436EB8E-524F-11CE-9F53-0020AF0BA770", KSDATAFORMAT_SUBTYPE_NONE)

;STATIC_KSDATAFORMAT_SPECIFIER_WILDCARD equ STATIC_GUID_NULL
;KSDATAFORMAT_SPECIFIER_WILDCARD equ GUID_NULL

DEFINE_GUIDSTRUCT("AA797B40-E974-11CF-A5D6-28DB04C10000", KSDATAFORMAT_SPECIFIER_FILENAME)
DEFINE_GUIDSTRUCT("65E8773C-8F56-11D0-A3B9-00A0C9223196", KSDATAFORMAT_SPECIFIER_FILEHANDLE)
DEFINE_GUIDSTRUCT("0F6417D6-C318-11D0-A43F-00A0C9223196", KSDATAFORMAT_SPECIFIER_NONE)
DEFINE_GUIDSTRUCT("D16AD380-AC1A-11CF-A5D6-28DB04C10000", KSPROPSETID_Quality)

KSPROPERTY_QUALITY_REPORT equ 0
KSPROPERTY_QUALITY_ERROR equ 1

DEFINE_KSPROPERTY_ITEM_QUALITY_REPORT macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_QUALITY_ERROR macro GetHandler, SetHandler
	endm

DEFINE_GUIDSTRUCT("1D58C920-AC9B-11CF-A5D6-28DB04C10000", KSPROPSETID_Connection)

KSPROPERTY_CONNECTION_STATE equ 0
KSPROPERTY_CONNECTION_PRIORITY equ 1
KSPROPERTY_CONNECTION_DATAFORMAT equ 2
KSPROPERTY_CONNECTION_ALLOCATORFRAMING equ 3
KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT equ 4
KSPROPERTY_CONNECTION_ACQUIREORDERING equ 5
KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX equ 6
KSPROPERTY_CONNECTION_STARTAT equ 7

DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_PRIORITY macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING_EX macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_PROPOSEDATAFORMAT macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_ACQUIREORDERING macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CONNECTION_STARTAT macro Handler
	endm

DEFINE_GUIDSTRUCT("0A3D1C5D-5243-4819-9ED0-AEE8044CEE2B", KSPROPSETID_MemoryTransport)
KSPROPERTY_MEMORY_TRANSPORT equ 1

DEFINE_KSPROPERTY_ITEM_MEMORY_TRANSPORT macro SetHandler
	endm

KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER equ 0x00000001
KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY equ 0x00000002
KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY equ 0x00000004
KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE equ 0x00000008
KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY equ 0x80000000

KSALLOCATOR_OPTIONF_COMPATIBLE equ 0x00000001
KSALLOCATOR_OPTIONF_SYSTEM_MEMORY equ 0x00000002
KSALLOCATOR_OPTIONF_VALID equ 0x00000003
KSALLOCATOR_FLAG_PARTIAL_READ_SUPPORT equ 0x00000010
KSALLOCATOR_FLAG_DEVICE_SPECIFIC equ 0x00000020
KSALLOCATOR_FLAG_CAN_ALLOCATE equ 0x00000040
KSALLOCATOR_FLAG_INSIST_ON_FRAMESIZE_RATIO equ 0x00000080
KSALLOCATOR_FLAG_NO_FRAME_INTEGRITY equ 0x00000100
KSALLOCATOR_FLAG_MULTIPLE_OUTPUT equ 0x00000200
KSALLOCATOR_FLAG_CYCLE	equ 0x00000400
KSALLOCATOR_FLAG_ALLOCATOR_EXISTS equ 0x00000800
KSALLOCATOR_FLAG_INDEPENDENT_RANGES equ 0x00001000
KSALLOCATOR_FLAG_ATTENTION_STEPPING equ 0x00002000


KSALLOCATOR_FRAMING	STRUC
UNION
 OptionsFlags		ULONG ?
 RequirementsFlags	ULONG ?
ENDS
ifdef _NTDDK_
PoolType		POOL_TYPE ?
else
PoolType		ULONG ?
endif
Frames			ULONG ?
FrameSize		ULONG ?
FileAlignment		ULONG ?
Reserved		ULONG ?
KSALLOCATOR_FRAMING	ENDS
PKSALLOCATOR_FRAMING	typedef ptr KSALLOCATOR_FRAMING

ifdef _NTDDK_
;PVOID
CALLBACK(PFNKSDEFAULTALLOCATE, :PVOID)
;VOID
CALLBACK(PFNKSDEFAULTFREE, :PVOID, :PVOID)
;NTSTATUS
CALLBACK(PFNKSINITIALIZEALLOCATOR, :PVOID, :PKSALLOCATOR_FRAMING, :PVOID)
;VOID
CALLBACK(PFNKSDELETEALLOCATOR, :PVOID)
endif

KS_FRAMING_RANGE	STRUC
MinFrameSize		ULONG ?
MaxFrameSize		ULONG ?
Stepping		ULONG ?
KS_FRAMING_RANGE	ENDS
PKS_FRAMING_RANGE	typedef ptr KS_FRAMING_RANGE

KS_FRAMING_RANGE_WEIGHTED STRUC
Range			KS_FRAMING_RANGE <>
InPlaceWeight		ULONG ?
NotInPlaceWeight	ULONG ?
KS_FRAMING_RANGE_WEIGHTED ENDS
PKS_FRAMING_RANGE_WEIGHTED typedef ptr KS_FRAMING_RANGE_WEIGHTED

KS_COMPRESSION		STRUC
RatioNumerator		ULONG ?
RatioDenominator	ULONG ?
RatioConstantMargin	ULONG ?
KS_COMPRESSION		ENDS
PKS_COMPRESSION		typedef ptr KS_COMPRESSION

KS_FRAMING_ITEM		STRUC
MemoryType		GUID <>
BusType			GUID <>
MemoryFlags		ULONG ?
BusFlags		ULONG ?
Flags			ULONG ?
Frames			ULONG ?
FileAlignment		ULONG ?
MemoryTypeWeight	ULONG ?
PhysicalRange		KS_FRAMING_RANGE <>
FramingRange		KS_FRAMING_RANGE_WEIGHTED <>
KS_FRAMING_ITEM		ENDS
PKS_FRAMING_ITEM	typedef ptr KS_FRAMING_ITEM

KSALLOCATOR_FRAMING_EX	STRUC
CountItems		ULONG ?
PinFlags		ULONG ?
OutputCompression	KS_COMPRESSION <>
PinWeight		ULONG ?
FramingItem		KS_FRAMING_ITEM 1 dup(<>)
KSALLOCATOR_FRAMING_EX	ENDS
PKSALLOCATOR_FRAMING_EX typedef ptr KSALLOCATOR_FRAMING_EX


;KSMEMORY_TYPE_WILDCARD equ GUID_NULL
;STATIC_KSMEMORY_TYPE_WILDCARD equ STATIC_GUID_NULL
;KSMEMORY_TYPE_DONT_CARE equ GUID_NULL
;STATIC_KSMEMORY_TYPE_DONT_CARE equ STATIC_GUID_NULL
;KS_TYPE_DONT_CARE	equ GUID_NULL
;STATIC_KS_TYPE_DONT_CARE equ STATIC_GUID_NULL

DEFINE_GUIDSTRUCT("091bb638-603f-11d1-b067-00a0c9062802", KSMEMORY_TYPE_SYSTEM)
DEFINE_GUIDSTRUCT("8cb0fc28-7893-11d1-b069-00a0c9062802", KSMEMORY_TYPE_USER)
DEFINE_GUIDSTRUCT("d833f8f8-7894-11d1-b069-00a0c9062802", KSMEMORY_TYPE_KERNEL_PAGED)
DEFINE_GUIDSTRUCT("4a6d5fc4-7895-11d1-b069-00a0c9062802", KSMEMORY_TYPE_KERNEL_NONPAGED)
DEFINE_GUIDSTRUCT("091bb639-603f-11d1-b067-00a0c9062802", KSMEMORY_TYPE_DEVICE_UNKNOWN)

DECLARE_SIMPLE_FRAMING_EX macro FramingExName, MemoryType, Flags, Frames, Alignment, MinFrameSize, MaxFrameSize
	endm
SetDefaultKsCompression macro KsCompressionPointer
	endm
SetDontCareKsFramingRange macro KsFramingRangePointer
	endm
SetKsFramingRange macro KsFramingRangePointer, P_MinFrameSize, P_MaxFrameSize
	endm
SetKsFramingRangeWeighted macro KsFramingRangeWeightedPointer, P_MinFrameSize, P_MaxFrameSize
	endm
INITIALIZE_SIMPLE_FRAMING_EX macro FramingExPointer, P_MemoryType, P_Flags, P_Frames, P_Alignment, P_MinFrameSize, P_MaxFrameSize
	endm

DEFINE_GUIDSTRUCT("75d95571-073c-11d0-a161-0020afd156e4", KSEVENTSETID_StreamAllocator)

KSEVENT_STREAMALLOCATOR_INTERNAL_FREEFRAME equ 0
KSEVENT_STREAMALLOCATOR_FREEFRAME equ 1

DEFINE_GUIDSTRUCT("cf6e4341-ec87-11cf-a130-0020afd156e4", KSMETHODSETID_StreamAllocator)

KSMETHOD_STREAMALLOCATOR_ALLOC equ 0
KSMETHOD_STREAMALLOCATOR_FREE equ 1

DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_ALLOC macro Handler
	endm
DEFINE_KSMETHOD_ITEM_STREAMALLOCATOR_FREE macro Handler
	endm
DEFINE_KSMETHOD_ALLOCATORSET macro AllocatorSet, MethodAlloc, MethodFree
	endm

DEFINE_GUIDSTRUCT("cf6e4342-ec87-11cf-a130-0020afd156e4", KSPROPSETID_StreamAllocator)

ifdef _NTDDK_
KSPROPERTY_STREAMALLOCATOR_FUNCTIONTABLE equ 0
KSPROPERTY_STREAMALLOCATOR_STATUS equ 1

DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_FUNCTIONTABLE macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAMALLOCATOR_STATUS macro Handler
	endm
DEFINE_KSPROPERTY_ALLOCATORSET macro AllocatorSet, PropFunctionTable, PropStatus
	endm

;NTSTATUS
CALLBACK(PFNALLOCATOR_ALLOCATEFRAME, :PFILE_OBJECT, :PVOID)
;VOID
CALLBACK(PFNALLOCATOR_FREEFRAME, :PFILE_OBJECT, :PVOID)

KSSTREAMALLOCATOR_FUNCTIONTABLE STRUC
AllocateFrame		PFNALLOCATOR_ALLOCATEFRAME ?
FreeFrame		PFNALLOCATOR_FREEFRAME ?
KSSTREAMALLOCATOR_FUNCTIONTABLE ENDS
PKSSTREAMALLOCATOR_FUNCTIONTABLE typedef ptr KSSTREAMALLOCATOR_FUNCTIONTABLE
endif

KSSTREAMALLOCATOR_STATUS STRUC
Framing			KSALLOCATOR_FRAMING <>
AllocatedFrames		ULONG ?
Reserved		ULONG ?
KSSTREAMALLOCATOR_STATUS ENDS
PKSSTREAMALLOCATOR_STATUS typedef ptr KSSTREAMALLOCATOR_STATUS

KSSTREAMALLOCATOR_STATUS_EX STRUC
Framing			KSALLOCATOR_FRAMING_EX <>
AllocatedFrames		ULONG ?
Reserved		ULONG ?
KSSTREAMALLOCATOR_STATUS_EX ENDS
PKSSTREAMALLOCATOR_STATUS_EX typedef ptr KSSTREAMALLOCATOR_STATUS_EX


KSSTREAM_HEADER_OPTIONSF_SPLICEPOINT equ 0x00000001
KSSTREAM_HEADER_OPTIONSF_PREROLL equ 0x00000002
KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY equ 0x00000004
KSSTREAM_HEADER_OPTIONSF_TYPECHANGED equ 0x00000008
KSSTREAM_HEADER_OPTIONSF_TIMEVALID equ 0x00000010
KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY equ 0x00000040
KSSTREAM_HEADER_OPTIONSF_FLUSHONPAUSE equ 0x00000080
KSSTREAM_HEADER_OPTIONSF_DURATIONVALID equ 0x00000100
KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM equ 0x00000200
KSSTREAM_HEADER_OPTIONSF_BUFFEREDTRANSFER equ 0x00000400
KSSTREAM_HEADER_OPTIONSF_VRAM_DATA_TRANSFER equ 0x00000800
KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA equ 0x80000000

KSTIME			STRUC
Time			LONGLONG ?
Numerator		ULONG ?
Denominator		ULONG ?
KSTIME			ENDS
PKSTIME			typedef ptr KSTIME

KSSTREAM_HEADER		STRUC
Size			ULONG ?
TypeSpecificFlags	ULONG ?
PresentationTime	KSTIME <>
Duration		LONGLONG ?
FrameExtent		ULONG ?
DataUsed		ULONG ?
Data			PVOID ?
OptionsFlags		ULONG ?
ifdef _WIN64
Reserved		ULONG ?
endif
KSSTREAM_HEADER		ENDS
PKSSTREAM_HEADER	typedef ptr KSSTREAM_HEADER

DEFINE_GUIDSTRUCT("1fdd8ee1-9cd3-11d0-82aa-0000f822fe8a", KSPROPSETID_StreamInterface)

KSPROPERTY_STREAMINTERFACE_HEADERSIZE equ 0

DEFINE_KSPROPERTY_ITEM_STREAMINTERFACE_HEADERSIZE macro GetHandler
	endm
DEFINE_KSPROPERTY_STREAMINTERFACESET macro StreamInterfaceSet
	endm

DEFINE_GUIDSTRUCT("65aaba60-98ae-11cf-a10d-0020afd156e4", KSPROPSETID_Stream)

KSPROPERTY_STREAM_ALLOCATOR		equ 0
KSPROPERTY_STREAM_QUALITY		equ 1
KSPROPERTY_STREAM_DEGRADATION		equ 2
KSPROPERTY_STREAM_MASTERCLOCK		equ 3
KSPROPERTY_STREAM_TIMEFORMAT		equ 4
KSPROPERTY_STREAM_PRESENTATIONTIME	equ 5
KSPROPERTY_STREAM_PRESENTATIONEXTENT	equ 6
KSPROPERTY_STREAM_FRAMETIME		equ 7
KSPROPERTY_STREAM_RATECAPABILITY	equ 8
KSPROPERTY_STREAM_RATE			equ 9
KSPROPERTY_STREAM_PIPE_ID		equ 10

DEFINE_KSPROPERTY_ITEM_STREAM_ALLOCATOR macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_QUALITY macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_DEGRADATION macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_MASTERCLOCK macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_TIMEFORMAT macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONTIME macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_PRESENTATIONEXTENT macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_FRAMETIME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_RATECAPABILITY macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_RATE macro GetHandler, SetHandler
	endm
DEFINE_KSPROPERTY_ITEM_STREAM_PIPE_ID macro GetHandler, SetHandler
	endm

KSQUALITY_MANAGER	STRUC
QualityManager		HANDLE ?
Context			PVOID ?
KSQUALITY_MANAGER	ENDS
PKSQUALITY_MANAGER	typedef ptr KSQUALITY_MANAGER

KSFRAMETIME		STRUC
Duration		LONGLONG ?
FrameFlags		ULONG ?
Reserved		ULONG ?
KSFRAMETIME		ENDS
PKSFRAMETIME		typedef ptr KSFRAMETIME

KSFRAMETIME_VARIABLESIZE equ 0x00000001

KSRATE			STRUC
PresentationStart	LONGLONG ?
Duration		LONGLONG ?
Interface		KSPIN_INTERFACE <>
Rate			LONG ?
Flags			ULONG ?
KSRATE			ENDS
PKSRATE			typedef ptr KSRATE

KSRATE_NOPRESENTATIONSTART equ 0x00000001
KSRATE_NOPRESENTATIONDURATION equ 0x00000002

KSRATE_CAPABILITY	STRUC
Property		KSPROPERTY <>
Rate			KSRATE <>
KSRATE_CAPABILITY	ENDS
PKSRATE_CAPABILITY	typedef ptr KSRATE_CAPABILITY

DEFINE_GUIDSTRUCT("DF12A4C0-AC17-11CF-A5D6-28DB04C10000", KSPROPSETID_Clock)

NANOSECONDS		equ 10000000
KSCONVERT_PERFORMANCE_TIME macro Frequency, PerformanceTime
	endm

KSCLOCK_CREATE		STRUC
CreateFlags		ULONG ?
KSCLOCK_CREATE		ENDS
PKSCLOCK_CREATE		typedef ptr KSCLOCK_CREATE

KSCORRELATED_TIME	STRUC
Time			LONGLONG ?
SystemTime		LONGLONG ?
KSCORRELATED_TIME	ENDS
PKSCORRELATED_TIME	typedef ptr KSCORRELATED_TIME

KSRESOLUTION		STRUC
Granularity		LONGLONG ?
Error			LONGLONG ?
KSRESOLUTION		ENDS
PKSRESOLUTION		typedef ptr KSRESOLUTION

KSPROPERTY_CLOCK_TIME	equ 0
KSPROPERTY_CLOCK_PHYSICALTIME equ 1
KSPROPERTY_CLOCK_CORRELATEDTIME equ 2
KSPROPERTY_CLOCK_CORRELATEDPHYSICALTIME equ 3
KSPROPERTY_CLOCK_RESOLUTION equ 4
KSPROPERTY_CLOCK_STATE	equ 5
ifdef _NTDDK_
KSPROPERTY_CLOCK_FUNCTIONTABLE equ 6
endif

ifdef _NTDDK_
;LONGLONG FASTCALL
CALLBACK(PFNKSCLOCK_GETTIME, :PFILE_OBJECT)
CALLBACK(PFNKSCLOCK_CORRELATEDTIME, :PFILE_OBJECT, :PLONGLONG)

KSCLOCK_FUNCTIONTABLE	STRUC
GetTime			PFNKSCLOCK_GETTIME ?
GetPhysicalTime		PFNKSCLOCK_GETTIME ?
GetCorrelatedTime	PFNKSCLOCK_CORRELATEDTIME ?
GetCorrelatedPhysicalTime PFNKSCLOCK_CORRELATEDTIME ?
KSCLOCK_FUNCTIONTABLE	ENDS
PKSCLOCK_FUNCTIONTABLE	typedef ptr KSCLOCK_FUNCTIONTABLE

if (NTDDI_VERSION GE NTDDI_WINXP)
;BOOLEAN
CALLBACK(PFNKSSETTIMER, :PVOID, :PKTIMER, :LARGE_INTEGER, :PKDPC)
;BOOLEAN
CALLBACK(PFNKSCANCELTIMER, :PVOID, :PKTIMER)
;LONGLONG FASTCALL
CALLBACK(PFNKSCORRELATEDTIME, :PVOID, :PLONGLONG)
endif

PKSDEFAULTCLOCK		typedef PVOID

DEFINE_KSPROPERTY_ITEM_CLOCK_TIME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_STATE macro Handler
	endm
DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE macro Handler
	endm

DEFINE_KSPROPERTY_CLOCKSET macro ClockSet, PropTime, PropPhysicalTime, PropCorrelatedTime, PropCorrelatedPhysicalTime, PropResolution, PropState, PropFunctionTable
	DEFINE_KSPROPERTY_TABLE(ClockSet)
	DEFINE_KSPROPERTY_ITEM_CLOCK_TIME(PropTime)
	DEFINE_KSPROPERTY_ITEM_CLOCK_PHYSICALTIME(PropPhysicalTime)
	DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDTIME(PropCorrelatedTime)
	DEFINE_KSPROPERTY_ITEM_CLOCK_CORRELATEDPHYSICALTIME(PropCorrelatedPhysicalTime)
	DEFINE_KSPROPERTY_ITEM_CLOCK_RESOLUTION(PropResolution)
	DEFINE_KSPROPERTY_ITEM_CLOCK_STATE(PropState)
	DEFINE_KSPROPERTY_ITEM_CLOCK_FUNCTIONTABLE(PropFunctionTable)
	endm

endif ;; _NTDDK_

DEFINE_GUIDSTRUCT("364D8E20-62C7-11CF-A5D6-28DB04C10000", KSEVENTSETID_Clock)

KSEVENT_CLOCK_INTERVAL_MARK equ 0
KSEVENT_CLOCK_POSITION_MARK equ 1

DEFINE_GUIDSTRUCT("7f4bcbe0-9ea5-11cf-a5d6-28db04c10000", KSEVENTSETID_Connection)

KSEVENT_CONNECTION_POSITIONUPDATE equ 0
KSEVENT_CONNECTION_DATADISCONTINUITY equ 1
KSEVENT_CONNECTION_TIMEDISCONTINUITY equ 2
KSEVENT_CONNECTION_PRIORITY equ 3
KSEVENT_CONNECTION_ENDOFSTREAM equ 4

KSQUALITY		STRUC
Context			PVOID ?
Proportion		ULONG ?
DeltaTime		LONGLONG ?
KSQUALITY		ENDS
PKSQUALITY		typedef ptr KSQUALITY

KSERROR			STRUC
Context			PVOID ?
Status			ULONG ?
KSERROR			ENDS
PKSERROR		typedef ptr KSERROR

PKSDEGRADE		typedef ptr KSIDENTIFIER
DEFINE_GUIDSTRUCT("9F564180-704C-11D0-A5D6-28DB04C10000", KSDEGRADESETID_Standard)

KSDEGRADE_STANDARD_SAMPLE equ 0
KSDEGRADE_STANDARD_QUALITY equ 1
KSDEGRADE_STANDARD_COMPUTATION equ 2
KSDEGRADE_STANDARD_SKIP equ 3

ifdef _NTDDK_

KSPROBE_STREAMREAD	equ 0x00000000
KSPROBE_STREAMWRITE	equ 0x00000001
KSPROBE_ALLOCATEMDL	equ 0x00000010
KSPROBE_PROBEANDLOCK	equ 0x00000020
KSPROBE_SYSTEMADDRESS	equ 0x00000040
KSPROBE_MODIFY		equ 0x00000200
KSPROBE_STREAMWRITEMODIFY equ (KSPROBE_MODIFY OR KSPROBE_STREAMWRITE)
KSPROBE_ALLOWFORMATCHANGE equ 0x00000080

KSSTREAM_READ		equ KSPROBE_STREAMREAD
KSSTREAM_WRITE		equ KSPROBE_STREAMWRITE
KSSTREAM_PAGED_DATA	equ 0x00000000
KSSTREAM_NONPAGED_DATA	equ 0x00000100
KSSTREAM_SYNCHRONOUS	equ 0x00001000
KSSTREAM_FAILUREEXCEPTION equ 0x00002000

;NTSTATUS
CALLBACK(PFNKSCONTEXT_DISPATCH, :PVOID, :PIRP)
;NTSTATUS
CALLBACK(PFNKSHANDLER, :PIRP, :PKSIDENTIFIER, :PVOID)
;BOOLEAN
CALLBACK(PFNKSFASTHANDLER, :PFILE_OBJECT, :PKSIDENTIFIER, :ULONG, :PVOID, :ULONG, :PIO_STATUS_BLOCK)
;NTSTATUS
CALLBACK(PFNKSALLOCATOR, :PIRP, :ULONG, :BOOLEAN)

KSPROPERTY_MEMBERSLIST	STRUC
MembersHeader		KSPROPERTY_MEMBERSHEADER <>
Members			PVOID ?
KSPROPERTY_MEMBERSLIST	ENDS
PKSPROPERTY_MEMBERSLIST typedef ptr KSPROPERTY_MEMBERSLIST

KSPROPERTY_VALUES	STRUC
PropTypeSet		KSIDENTIFIER <>
MembersListCount	ULONG ?
MembersList		PKSPROPERTY_MEMBERSLIST ?
KSPROPERTY_VALUES	ENDS
PKSPROPERTY_VALUES	typedef ptr KSPROPERTY_VALUES

DEFINE_KSPROPERTY_TABLE macro tablename
tablename label KSPROPERTY_ITEM
	endm
DEFINE_KSPROPERTY_ITEM macro PropertyId, GetHandler
	endm

KSPROPERTY_ITEM		STRUC
PropertyId		ULONG ?
UNION
 GetPropertyHandler	PFNKSHANDLER ?
 GetSupported		BOOLEAN ?
ENDS
MinProperty		ULONG ?
MinData			ULONG ?
UNION
 SetPropertyHandler	PFNKSHANDLER ?
 SetSupported		BOOLEAN ?
ENDS
RelationsCount		ULONG ?
Relations		LPKSPROPERTY ?
SupportHandler		PFNKSHANDLER ?
SerializedSize		ULONG ?
KSPROPERTY_ITEM		ENDS
PKSPROPERTY_ITEM	typedef ptr KSPROPERTY_ITEM

DEFINE_KSFASTPROPERTY_ITEM macro PropertyId, GetHandler, SetHandler
	endm

KSFASTPROPERTY_ITEM	STRUC
PropertyId		ULONG ?
UNION
 GetPropertyHandler	PFNKSFASTHANDLER ?
 GetSupported		BOOLEAN ?
ENDS
UNION
 SetPropertyHandler	PFNKSFASTHANDLER ?
 SetSupported		BOOLEAN ?
ENDS
Reserved		ULONG ?
KSFASTPROPERTY_ITEM	ENDS
PKSFASTPROPERTY_ITEM	typedef ptr KSFASTPROPERTY_ITEM

DEFINE_KSPROPERTY_SET macro Set
	endm

DEFINE_KSPROPERTY_SET_TABLE macro tablename
tablename label KSPROPERTY_SET
	endm

KSPROPERTY_SET		STRUC
Set			LPGUID ?
PropertiesCount		ULONG ?
PropertyItem		PKSPROPERTY_ITEM ?
FastIoCount		ULONG ?
FastIoTable		PKSFASTPROPERTY_ITEM ?
KSPROPERTY_SET		ENDS
PKSPROPERTY_SET		typedef ptr KSPROPERTY_SET

DEFINE_KSMETHOD_TABLE macro tablename
tablename label KSMETHOD_ITEM
	endm

DEFINE_KSMETHOD_ITEM macro MethodId, Flags
	endm

KSMETHOD_ITEM		STRUC
MethodId		ULONG ?
UNION
 MethodHandler		PFNKSHANDLER ?
 MethodSupported	BOOLEAN ?
ENDS
MinMethod		ULONG ?
MinData			ULONG ?
SupportHandler		PFNKSHANDLER ?
Flags			ULONG ?
KSMETHOD_ITEM		ENDS
PKSMETHOD_ITEM		typedef ptr KSMETHOD_ITEM

DEFINE_KSFASTMETHOD_ITEM macro MethodId, MethodHandler
	endm

KSFASTMETHOD_ITEM	STRUC
MethodId		ULONG ?
UNION
 MethodHandler		PFNKSFASTHANDLER ?
 MethodSupported	BOOLEAN ?
ENDS
KSFASTMETHOD_ITEM	ENDS
PKSFASTMETHOD_ITEM	typedef ptr KSFASTMETHOD_ITEM

DEFINE_KSMETHOD_SET macro Set
	endm

DEFINE_KSMETHOD_SET_TABLE macro tablename
tablename label KSMETHOD_SET
	endm

KSMETHOD_SET		STRUC
Set			LPGUID ?
MethodsCount		ULONG ?
MethodItem		PKSMETHOD_ITEM ?
FastIoCount		ULONG ?
FastIoTable		PKSFASTMETHOD_ITEM ?
KSMETHOD_SET		ENDS
PKSMETHOD_SET		typedef ptr KSMETHOD_SET

PKSEVENT_ENTRY		typedef ptr KSEVENT_ENTRY

;NTSTATUS
CALLBACK(PFNKSADDEVENT, :PIRP, :PKSEVENTDATA, :PKSEVENT_ENTRY)
;VOID
CALLBACK(PFNKSREMOVEEVENT, :PFILE_OBJECT, :PKSEVENT_ENTRY)

DEFINE_KSEVENT_TABLE macro tablename
tablename label KSEVENT_ITEM
	endm
DEFINE_KSEVENT_ITEM macro EventId, DataInput, ExtraEntryData
	endm

KSEVENT_ITEM		STRUC
EventId			ULONG ?
DataInput		ULONG ?
ExtraEntryData		ULONG ?
AddHandler		PFNKSADDEVENT ?
RemoveHandler		PFNKSREMOVEEVENT ?
SupportHandler		PFNKSHANDLER ?
KSEVENT_ITEM		ENDS
PKSEVENT_ITEM		typedef ptr KSEVENT_ITEM

DEFINE_KSEVENT_SET macro Set
	endm

DEFINE_KSEVENT_SET_TABLE macro tablename
tablename label KSEVENT_SET
	endm

KSEVENT_SET		STRUC
Set			LPGUID ?
EventsCount		ULONG ?
EventItem		PKSEVENT_ITEM ?
KSEVENT_SET		ENDS
PKSEVENT_SET		typedef ptr KSEVENT_SET

KSDPC_ITEM		STRUC
Dpc			KDPC ?
ReferenceCount		ULONG ?
AccessLock		KSPIN_LOCK ?
KSDPC_ITEM		ENDS
PKSDPC_ITEM		typedef ptr KSDPC_ITEM

KSBUFFER_ITEM		STRUC
DpcItem			KSDPC_ITEM <>
BufferList		LIST_ENTRY <>
KSBUFFER_ITEM		ENDS
PKSBUFFER_ITEM		typedef ptr KSBUFFER_ITEM

KSEVENT_ENTRY_DELETED	equ 1
KSEVENT_ENTRY_ONESHOT	equ 2
KSEVENT_ENTRY_BUFFERED	equ 4

KSEVENT_ENTRY		STRUC
ListEntry		LIST_ENTRY <>
Object			PVOID ?
UNION
 DpcItem		PKSDPC_ITEM ?
 BufferItem		PKSBUFFER_ITEM ?
ENDS
EventData		PKSEVENTDATA ?
NotificationType	ULONG ?
EventSet		PKSEVENT_SET ?
EventItem		PKSEVENT_ITEM ?
FileObject		PFILE_OBJECT ?
SemaphoreAdjustment	ULONG ?
Reserved		ULONG ?
Flags			ULONG ?
KSEVENT_ENTRY		ENDS

KSEVENTS_NONE		equ 0
KSEVENTS_SPINLOCK	equ 1
KSEVENTS_MUTEX		equ 2
KSEVENTS_FMUTEX		equ 3
KSEVENTS_FMUTEXUNSAFE	equ 4
KSEVENTS_INTERRUPT	equ 5
KSEVENTS_ERESOURCE	equ 6

KSDISPATCH_FASTIO	equ 0x80000000

KSOBJECT_CREATE_ITEM	STRUC
Create			PDRIVER_DISPATCH ?
Context			PVOID ?
ObjectClass		UNICODE_STRING ?
SecurityDescriptor	PSECURITY_DESCRIPTOR ?
Flags			ULONG ?
KSOBJECT_CREATE_ITEM	ENDS
PKSOBJECT_CREATE_ITEM	typedef ptr KSOBJECT_CREATE_ITEM

;VOID
CALLBACK(PFNKSITEMFREECALLBACK, :PKSOBJECT_CREATE_ITEM)

KSCREATE_ITEM_SECURITYCHANGED	equ 0x00000001
KSCREATE_ITEM_WILDCARD		equ 0x00000002
KSCREATE_ITEM_NOPARAMETERS	equ 0x00000004
KSCREATE_ITEM_FREEONSTOP	equ 0x00000008

DEFINE_KSCREATE_DISPATCH_TABLE macro tablename
	endm
DEFINE_KSCREATE_ITEM macro DispatchCreate, TypeName, Context
	endm
DEFINE_KSCREATE_ITEMEX macro DispatchCreate, TypeName, Context, Flags
	endm
DEFINE_KSCREATE_ITEMNULL macro DispatchCreate, Context
	endm

KSOBJECT_CREATE		STRUC
CreateItemsCount	ULONG ?
CreateItemsList		PKSOBJECT_CREATE_ITEM ?
KSOBJECT_CREATE		ENDS
PKSOBJECT_CREATE	typedef ptr KSOBJECT_CREATE

KSDISPATCH_TABLE	STRUC
DeviceIoControl		PDRIVER_DISPATCH ?
Read			PDRIVER_DISPATCH ?
Write			PDRIVER_DISPATCH ?
Flush			PDRIVER_DISPATCH ?
Close			PDRIVER_DISPATCH ?
QuerySecurity		PDRIVER_DISPATCH ?
SetSecurity		PDRIVER_DISPATCH ?
FastDeviceIoControl	PFAST_IO_DEVICE_CONTROL ?
FastRead		PFAST_IO_READ ?
FastWrite		PFAST_IO_WRITE ?
KSDISPATCH_TABLE	ENDS
PKSDISPATCH_TABLE	typedef ptr KSDISPATCH_TABLE

DEFINE_KSDISPATCH_TABLE macro tablename, DeviceIoControl, Read, Write
	endm
KSCREATE_ITEM_IRP_STORAGE macro Irp
	endm
KSEVENT_SET_IRP_STORAGE macro Irp
	endm
KSEVENT_ITEM_IRP_STORAGE macro Irp
	endm
KSEVENT_ENTRY_IRP_STORAGE macro Irp
	endm
KSMETHOD_SET_IRP_STORAGE macro Irp
	endm
KSMETHOD_ITEM_IRP_STORAGE macro Irp
	endm
KSMETHOD_TYPE_IRP_STORAGE macro Irp
	endm
KSQUEUE_SPINLOCK_IRP_STORAGE macro Irp
	endm
KSPROPERTY_SET_IRP_STORAGE macro Irp
	endm
KSPROPERTY_ITEM_IRP_STORAGE macro Irp
	endm
KSPROPERTY_ATTRIBUTES_IRP_STORAGE macro Irp
	endm

KSOBJECT_HEADER		typedef PVOID
KSDEVICE_HEADER		typedef PVOID

KsInvokeOnSuccess	equ 1
KsInvokeOnError		equ 2
KsInvokeOnCancel	equ 4

KsListEntryTail		equ 0
KsListEntryHead		equ 1

KsAcquireOnly		equ 0
KsAcquireAndRemove	equ 1
KsAcquireOnlySingleItem equ 2
KsAcquireAndRemoveOnlySingleItem equ 3

KsStackCopyToNewLocation equ 0
KsStackReuseCurrentLocation equ 1
KsStackUseNewLocation	equ 2

KSTARGET_STATE_DISABLED equ 0
KSTARGET_STATE_ENABLED	equ 1

;NTSTATUS
CALLBACK(PFNKSIRPLISTCALLBACK, :PIRP, :PVOID)
;VOID
CALLBACK(PFNREFERENCEDEVICEOBJECT, :PVOID)
;VOID
CALLBACK(PFNDEREFERENCEDEVICEOBJECT, :PVOID)
;NTSTATUS
CALLBACK(PFNQUERYREFERENCESTRING, :PVOID, :PWCHAR)

BUS_INTERFACE_REFERENCE_VERSION equ 0x100

BUS_INTERFACE_REFERENCE STRUC
ReferenceDeviceObject	PFNREFERENCEDEVICEOBJECT ?
DereferenceDeviceObject PFNDEREFERENCEDEVICEOBJECT ?
QueryReferenceString	PFNQUERYREFERENCESTRING ?
BUS_INTERFACE_REFERENCE ENDS
PBUS_INTERFACE_REFERENCE typedef ptr BUS_INTERFACE_REFERENCE

;STATIC_REFERENCE_BUS_INTERFACE equ STATIC_KSMEDIUMSETID_Standard
;REFERENCE_BUS_INTERFACE equ KSMEDIUMSETID_Standard

;NTSTATUS
CALLBACK(PFNQUERYMEDIUMSLIST, :PVOID, :ptr ULONG, :PKSPIN_MEDIUM)

BUS_INTERFACE_MEDIUMS	STRUC
QueryMediumsList	PFNQUERYMEDIUMSLIST ?
BUS_INTERFACE_MEDIUMS	ENDS
PBUS_INTERFACE_MEDIUMS	typedef ptr BUS_INTERFACE_MEDIUMS

DEFINE_GUIDSTRUCT("4EC35C3E-201B-11D2-8745-00A0C9223196", GUID_BUS_INTERFACE_MEDIUMS)

endif ;; _NTDDK_

.pragma pack(push, 1)

KSPROPERTY_SERIALHDR	STRUC
PropertySet		GUID <>
Count			ULONG ?
KSPROPERTY_SERIALHDR	ENDS
PKSPROPERTY_SERIALHDR	typedef ptr KSPROPERTY_SERIALHDR

.pragma pack(pop)

KSPROPERTY_SERIAL	STRUC
PropTypeSet		KSIDENTIFIER <>
Id			ULONG ?
PropertyLength		ULONG ?
KSPROPERTY_SERIAL	ENDS
PKSPROPERTY_SERIAL	typedef ptr KSPROPERTY_SERIAL

if (NTDDI_VERSION GE NTDDI_WINXP)

ifdef _NTDDK_

IOCTL_KS_HANDSHAKE	equ CTL_CODE(FILE_DEVICE_KS,0x007, METHOD_NEITHER, FILE_ANY_ACCESS)

KSHANDSHAKE		STRUC
ProtocolId		GUID <>
Argument1		PVOID ?
Argument2		PVOID ?
KSHANDSHAKE		ENDS
PKSHANDSHAKE		typedef ptr KSHANDSHAKE

KSGATE			STRUC
Count			LONG ?
NextGate		PKSGATE ?
KSGATE			ENDS
PKSGATE			typedef ptr KSGATE

ifndef _NTOS_
KsGateTurnInputOn proto WINAPI :PKSGATE
KsGateTurnInputOff proto WINAPI :PKSGATE
KsGateGetStateUnsafe proto WINAPI :PKSGATE
KsGateCaptureThreshold proto WINAPI :PKSGATE
KsGateInitialize proto WINAPI :PKSGATE, :LONG, :PKSGATE, :BOOLEAN
KsGateInitializeAnd proto WINAPI :PKSGATE, :PKSGATE
KsGateInitializeOr proto WINAPI :PKSGATE, :PKSGATE
KsGateTerminateAnd proto WINAPI :PKSGATE
KsGateTerminateOr proto WINAPI :PKSGATE
endif
KSOBJECT_BAG		typedef PVOID

CALLBACK(PFNKSGENERATEEVENTCALLBACK, :PVOID, :PKSEVENT_ENTRY)

CALLBACK(PFNKSDEVICECREATE, :PKSDEVICE)
CALLBACK(PFNKSDEVICEPNPSTART, :PKSDEVICE, :PIRP, :PCM_RESOURCE_LIST, :PCM_RESOURCE_LIST)
CALLBACK(PFNKSDEVICE, :PKSDEVICE)
CALLBACK(PFNKSDEVICEIRP, :PKSDEVICE, :PIRP)
CALLBACK(PFNKSDEVICEIRPVOID, :PKSDEVICE, :PIRP)
CALLBACK(PFNKSDEVICEQUERYCAPABILITIES, :PKSDEVICE, :PIRP, :PDEVICE_CAPABILITIES)
CALLBACK(PFNKSDEVICEQUERYPOWER, :PKSDEVICE, :PIRP, :DEVICE_POWER_STATE, :DEVICE_POWER_STATE, :SYSTEM_POWER_STATE, :SYSTEM_POWER_STATE, :POWER_ACTION)
CALLBACK(PFNKSDEVICESETPOWER, :PKSDEVICE, :PIRP, :DEVICE_POWER_STATE, :DEVICE_POWER_STATE)
CALLBACK(PFNKSFILTERFACTORYVOID, :PKSFILTERFACTORY)
CALLBACK(PFNKSFILTERFACTORYPOWER, :PKSFILTERFACTORY, :DEVICE_POWER_STATE)
CALLBACK(PFNKSFILTERIRP, :PKSFILTER, :PIRP)
CALLBACK(PFNKSFILTERPROCESS, :PKSFILTER, :PKSPROCESSPIN_INDEXENTRY)
CALLBACK(PFNKSFILTERVOID, :PKSFILTER)
CALLBACK(PFNKSFILTERPOWER, :PKSFILTER, :DEVICE_POWER_STATE)
CALLBACK(PFNKSPINIRP, :PKSPIN, :PIRP)
CALLBACK(PFNKSPINSETDEVICESTATE, :PKSPIN, :KSSTATE, :KSSTATE)
CALLBACK(PFNKSPINSETDATAFORMAT, :PKSPIN, :PKSDATAFORMAT, :PKSMULTIPLE_ITEM, :ptr KSDATARANGE, :ptr KSATTRIBUTE_LIST)
CALLBACK(PFNKSPINHANDSHAKE, :PKSPIN, :PKSHANDSHAKE, :PKSHANDSHAKE)
CALLBACK(PFNKSPIN, :PKSPIN)
CALLBACK(PFNKSPINVOID, :PKSPIN)
CALLBACK(PFNKSPINPOWER, :PKSPIN, :DEVICE_POWER_STATE)
CALLBACK(PFNKSPINSETTIMER, :PKSPIN, :PKTIMER, :LARGE_INTEGER, :PKDPC)
CALLBACK(PFNKSPINCANCELTIMER, :PKSPIN, :PKTIMER)
CALLBACK(PFNKSPINCORRELATEDTIME, FASTCALL, :PKSPIN, :PLONGLONG)
CALLBACK(PFNKSPINRESOLUTION, :PKSPIN, :PKSRESOLUTION)
CALLBACK(PFNKSPININITIALIZEALLOCATOR, :PKSPIN, :PKSALLOCATOR_FRAMING, :PVOID)
CALLBACK(PFNKSSTREAMPOINTER, :PKSSTREAM_POINTER)

KSAUTOMATION_TABLE	STRUC
PropertySetsCount	ULONG ?
PropertyItemSize	ULONG ?
PropertySets		PVOID ?
MethodSetsCount		ULONG ?
MethodItemSize		ULONG ?
MethodSets		ULONG ?
EventSetsCount		ULONG ?
EventItemSize		ULONG ?
EventSets		ULONG ?
ifndef _WIN64
Alignment		PVOID ?
endif
KSAUTOMATION_TABLE	ENDS
PKSAUTOMATION_TABLE	typedef ptr KSAUTOMATION_TABLE

DEFINE_KSAUTOMATION_TABLE macro table
	endm
DEFINE_KSAUTOMATION_PROPERTIES macro table
	endm
DEFINE_KSAUTOMATION_METHODS macro table
	endm
DEFINE_KSAUTOMATION_EVENTS macro table
	endm

DEFINE_KSAUTOMATION_PROPERTIES_NULL equ 1
DEFINE_KSAUTOMATION_METHODS_NULL equ 1
DEFINE_KSAUTOMATION_EVENTS_NULL equ 1

MIN_DEV_VER_FOR_QI	equ (0x100)

KSDEVICE_DISPATCH	STRUC
_Add			PFNKSDEVICECREATE ?
Start			PFNKSDEVICEPNPSTART ?
PostStart		PFNKSDEVICE ?
QueryStop		PFNKSDEVICEIRP ?
CancelStop		PFNKSDEVICEIRPVOID ?
Stop			PFNKSDEVICEIRPVOID ?
QueryRemove		PFNKSDEVICEIRP ?
CancelRemove		PFNKSDEVICEIRPVOID ?
Remove			PFNKSDEVICEIRPVOID ?
QueryCapabilities	PFNKSDEVICEQUERYCAPABILITIES ?
SurpriseRemoval		PFNKSDEVICEIRPVOID ?
QueryPower		PFNKSDEVICEQUERYPOWER ?
SetPower		PFNKSDEVICESETPOWER ?
QueryInterface		PFNKSDEVICEIRP ?
KSDEVICE_DISPATCH	ENDS

KSFILTER_DISPATCH	STRUC
Create			PFNKSFILTERIRP ?
Close			PFNKSFILTERIRP ?
Process			PFNKSFILTERPROCESS ?
Reset			PFNKSFILTERVOID ?
KSFILTER_DISPATCH	ENDS

KSPIN_DISPATCH		STRUC
Create			PFNKSPINIRP ?
Close			PFNKSPINIRP ?
Process			PFNKSPIN ?
Reset			PFNKSPINVOID ?
SetDataFormat		PFNKSPINSETDATAFORMAT ?
SetDeviceState		PFNKSPINSETDEVICESTATE ?
Connect			PFNKSPIN ?
Disconnect		PFNKSPINVOID ?
Clock			LPKSCLOCK_DISPATCH ?
Allocator		KSALLOCATOR_DISPATCH* ?
KSPIN_DISPATCH		ENDS

KSCLOCK_DISPATCH	STRUC
SetTimer		PFNKSPINSETTIMER ?
CancelTimer		PFNKSPINCANCELTIMER ?
CorrelatedTime		PFNKSPINCORRELATEDTIME ?
Resolution		PFNKSPINRESOLUTION ?
KSCLOCK_DISPATCH	ENDS

KSALLOCATOR_DISPATCH	STRUC
InitializeAllocator	PFNKSPININITIALIZEALLOCATOR ?
DeleteAllocator		PFNKSDELETEALLOCATOR ?
Allocate		PFNKSDEFAULTALLOCATE ?
Free			PFNKSDEFAULTFREE ?
KSALLOCATOR_DISPATCH	ENDS

KSDEVICE_DESCRIPTOR_VERSION equ (0x100)

if (NTDDI_VERSION GE NTDDI_VISTA)

KSDEVICE_DESCRIPTOR_VERSION_2 equ (0x110)
MIN_DEV_VER_FOR_FLAGS	equ (0x110)

endif

KSDEVICE_DESCRIPTOR	STRUC
Dispatch		KSDEVICE_DISPATCH* ?
FilterDescriptorsCount	ULONG ?
FilterDescriptors	PVOID ?
Version			ULONG ?
if (NTDDI_VERSION GE NTDDI_VISTA)
Flags			ULONG ?
KSDEVICE_FLAG_ENABLE_REMOTE_WAKEUP equ 0x00000001
KSDEVICE_FLAG_LOWPOWER_PASSTHROUGH equ 0x00000002
ifndef _WIN64
Alignment		PVOID ?
endif
endif
KSDEVICE_DESCRIPTOR	ENDS

KSFILTER_DESCRIPTOR	STRUC
Dispatch		KSFILTER_DISPATCH* ?
AutomationTable		KSAUTOMATION_TABLE* ?
Version			ULONG ?
KSFILTER_DESCRIPTOR_VERSION equ (-1)
Flags			ULONG ?
KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING equ 0x00000001
KSFILTER_FLAG_CRITICAL_PROCESSING equ 0x00000002
KSFILTER_FLAG_HYPERCRITICAL_PROCESSING equ 0x00000004
KSFILTER_FLAG_RECEIVE_ZERO_LENGTH_SAMPLES equ 0x00000008
if (NTDDI_VERSION GE NTDDI_WINXPSP2)
KSFILTER_FLAG_DENY_USERMODE_ACCESS equ 0x80000000
endif
ReferenceGuid		LPGUID ?
PinDescriptorsCount	ULONG ?
PinDescriptorSize	ULONG ?
PinDescriptors		PKSPIN_DESCRIPTOR_EX ?
CategoriesCount		ULONG ?
Categories		LPGUID ?
NodeDescriptorsCount	ULONG ?
NodeDescriptorSize	ULONG ?
NodeDescriptors		PKSNODE_DESCRIPTOR ?
ConnectionsCount	ULONG ?
Connections		PKSTOPOLOGY_CONNECTION ?
ComponentId		PKSCOMPONENTID ?
KSFILTER_DESCRIPTOR	ENDS

DEFINE_KSFILTER_DESCRIPTOR macro descriptor
	endm
DEFINE_KSFILTER_PIN_DESCRIPTORS macro table
	endm
DEFINE_KSFILTER_CATEGORIES macro table
	endm
DEFINE_KSFILTER_CATEGORY macro category
	endm
DEFINE_KSFILTER_CATEGORIES_NULL equ 1
DEFINE_KSFILTER_NODE_DESCRIPTORS macro table
	endm
DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL equ 1
DEFINE_KSFILTER_CONNECTIONS macro table
	endm
DEFINE_KSFILTER_DEFAULT_CONNECTIONS equ 1
DEFINE_KSFILTER_DESCRIPTOR_TABLE macro table
	endm

KSPIN_DESCRIPTOR_EX	STRUC
Dispatch		PKSPIN_DISPATCH ?
AutomationTable		PKSAUTOMATION_TABLE ?
PinDescriptor		KSPIN_DESCRIPTOR ?
Flags			ULONG ?

KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING equ KSFILTER_FLAG_DISPATCH_LEVEL_PROCESSING
KSPIN_FLAG_CRITICAL_PROCESSING equ KSFILTER_FLAG_CRITICAL_PROCESSING
KSPIN_FLAG_HYPERCRITICAL_PROCESSING equ KSFILTER_FLAG_HYPERCRITICAL_PROCESSING
KSPIN_FLAG_ASYNCHRONOUS_PROCESSING equ 0x00000008
KSPIN_FLAG_DO_NOT_INITIATE_PROCESSING equ 0x00000010
KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL equ 0x00000020
KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING equ 0x00000040
KSPIN_FLAG_ENFORCE_FIFO equ 0x00000080

KSPIN_FLAG_GENERATE_MAPPINGS equ 0x00000100
KSPIN_FLAG_DISTINCT_TRAILING_EDGE equ 0x00000200

KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY equ 0x00010000
KSPIN_FLAG_SPLITTER	equ 0x00020000
KSPIN_FLAG_USE_STANDARD_TRANSPORT equ 0x00040000
KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT equ 0x00080000
KSPIN_FLAG_FIXED_FORMAT equ 0x00100000
KSPIN_FLAG_GENERATE_EOS_EVENTS equ 0x00200000
KSPIN_FLAG_RENDERER	equ (KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY OR KSPIN_FLAG_GENERATE_EOS_EVENTS)
KSPIN_FLAG_IMPLEMENT_CLOCK equ 0x00400000
KSPIN_FLAG_SOME_FRAMES_REQUIRED_FOR_PROCESSING equ 0x00800000
KSPIN_FLAG_PROCESS_IF_ANY_IN_RUN_STATE equ 0x01000000
if (NTDDI_VERSION GE NTDDI_WINXPSP2)
KSPIN_FLAG_DENY_USERMODE_ACCESS equ 0x80000000
endif

InstancesPossible	ULONG ?
InstancesNecessary	ULONG ?
AllocatorFraming	KSALLOCATOR_FRAMING_EX* ?
IntersectHandler	PFNKSINTERSECTHANDLEREX ?
KSPIN_DESCRIPTOR_EX	ENDS

DEFINE_KSPIN_DEFAULT_INTERFACES equ 1
DEFINE_KSPIN_DEFAULT_MEDIUMS equ 1

KSNODE_DESCRIPTOR	STRUC
AutomationTable		PKSAUTOMATION_TABLE ?
Type			LPGUID ?
Name			LPGUID ?
ifndef _WIN64
Alignment		PVOID ?
endif
KSNODE_DESCRIPTOR	ENDS

ifndef _WIN64
DEFINE_NODE_DESCRIPTOR macro automation,type,name
	endm
else
DEFINE_NODE_DESCRIPTOR macro automation,type,name
	endm
endif

KSDEVICE		STRUC
Descriptor		KSDEVICE_DESCRIPTOR* ?
Bag			KSOBJECT_BAG ?
Context			PVOID ?
FunctionalDeviceObject	PDEVICE_OBJECT ?
PhysicalDeviceObject	PDEVICE_OBJECT ?
NextDeviceObject	PDEVICE_OBJECT ?
Started			BOOLEAN ?
SystemPowerState	SYSTEM_POWER_STATE ?
DevicePowerState	DEVICE_POWER_STATE ?
KSDEVICE		ENDS

KSFILTERFACTORY		STRUC
FilterDescriptor	KSFILTER_DESCRIPTOR* ?
Bag			KSOBJECT_BAG ?
Context			PVOID ?
KSFILTERFACTORY		ENDS

KSFILTER		STRUC
Descriptor		KSFILTER_DESCRIPTOR* ?
Bag			KSOBJECT_BAG ?
Context			PVOID ?
KSFILTER		ENDS

KSPIN			STRUC
Descriptor		KSPIN_DESCRIPTOR_EX* ?
Bag			KSOBJECT_BAG ?
Context			PVOID ?
Id			ULONG ?
Communication		KSPIN_COMMUNICATION ?
ConnectionIsExternal	BOOLEAN ?
ConnectionInterface	KSPIN_INTERFACE ?
ConnectionMedium	KSPIN_MEDIUM ?
ConnectionPriority	KSPRIORITY ?
ConnectionFormat	PKSDATAFORMAT ?
AttributeList		PKSMULTIPLE_ITEM ?
StreamHeaderSize	ULONG ?
DataFlow		KSPIN_DATAFLOW ?
DeviceState		KSSTATE ?
ResetState		KSRESET ?
ClientState		KSSTATE ?
KSPIN			ENDS

KSMAPPING		STRUC
PhysicalAddress		PHYSICAL_ADDRESS ?
ByteCount		ULONG ?
Alignment		ULONG ?
KSMAPPING		ENDS

KSSTREAM_POINTER_OFFSET STRUC
ifdef _NTDDK_
UNION
 Data			PUCHAR ?
 Mappings		PKSMAPPING ?
ENDS
else
Data			PUCHAR ?
endif
ifndef _WIN64
Alignment		PVOID ?
endif
Count			ULONG ?
Remaining		ULONG ?
KSSTREAM_POINTER_OFFSET ENDS

KSSTREAM_POINTER	STRUC
Context			PVOID ?
Pin			PKSPIN ?
StreamHeader		PKSSTREAM_HEADER ?
Offset			PKSSTREAM_POINTER_OFFSET ?
OffsetIn		KSSTREAM_POINTER_OFFSET ?
OffsetOut		KSSTREAM_POINTER_OFFSET ?
KSSTREAM_POINTER	ENDS

KSPROCESSPIN		STRUC
Pin			PKSPIN ?
StreamPointer		PKSSTREAM_POINTER ?
InPlaceCounterpart	PKSPROCESSPIN ?
DelegateBranch		PKSPROCESSPIN ?
CopySource		PKSPROCESSPIN ?
Data			PVOID ?
BytesAvailable		ULONG ?
BytesUsed		ULONG ?
Flags			ULONG ?
Terminate		BOOLEAN ?
KSPROCESSPIN		ENDS

KSPROCESSPIN_INDEXENTRY STRUC
Pins			PKSPROCESSPIN ?
Count			ULONG ?
KSPROCESSPIN_INDEXENTRY ENDS

KsObjectTypeDevice	equ 0
KsObjectTypeFilterFactory equ 1
KsObjectTypeFilter	equ 2
KsObjectTypePin		equ 3

;void
CALLBACK(PFNKSFREE, :PVOID)
;void
CALLBACK(PFNKSPINFRAMERETURN, :PKSPIN, :PVOID, :ULONG, :PMDL, :PVOID, :NTSTATUS)
;void
CALLBACK(PFNKSPINIRPCOMPLETION, :PKSPIN, :PIRP)

ifdef __IUnknown_INTERFACE_DEFINED__

ifndef _IKsControl_
define _IKsControl_

.comdef IKsControl : public IUnknown

	KsProperty	proc :ULONG, :PVOID, :ULONG, :ptr ULONG
	KsMethod	proc :ULONG, :PVOID, :ULONG, :ptr ULONG
	KsEvent		proc :ULONG, :PVOID, :ULONG, :ptr ULONG
       .ends

.comdef IKsReferenceClock : public IUnknown

	GetTime		proc
	GetPhysicalTime proc
	GetCorrelatedTime proc :PLONGLONG
	GetCorrelatedPhysicalTime proc :PLONGLONG
	GetResolution	proc :PKSRESOLUTION
	GetState	proc :PKSSTATE
       .ends

if (NTDDI_VERSION GE NTDDI_WS03SP1)

.comdef IKsDeviceFunctions : public IUnknown

	RegisterAdapterObjectEx proc :PADAPTER_OBJECT, :PDEVICE_DESCRIPTION, :ULONG, :ULONG, :ULONG

	.ends
endif

STATIC_IID_IKsControl	equ <{0x28F54685,0x06FD,0x11D2,{0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96}}>
DEFINE_GUID(IID_IKsControl,0x28F54685,0x06FD,0x11D2,0xB2,0x7A,0x00,0xA0,0xC9,0x22,0x31,0x96)
DEFINE_GUID(IID_IKsFastClock,0xc9902485,0xc180,0x11d2,0x84,0x73,0xd4,0x23,0x94,0x45,0x9e,0x5e)
if (NTDDI_VERSION GE NTDDI_WS03SP1)
DEFINE_GUID(IID_IKsDeviceFunctions,0xe234f2e2,0xbd69,0x4f8c,0xb3,0xf2,0x7c,0xd7,0x9e,0xd4,0x66,0xbd)
endif

endif ;; _IKsControl_
endif ;; __IUnknown_INTERFACE_DEFINED__

endif ;; defined(_NTDDK_)
endif ;; (NTDDI_VERSION >= NTDDI_WINXP)

ifdef _KSDDK_
;define KSDDKAPI
else
;define KSDDKAPI DECLSPEC_IMPORT
endif

ifdef _NTDDK_

KsEnableEvent proto WINAPI :PIRP, :ULONG, :ptr KSEVENT_SET, :PLIST_ENTRY, :KSEVENTS_LOCKTYPE, :ptr
KsEnableEventWithAllocator proto WINAPI :PIRP, :ULONG, :ptr KSEVENT_SET, :PLIST_ENTRY, :KSEVENTS_LOCKTYPE, :ptr, :PFNKSALLOCATOR, :ULONG
KsDisableEvent proto WINAPI :PIRP, :PLIST_ENTRY, :KSEVENTS_LOCKTYPE, :ptr
KsDiscardEvent proto WINAPI :PKSEVENT_ENTRY
KsFreeEventList proto WINAPI :PFILE_OBJECT, :PLIST_ENTRY, :KSEVENTS_LOCKTYPE, :ptr
KsGenerateEvent proto WINAPI :PKSEVENT_ENTRY
KsGenerateDataEvent proto WINAPI :PKSEVENT_ENTRY, :ULONG, :ptr
KsGenerateEventList proto WINAPI :ptr, :ULONG, :PLIST_ENTRY, :KSEVENTS_LOCKTYPE, :ptr
KsPropertyHandler proto WINAPI :PIRP, :ULONG, :KSPROPERTY_SET
KsPropertyHandlerWithAllocator proto WINAPI :PIRP, :ULONG, :ptr, :PFNKSALLOCATOR, :ULONG
KsFastPropertyHandler proto WINAPI :PFILE_OBJECT, :PKSPROPERTY, :ULONG, :ptr, :ULONG, :PIO_STATUS_BLOCK, :ULONG, :ptr
KsMethodHandler proto WINAPI :PIRP, :ULONG, :ptr
KsMethodHandlerWithAllocator proto WINAPI :PIRP, :ULONG, :ptr, :PFNKSALLOCATOR, :ULONG
KsFastMethodHandler proto WINAPI :PFILE_OBJECT, :PKSMETHOD, :ULONG, :ptr, :ULONG, :PIO_STATUS_BLOCK, :ULONG, :ptr
KsCreateDefaultAllocator proto WINAPI :PIRP
KsCreateDefaultAllocatorEx proto WINAPI :PIRP, :ptr, :PFNKSDEFAULTALLOCATE, :PFNKSDEFAULTFREE, :PFNKSINITIALIZEALLOCATOR, :PFNKSDELETEALLOCATOR
KsCreateAllocator proto WINAPI :HANDLE, :PKSALLOCATOR_FRAMING, :PHANDLE
KsValidateAllocatorCreateRequest proto WINAPI :PIRP, :ptr
KsValidateAllocatorFramingEx proto WINAPI :PKSALLOCATOR_FRAMING_EX, :ULONG, :ptr
KsAllocateDefaultClock proto WINAPI :ptr
if (NTDDI_VERSION GE NTDDI_WINXP)
KsAllocateDefaultClockEx proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :ptr, :ULONG
endif
KsFreeDefaultClock proto WINAPI :PKSDEFAULTCLOCK
KsCreateDefaultClock proto WINAPI :PIRP, :PKSDEFAULTCLOCK
KsCreateClock proto WINAPI :HANDLE, :PKSCLOCK_CREATE, :PHANDLE
KsValidateClockCreateRequest proto WINAPI :PIRP, :ptr
KsGetDefaultClockState proto WINAPI :PKSDEFAULTCLOCK
KsSetDefaultClockState proto WINAPI :PKSDEFAULTCLOCK, :KSSTATE
KsGetDefaultClockTime proto WINAPI :PKSDEFAULTCLOCK
KsSetDefaultClockTime proto WINAPI :PKSDEFAULTCLOCK, :LONGLONG
KsCreatePin proto WINAPI :HANDLE, :PKSPIN_CONNECT, :ACCESS_MASK, :PHANDLE
KsValidateConnectRequest proto WINAPI :PIRP, :ULONG, :ptr, :ptr
KsPinPropertyHandler proto WINAPI :PIRP, :PKSPROPERTY, :ptr, :ULONG, :ptr
KsPinDataIntersection proto WINAPI :PIRP, :PKSP_PIN, :ptr, :ULONG, :ptr, :PFNKSINTERSECTHANDLER
KsPinDataIntersectionEx proto WINAPI :PIRP, :PKSP_PIN, :ptr, :ULONG, :ptr, :ULONG, :PFNKSINTERSECTHANDLEREX, :ptr
KsHandleSizedListQuery proto WINAPI :PIRP, :ULONG, :ULONG, :ptr

if ( NOT defined( MAKEINTRESOURCE ))
MAKEINTRESOURCE macro res
	exitm<(res)>
	endm
endif

ifndef RT_STRING
RT_STRING		equ MAKEINTRESOURCE( 6 )
RT_RCDATA		equ MAKEINTRESOURCE( 10 )
endif

KsLoadResource proto WINAPI :ptr, :POOL_TYPE, :ULONG_PTR, :ULONG, :ptr, :PULONG
KsGetImageNameAndResourceId proto WINAPI :HANDLE, :PUNICODE_STRING, :PULONG_PTR, :PULONG
KsMapModuleName proto WINAPI :PDEVICE_OBJECT, :PUNICODE_STRING, :PUNICODE_STRING, :PULONG_PTR, :PULONG
KsReferenceBusObject proto WINAPI :KSDEVICE_HEADER
KsDereferenceBusObject proto WINAPI :KSDEVICE_HEADER
KsDispatchQuerySecurity proto WINAPI :PDEVICE_OBJECT, :PIRP
KsDispatchSetSecurity proto WINAPI :PDEVICE_OBJECT, :PIRP
KsDispatchSpecificProperty proto WINAPI :PIRP, :PFNKSHANDLER
KsDispatchSpecificMethod proto WINAPI :PIRP, :PFNKSHANDLER
KsReadFile proto WINAPI :PFILE_OBJECT, :PKEVENT, :ptr, :PIO_STATUS_BLOCK, :ptr, :ULONG, :ULONG, :KPROCESSOR_MODE
KsWriteFile proto WINAPI :PFILE_OBJECT, :PKEVENT, :ptr, :PIO_STATUS_BLOCK, :ptr, :ULONG, :ULONG, :KPROCESSOR_MODE
KsQueryInformationFile proto WINAPI :PFILE_OBJECT, :ptr, :ULONG, :FILE_INFORMATION_CLASS
KsSetInformationFile proto WINAPI :PFILE_OBJECT, :ptr, :ULONG, :FILE_INFORMATION_CLASS
KsStreamIo proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :KSCOMPLETION_INVOCATION, :ptr, :ptr, :ULONG, :ULONG, :KPROCESSOR_MODE
KsProbeStreamIrp proto WINAPI :PIRP, :ULONG, :ULONG
KsAllocateExtraData proto WINAPI :PIRP, :ULONG, :ptr
KsNullDriverUnload proto WINAPI :PDRIVER_OBJECT
KsSetMajorFunctionHandler proto WINAPI :PDRIVER_OBJECT, :ULONG
KsDispatchInvalidDeviceRequest proto WINAPI :PDEVICE_OBJECT, :PIRP
KsDefaultDeviceIoCompletion proto WINAPI :PDEVICE_OBJECT, :PIRP
KsDispatchIrp proto WINAPI :PDEVICE_OBJECT, :PIRP
KsDispatchFastIoDeviceControlFailure proto WINAPI :ptr, :BOOLEAN, :ptr, :ULONG, :ptr, :ULONG, :ULONG, :ptr, :ptr
KsDispatchFastReadFailure proto WINAPI :ptr, :ptr, :ULONG, :BOOLEAN, :ULONG, :ptr, :ptr, :ptr

KsDispatchFastWriteFailure equ <KsDispatchFastReadFailure>

KsCancelIo proto WINAPI :PLIST_ENTRY, :PKSPIN_LOCK
KsReleaseIrpOnCancelableQueue proto WINAPI :PIRP, :PDRIVER_CANCEL
KsRemoveIrpFromCancelableQueue proto WINAPI :PLIST_ENTRY, :PKSPIN_LOCK, :KSLIST_ENTRY_LOCATION, :KSIRP_REMOVAL_OPERATION
KsMoveIrpsOnCancelableQueue proto WINAPI :ptr, :ptr, :ptr, :ptr, :KSLIST_ENTRY_LOCATION, :ptr, :ptr
KsRemoveSpecificIrpFromCancelableQueue proto WINAPI :PIRP
KsAddIrpToCancelableQueue proto WINAPI :PLIST_ENTRY, :PKSPIN_LOCK, :PIRP, :KSLIST_ENTRY_LOCATION, :PDRIVER_CANCEL
KsAcquireResetValue proto WINAPI :PIRP, :ptr KSRESET
KsTopologyPropertyHandler proto WINAPI :PIRP, :PKSPROPERTY, :ptr, :ptr KSTOPOLOGY
KsAcquireDeviceSecurityLock proto WINAPI :KSDEVICE_HEADER, :BOOLEAN
KsReleaseDeviceSecurityLock proto WINAPI :KSDEVICE_HEADER
KsSetDevicePnpAndBaseObject proto WINAPI :KSDEVICE_HEADER, :PDEVICE_OBJECT, :PDEVICE_OBJECT
KsQueryDevicePnpObject proto WINAPI :KSDEVICE_HEADER
KsQueryObjectAccessMask proto WINAPI :KSOBJECT_HEADER
KsRecalculateStackDepth proto WINAPI :KSDEVICE_HEADER, :BOOLEAN
KsSetTargetState proto WINAPI :KSOBJECT_HEADER, :KSTARGET_STATE
KsSetTargetDeviceObject proto WINAPI :KSOBJECT_HEADER, :PDEVICE_OBJECT
KsSetPowerDispatch proto WINAPI :KSOBJECT_HEADER, :PFNKSCONTEXT_DISPATCH, :ptr
KsQueryObjectCreateItem proto WINAPI :KSOBJECT_HEADER
KsAllocateDeviceHeader proto WINAPI :ptr KSDEVICE_HEADER, :ULONG, :PKSOBJECT_CREATE_ITEM
KsFreeDeviceHeader proto WINAPI :KSDEVICE_HEADER
KsAllocateObjectHeader proto WINAPI :ptr KSOBJECT_HEADER, :ULONG, :PKSOBJECT_CREATE_ITEM, :PIRP, :ptr KSDISPATCH_TABLE
KsFreeObjectHeader proto WINAPI :KSOBJECT_HEADER
KsAddObjectCreateItemToDeviceHeader proto WINAPI :KSDEVICE_HEADER, :PDRIVER_DISPATCH, :ptr, :PWSTR, :PSECURITY_DESCRIPTOR
KsAddObjectCreateItemToObjectHeader proto WINAPI :KSOBJECT_HEADER, :PDRIVER_DISPATCH, :ptr, :PWSTR, :PSECURITY_DESCRIPTOR
KsAllocateObjectCreateItem proto WINAPI :KSDEVICE_HEADER, :PKSOBJECT_CREATE_ITEM, :BOOLEAN, :PFNKSITEMFREECALLBACK
KsFreeObjectCreateItem proto WINAPI :KSDEVICE_HEADER, :PUNICODE_STRING
KsFreeObjectCreateItemsByContext proto WINAPI :KSDEVICE_HEADER, :ptr
KsCreateDefaultSecurity proto WINAPI :PSECURITY_DESCRIPTOR, :PSECURITY_DESCRIPTOR
KsForwardIrp proto WINAPI :PIRP, :PFILE_OBJECT, :BOOLEAN
KsForwardAndCatchIrp proto WINAPI :PDEVICE_OBJECT, :PIRP, :PFILE_OBJECT, :KSSTACK_USE
KsSynchronousIoControlDevice proto WINAPI :PFILE_OBJECT, :KPROCESSOR_MODE, :ULONG, :ptr, :LONG, :ptr, :ULONG, :PULONG
KsUnserializeObjectPropertiesFromRegistry proto WINAPI :PFILE_OBJECT, :HANDLE, :PUNICODE_STRING
if (NTDDI_VERSION GE NTDDI_WINXP)
KsCacheMedium proto WINAPI :PUNICODE_STRING, :PKSPIN_MEDIUM, :ULONG
endif
KsRegisterWorker proto WINAPI :WORK_QUEUE_TYPE, :ptr PKSWORKER
KsRegisterCountedWorker proto WINAPI :WORK_QUEUE_TYPE, :PWORK_QUEUE_ITEM, :ptr PKSWORKER
KsUnregisterWorker proto WINAPI :PKSWORKER
KsQueueWorkItem proto WINAPI :PKSWORKER, :PWORK_QUEUE_ITEM
KsIncrementCountedWorker proto WINAPI :PKSWORKER
KsDecrementCountedWorker proto WINAPI :PKSWORKER
KsCreateTopologyNode proto WINAPI :HANDLE, :PKSNODE_CREATE, :ACCESS_MASK, :PHANDLE
KsValidateTopologyNodeCreateRequest proto WINAPI :PIRP, :PKSTOPOLOGY, :ptr PKSNODE_CREATE

if (NTDDI_VERSION GE NTDDI_WINXP)
KsMergeAutomationTables proto WINAPI :ptr PKSAUTOMATION_TABLE, :PKSAUTOMATION_TABLE, :PKSAUTOMATION_TABLE, :KSOBJECT_BAG
KsInitializeDriver proto WINAPI :PDRIVER_OBJECT, :PUNICODE_STRING, :ptr KSDEVICE_DESCRIPTOR
KsAddDevice proto WINAPI :PDRIVER_OBJECT, :PDEVICE_OBJECT
KsCreateDevice proto WINAPI :PDRIVER_OBJECT, :PDEVICE_OBJECT, :ptr KSDEVICE_DESCRIPTOR, :ULONG, :ptr PKSDEVICE
KsInitializeDevice proto WINAPI :PDEVICE_OBJECT, :PDEVICE_OBJECT, :PDEVICE_OBJECT, :ptr KSDEVICE_DESCRIPTOR
KsTerminateDevice proto WINAPI :PDEVICE_OBJECT
KsGetDeviceForDeviceObject proto WINAPI :PDEVICE_OBJECT
KsAcquireDevice proto WINAPI :PKSDEVICE
KsReleaseDevice proto WINAPI :PKSDEVICE
KsDeviceRegisterAdapterObject proto WINAPI :PKSDEVICE, :PADAPTER_OBJECT, :ULONG, :ULONG
KsDeviceGetBusData proto WINAPI :PKSDEVICE, :ULONG, :ptr, :ULONG, :ULONG
KsDeviceSetBusData proto WINAPI :PKSDEVICE, :ULONG, :ptr, :ULONG, :ULONG
KsCreateFilterFactory proto WINAPI :ptr, :ptr, :PWSTR, :ptr, :ULONG, :ptr, :ptr, :ptr


KsDeleteFilterFactory macro FilterFactory
	exitm<>
	endm

KsFilterFactoryUpdateCacheData proto WINAPI :PKSFILTERFACTORY, :ptr KSFILTER_DESCRIPTOR
KsFilterFactoryAddCreateItem proto WINAPI :PKSFILTERFACTORY, :PWSTR, :PSECURITY_DESCRIPTOR, :ULONG
KsFilterFactorySetDeviceClassesState proto WINAPI :PKSFILTERFACTORY, :BOOLEAN
KsFilterFactoryGetSymbolicLink proto WINAPI :PKSFILTERFACTORY
KsAddEvent proto WINAPI :ptr, :PKSEVENT_ENTRY
KsFilterAddEvent proto WINAPI :PKSFILTER, :PKSEVENT_ENTRY
KsPinAddEvent proto WINAPI :PKSPIN, :PKSEVENT_ENTRY
KsDefaultAddEventHandler proto WINAPI :PIRP, :PKSEVENTDATA, :PKSEVENT_ENTRY
KsGenerateEvents proto WINAPI :ptr, :ptr, :ULONG, :ULONG, :ptr, :PFNKSGENERATEEVENTCALLBACK, :ptr
KsFilterGenerateEvents proto WINAPI :PKSFILTER, :ptr, :ULONG, :ULONG, :ptr, :ptr, :ptr
KsPinGenerateEvents proto WINAPI :PKSPIN, :ptr, :ULONG, :ULONG, :ptr, :ptr, :ptr

KSSTREAM_POINTER_STATE_UNLOCKED equ 0
KSSTREAM_POINTER_STATE_LOCKED equ 1

KsPinGetAvailableByteCount proto WINAPI :PKSPIN, :PLONG, :PLONG
KsPinGetLeadingEdgeStreamPointer proto WINAPI :PKSPIN, :KSSTREAM_POINTER_STATE
KsPinGetTrailingEdgeStreamPointer proto WINAPI :PKSPIN, :KSSTREAM_POINTER_STATE
KsStreamPointerSetStatusCode proto WINAPI :PKSSTREAM_POINTER, :NTSTATUS
KsStreamPointerLock proto WINAPI :PKSSTREAM_POINTER
KsStreamPointerUnlock proto WINAPI :PKSSTREAM_POINTER, :BOOLEAN
KsStreamPointerAdvanceOffsetsAndUnlock proto WINAPI :PKSSTREAM_POINTER, :ULONG, :ULONG, :BOOLEAN
KsStreamPointerDelete proto WINAPI :PKSSTREAM_POINTER
KsStreamPointerClone proto WINAPI :PKSSTREAM_POINTER, :PFNKSSTREAMPOINTER, :ULONG, :PKSSTREAM_POINTER
KsStreamPointerAdvanceOffsets proto WINAPI :PKSSTREAM_POINTER, :ULONG, :ULONG, :BOOLEAN
KsStreamPointerAdvance proto WINAPI :PKSSTREAM_POINTER
KsStreamPointerGetMdl proto WINAPI :PKSSTREAM_POINTER
KsStreamPointerGetIrp proto WINAPI :PKSSTREAM_POINTER, :PBOOLEAN, :PBOOLEAN
KsStreamPointerScheduleTimeout proto WINAPI :PKSSTREAM_POINTER, :PFNKSSTREAMPOINTER, :ULONGLONG
KsStreamPointerCancelTimeout proto WINAPI :PKSSTREAM_POINTER
KsPinGetFirstCloneStreamPointer proto WINAPI :PKSPIN
KsStreamPointerGetNextClone proto WINAPI :PKSSTREAM_POINTER
KsPinHandshake proto WINAPI :PKSPIN, :PKSHANDSHAKE, :PKSHANDSHAKE
KsCompletePendingRequest proto WINAPI :PIRP
KsGetObjectTypeFromIrp proto WINAPI :PIRP
KsGetObjectFromFileObject proto WINAPI :PFILE_OBJECT
KsGetObjectTypeFromFileObject proto WINAPI :PFILE_OBJECT
KsFilterGetAndGate proto WINAPI :PKSFILTER
KsFilterAcquireProcessingMutex proto WINAPI :PKSFILTER
KsFilterReleaseProcessingMutex proto WINAPI :PKSFILTER
KsFilterAttemptProcessing proto WINAPI :PKSFILTER, :BOOLEAN
KsPinGetAndGate proto WINAPI :PKSPIN
KsPinAttachAndGate proto WINAPI :PKSPIN, :PKSGATE
KsPinAttachOrGate proto WINAPI :PKSPIN, :PKSGATE
KsPinAcquireProcessingMutex proto WINAPI :PKSPIN
KsPinReleaseProcessingMutex proto WINAPI :PKSPIN
KsProcessPinUpdate proto WINAPI :PKSPROCESSPIN
KsPinGetCopyRelationships proto WINAPI :PKSPIN, :PKSPIN, :ptr PKSPIN
KsPinAttemptProcessing proto WINAPI :PKSPIN, :BOOLEAN
KsGetParent proto WINAPI :ptr
KsPinGetParentFilter proto WINAPI :PKSPIN
KsGetFirstChild proto WINAPI :ptr
KsFilterGetChildPinCount proto WINAPI :PKSFILTER, :ULONG
KsFilterGetFirstChildPin proto WINAPI :PKSFILTER, :ULONG
KsGetNextSibling proto WINAPI :ptr
KsPinGetNextSiblingPin proto WINAPI :PKSPIN
KsGetDevice proto WINAPI :ptr
KsGetFilterFromIrp proto WINAPI :PIRP
KsGetPinFromIrp proto WINAPI :PIRP
KsGetNodeIdFromIrp proto WINAPI :PIRP
KsAcquireControl proto WINAPI :ptr
KsReleaseControl proto WINAPI :ptr
KsAddItemToObjectBag proto WINAPI :KSOBJECT_BAG, :ptr, :PFNKSFREE
KsRemoveItemFromObjectBag proto WINAPI :KSOBJECT_BAG, :ptr, :BOOLEAN
KsAllocateObjectBag proto WINAPI :PKSDEVICE, :KSOBJECT_BAG
KsFreeObjectBag proto WINAPI :KSOBJECT_BAG
KsCopyObjectBagItems proto WINAPI :KSOBJECT_BAG, :KSOBJECT_BAG
_KsEdit proto WINAPI :KSOBJECT_BAG, :ptr, :ULONG, :ULONG, :ULONG

KsRegisterFilterWithNoKSPins proto WINAPI :ptr, :ptr, :ULONG, :ptr, :ptr, :ptr
KsFilterCreatePinFactory proto WINAPI :PKSFILTER, :ptr, :PULONG
KsFilterCreateNode proto WINAPI :PKSFILTER, :ptr, :PULONG
KsFilterAddTopologyConnections proto WINAPI :PKSFILTER, :ULONG, :ptr KSTOPOLOGY_CONNECTION
KsPinGetConnectedPinInterface proto WINAPI :PKSPIN, :ptr, :ptr
KsPinGetConnectedPinFileObject proto WINAPI :PKSPIN
KsPinGetConnectedPinDeviceObject proto WINAPI :PKSPIN
KsPinGetConnectedFilterInterface proto WINAPI :PKSPIN, :ptr, :ptr
ifdef __IUnknown_INTERFACE_DEFINED__
KsPinGetReferenceClockInterface proto WINAPI :PKSPIN, :ptr PIKSREFERENCECLOCK
endif
KsPinSetPinClockTime proto WINAPI :PKSPIN, :LONGLONG
KsPinSubmitFrame proto WINAPI :PKSPIN, :ptr, :ULONG, :PKSSTREAM_HEADER, :ptr
KsPinSubmitFrameMdl proto WINAPI :PKSPIN, :PMDL, :PKSSTREAM_HEADER, :ptr
KsPinRegisterFrameReturnCallback proto WINAPI :PKSPIN, :PFNKSPINFRAMERETURN
KsPinRegisterIrpCompletionCallback proto WINAPI :PKSPIN, :PFNKSPINIRPCOMPLETION
KsPinRegisterHandshakeCallback proto WINAPI :PKSPIN, :PFNKSPINHANDSHAKE
KsFilterRegisterPowerCallbacks proto WINAPI :PKSFILTER, :PFNKSFILTERPOWER, :PFNKSFILTERPOWER
KsPinRegisterPowerCallbacks proto WINAPI :PKSPIN, :PFNKSPINPOWER, :PFNKSPINPOWER
ifdef __IUnknown_INTERFACE_DEFINED__
KsRegisterAggregatedClientUnknown proto WINAPI :ptr, :PUNKNOWN
KsGetOuterUnknown proto WINAPI :ptr
endif
endif ;; (NTDDI_VERSION >= NTDDI_WINXP)
else  ;; !defined(_NTDDK_)

ifndef KS_NO_CREATE_FUNCTIONS
KsCreateAllocator proto WINAPI :HANDLE, :PKSALLOCATOR_FRAMING, :PHANDLE
KsCreateClock proto WINAPI :HANDLE, :PKSCLOCK_CREATE, :PHANDLE
KsCreatePin proto WINAPI :HANDLE, :PKSPIN_CONNECT, :ACCESS_MASK, :PHANDLE
KsCreateTopologyNode proto WINAPI :HANDLE, :PKSNODE_CREATE, :ACCESS_MASK, :PHANDLE
endif

endif ;; !defined(_NTDDK_)

endif

