1 /* 2 PortCls FDO Extension 3 4 by Andrew Greenwood 5 */ 6 7 #ifndef PORTCLS_PRIVATE_H 8 #define PORTCLS_PRIVATE_H 9 10 #include <stdio.h> 11 12 //#define _KS_NO_ANONYMOUS_STRUCTURES_ 13 #define PC_IMPLEMENTATION 14 #define COM_STDMETHOD_CAN_THROW 15 #define PC_NO_IMPORTS 16 17 #include <ntddk.h> 18 #include <portcls.h> 19 #include <dmusicks.h> 20 #include <kcom.h> 21 22 #include "interfaces.hpp" 23 24 #define TAG_PORTCLASS 'SLCP' 25 26 #define PC_ASSERT(exp) \ 27 (VOID)((!(exp)) ? \ 28 RtlAssert((PVOID) #exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) 29 30 #define PC_ASSERT_IRQL(x) PC_ASSERT(KeGetCurrentIrql() <= (x)) 31 #define PC_ASSERT_IRQL_EQUAL(x) PC_ASSERT(KeGetCurrentIrql()==(x)) 32 33 extern 34 "C" 35 NTSTATUS 36 NTAPI 37 PortClsCreate( 38 IN PDEVICE_OBJECT DeviceObject, 39 IN PIRP Irp); 40 41 extern 42 "C" 43 NTSTATUS 44 NTAPI 45 PortClsPnp( 46 IN PDEVICE_OBJECT DeviceObject, 47 IN PIRP Irp); 48 49 extern 50 "C" 51 NTSTATUS 52 NTAPI 53 PortClsPower( 54 IN PDEVICE_OBJECT DeviceObject, 55 IN PIRP Irp); 56 57 extern 58 "C" 59 NTSTATUS 60 NTAPI 61 PortClsSysControl( 62 IN PDEVICE_OBJECT DeviceObject, 63 IN PIRP Irp); 64 65 NTSTATUS 66 NewMiniportDMusUART( 67 OUT PMINIPORT* OutMiniport, 68 IN REFCLSID ClassId); 69 70 NTSTATUS 71 NewMiniportFmSynth( 72 OUT PMINIPORT* OutMiniport, 73 IN REFCLSID ClassId); 74 75 NTSTATUS 76 NewPortDMus( 77 OUT PPORT* OutPort); 78 79 NTSTATUS 80 NewPortTopology( 81 OUT PPORT* OutPort); 82 83 NTSTATUS 84 NewPortWaveCyclic( 85 OUT PPORT* OutPort); 86 87 NTSTATUS 88 NewPortWavePci( 89 OUT PPORT* OutPort); 90 91 NTSTATUS 92 NewIDrmPort( 93 OUT PDRMPORT2 *OutPort); 94 95 NTSTATUS 96 NewPortClsVersion( 97 OUT PPORTCLSVERSION * OutVersion); 98 99 NTSTATUS 100 NewPortFilterWaveCyclic( 101 OUT IPortFilterWaveCyclic ** OutFilter); 102 103 NTSTATUS 104 NewPortPinWaveCyclic( 105 OUT IPortPinWaveCyclic ** OutPin); 106 107 NTSTATUS 108 NewPortFilterWavePci( 109 OUT IPortFilterWavePci ** OutFilter); 110 111 NTSTATUS 112 NewPortPinWavePci( 113 OUT IPortPinWavePci ** OutPin); 114 115 PDEVICE_OBJECT 116 GetDeviceObjectFromWaveCyclic( 117 IPortWavePci* iface); 118 119 PDEVICE_OBJECT 120 GetDeviceObjectFromPortWavePci( 121 IPortWavePci* iface); 122 123 PMINIPORTWAVEPCI 124 GetWavePciMiniport( 125 PPORTWAVEPCI Port); 126 127 128 NTSTATUS 129 NewPortFilterDMus( 130 OUT PPORTFILTERDMUS * OutFilter); 131 132 133 NTSTATUS 134 NewPortPinDMus( 135 OUT PPORTPINDMUS * OutPin); 136 137 VOID 138 GetDMusMiniport( 139 IN IPortDMus * iface, 140 IN PMINIPORTDMUS * Miniport, 141 IN PMINIPORTMIDI * MidiMiniport); 142 143 #if (NTDDI_VERSION >= NTDDI_VISTA) 144 145 NTSTATUS 146 NewPortFilterWaveRT( 147 OUT IPortFilterWaveRT ** OutFilter); 148 149 NTSTATUS 150 NewPortPinWaveRT( 151 OUT IPortPinWaveRT ** OutPin); 152 153 PMINIPORTWAVERT 154 GetWaveRTMiniport( 155 IN IPortWaveRT* iface); 156 157 PDEVICE_OBJECT 158 GetDeviceObjectFromPortWaveRT( 159 IPortWaveRT* iface); 160 161 162 NTSTATUS 163 NewPortWaveRTStream( 164 PPORTWAVERTSTREAM *OutStream); 165 166 NTSTATUS 167 NewPortWaveRT( 168 OUT PPORT* OutPort); 169 170 171 #endif 172 173 NTSTATUS 174 NewPortFilterTopology( 175 OUT IPortFilterTopology ** OutFilter); 176 177 PMINIPORTTOPOLOGY 178 GetTopologyMiniport( 179 PPORTTOPOLOGY Port); 180 181 NTSTATUS 182 NTAPI 183 NewDispatchObject( 184 IN PIRP Irp, 185 IN IIrpTarget * Target, 186 IN ULONG ObjectCreateItemCount, 187 IN PKSOBJECT_CREATE_ITEM ObjectCreateItem); 188 189 PMINIPORTWAVECYCLIC 190 GetWaveCyclicMiniport( 191 IN IPortWaveCyclic* iface); 192 193 PVOID 194 AllocateItem( 195 IN POOL_TYPE PoolType, 196 IN SIZE_T NumberOfBytes, 197 IN ULONG Tag); 198 199 VOID 200 FreeItem( 201 IN PVOID Item, 202 IN ULONG Tag); 203 204 NTSTATUS 205 NTAPI 206 NewIrpQueue( 207 IN IIrpQueue **Queue); 208 209 NTSTATUS 210 NTAPI 211 TopologyPropertyHandler( 212 IN PIRP Irp, 213 IN PKSIDENTIFIER Request, 214 IN OUT PVOID Data); 215 216 NTSTATUS 217 NTAPI 218 PinPropertyHandler( 219 IN PIRP Irp, 220 IN PKSIDENTIFIER Request, 221 IN OUT PVOID Data); 222 223 extern 224 "C" 225 NTSTATUS 226 NTAPI 227 PcDmaMasterDescription( 228 IN PRESOURCELIST ResourceList OPTIONAL, 229 IN BOOLEAN ScatterGather, 230 IN BOOLEAN Dma32BitAddresses, 231 IN BOOLEAN IgnoreCount, 232 IN BOOLEAN Dma64BitAddresses, 233 IN DMA_WIDTH DmaWidth, 234 IN DMA_SPEED DmaSpeed, 235 IN ULONG MaximumLength, 236 IN ULONG DmaPort, 237 OUT PDEVICE_DESCRIPTION DeviceDescription); 238 239 extern 240 "C" 241 NTSTATUS 242 NTAPI 243 PcDmaSlaveDescription( 244 IN PRESOURCELIST ResourceList OPTIONAL, 245 IN ULONG DmaIndex, 246 IN BOOLEAN DemandMode, 247 IN BOOLEAN AutoInitialize, 248 IN DMA_SPEED DmaSpeed, 249 IN ULONG MaximumLength, 250 IN ULONG DmaPort, 251 OUT PDEVICE_DESCRIPTION DeviceDescription); 252 253 extern 254 "C" 255 NTSTATUS 256 NTAPI 257 PcCreateSubdeviceDescriptor( 258 OUT SUBDEVICE_DESCRIPTOR ** OutSubdeviceDescriptor, 259 IN ULONG InterfaceCount, 260 IN GUID * InterfaceGuids, 261 IN ULONG IdentifierCount, 262 IN KSIDENTIFIER *Identifier, 263 IN ULONG FilterPropertiesCount, 264 IN KSPROPERTY_SET * FilterProperties, 265 IN ULONG Unknown1, 266 IN ULONG Unknown2, 267 IN ULONG PinPropertiesCount, 268 IN KSPROPERTY_SET * PinProperties, 269 IN ULONG EventSetCount, 270 IN KSEVENT_SET * EventSet, 271 IN PPCFILTER_DESCRIPTOR FilterDescription); 272 273 extern 274 "C" 275 NTSTATUS 276 NTAPI 277 PcValidateConnectRequest( 278 IN PIRP Irp, 279 IN KSPIN_FACTORY * Descriptor, 280 OUT PKSPIN_CONNECT* Connect); 281 282 NTSTATUS 283 NTAPI 284 PcCreateItemDispatch( 285 IN PDEVICE_OBJECT DeviceObject, 286 IN PIRP Irp); 287 288 PDEVICE_OBJECT 289 GetDeviceObject( 290 IPortWaveCyclic* iface); 291 292 VOID 293 NTAPI 294 PcIoTimerRoutine( 295 IN PDEVICE_OBJECT DeviceObject, 296 IN PVOID Context); 297 298 NTSTATUS 299 NTAPI 300 NewIUnregisterSubdevice( 301 OUT PUNREGISTERSUBDEVICE *OutDevice); 302 303 NTSTATUS 304 NTAPI 305 NewIUnregisterPhysicalConnection( 306 OUT PUNREGISTERPHYSICALCONNECTION *OutConnection); 307 308 NTSTATUS 309 NTAPI 310 PcHandlePropertyWithTable( 311 IN PIRP Irp, 312 IN ULONG PropertySetCount, 313 IN PKSPROPERTY_SET PropertySet, 314 IN PSUBDEVICE_DESCRIPTOR Descriptor); 315 316 NTSTATUS 317 NTAPI 318 PcHandleEnableEventWithTable( 319 IN PIRP Irp, 320 IN PSUBDEVICE_DESCRIPTOR Descriptor); 321 322 NTSTATUS 323 NTAPI 324 PcHandleDisableEventWithTable( 325 IN PIRP Irp, 326 IN PSUBDEVICE_DESCRIPTOR Descriptor); 327 328 IIrpTarget * 329 NTAPI 330 KsoGetIrpTargetFromIrp( 331 PIRP Irp); 332 333 #define DEFINE_KSPROPERTY_CONNECTIONSET(PinSet,\ 334 PropStateHandler, PropDataFormatHandler, PropAllocatorFraming)\ 335 DEFINE_KSPROPERTY_TABLE(PinSet) {\ 336 DEFINE_KSPROPERTY_ITEM_CONNECTION_STATE(PropStateHandler, PropStateHandler),\ 337 DEFINE_KSPROPERTY_ITEM_CONNECTION_DATAFORMAT(PropDataFormatHandler, PropDataFormatHandler),\ 338 DEFINE_KSPROPERTY_ITEM_CONNECTION_ALLOCATORFRAMING(PropAllocatorFraming)\ 339 } 340 341 #define DEFINE_KSPROPERTY_ITEM_AUDIO_POSITION(GetHandler, SetHandler)\ 342 DEFINE_KSPROPERTY_ITEM(\ 343 KSPROPERTY_AUDIO_POSITION,\ 344 (GetHandler),\ 345 sizeof(KSPROPERTY),\ 346 sizeof(KSAUDIO_POSITION),\ 347 (SetHandler),\ 348 NULL, 0, NULL, NULL, 0) 349 350 #define DEFINE_KSPROPERTY_AUDIOSET(PinSet,\ 351 PropPositionHandler)\ 352 DEFINE_KSPROPERTY_TABLE(PinSet) {\ 353 DEFINE_KSPROPERTY_ITEM_AUDIO_POSITION(PropPositionHandler, PropPositionHandler)\ 354 } 355 356 357 #define DEFINE_KSPROPERTY_ITEM_DRMAUDIOSTREAM_CONTENTID(SetHandler)\ 358 DEFINE_KSPROPERTY_ITEM(\ 359 KSPROPERTY_DRMAUDIOSTREAM_CONTENTID,\ 360 NULL,\ 361 sizeof(KSPROPERTY),\ 362 sizeof(ULONG),\ 363 (SetHandler),\ 364 NULL, 0, NULL, NULL, 0) 365 366 #define DEFINE_KSPROPERTY_DRMSET(PinSet,\ 367 PropPositionHandler)\ 368 DEFINE_KSPROPERTY_TABLE(PinSet) {\ 369 DEFINE_KSPROPERTY_ITEM_DRMAUDIOSTREAM_CONTENTID(PropPositionHandler)\ 370 } 371 372 #define DEFINE_KSPROPERTY_PINPROPOSEDATAFORMAT(PinSet,\ 373 PropGeneral, PropInstances, PropIntersection)\ 374 DEFINE_KSPROPERTY_TABLE(PinSet) {\ 375 DEFINE_KSPROPERTY_ITEM_PIN_CINSTANCES(PropInstances),\ 376 DEFINE_KSPROPERTY_ITEM_PIN_CTYPES(PropGeneral),\ 377 DEFINE_KSPROPERTY_ITEM_PIN_DATAFLOW(PropGeneral),\ 378 DEFINE_KSPROPERTY_ITEM_PIN_DATARANGES(PropGeneral),\ 379 DEFINE_KSPROPERTY_ITEM_PIN_DATAINTERSECTION(PropIntersection),\ 380 DEFINE_KSPROPERTY_ITEM_PIN_INTERFACES(PropGeneral),\ 381 DEFINE_KSPROPERTY_ITEM_PIN_MEDIUMS(PropGeneral),\ 382 DEFINE_KSPROPERTY_ITEM_PIN_COMMUNICATION(PropGeneral),\ 383 DEFINE_KSPROPERTY_ITEM_PIN_GLOBALCINSTANCES(PropGeneral),\ 384 DEFINE_KSPROPERTY_ITEM_PIN_NECESSARYINSTANCES(PropGeneral),\ 385 DEFINE_KSPROPERTY_ITEM_PIN_PHYSICALCONNECTION(PropGeneral),\ 386 DEFINE_KSPROPERTY_ITEM_PIN_CATEGORY(PropGeneral),\ 387 DEFINE_KSPROPERTY_ITEM_PIN_NAME(PropGeneral),\ 388 DEFINE_KSPROPERTY_ITEM_PIN_CONSTRAINEDDATARANGES(PropGeneral),\ 389 DEFINE_KSPROPERTY_ITEM_PIN_PROPOSEDATAFORMAT(PropGeneral)\ 390 } 391 392 typedef struct 393 { 394 KSDEVICE_HEADER KsDeviceHeader; 395 PDEVICE_OBJECT PhysicalDeviceObject; 396 PDEVICE_OBJECT PrevDeviceObject; 397 PCPFNSTARTDEVICE StartDevice; 398 ULONG_PTR Unused[4]; 399 IAdapterPowerManagement * AdapterPowerManagement; 400 ULONG MaxSubDevices; 401 KSOBJECT_CREATE_ITEM * CreateItems; 402 403 IResourceList* resources; 404 405 LIST_ENTRY TimerList; 406 KSPIN_LOCK TimerListLock; 407 408 DEVICE_POWER_STATE DevicePowerState; 409 SYSTEM_POWER_STATE SystemPowerState; 410 411 } PCLASS_DEVICE_EXTENSION, *PPCLASS_DEVICE_EXTENSION; 412 413 414 typedef struct 415 { 416 PVOID Pin; 417 PIO_WORKITEM WorkItem; 418 PIRP Irp; 419 }CLOSESTREAM_CONTEXT, *PCLOSESTREAM_CONTEXT; 420 421 typedef struct 422 { 423 LIST_ENTRY Entry; 424 PIO_TIMER_ROUTINE pTimerRoutine; 425 PVOID Context; 426 }TIMER_CONTEXT, *PTIMER_CONTEXT; 427 428 typedef struct 429 { 430 KSOBJECT_HEADER ObjectHeader; 431 IIrpTarget * Target; 432 PKSOBJECT_CREATE_ITEM CreateItem; 433 }DISPATCH_CONTEXT, *PDISPATCH_CONTEXT; 434 435 #endif /* PORTCLS_PRIVATE_H */ 436