Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1329 lines
40 KiB

  1. /*****************************************************************************
  2. * portclsp.h - WDM Streaming port class driver definitions for port drivers
  3. *****************************************************************************
  4. * Copyright (c) 1996-2000 Microsoft Corporation. All Rights Reserved.
  5. */
  6. #ifndef _PORTCLSP_H_
  7. #define _PORTCLSP_H_
  8. #include "kso.h"
  9. #define PC_NEW_NAMES
  10. #define PC_IMPLEMENTATION
  11. #include "portcls.h"
  12. #include "ksshellp.h"
  13. extern ULONG gBufferDuration;
  14. extern KAFFINITY gInterruptAffinity;
  15. #define WAVECYC_NOTIFICATION_FREQUENCY gBufferDuration
  16. #ifdef UNDER_NT
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. NTKERNELAPI
  21. ULONG
  22. KeGetRecommendedSharedDataAlignment (
  23. VOID
  24. );
  25. KAFFINITY
  26. KeQueryActiveProcessors (
  27. VOID
  28. );
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #else // UNDER_NT
  33. #define KeGetRecommendedSharedDataAlignment() 0x40
  34. #define KeQueryActiveProcessors() 1
  35. #endif
  36. PKSPIN_LOCK
  37. GetServiceGroupSpinLock (
  38. PSERVICEGROUP pServiceGroup
  39. );
  40. #ifndef _WIN64
  41. #define DRM_PORTCLS
  42. #endif
  43. #if DBG
  44. #define kEnableDebugLogging 1
  45. #endif
  46. #if kEnableDebugLogging
  47. #define kNumDebugLogEntries 256
  48. #define kNumULONG_PTRsPerEntry 4
  49. #define DebugLog PcDebugLog
  50. extern ULONG_PTR *gPcDebugLog;
  51. extern DWORD gPcDebugLogIndex;
  52. void PcDebugLog(ULONG_PTR param1,ULONG_PTR param2,ULONG_PTR param3,ULONG_PTR param4);
  53. #else // !kEnableDebugLogging
  54. #define DebugLog (void)
  55. #endif // !kEnableDebugLogging
  56. /*****************************************************************************
  57. * Structures.
  58. */
  59. /*****************************************************************************
  60. * PORT_DRIVER
  61. *****************************************************************************
  62. * This structure describes a port driver. This is just a hack until we get
  63. * real object servers running.
  64. * TODO: Create real object servers and put port drivers in 'em.
  65. */
  66. typedef struct
  67. {
  68. const GUID * ClassId;
  69. PFNCREATEINSTANCE Create;
  70. }
  71. PORT_DRIVER, *PPORT_DRIVER;
  72. /*****************************************************************************
  73. * Interface identifiers.
  74. */
  75. DEFINE_GUID(IID_ISubdevice,
  76. 0xb4c90a61, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  77. DEFINE_GUID(IID_IIrpStream,
  78. 0xb4c90a70, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  79. DEFINE_GUID(IID_IIrpStreamSubmit,
  80. 0xb4c90a71, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  81. DEFINE_GUID(IID_IIrpStreamVirtual,
  82. 0xb4c90a72, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  83. DEFINE_GUID(IID_IIrpStreamPhysical,
  84. 0xb4c90a73, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  85. DEFINE_GUID(IID_IIrpStreamNotify,
  86. 0xb4c90a74, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  87. DEFINE_GUID(IID_IIrpStreamNotifyPhysical,
  88. 0xb4c90a75, 0x5791, 0x11d0, 0x86, 0xf9, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  89. /*****************************************************************************
  90. * Types
  91. */
  92. /*****************************************************************************
  93. * PROPERTY_TABLE
  94. *****************************************************************************
  95. * Table of properties for KS consumption.
  96. */
  97. typedef struct
  98. {
  99. ULONG PropertySetCount;
  100. PKSPROPERTY_SET PropertySets;
  101. BOOLEAN StaticSets;
  102. PBOOLEAN StaticItems; // NULL means all item tables are static.
  103. }
  104. PROPERTY_TABLE, *PPROPERTY_TABLE;
  105. /*****************************************************************************
  106. * EVENT_TABLE
  107. *****************************************************************************
  108. * Table of events for KS consumption.
  109. */
  110. typedef struct
  111. {
  112. ULONG EventSetCount;
  113. PKSEVENT_SET EventSets;
  114. BOOLEAN StaticSets;
  115. PBOOLEAN StaticItems; // NULL means all item tables are static.
  116. }
  117. EVENT_TABLE, *PEVENT_TABLE;
  118. /*****************************************************************************
  119. * PIN_CINSTANCES
  120. *****************************************************************************
  121. * This structure stores instance information for a pin.
  122. */
  123. typedef struct
  124. {
  125. ULONG FilterPossible;
  126. ULONG FilterNecessary;
  127. ULONG GlobalPossible;
  128. ULONG GlobalCurrent;
  129. }
  130. PIN_CINSTANCES, *PPIN_CINSTANCES;
  131. /*****************************************************************************
  132. * SUBDEVICE_DESCRIPTOR
  133. *****************************************************************************
  134. * This structure describes a filter.
  135. */
  136. typedef struct
  137. {
  138. ULONG PinCount;
  139. PKSTOPOLOGY Topology;
  140. PKSPIN_DESCRIPTOR PinDescriptors;
  141. PPIN_CINSTANCES PinInstances;
  142. PROPERTY_TABLE FilterPropertyTable;
  143. PPROPERTY_TABLE PinPropertyTables;
  144. EVENT_TABLE FilterEventTable;
  145. PEVENT_TABLE PinEventTables;
  146. }
  147. SUBDEVICE_DESCRIPTOR, *PSUBDEVICE_DESCRIPTOR;
  148. /*****************************************************************************
  149. * PROPERTY_CONTEXT
  150. *****************************************************************************
  151. * Context for property handling.
  152. */
  153. typedef struct
  154. {
  155. struct ISubdevice * pSubdevice;
  156. PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor;
  157. PPCFILTER_DESCRIPTOR pPcFilterDescriptor;
  158. PUNKNOWN pUnknownMajorTarget;
  159. PUNKNOWN pUnknownMinorTarget;
  160. ULONG ulNodeId;
  161. PULONG pulPinInstanceCounts;
  162. }
  163. PROPERTY_CONTEXT, *PPROPERTY_CONTEXT;
  164. /*****************************************************************************
  165. * INTERLOCKED_LIST
  166. *****************************************************************************
  167. * A LIST_ENTRY with a SPIN_LOCK.
  168. */
  169. typedef struct
  170. {
  171. LIST_ENTRY List;
  172. KSPIN_LOCK ListLock;
  173. } INTERLOCKED_LIST, *PINTERLOCKED_LIST;
  174. /*****************************************************************************
  175. * EVENT_CONTEXT
  176. *****************************************************************************
  177. * Context for event handling.
  178. */
  179. typedef struct
  180. {
  181. PPROPERTY_CONTEXT pPropertyContext;
  182. PINTERLOCKED_LIST pEventList;
  183. ULONG ulPinId;
  184. ULONG ulEventSetCount;
  185. const KSEVENT_SET* pEventSets;
  186. } EVENT_CONTEXT, *PEVENT_CONTEXT;
  187. /*****************************************************************************
  188. * PCEVENT_ENTRY
  189. *****************************************************************************
  190. * An event entry with attached node and pin ids.
  191. */
  192. typedef struct
  193. {
  194. KSEVENT_ENTRY EventEntry;
  195. const PCEVENT_ITEM * EventItem;
  196. PUNKNOWN pUnknownMajorTarget;
  197. PUNKNOWN pUnknownMinorTarget;
  198. ULONG PinId;
  199. ULONG NodeId;
  200. } PCEVENT_ENTRY, *PPCEVENT_ENTRY;
  201. typedef struct
  202. {
  203. GUID* Set;
  204. ULONG EventId;
  205. BOOL PinEvent;
  206. ULONG PinId;
  207. BOOL NodeEvent;
  208. ULONG NodeId;
  209. BOOL ContextInUse;
  210. } EVENT_DPC_CONTEXT,*PEVENT_DPC_CONTEXT;
  211. /*****************************************************************************
  212. * IRPSTREAM_POSITION
  213. *****************************************************************************
  214. * Position descriptor for IrpStream.
  215. */
  216. typedef struct
  217. {
  218. ULONGLONG ullCurrentExtent; // Current Extent - Maximum stream position
  219. ULONGLONG ullMappingPosition; // Mapping Position - The current mapping position
  220. ULONGLONG ullUnmappingPosition; // Unmapping Position - The current unmapping position
  221. ULONGLONG ullStreamPosition; // Stream Position - The current stream position
  222. ULONGLONG ullStreamOffset; // Stream Base Position - The offset between stream and unmapping position
  223. ULONGLONG ullPhysicalOffset; // Physical Offset - Used by clock to adjust for starvation
  224. ULONG ulMappingPacketSize; // Size of current mapping packet
  225. ULONG ulMappingOffset; // Offset into mapping packet that is currently mapped
  226. ULONG ulUnmappingPacketSize; // Size of current unmapping packet
  227. ULONG ulUnmappingOffset; // Offset into unmapping packet that is currently unmapped
  228. BOOLEAN bLoopedInterface; // Pin interface is KSINTERFACE_STANDARD_LOOPED_STREAMING ?
  229. BOOLEAN bMappingPacketLooped; // Mapping packet is KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA ?
  230. BOOLEAN bUnmappingPacketLooped; // Unmapping packet is KSSTREAM_HEADER_OPTIONSF_LOOPEDDATA ?
  231. }
  232. IRPSTREAM_POSITION, *PIRPSTREAM_POSITION;
  233. /*****************************************************************************
  234. * Interfaces.
  235. */
  236. /*****************************************************************************
  237. * ISubdevice
  238. *****************************************************************************
  239. * Interface for subdevices.
  240. */
  241. #if !defined(DEFINE_ABSTRACT_SUBDEVICE)
  242. #define DEFINE_ABSTRACT_SUBDEVICE() \
  243. STDMETHOD_(void,ReleaseChildren) \
  244. ( THIS \
  245. ) PURE; \
  246. STDMETHOD_(NTSTATUS,GetDescriptor) \
  247. ( THIS_ \
  248. OUT const SUBDEVICE_DESCRIPTOR ** Descriptor \
  249. ) PURE; \
  250. STDMETHOD_(NTSTATUS,DataRangeIntersection) \
  251. ( THIS_ \
  252. IN ULONG PinId, \
  253. IN PKSDATARANGE DataRange, \
  254. IN PKSDATARANGE MatchingDataRange, \
  255. IN ULONG OutputBufferLength, \
  256. OUT PVOID ResultantFormat OPTIONAL, \
  257. OUT PULONG ResultantFormatLength \
  258. ) PURE; \
  259. STDMETHOD_(void,PowerChangeNotify) \
  260. ( THIS_ \
  261. IN POWER_STATE PowerState \
  262. ) PURE; \
  263. STDMETHOD_(void,PinCount) \
  264. ( THIS_ \
  265. IN ULONG PinId, \
  266. IN OUT PULONG FilterNecessary, \
  267. IN OUT PULONG FilterCurrent, \
  268. IN OUT PULONG FilterPossible, \
  269. IN OUT PULONG GlobalCurrent, \
  270. IN OUT PULONG GlobalPossible \
  271. ) PURE;
  272. #endif //!defined(DEFINE_ABSTRACT_SUBDEVICE)
  273. DECLARE_INTERFACE_(ISubdevice,IIrpTargetFactory)
  274. {
  275. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  276. DEFINE_ABSTRACT_IRPTARGETFACTORY() // For IIrpTargetFactory
  277. DEFINE_ABSTRACT_SUBDEVICE() // For ISubdevice
  278. };
  279. typedef ISubdevice *PSUBDEVICE;
  280. #define IMP_ISubdevice_\
  281. STDMETHODIMP_(void)\
  282. ReleaseChildren\
  283. ( void\
  284. );\
  285. STDMETHODIMP_(NTSTATUS)\
  286. GetDescriptor\
  287. ( OUT const SUBDEVICE_DESCRIPTOR ** Descriptor\
  288. );\
  289. STDMETHODIMP_(NTSTATUS)\
  290. DataRangeIntersection\
  291. ( IN ULONG PinId,\
  292. IN PKSDATARANGE DataRange,\
  293. IN PKSDATARANGE MatchingDataRange,\
  294. IN ULONG OutputBufferLength,\
  295. OUT PVOID ResultantFormat OPTIONAL,\
  296. OUT PULONG ResultantFormatLength\
  297. );\
  298. STDMETHODIMP_(void)\
  299. PowerChangeNotify\
  300. ( IN POWER_STATE PowerState\
  301. );\
  302. STDMETHODIMP_(void)\
  303. PinCount\
  304. ( IN ULONG PinId,\
  305. IN OUT PULONG FilterNecessary,\
  306. IN OUT PULONG FilterCurrent,\
  307. IN OUT PULONG FilterPossible,\
  308. IN OUT PULONG GlobalCurrent,\
  309. IN OUT PULONG GlobalPossible\
  310. )
  311. #define IMP_ISubdevice\
  312. IMP_IIrpTargetFactory;\
  313. IMP_ISubdevice_
  314. /*****************************************************************************
  315. * IIrpStreamNotify
  316. *****************************************************************************
  317. * Irp stream notification interface (IrpStream sources this).
  318. */
  319. DECLARE_INTERFACE_(IIrpStreamNotify,IUnknown)
  320. {
  321. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  322. STDMETHOD_(void,IrpSubmitted)
  323. ( THIS_
  324. IN PIRP Irp,
  325. IN BOOLEAN WasExhausted
  326. ) PURE;
  327. STDMETHOD_(NTSTATUS,GetPosition)
  328. ( THIS_
  329. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  330. ) PURE;
  331. };
  332. typedef IIrpStreamNotify *PIRPSTREAMNOTIFY;
  333. #define IMP_IIrpStreamNotify\
  334. STDMETHODIMP_(void)\
  335. IrpSubmitted\
  336. ( IN PIRP pIrp\
  337. , IN BOOLEAN bWasExhausted\
  338. );\
  339. STDMETHODIMP_(NTSTATUS)\
  340. GetPosition\
  341. ( IN OUT PIRPSTREAM_POSITION pIrpStreamPosition\
  342. )
  343. /*****************************************************************************
  344. * IIrpStreamNotifyPhysical
  345. *****************************************************************************
  346. * Irp stream notification interface (IrpStream sources this).
  347. */
  348. DECLARE_INTERFACE_(IIrpStreamNotifyPhysical,IIrpStreamNotify)
  349. {
  350. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  351. // For IIrpStreamNotify
  352. STDMETHOD_(void,IrpSubmitted)
  353. ( THIS_
  354. IN PIRP Irp,
  355. IN BOOLEAN WasExhausted
  356. ) PURE;
  357. STDMETHOD_(NTSTATUS,GetPosition)
  358. ( THIS_
  359. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  360. ) PURE;
  361. // For IIrpStreamNotifyPhysical
  362. STDMETHOD_(void,MappingsCancelled)
  363. ( THIS_
  364. IN PVOID FirstTag,
  365. IN PVOID LastTag,
  366. OUT PULONG MappingsCancelled
  367. ) PURE;
  368. };
  369. typedef IIrpStreamNotifyPhysical *PIRPSTREAMNOTIFYPHYSICAL;
  370. #define IMP_IIrpStreamNotifyPhysical_\
  371. STDMETHODIMP_(void)\
  372. MappingsCancelled\
  373. ( IN PVOID FirstTag\
  374. , IN PVOID LastTag\
  375. , OUT PULONG MappingsCancelled\
  376. )
  377. #define IMP_IIrpStreamNotifyPhysical\
  378. IMP_IIrpStreamNotify;\
  379. IMP_IIrpStreamNotifyPhysical_
  380. /*****************************************************************************
  381. * IIrpStreamSubmit
  382. *****************************************************************************
  383. * Irp stream submission interface.
  384. */
  385. DECLARE_INTERFACE_(IIrpStreamSubmit,IKsShellTransport)
  386. {
  387. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  388. // for IKsShellTransport
  389. STDMETHOD_(NTSTATUS,TransferKsIrp)(THIS_
  390. IN PIRP Irp,
  391. OUT PIKSSHELLTRANSPORT* NextTransport
  392. ) PURE;
  393. STDMETHOD_(void,Connect)(THIS_
  394. IN PIKSSHELLTRANSPORT NewTransport OPTIONAL,
  395. OUT PIKSSHELLTRANSPORT *OldTransport OPTIONAL,
  396. IN KSPIN_DATAFLOW DataFlow
  397. ) PURE;
  398. STDMETHOD_(NTSTATUS,SetDeviceState)(THIS_
  399. IN KSSTATE NewState,
  400. IN KSSTATE OldState,
  401. OUT PIKSSHELLTRANSPORT* NextTransport
  402. ) PURE;
  403. STDMETHOD_(void,SetResetState)(THIS_
  404. IN KSRESET ksReset,
  405. OUT PIKSSHELLTRANSPORT* NextTransport
  406. ) PURE;
  407. #if DBG
  408. STDMETHOD_(void,DbgRollCall)(THIS_
  409. IN ULONG NameMaxSize,
  410. OUT PCHAR Name,
  411. OUT PIKSSHELLTRANSPORT* NextTransport,
  412. OUT PIKSSHELLTRANSPORT* PrevTransport
  413. ) PURE;
  414. #endif
  415. // for IIrpStreamSubmit
  416. STDMETHOD_(NTSTATUS,GetPosition)
  417. ( THIS_
  418. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  419. ) PURE;
  420. };
  421. typedef IIrpStreamSubmit *PIRPSTREAMSUBMIT;
  422. #define IMP_IIrpStreamSubmit\
  423. IMP_IKsShellTransport;\
  424. STDMETHODIMP_(NTSTATUS)\
  425. GetPosition\
  426. ( IN OUT PIRPSTREAM_POSITION pIrpStreamPosition\
  427. )
  428. /*****************************************************************************
  429. * IRPSTREAMPACKETINFO
  430. *****************************************************************************
  431. * Structure for information regarding an IrpStream packet.
  432. */
  433. typedef struct
  434. {
  435. KSSTREAM_HEADER Header;
  436. ULONGLONG InputPosition;
  437. ULONGLONG OutputPosition;
  438. ULONG CurrentOffset;
  439. } IRPSTREAMPACKETINFO, *PIRPSTREAMPACKETINFO;
  440. /*****************************************************************************
  441. * IIrpStream
  442. *****************************************************************************
  443. * Irp stream primary interface.
  444. */
  445. DECLARE_INTERFACE_(IIrpStream,IIrpStreamSubmit)
  446. {
  447. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  448. // for IKsShellTransport
  449. STDMETHOD_(NTSTATUS,TransferKsIrp)(THIS_
  450. IN PIRP Irp,
  451. OUT PIKSSHELLTRANSPORT* NextTransport
  452. ) PURE;
  453. STDMETHOD_(void,Connect)(THIS_
  454. IN PIKSSHELLTRANSPORT NewTransport OPTIONAL,
  455. OUT PIKSSHELLTRANSPORT *OldTransport OPTIONAL,
  456. IN KSPIN_DATAFLOW DataFlow
  457. ) PURE;
  458. STDMETHOD_(NTSTATUS,SetDeviceState)(THIS_
  459. IN KSSTATE NewState,
  460. IN KSSTATE OldState,
  461. OUT PIKSSHELLTRANSPORT* NextTransport
  462. ) PURE;
  463. STDMETHOD_(void,SetResetState)(THIS_
  464. IN KSRESET ksReset,
  465. OUT PIKSSHELLTRANSPORT* NextTransport
  466. ) PURE;
  467. #if DBG
  468. STDMETHOD_(void,DbgRollCall)(THIS_
  469. IN ULONG NameMaxSize,
  470. OUT PCHAR Name,
  471. OUT PIKSSHELLTRANSPORT* NextTransport,
  472. OUT PIKSSHELLTRANSPORT* PrevTransport
  473. ) PURE;
  474. #endif
  475. // for IIrpStreamSubmit
  476. STDMETHOD_(NTSTATUS,GetPosition)
  477. ( THIS_
  478. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  479. ) PURE;
  480. // for IIrpStream
  481. STDMETHOD_(NTSTATUS,Init)
  482. ( THIS_
  483. IN BOOLEAN WriteOperation,
  484. IN PKSPIN_CONNECT PinConnect,
  485. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  486. IN PADAPTER_OBJECT AdapterObject OPTIONAL
  487. ) PURE;
  488. STDMETHOD_(void,CancelAllIrps)
  489. ( THIS_
  490. IN BOOL ClearPositionCounters
  491. ) PURE;
  492. STDMETHOD_(void,TerminatePacket)
  493. ( THIS
  494. ) PURE;
  495. STDMETHOD_(NTSTATUS,ChangeOptionsFlags)
  496. ( THIS_
  497. IN ULONG MappingOrMask,
  498. IN ULONG MappingAndMask,
  499. IN ULONG UnmappingOrMask,
  500. IN ULONG UnmappingAndMask
  501. ) PURE;
  502. STDMETHOD_(NTSTATUS,GetPacketInfo)
  503. ( THIS_
  504. OUT PIRPSTREAMPACKETINFO Mapping OPTIONAL,
  505. OUT PIRPSTREAMPACKETINFO Unmapping OPTIONAL
  506. ) PURE;
  507. STDMETHOD_(NTSTATUS,SetPacketOffsets)
  508. ( THIS_
  509. IN ULONG MappingOffset,
  510. IN ULONG UnmappingOffset
  511. ) PURE;
  512. };
  513. typedef IIrpStream *PIRPSTREAM;
  514. #define IMP_IIrpStream_\
  515. STDMETHODIMP_(NTSTATUS)\
  516. Init\
  517. ( IN BOOLEAN WriteOperation,\
  518. IN PKSPIN_CONNECT PinConnect,\
  519. IN PDEVICE_OBJECT DeviceObject OPTIONAL,\
  520. IN PADAPTER_OBJECT AdapterObject OPTIONAL\
  521. );\
  522. STDMETHODIMP_(void)\
  523. CancelAllIrps\
  524. ( IN BOOL ClearPositionCounters\
  525. );\
  526. STDMETHODIMP_(void)\
  527. TerminatePacket\
  528. ( void\
  529. );\
  530. STDMETHODIMP_(NTSTATUS)\
  531. ChangeOptionsFlags\
  532. ( IN ULONG MappingOrMask,\
  533. IN ULONG MappingAndMask,\
  534. IN ULONG UnmappingOrMask,\
  535. IN ULONG UnmappingAndMask\
  536. );\
  537. STDMETHODIMP_(NTSTATUS)\
  538. GetPacketInfo\
  539. ( OUT PIRPSTREAMPACKETINFO Mapping OPTIONAL,\
  540. OUT PIRPSTREAMPACKETINFO Unmapping OPTIONAL\
  541. );\
  542. STDMETHODIMP_(NTSTATUS)\
  543. SetPacketOffsets\
  544. ( IN ULONG MappingOffset,\
  545. IN ULONG UnmappingOffset\
  546. )
  547. #define IMP_IIrpStream\
  548. IMP_IIrpStreamSubmit;\
  549. IMP_IIrpStream_
  550. /*****************************************************************************
  551. * IIrpStreamVirtual
  552. *****************************************************************************
  553. * Irp stream virtual mapping interface.
  554. */
  555. DECLARE_INTERFACE_(IIrpStreamVirtual,IIrpStream)
  556. {
  557. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  558. // for IKsShellTransport
  559. STDMETHOD_(NTSTATUS,TransferKsIrp)(THIS_
  560. IN PIRP Irp,
  561. OUT PIKSSHELLTRANSPORT* NextTransport
  562. ) PURE;
  563. STDMETHOD_(void,Connect)(THIS_
  564. IN PIKSSHELLTRANSPORT NewTransport OPTIONAL,
  565. OUT PIKSSHELLTRANSPORT *OldTransport OPTIONAL,
  566. IN KSPIN_DATAFLOW DataFlow
  567. ) PURE;
  568. STDMETHOD_(NTSTATUS,SetDeviceState)(THIS_
  569. IN KSSTATE NewState,
  570. IN KSSTATE OldState,
  571. OUT PIKSSHELLTRANSPORT* NextTransport
  572. ) PURE;
  573. STDMETHOD_(void,SetResetState)(THIS_
  574. IN KSRESET ksReset,
  575. OUT PIKSSHELLTRANSPORT* NextTransport
  576. ) PURE;
  577. #if DBG
  578. STDMETHOD_(void,DbgRollCall)(THIS_
  579. IN ULONG NameMaxSize,
  580. OUT PCHAR Name,
  581. OUT PIKSSHELLTRANSPORT* NextTransport,
  582. OUT PIKSSHELLTRANSPORT* PrevTransport
  583. ) PURE;
  584. #endif
  585. // for IIrpStreamSubmit
  586. STDMETHOD_(NTSTATUS,GetPosition)
  587. ( THIS_
  588. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  589. ) PURE;
  590. // for IIrpStream
  591. STDMETHOD_(NTSTATUS,Init)
  592. ( THIS_
  593. IN BOOLEAN WriteOperation,
  594. IN PKSPIN_CONNECT PinConnect,
  595. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  596. IN PADAPTER_OBJECT AdapterObject OPTIONAL
  597. ) PURE;
  598. STDMETHOD_(void,CancelAllIrps)
  599. ( THIS_
  600. IN BOOL ClearPositionCounters
  601. ) PURE;
  602. STDMETHOD_(void,TerminatePacket)
  603. ( THIS
  604. ) PURE;
  605. STDMETHOD_(NTSTATUS,ChangeOptionsFlags)
  606. ( THIS_
  607. IN ULONG MappingOrMask,
  608. IN ULONG MappingAndMask,
  609. IN ULONG UnmappingOrMask,
  610. IN ULONG UnmappingAndMask
  611. ) PURE;
  612. STDMETHOD_(NTSTATUS,GetPacketInfo)
  613. ( THIS_
  614. OUT PIRPSTREAMPACKETINFO Mapping OPTIONAL,
  615. OUT PIRPSTREAMPACKETINFO Unmapping OPTIONAL
  616. ) PURE;
  617. STDMETHOD_(NTSTATUS,SetPacketOffsets)
  618. ( THIS_
  619. IN ULONG MappingOffset,
  620. IN ULONG UnmappingOffset
  621. ) PURE;
  622. // For IIrpStreamVirtual
  623. STDMETHOD_(void,RegisterNotifySink)
  624. ( THIS_
  625. IN PIRPSTREAMNOTIFY NotificationSink OPTIONAL
  626. ) PURE;
  627. STDMETHOD_(void,GetLockedRegion)
  628. ( THIS_
  629. OUT PULONG ByteCount,
  630. OUT PVOID * SystemAddress
  631. ) PURE;
  632. STDMETHOD_(void,ReleaseLockedRegion)
  633. ( THIS_
  634. IN ULONG ByteCount
  635. ) PURE;
  636. STDMETHOD_(void,Copy)
  637. ( THIS_
  638. IN BOOLEAN WriteOperation,
  639. IN ULONG RequestedSize,
  640. OUT PULONG ActualSize,
  641. IN OUT PVOID Buffer
  642. ) PURE;
  643. STDMETHOD_(void,Complete)
  644. ( THIS_
  645. IN ULONG RequestedSize,
  646. OUT PULONG ActualSize
  647. ) PURE;
  648. STDMETHOD_(PKSPIN_LOCK,GetIrpStreamPositionLock)
  649. ( THIS
  650. ) PURE;
  651. };
  652. typedef IIrpStreamVirtual *PIRPSTREAMVIRTUAL;
  653. #define IMP_IIrpStreamVirtual_\
  654. STDMETHODIMP_(void)\
  655. RegisterNotifySink\
  656. ( IN PIRPSTREAMNOTIFY NotificationSink OPTIONAL\
  657. );\
  658. STDMETHODIMP_(void)\
  659. GetLockedRegion\
  660. ( OUT PULONG ByteCount,\
  661. OUT PVOID * SystemAddress\
  662. );\
  663. STDMETHODIMP_(void)\
  664. ReleaseLockedRegion\
  665. ( IN ULONG ByteCount\
  666. );\
  667. STDMETHODIMP_(void)\
  668. Copy\
  669. ( IN BOOLEAN WriteOperation,\
  670. IN ULONG RequestedSize,\
  671. OUT PULONG ActualSize,\
  672. IN OUT PVOID Buffer\
  673. );\
  674. STDMETHODIMP_(void)\
  675. Complete\
  676. ( IN ULONG RequestedSize,\
  677. OUT PULONG ActualSize\
  678. );\
  679. STDMETHODIMP_(PKSPIN_LOCK)\
  680. GetIrpStreamPositionLock\
  681. (\
  682. )
  683. #define IMP_IIrpStreamVirtual\
  684. IMP_IIrpStream;\
  685. IMP_IIrpStreamVirtual_
  686. /*****************************************************************************
  687. * IIrpStreamPhysical
  688. *****************************************************************************
  689. * Irp stream physical mapping interface.
  690. */
  691. DECLARE_INTERFACE_(IIrpStreamPhysical,IIrpStream)
  692. {
  693. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  694. // for IKsShellTransport
  695. STDMETHOD_(NTSTATUS,TransferKsIrp)(THIS_
  696. IN PIRP Irp,
  697. OUT PIKSSHELLTRANSPORT* NextTransport
  698. ) PURE;
  699. STDMETHOD_(void,Connect)(THIS_
  700. IN PIKSSHELLTRANSPORT NewTransport OPTIONAL,
  701. OUT PIKSSHELLTRANSPORT *OldTransport OPTIONAL,
  702. IN KSPIN_DATAFLOW DataFlow
  703. ) PURE;
  704. STDMETHOD_(NTSTATUS,SetDeviceState)(THIS_
  705. IN KSSTATE NewState,
  706. IN KSSTATE OldState,
  707. OUT PIKSSHELLTRANSPORT* NextTransport
  708. ) PURE;
  709. STDMETHOD_(void,SetResetState)(THIS_
  710. IN KSRESET ksReset,
  711. OUT PIKSSHELLTRANSPORT* NextTransport
  712. ) PURE;
  713. #if DBG
  714. STDMETHOD_(void,DbgRollCall)(THIS_
  715. IN ULONG NameMaxSize,
  716. OUT PCHAR Name,
  717. OUT PIKSSHELLTRANSPORT* NextTransport,
  718. OUT PIKSSHELLTRANSPORT* PrevTransport
  719. ) PURE;
  720. #endif
  721. // for IIrpStreamSubmit
  722. STDMETHOD_(NTSTATUS,GetPosition)
  723. ( THIS_
  724. IN OUT PIRPSTREAM_POSITION pIrpStreamPosition
  725. ) PURE;
  726. // for IIrpStream
  727. STDMETHOD_(NTSTATUS,Init)
  728. ( THIS_
  729. IN BOOLEAN WriteOperation,
  730. IN PKSPIN_CONNECT PinConnect,
  731. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  732. IN PADAPTER_OBJECT AdapterObject OPTIONAL
  733. ) PURE;
  734. STDMETHOD_(void,CancelAllIrps)
  735. ( THIS_
  736. IN BOOL ClearPositionCounters
  737. ) PURE;
  738. STDMETHOD_(void,TerminatePacket)
  739. ( THIS
  740. ) PURE;
  741. STDMETHOD_(NTSTATUS,ChangeOptionsFlags)
  742. ( THIS_
  743. IN ULONG MappingOrMask,
  744. IN ULONG MappingAndMask,
  745. IN ULONG UnmappingOrMask,
  746. IN ULONG UnmappingAndMask
  747. ) PURE;
  748. STDMETHOD_(NTSTATUS,GetPacketInfo)
  749. ( THIS_
  750. OUT PIRPSTREAMPACKETINFO Mapping OPTIONAL,
  751. OUT PIRPSTREAMPACKETINFO Unmapping OPTIONAL
  752. ) PURE;
  753. STDMETHOD_(NTSTATUS,SetPacketOffsets)
  754. ( THIS_
  755. IN ULONG MappingOffset,
  756. IN ULONG UnmappingOffset
  757. ) PURE;
  758. // For IIrpStreamPhysical
  759. STDMETHOD_(void,RegisterPhysicalNotifySink)
  760. ( THIS_
  761. IN PIRPSTREAMNOTIFYPHYSICAL NotificationSink OPTIONAL
  762. ) PURE;
  763. STDMETHOD_(void,GetMapping)
  764. ( THIS_
  765. IN PVOID Tag,
  766. OUT PPHYSICAL_ADDRESS PhysicalAddress,
  767. OUT PVOID * VirtualAddress,
  768. OUT PULONG ByteCount,
  769. OUT PULONG Flags
  770. #define MAPPING_FLAG_END_OF_PACKET 0x00000001
  771. ) PURE;
  772. STDMETHOD_(void,ReleaseMapping)
  773. ( THIS_
  774. IN PVOID Tag
  775. ) PURE;
  776. };
  777. typedef IIrpStreamPhysical *PIRPSTREAMPHYSICAL;
  778. #define IMP_IIrpStreamPhysical_\
  779. STDMETHODIMP_(void)\
  780. RegisterPhysicalNotifySink\
  781. ( IN PIRPSTREAMNOTIFYPHYSICAL NotificationSink OPTIONAL\
  782. );\
  783. STDMETHODIMP_(void)\
  784. GetMapping\
  785. ( IN PVOID Tag,\
  786. OUT PPHYSICAL_ADDRESS PhysicalAddress,\
  787. OUT PVOID * VirtualAddress,\
  788. OUT PULONG ByteCount,\
  789. OUT PULONG Flags\
  790. );\
  791. STDMETHODIMP_(void)\
  792. ReleaseMapping\
  793. ( IN PVOID Tag\
  794. )
  795. #define IMP_IIrpStreamPhysical\
  796. IMP_IIrpStream;\
  797. IMP_IIrpStreamPhysical_
  798. #define IMP_IPortClsVersion \
  799. STDMETHODIMP_(DWORD) GetVersion() { return kVersionWinXPServer; };
  800. /*****************************************************************************
  801. * PcCreateSubdeviceDescriptor()
  802. *****************************************************************************
  803. * Creates a subdevice descriptor.
  804. */
  805. PORTCLASSAPI
  806. NTSTATUS
  807. NTAPI
  808. PcCreateSubdeviceDescriptor
  809. (
  810. IN PPCFILTER_DESCRIPTOR FilterDescriptor,
  811. IN ULONG CategoriesCount,
  812. IN GUID * Categories,
  813. IN ULONG StreamInterfacesCount,
  814. IN PKSPIN_INTERFACE StreamInterfaces,
  815. IN ULONG FilterPropertySetCount,
  816. IN PKSPROPERTY_SET FilterPropertySets,
  817. IN ULONG FilterEventSetCount,
  818. IN PKSEVENT_SET FilterEventSets,
  819. IN ULONG PinPropertySetCount,
  820. IN PKSPROPERTY_SET PinPropertySets,
  821. IN ULONG PinEventSetCount,
  822. IN PKSEVENT_SET PinEventSets,
  823. OUT PSUBDEVICE_DESCRIPTOR * OutDescriptor
  824. );
  825. /*****************************************************************************
  826. * PcDeleteSubdeviceDescriptor()
  827. *****************************************************************************
  828. * Deletes a subdevice descriptor.
  829. */
  830. PORTCLASSAPI
  831. void
  832. NTAPI
  833. PcDeleteSubdeviceDescriptor
  834. (
  835. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor
  836. );
  837. /*****************************************************************************
  838. * PcValidateConnectRequest()
  839. *****************************************************************************
  840. * Validate attempt to create a pin.
  841. */
  842. PORTCLASSAPI
  843. NTSTATUS
  844. NTAPI
  845. PcValidateConnectRequest
  846. (
  847. IN PIRP pIrp,
  848. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  849. OUT PKSPIN_CONNECT * ppKsPinConnect
  850. );
  851. /*****************************************************************************
  852. * PcValidatePinCount()
  853. *****************************************************************************
  854. * Validate pin count.
  855. */
  856. PORTCLASSAPI
  857. NTSTATUS
  858. NTAPI
  859. PcValidatePinCount
  860. ( IN ULONG ulPinId,
  861. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  862. IN PULONG pulPinInstanceCounts
  863. );
  864. /*****************************************************************************
  865. * PcTerminateConnection()
  866. *****************************************************************************
  867. * Decrement instance counts associated with a pin.
  868. */
  869. PORTCLASSAPI
  870. void
  871. NTAPI
  872. PcTerminateConnection
  873. (
  874. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  875. IN PULONG pulPinInstanceCounts,
  876. IN ULONG ulPinId
  877. );
  878. /*****************************************************************************
  879. * PcVerifyFilterIsReady()
  880. *****************************************************************************
  881. * Verify necessary pins are connected.
  882. */
  883. PORTCLASSAPI
  884. NTSTATUS
  885. NTAPI
  886. PcVerifyFilterIsReady
  887. (
  888. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  889. IN PULONG pulPinInstanceCounts
  890. );
  891. /*****************************************************************************
  892. * PcAddToPropertyTable()
  893. *****************************************************************************
  894. * Adds a PROPERTYITEM property table to a PROPERTY_TABLE structure.
  895. */
  896. PORTCLASSAPI
  897. NTSTATUS
  898. NTAPI
  899. PcAddToPropertyTable
  900. (
  901. IN OUT PPROPERTY_TABLE PropertyTable,
  902. IN ULONG PropertyItemCount,
  903. IN const PCPROPERTY_ITEM * PropertyItems,
  904. IN ULONG PropertyItemSize,
  905. IN BOOLEAN NodeTable
  906. );
  907. /*****************************************************************************
  908. * PcFreePropertyTable()
  909. *****************************************************************************
  910. * Frees allocated memory in a PROPERTY_TABLE structure.
  911. */
  912. PORTCLASSAPI
  913. void
  914. NTAPI
  915. PcFreePropertyTable
  916. (
  917. IN PPROPERTY_TABLE PropertyTable
  918. );
  919. /*****************************************************************************
  920. * PcHandlePropertyWithTable()
  921. *****************************************************************************
  922. * Uses a property table to handle a property request IOCTL.
  923. */
  924. PORTCLASSAPI
  925. NTSTATUS
  926. NTAPI
  927. PcHandlePropertyWithTable
  928. (
  929. IN PIRP pIrp,
  930. IN ULONG ulPropertySetsCount,
  931. IN const KSPROPERTY_SET* pKsPropertySet,
  932. IN PPROPERTY_CONTEXT pPropertyContext
  933. );
  934. /*****************************************************************************
  935. * PcPinPropertyHandler()
  936. *****************************************************************************
  937. * Property handler for pin properties on the filter.
  938. */
  939. PORTCLASSAPI
  940. NTSTATUS
  941. NTAPI
  942. PcPinPropertyHandler
  943. (
  944. IN PIRP pIrp,
  945. IN PKSP_PIN pKsPPin,
  946. IN OUT PVOID pvData
  947. );
  948. /*****************************************************************************
  949. * PcAddToEventTable()
  950. *****************************************************************************
  951. * Adds a EVENTITEM event table to an EVENT_TABLE structure.
  952. */
  953. PORTCLASSAPI
  954. NTSTATUS
  955. NTAPI
  956. PcAddToEventTable
  957. (
  958. IN OUT PEVENT_TABLE EventTable,
  959. IN ULONG EventItemCount,
  960. IN const PCEVENT_ITEM * EventItems,
  961. IN ULONG EventItemSize,
  962. IN BOOLEAN NodeTable
  963. );
  964. /*****************************************************************************
  965. * PcFreeEventTable()
  966. *****************************************************************************
  967. * Frees allocated memory in an EVENT_TABLE structure.
  968. */
  969. PORTCLASSAPI
  970. void
  971. NTAPI
  972. PcFreeEventTable
  973. (
  974. IN PEVENT_TABLE EventTable
  975. );
  976. /*****************************************************************************
  977. * PcHandleEnableEventWithTable()
  978. *****************************************************************************
  979. * Uses an event table to handle a KS enable event IOCTL.
  980. */
  981. PORTCLASSAPI
  982. NTSTATUS
  983. NTAPI
  984. PcHandleEnableEventWithTable
  985. (
  986. IN PIRP pIrp,
  987. IN PEVENT_CONTEXT pContext
  988. );
  989. /*****************************************************************************
  990. * PcHandleDisableEventWithTable()
  991. *****************************************************************************
  992. * Uses an event table to handle a KS disable event IOCTL.
  993. */
  994. PORTCLASSAPI
  995. NTSTATUS
  996. NTAPI
  997. PcHandleDisableEventWithTable
  998. (
  999. IN PIRP pIrp,
  1000. IN PEVENT_CONTEXT pContext
  1001. );
  1002. /*****************************************************************************
  1003. * PcGenerateEventList()
  1004. *****************************************************************************
  1005. * Walks an event list and generates desired events.
  1006. */
  1007. PORTCLASSAPI
  1008. void
  1009. NTAPI
  1010. PcGenerateEventList
  1011. (
  1012. IN PINTERLOCKED_LIST EventList,
  1013. IN GUID* Set OPTIONAL,
  1014. IN ULONG EventId,
  1015. IN BOOL PinEvent,
  1016. IN ULONG PinId,
  1017. IN BOOL NodeEvent,
  1018. IN ULONG NodeId
  1019. );
  1020. /*****************************************************************************
  1021. * PcGenerateEventDeferredRoutine()
  1022. *****************************************************************************
  1023. * This DPC routine is used when GenerateEventList is called at greater
  1024. * that DISPATCH_LEVEL.
  1025. */
  1026. PORTCLASSAPI
  1027. void
  1028. NTAPI
  1029. PcGenerateEventDeferredRoutine
  1030. (
  1031. IN PKDPC Dpc,
  1032. IN PVOID DeferredContext, // PEVENT_DPC_CONTEXT
  1033. IN PVOID SystemArgument1, // PINTERLOCKED_LIST
  1034. IN PVOID SystemArgument2
  1035. );
  1036. /*****************************************************************************
  1037. * PcNewIrpStreamVirtual()
  1038. *****************************************************************************
  1039. * Creates and initializes an IrpStream object with a virtual access
  1040. * interface.
  1041. */
  1042. PORTCLASSAPI
  1043. NTSTATUS
  1044. NTAPI
  1045. PcNewIrpStreamVirtual
  1046. (
  1047. OUT PIRPSTREAMVIRTUAL * OutIrpStreamVirtual,
  1048. IN PUNKNOWN OuterUnknown OPTIONAL,
  1049. IN BOOLEAN WriteOperation,
  1050. IN PKSPIN_CONNECT PinConnect,
  1051. IN PDEVICE_OBJECT DeviceObject
  1052. );
  1053. /*****************************************************************************
  1054. * PcNewIrpStreamPhysical()
  1055. *****************************************************************************
  1056. * Creates and initializes an IrpStream object with a physical access
  1057. * interface.
  1058. */
  1059. PORTCLASSAPI
  1060. NTSTATUS
  1061. NTAPI
  1062. PcNewIrpStreamPhysical
  1063. (
  1064. OUT PIRPSTREAMPHYSICAL * OutIrpStreamPhysical,
  1065. IN PUNKNOWN OuterUnknown OPTIONAL,
  1066. IN BOOLEAN WriteOperation,
  1067. IN PKSPIN_CONNECT PinConnect,
  1068. IN PDEVICE_OBJECT DeviceObject,
  1069. IN PADAPTER_OBJECT AdapterObject
  1070. );
  1071. /*****************************************************************************
  1072. * PcDmaSlaveDescription()
  1073. *****************************************************************************
  1074. * Fills in a DMA device description for a slave device based on a resource.
  1075. */
  1076. PORTCLASSAPI
  1077. NTSTATUS
  1078. NTAPI
  1079. PcDmaSlaveDescription
  1080. (
  1081. IN PRESOURCELIST ResourceList,
  1082. IN ULONG ResourceIndex,
  1083. IN BOOLEAN DemandMode,
  1084. IN BOOLEAN AutoInitialize,
  1085. IN DMA_SPEED DmaSpeed,
  1086. IN ULONG MaximumLength,
  1087. IN ULONG DmaPort,
  1088. OUT PDEVICE_DESCRIPTION DeviceDescription
  1089. );
  1090. /*****************************************************************************
  1091. * PcDmaMasterDescription()
  1092. *****************************************************************************
  1093. * Fills in a DMA device description for a master device based on a resource
  1094. * list.
  1095. */
  1096. PORTCLASSAPI
  1097. void
  1098. NTAPI
  1099. PcDmaMasterDescription
  1100. (
  1101. IN PRESOURCELIST ResourceList OPTIONAL,
  1102. IN BOOLEAN ScatterGather,
  1103. IN BOOLEAN Dma32BitAddresses,
  1104. IN BOOLEAN IgnoreCount,
  1105. IN BOOLEAN Dma64BitAddresses,
  1106. IN DMA_WIDTH DmaWidth,
  1107. IN DMA_SPEED DmaSpeed,
  1108. IN ULONG MaximumLength,
  1109. IN ULONG DmaPort,
  1110. OUT PDEVICE_DESCRIPTION DeviceDescription
  1111. );
  1112. /*****************************************************************************
  1113. * PcCaptureFormat()
  1114. *****************************************************************************
  1115. * Capture a data format in an allocated buffer, possibly changing offensive
  1116. * formats.
  1117. */
  1118. PORTCLASSAPI
  1119. NTSTATUS
  1120. NTAPI
  1121. PcCaptureFormat
  1122. (
  1123. OUT PKSDATAFORMAT * ppKsDataFormatOut,
  1124. IN PKSDATAFORMAT pKsDataFormatIn,
  1125. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  1126. IN ULONG ulPinId
  1127. );
  1128. /*****************************************************************************
  1129. * PcAcquireFormatResources()
  1130. *****************************************************************************
  1131. * Acquire resources specified in a format.
  1132. */
  1133. PORTCLASSAPI
  1134. void
  1135. NTAPI
  1136. PcAcquireFormatResources
  1137. (
  1138. IN PKSDATAFORMAT pKsDataFormatIn,
  1139. IN PSUBDEVICE_DESCRIPTOR pSubdeviceDescriptor,
  1140. IN ULONG ulPinId,
  1141. IN PPROPERTY_CONTEXT pPropertyContext
  1142. );
  1143. NTSTATUS
  1144. KspShellCreateRequestor(
  1145. OUT PIKSSHELLTRANSPORT* TransportInterface,
  1146. IN ULONG ProbeFlags,
  1147. IN ULONG StreamHeaderSize OPTIONAL,
  1148. IN ULONG FrameSize,
  1149. IN ULONG FrameCount,
  1150. IN PDEVICE_OBJECT NextDeviceObject,
  1151. IN PFILE_OBJECT AllocatorFileObject OPTIONAL
  1152. );
  1153. #endif