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.

1910 lines
53 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: util.c
  4. //
  5. // Description:
  6. //
  7. //
  8. //@@BEGIN_MSINTERNAL
  9. // Development Team:
  10. // Mike McLaughlin
  11. //
  12. // History: Date Author Comment
  13. //
  14. // To Do: Date Author Comment
  15. //
  16. //@@END_MSINTERNAL
  17. //
  18. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  19. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  20. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  21. // PURPOSE.
  22. //
  23. // Copyright (c) 1996-1999 Microsoft Corporation. All Rights Reserved.
  24. //
  25. //---------------------------------------------------------------------------
  26. #include "common.h"
  27. #define SMALL_BLOCK_SIZE 32
  28. extern KSDATARANGE DataRangeWildCard;
  29. extern KSDATARANGE VirtualPinDataRange;
  30. //===========================================================================
  31. //===========================================================================
  32. #pragma LOCKED_DATA
  33. #ifdef DEBUG
  34. //#define MEMORY_LIST // Enable this to use ExAlloc instead of Zones.
  35. ULONG ulDebugFlags = 0;
  36. ULONG ulDebugNumber = MAXULONG;
  37. int SYSAUDIOTraceLevel = 5;
  38. ULONG cAllocMem = 0;
  39. ULONG cAllocMemSmall = 0;
  40. ULONG cAllocMem64 = 0;
  41. ULONG cAllocMem128 = 0;
  42. ULONG cbMemoryUsage = 0;
  43. #endif
  44. //===========================================================================
  45. //===========================================================================
  46. LIST_ENTRY glehQueueWorkList;
  47. KSPIN_LOCK gSpinLockQueueWorkList;
  48. WORK_QUEUE_ITEM gWorkItem;
  49. LONG gcQueueWorkList = 0;
  50. KMUTEX gMutex;
  51. PKSWORKER gWorkerObject = NULL;
  52. #ifdef USE_ZONES
  53. ZONE_HEADER gZone;
  54. #endif
  55. #ifdef MEMORY_LIST
  56. LIST_ENTRY gleMemoryHead;
  57. KSPIN_LOCK gSpinLockMemoryHead;
  58. #endif
  59. #pragma PAGEABLE_DATA
  60. //===========================================================================
  61. //===========================================================================
  62. #pragma INIT_CODE
  63. #pragma INIT_DATA
  64. NTSTATUS
  65. InitializeUtil()
  66. {
  67. NTSTATUS Status = STATUS_SUCCESS;
  68. #ifdef USE_ZONES
  69. PVOID pInitial = NULL;
  70. pInitial = ExAllocatePoolWithTag(PagedPool, 4096, POOLTAG_SYSA);
  71. if(pInitial == NULL) {
  72. Trap();
  73. Status = STATUS_INSUFFICIENT_RESOURCES;
  74. goto exit;
  75. }
  76. Status = ExInitializeZone(&gZone, SMALL_BLOCK_SIZE, pInitial, 4096);
  77. if(!NT_SUCCESS(Status)) {
  78. Trap();
  79. goto exit;
  80. }
  81. #endif
  82. #ifdef MEMORY_LIST
  83. InitializeListHead(&gleMemoryHead);
  84. KeInitializeSpinLock(&gSpinLockMemoryHead);
  85. #endif
  86. KeInitializeSpinLock(&gSpinLockQueueWorkList);
  87. InitializeListHead(&glehQueueWorkList);
  88. ExInitializeWorkItem(
  89. &gWorkItem,
  90. CQueueWorkListData::AsyncWorker,
  91. NULL);
  92. //
  93. // Note... if we fail during preparation, the DriverUnload() routine
  94. // calls the UninitializeUtil() function which handles the clean up.
  95. //
  96. Status = KsRegisterWorker(DelayedWorkQueue, &gWorkerObject);
  97. if(!NT_SUCCESS(Status)) {
  98. Trap();
  99. goto exit;
  100. }
  101. exit:
  102. #ifdef USE_ZONES
  103. if(!NT_SUCCESS(Status)) {
  104. if(pInitial != NULL) {
  105. //
  106. // Make sure UninitializeMemory doesn't also try to free this.
  107. //
  108. gZone.SegmentList.Next = NULL;
  109. //
  110. // Free initial zone page if failure
  111. //
  112. ExFreePool(pInitial);
  113. }
  114. }
  115. #endif
  116. return(Status);
  117. }
  118. #pragma PAGEABLE_CODE
  119. #pragma PAGEABLE_DATA
  120. VOID
  121. UninitializeUtil()
  122. {
  123. if(gWorkerObject != NULL) {
  124. KsUnregisterWorker(gWorkerObject);
  125. gWorkerObject = NULL;
  126. }
  127. }
  128. VOID
  129. UninitializeMemory()
  130. {
  131. #ifdef USE_ZONES
  132. PSINGLE_LIST_ENTRY psle, psleNext;
  133. psle = gZone.SegmentList.Next;
  134. while(psle != NULL) {
  135. psleNext = psle->Next;
  136. ExFreePool(psle);
  137. psle = psleNext;
  138. }
  139. #endif
  140. ASSERT(cbMemoryUsage == 0);
  141. }
  142. //
  143. // NOTE:
  144. // These functions are necessary to avoid the linker error LNK4210.
  145. // If you fill the dispatch tables with KsXXX functions instead of XXX
  146. // functions, the linker will error out. It will think that global-variables
  147. // are initialized with a non-compile-time constant.
  148. //
  149. NTSTATUS
  150. DispatchInvalidDeviceRequest(
  151. IN PDEVICE_OBJECT pdo,
  152. IN PIRP pIrp
  153. )
  154. {
  155. return KsDispatchInvalidDeviceRequest(pdo,pIrp);
  156. }
  157. BOOLEAN
  158. DispatchFastIoDeviceControlFailure(
  159. IN PFILE_OBJECT FileObject,
  160. IN BOOLEAN Wait,
  161. IN PVOID InputBuffer OPTIONAL,
  162. IN ULONG InputBufferLength,
  163. OUT PVOID OutputBuffer OPTIONAL,
  164. IN ULONG OutputBufferLength,
  165. IN ULONG IoControlCode,
  166. OUT PIO_STATUS_BLOCK IoStatus,
  167. IN PDEVICE_OBJECT DeviceObject
  168. )
  169. {
  170. return KsDispatchFastIoDeviceControlFailure(
  171. FileObject,
  172. Wait,
  173. InputBuffer,
  174. InputBufferLength,
  175. OutputBuffer,
  176. OutputBufferLength,
  177. IoControlCode,
  178. IoStatus,
  179. DeviceObject);
  180. }
  181. BOOLEAN
  182. DispatchFastReadFailure(
  183. IN PFILE_OBJECT FileObject,
  184. IN PLARGE_INTEGER FileOffset,
  185. IN ULONG Length,
  186. IN BOOLEAN Wait,
  187. IN ULONG LockKey,
  188. OUT PVOID Buffer,
  189. OUT PIO_STATUS_BLOCK IoStatus,
  190. IN PDEVICE_OBJECT DeviceObject
  191. )
  192. {
  193. return KsDispatchFastReadFailure(
  194. FileObject,
  195. FileOffset,
  196. Length,
  197. Wait,
  198. LockKey,
  199. Buffer,
  200. IoStatus,
  201. DeviceObject);
  202. }
  203. // END_NOTE
  204. BOOL
  205. CompareDataRange(
  206. PKSDATARANGE pDataRange1,
  207. PKSDATARANGE pDataRange2
  208. )
  209. {
  210. KSDATARANGE_AUDIO DataRangeAudioIntersection;
  211. if(CompareDataRangeGuids(pDataRange1, pDataRange2)) {
  212. //
  213. // See if there is a valid intersection
  214. //
  215. if(DataIntersectionAudio(
  216. (PKSDATARANGE_AUDIO)pDataRange1,
  217. (PKSDATARANGE_AUDIO)pDataRange2,
  218. &DataRangeAudioIntersection)) {
  219. return(TRUE);
  220. }
  221. if(pDataRange1 == &DataRangeWildCard ||
  222. pDataRange2 == &DataRangeWildCard ||
  223. pDataRange1 == &VirtualPinDataRange ||
  224. pDataRange2 == &VirtualPinDataRange) {
  225. return(TRUE);
  226. }
  227. return(FALSE);
  228. }
  229. return(FALSE);
  230. }
  231. BOOL DataIntersectionRange(
  232. PKSDATARANGE pDataRange1,
  233. PKSDATARANGE pDataRange2,
  234. PKSDATARANGE pDataRangeIntersection
  235. )
  236. {
  237. // Pick up pDataRange1 values by default.
  238. *pDataRangeIntersection = *pDataRange1;
  239. if(IsEqualGUID(&pDataRange1->MajorFormat, &pDataRange2->MajorFormat) ||
  240. IsEqualGUID(&pDataRange1->MajorFormat, &KSDATAFORMAT_TYPE_WILDCARD)) {
  241. pDataRangeIntersection->MajorFormat = pDataRange2->MajorFormat;
  242. }
  243. else if(!IsEqualGUID(
  244. &pDataRange2->MajorFormat,
  245. &KSDATAFORMAT_TYPE_WILDCARD)) {
  246. return FALSE;
  247. }
  248. if(IsEqualGUID(&pDataRange1->SubFormat, &pDataRange2->SubFormat) ||
  249. IsEqualGUID(&pDataRange1->SubFormat, &KSDATAFORMAT_SUBTYPE_WILDCARD)) {
  250. pDataRangeIntersection->SubFormat = pDataRange2->SubFormat;
  251. }
  252. else if(!IsEqualGUID(
  253. &pDataRange2->SubFormat,
  254. &KSDATAFORMAT_SUBTYPE_WILDCARD)) {
  255. return FALSE;
  256. }
  257. if(IsEqualGUID(&pDataRange1->Specifier, &pDataRange2->Specifier) ||
  258. IsEqualGUID(&pDataRange1->Specifier, &KSDATAFORMAT_SPECIFIER_WILDCARD)) {
  259. pDataRangeIntersection->Specifier = pDataRange2->Specifier;
  260. }
  261. else if(!IsEqualGUID(
  262. &pDataRange2->Specifier,
  263. &KSDATAFORMAT_SPECIFIER_WILDCARD)) {
  264. return FALSE;
  265. }
  266. pDataRangeIntersection->Reserved = 0; // Must be zero
  267. return(TRUE);
  268. }
  269. BOOL
  270. DataIntersectionAudio(
  271. PKSDATARANGE_AUDIO pDataRangeAudio1,
  272. PKSDATARANGE_AUDIO pDataRangeAudio2,
  273. PKSDATARANGE_AUDIO pDataRangeAudioIntersection
  274. )
  275. {
  276. if((IsEqualGUID(
  277. &pDataRangeAudio1->DataRange.Specifier,
  278. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) ||
  279. IsEqualGUID(
  280. &pDataRangeAudio1->DataRange.Specifier,
  281. &KSDATAFORMAT_SPECIFIER_DSOUND)) &&
  282. IsEqualGUID(
  283. &pDataRangeAudio2->DataRange.Specifier,
  284. &KSDATAFORMAT_SPECIFIER_WILDCARD)) {
  285. pDataRangeAudioIntersection->MaximumChannels =
  286. pDataRangeAudio1->MaximumChannels;
  287. pDataRangeAudioIntersection->MaximumSampleFrequency =
  288. pDataRangeAudio1->MaximumSampleFrequency;
  289. pDataRangeAudioIntersection->MinimumSampleFrequency =
  290. pDataRangeAudio1->MinimumSampleFrequency;
  291. pDataRangeAudioIntersection->MaximumBitsPerSample =
  292. pDataRangeAudio1->MaximumBitsPerSample;
  293. pDataRangeAudioIntersection->MinimumBitsPerSample =
  294. pDataRangeAudio1->MinimumBitsPerSample;
  295. return(TRUE);
  296. }
  297. if(IsEqualGUID(
  298. &pDataRangeAudio1->DataRange.Specifier,
  299. &KSDATAFORMAT_SPECIFIER_WILDCARD) &&
  300. (IsEqualGUID(
  301. &pDataRangeAudio2->DataRange.Specifier,
  302. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) ||
  303. IsEqualGUID(
  304. &pDataRangeAudio2->DataRange.Specifier,
  305. &KSDATAFORMAT_SPECIFIER_DSOUND))) {
  306. pDataRangeAudioIntersection->MaximumChannels =
  307. pDataRangeAudio2->MaximumChannels;
  308. pDataRangeAudioIntersection->MaximumSampleFrequency =
  309. pDataRangeAudio2->MaximumSampleFrequency;
  310. pDataRangeAudioIntersection->MinimumSampleFrequency =
  311. pDataRangeAudio2->MinimumSampleFrequency;
  312. pDataRangeAudioIntersection->MaximumBitsPerSample =
  313. pDataRangeAudio2->MaximumBitsPerSample;
  314. pDataRangeAudioIntersection->MinimumBitsPerSample =
  315. pDataRangeAudio2->MinimumBitsPerSample;
  316. return(TRUE);
  317. }
  318. if((IsEqualGUID(
  319. &pDataRangeAudio1->DataRange.Specifier,
  320. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) ||
  321. IsEqualGUID(
  322. &pDataRangeAudio1->DataRange.Specifier,
  323. &KSDATAFORMAT_SPECIFIER_DSOUND)) &&
  324. (IsEqualGUID(
  325. &pDataRangeAudio2->DataRange.Specifier,
  326. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) ||
  327. IsEqualGUID(
  328. &pDataRangeAudio2->DataRange.Specifier,
  329. &KSDATAFORMAT_SPECIFIER_DSOUND))) {
  330. if(pDataRangeAudio1->MaximumChannels <
  331. pDataRangeAudio2->MaximumChannels) {
  332. pDataRangeAudioIntersection->MaximumChannels =
  333. pDataRangeAudio1->MaximumChannels;
  334. }
  335. else {
  336. pDataRangeAudioIntersection->MaximumChannels =
  337. pDataRangeAudio2->MaximumChannels;
  338. }
  339. if(pDataRangeAudio1->MaximumSampleFrequency <
  340. pDataRangeAudio2->MaximumSampleFrequency) {
  341. pDataRangeAudioIntersection->MaximumSampleFrequency =
  342. pDataRangeAudio1->MaximumSampleFrequency;
  343. }
  344. else {
  345. pDataRangeAudioIntersection->MaximumSampleFrequency =
  346. pDataRangeAudio2->MaximumSampleFrequency;
  347. }
  348. if(pDataRangeAudio1->MinimumSampleFrequency >
  349. pDataRangeAudio2->MinimumSampleFrequency) {
  350. pDataRangeAudioIntersection->MinimumSampleFrequency =
  351. pDataRangeAudio1->MinimumSampleFrequency;
  352. }
  353. else {
  354. pDataRangeAudioIntersection->MinimumSampleFrequency =
  355. pDataRangeAudio2->MinimumSampleFrequency;
  356. }
  357. if(pDataRangeAudioIntersection->MaximumSampleFrequency <
  358. pDataRangeAudioIntersection->MinimumSampleFrequency ) {
  359. DPF2(110, "DataIntersectionAudio: SR %08x %08x",
  360. pDataRangeAudio1,
  361. pDataRangeAudio2);
  362. return(FALSE);
  363. }
  364. if(pDataRangeAudio1->MaximumBitsPerSample <
  365. pDataRangeAudio2->MaximumBitsPerSample) {
  366. pDataRangeAudioIntersection->MaximumBitsPerSample =
  367. pDataRangeAudio1->MaximumBitsPerSample;
  368. }
  369. else {
  370. pDataRangeAudioIntersection->MaximumBitsPerSample =
  371. pDataRangeAudio2->MaximumBitsPerSample;
  372. }
  373. if(pDataRangeAudio1->MinimumBitsPerSample >
  374. pDataRangeAudio2->MinimumBitsPerSample) {
  375. pDataRangeAudioIntersection->MinimumBitsPerSample =
  376. pDataRangeAudio1->MinimumBitsPerSample;
  377. }
  378. else {
  379. pDataRangeAudioIntersection->MinimumBitsPerSample =
  380. pDataRangeAudio2->MinimumBitsPerSample;
  381. }
  382. if(pDataRangeAudioIntersection->MaximumBitsPerSample <
  383. pDataRangeAudioIntersection->MinimumBitsPerSample ) {
  384. DPF2(110, "DataIntersectionAudio: BPS %08x %08x",
  385. pDataRangeAudio1,
  386. pDataRangeAudio2);
  387. return(FALSE);
  388. }
  389. return(TRUE);
  390. }
  391. return(FALSE);
  392. }
  393. BOOL
  394. CompareDataRangeExact(
  395. PKSDATARANGE pDataRange1,
  396. PKSDATARANGE pDataRange2
  397. )
  398. {
  399. if(pDataRange1 == NULL || pDataRange2 == NULL) {
  400. Trap();
  401. return(FALSE);
  402. }
  403. ASSERT(pDataRange1->Reserved == pDataRange2->Reserved);
  404. if(pDataRange1->FormatSize == pDataRange2->FormatSize) {
  405. return(!memcmp(pDataRange1, pDataRange2, pDataRange1->FormatSize));
  406. }
  407. return(FALSE);
  408. }
  409. BOOL
  410. CompareDataRangeGuids(
  411. PKSDATARANGE pDataRange1,
  412. PKSDATARANGE pDataRange2
  413. )
  414. {
  415. if(pDataRange1 == NULL || pDataRange2 == NULL) {
  416. Trap();
  417. return(FALSE);
  418. }
  419. if((IsEqualGUID(&pDataRange1->MajorFormat, &pDataRange2->MajorFormat) ||
  420. IsEqualGUID(&pDataRange1->MajorFormat, &KSDATAFORMAT_TYPE_WILDCARD) ||
  421. IsEqualGUID(&pDataRange2->MajorFormat, &KSDATAFORMAT_TYPE_WILDCARD)) &&
  422. (IsEqualGUID(&pDataRange1->SubFormat, &pDataRange2->SubFormat) ||
  423. IsEqualGUID(&pDataRange1->SubFormat, &KSDATAFORMAT_SUBTYPE_WILDCARD) ||
  424. IsEqualGUID(&pDataRange2->SubFormat, &KSDATAFORMAT_SUBTYPE_WILDCARD)) &&
  425. (IsEqualGUID(&pDataRange1->Specifier, &pDataRange2->Specifier) ||
  426. IsEqualGUID(&pDataRange1->Specifier, &KSDATAFORMAT_SPECIFIER_WILDCARD) ||
  427. IsEqualGUID(&pDataRange2->Specifier, &KSDATAFORMAT_SPECIFIER_WILDCARD))) {
  428. return(TRUE);
  429. }
  430. return(FALSE);
  431. }
  432. BOOL
  433. CompareIdentifier(
  434. PKSIDENTIFIER pIdentifier1,
  435. PKSIDENTIFIER pIdentifier2
  436. )
  437. {
  438. if(pIdentifier1 == NULL || pIdentifier2 == NULL) {
  439. Trap();
  440. return(FALSE);
  441. }
  442. if(pIdentifier1 == INTERNAL_WILDCARD ||
  443. pIdentifier2 == INTERNAL_WILDCARD) {
  444. return(TRUE);
  445. }
  446. if(IsEqualGUID(&pIdentifier1->Set, &pIdentifier2->Set) &&
  447. (pIdentifier1->Id == pIdentifier2->Id)) {
  448. return(TRUE);
  449. }
  450. return(FALSE);
  451. }
  452. //===========================================================================
  453. //
  454. // Returns the WAVEFORMATEX structure appended to KSDATAFORMAT.
  455. // Assumptions:
  456. // - pDataFormat is totally trusted. It has been probed and buffered
  457. // properly.
  458. // - This function should only be called if MajorFormat is AUDIO.
  459. //
  460. PWAVEFORMATEX
  461. GetWaveFormatExFromKsDataFormat(
  462. PKSDATAFORMAT pDataFormat,
  463. PULONG pcbFormat
  464. )
  465. {
  466. ASSERT(pDataFormat);
  467. PWAVEFORMATEX pWaveFormat = NULL;
  468. if(IsEqualGUID(&pDataFormat->Specifier, &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX)) {
  469. pWaveFormat =
  470. &PKSDATAFORMAT_WAVEFORMATEX(pDataFormat)->WaveFormatEx;
  471. if (pcbFormat) {
  472. *pcbFormat = sizeof(KSDATAFORMAT_WAVEFORMATEX);
  473. }
  474. }
  475. else if(IsEqualGUID(&pDataFormat->Specifier, &KSDATAFORMAT_SPECIFIER_DSOUND)) {
  476. pWaveFormat =
  477. &PKSDATAFORMAT_DSOUND(pDataFormat)->BufferDesc.WaveFormatEx;
  478. if (pcbFormat) {
  479. *pcbFormat = sizeof(KSDATAFORMAT_DSOUND);
  480. }
  481. }
  482. else {
  483. DPF(20, "GetWaveFormatExFromKsDataFormat : Unknown format specifier");
  484. }
  485. return pWaveFormat;
  486. } // GetWaveFormatExFromKsDataFormat
  487. //===========================================================================
  488. //
  489. // Edits the WAVEFORMATEX structure embedded in pPinConnect.
  490. // Assumptions:
  491. // - pPinConnect and following KSDATAFORMAT is totally trusted.
  492. // It has been probed and buffered properly.
  493. // - This function should only be called if MajorFormat is AUDIO.
  494. //
  495. void
  496. ModifyPinConnect(
  497. PKSPIN_CONNECT pPinConnect,
  498. WORD nChannels
  499. )
  500. {
  501. ASSERT(pPinConnect);
  502. PKSDATAFORMAT pDataFormat = (PKSDATAFORMAT) (pPinConnect + 1);
  503. PWAVEFORMATEX pWaveFormat = NULL;
  504. pWaveFormat = GetWaveFormatExFromKsDataFormat(pDataFormat, NULL);
  505. if (NULL != pWaveFormat) {
  506. if (IsEqualGUID(&pDataFormat->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)) {
  507. pWaveFormat->nChannels = nChannels;
  508. pWaveFormat->nBlockAlign =
  509. (pWaveFormat->wBitsPerSample / 8) * pWaveFormat->nChannels;
  510. pWaveFormat->nAvgBytesPerSec =
  511. pWaveFormat->nSamplesPerSec * pWaveFormat->nBlockAlign;
  512. //
  513. // Modify speaker configuration for WAVEFORMATEXTENSIBLE.
  514. //
  515. if (WAVE_FORMAT_EXTENSIBLE == pWaveFormat->wFormatTag) {
  516. PWAVEFORMATEXTENSIBLE pWaveFormatExt =
  517. (PWAVEFORMATEXTENSIBLE) pWaveFormat;
  518. if (1 == nChannels) {
  519. pWaveFormatExt->dwChannelMask = SPEAKER_FRONT_CENTER;
  520. }
  521. else if (2 == nChannels) {
  522. pWaveFormatExt->dwChannelMask =
  523. SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
  524. }
  525. }
  526. }
  527. else {
  528. DPF(5, "ModifyPinConnect : Not touching NON-PCM formats.");
  529. }
  530. }
  531. } // ModifyPinConnect
  532. NTSTATUS
  533. OpenDevice(
  534. PWSTR pwstrDevice,
  535. PHANDLE pHandle
  536. )
  537. {
  538. IO_STATUS_BLOCK IoStatusBlock;
  539. UNICODE_STRING UnicodeDeviceString;
  540. OBJECT_ATTRIBUTES ObjectAttributes;
  541. RtlInitUnicodeString(&UnicodeDeviceString, pwstrDevice);
  542. //
  543. // SECURITY NOTE:
  544. // OBJ_KERNEL_HANDLE is required here since this code might also be
  545. // running in a USER process.
  546. //
  547. InitializeObjectAttributes(
  548. &ObjectAttributes,
  549. &UnicodeDeviceString,
  550. OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
  551. NULL,
  552. NULL);
  553. return(ZwCreateFile(pHandle,
  554. GENERIC_READ | GENERIC_WRITE,
  555. &ObjectAttributes,
  556. &IoStatusBlock,
  557. NULL,
  558. FILE_ATTRIBUTE_NORMAL,
  559. 0,
  560. FILE_OPEN,
  561. 0,
  562. NULL,
  563. 0));
  564. }
  565. NTSTATUS
  566. GetPinProperty(
  567. PFILE_OBJECT pFileObject,
  568. ULONG PropertyId,
  569. ULONG PinId,
  570. ULONG cbProperty,
  571. PVOID pProperty
  572. )
  573. {
  574. ULONG BytesReturned;
  575. KSP_PIN Pin;
  576. NTSTATUS Status;
  577. Pin.Property.Set = KSPROPSETID_Pin;
  578. Pin.Property.Id = PropertyId;
  579. Pin.Property.Flags = KSPROPERTY_TYPE_GET;
  580. Pin.PinId = PinId;
  581. Pin.Reserved = 0;
  582. AssertFileObject(pFileObject);
  583. Status = KsSynchronousIoControlDevice(
  584. pFileObject,
  585. KernelMode,
  586. IOCTL_KS_PROPERTY,
  587. &Pin,
  588. sizeof(Pin),
  589. pProperty,
  590. cbProperty,
  591. &BytesReturned);
  592. if(!NT_SUCCESS(Status)) {
  593. DPF2(10,
  594. "GetPinProperty: id %d p %d KsSynchronousIoControlDevice FAILED",
  595. PropertyId,
  596. PinId);
  597. goto exit;
  598. }
  599. ASSERT(BytesReturned == cbProperty);
  600. exit:
  601. return(Status);
  602. }
  603. NTSTATUS
  604. PinConnectionProperty(
  605. PFILE_OBJECT pFileObject,
  606. ULONG ulPropertyId,
  607. ULONG ulFlags,
  608. ULONG cbProperty,
  609. PVOID pProperty
  610. )
  611. {
  612. KSIDENTIFIER Property;
  613. ULONG BytesReturned;
  614. NTSTATUS Status;
  615. Property.Set = KSPROPSETID_Connection;
  616. Property.Id = ulPropertyId;
  617. Property.Flags = ulFlags;
  618. AssertFileObject(pFileObject);
  619. Status = KsSynchronousIoControlDevice(
  620. pFileObject,
  621. KernelMode,
  622. IOCTL_KS_PROPERTY,
  623. &Property,
  624. sizeof(Property),
  625. pProperty,
  626. cbProperty,
  627. &BytesReturned);
  628. if(!NT_SUCCESS(Status)) {
  629. DPF(10, "SetPinConnectionProperty: KsSynchronousIoControlDevice Failed");
  630. goto exit;
  631. }
  632. exit:
  633. return(Status);
  634. }
  635. NTSTATUS
  636. GetPinPropertyEx(
  637. PFILE_OBJECT pFileObject,
  638. ULONG PropertyId,
  639. ULONG PinId,
  640. PVOID *ppProperty
  641. )
  642. {
  643. ULONG BytesReturned;
  644. NTSTATUS Status;
  645. KSP_PIN Pin;
  646. ASSERT(pFileObject);
  647. //
  648. // Setup the Property.
  649. //
  650. Pin.Property.Set = KSPROPSETID_Pin;
  651. Pin.Property.Id = PropertyId;
  652. Pin.Property.Flags = KSPROPERTY_TYPE_GET;
  653. Pin.PinId = PinId;
  654. Pin.Reserved = 0;
  655. //
  656. // Send IOCTL to FILE_OBJECT to get the size of output buffer.
  657. // This should always fail.
  658. //
  659. AssertFileObject(pFileObject);
  660. Status = KsSynchronousIoControlDevice(
  661. pFileObject,
  662. KernelMode,
  663. IOCTL_KS_PROPERTY,
  664. &Pin,
  665. sizeof(KSP_PIN),
  666. NULL,
  667. 0,
  668. &BytesReturned);
  669. //
  670. // SECURITY NOTE:
  671. // KsSynchronousIoControlDevice should never return STATUS_SUCCESS.
  672. //
  673. ASSERT(!NT_SUCCESS(Status));
  674. if(Status != STATUS_BUFFER_OVERFLOW) {
  675. goto exit;
  676. }
  677. if(BytesReturned == 0) {
  678. *ppProperty = NULL;
  679. Status = STATUS_SUCCESS;
  680. goto exit;
  681. }
  682. //
  683. // Now allocate the output buffer.
  684. //
  685. *ppProperty = new BYTE[BytesReturned];
  686. if(*ppProperty == NULL) {
  687. Status = STATUS_INSUFFICIENT_RESOURCES;
  688. goto exit;
  689. }
  690. //
  691. // Send IOCTL to FILE_OBJECT with actual output buffer.
  692. //
  693. AssertFileObject(pFileObject);
  694. Status = KsSynchronousIoControlDevice(
  695. pFileObject,
  696. KernelMode,
  697. IOCTL_KS_PROPERTY,
  698. &Pin,
  699. sizeof(KSP_PIN),
  700. *ppProperty,
  701. BytesReturned,
  702. &BytesReturned);
  703. if(!NT_SUCCESS(Status)) {
  704. Trap();
  705. delete *ppProperty;
  706. *ppProperty = NULL;
  707. goto exit;
  708. }
  709. exit:
  710. if(Status == STATUS_PROPSET_NOT_FOUND ||
  711. Status == STATUS_NOT_FOUND) {
  712. Status = STATUS_SUCCESS;
  713. *ppProperty = NULL;
  714. }
  715. return(Status);
  716. }
  717. NTSTATUS
  718. GetPinProperty2(
  719. PFILE_OBJECT pFileObject,
  720. ULONG ulPropertyId,
  721. ULONG ulPinId,
  722. ULONG cbInput,
  723. PVOID pInputData,
  724. PVOID *ppPropertyOutput
  725. )
  726. {
  727. ULONG cbPropertyInput = sizeof(KSP_PIN);
  728. ULONG BytesReturned;
  729. NTSTATUS Status;
  730. PKSP_PIN pPin;
  731. //
  732. // Allocate input buffer (sizeof(KSP_PIN) + cbInput) and set its
  733. // fields
  734. //
  735. cbPropertyInput += cbInput;
  736. pPin = (PKSP_PIN)new BYTE[cbPropertyInput];
  737. if(pPin == NULL) {
  738. Status = STATUS_INSUFFICIENT_RESOURCES;
  739. goto exit;
  740. }
  741. pPin->Property.Set = KSPROPSETID_Pin;
  742. pPin->Property.Id = ulPropertyId;
  743. pPin->Property.Flags = KSPROPERTY_TYPE_GET;
  744. pPin->PinId = ulPinId;
  745. pPin->Reserved = 0;
  746. if(pInputData != NULL) {
  747. memcpy(pPin + 1, pInputData, cbInput);
  748. }
  749. //
  750. // Send IOCTL to FILE_OBJECT with NULL output buffer to get real
  751. // output size.
  752. // This call should always fail.
  753. //
  754. AssertFileObject(pFileObject);
  755. Status = KsSynchronousIoControlDevice(
  756. pFileObject,
  757. KernelMode,
  758. IOCTL_KS_PROPERTY,
  759. pPin,
  760. cbPropertyInput,
  761. NULL,
  762. 0,
  763. &BytesReturned);
  764. //
  765. // SECURITY NOTE:
  766. // KsSynchronousIoControlDevice should never return STATUS_SUCCESS.
  767. //
  768. ASSERT(!NT_SUCCESS(Status));
  769. if(Status != STATUS_BUFFER_OVERFLOW) {
  770. DPF(10, "GetPinProperty2: KsSynchronousIoControlDevice 1 Failed");
  771. goto exit;
  772. }
  773. if(BytesReturned == 0) {
  774. *ppPropertyOutput = NULL;
  775. Status = STATUS_SUCCESS;
  776. goto exit;
  777. }
  778. //
  779. // Allocate the real output buffer.
  780. //
  781. *ppPropertyOutput = new BYTE[BytesReturned];
  782. if(*ppPropertyOutput == NULL) {
  783. Status = STATUS_INSUFFICIENT_RESOURCES;
  784. goto exit;
  785. }
  786. //
  787. // Send the IOCTL to FILE_OBJECT with real output buffer.
  788. //
  789. AssertFileObject(pFileObject);
  790. Status = KsSynchronousIoControlDevice(
  791. pFileObject,
  792. KernelMode,
  793. IOCTL_KS_PROPERTY,
  794. pPin,
  795. cbPropertyInput,
  796. *ppPropertyOutput,
  797. BytesReturned,
  798. &BytesReturned);
  799. if(!NT_SUCCESS(Status)) {
  800. DPF(10, "GetPinProperty2: KsSynchronousIoControlDevice 2 Failed");
  801. delete *ppPropertyOutput;
  802. goto exit;
  803. }
  804. exit:
  805. delete [] pPin;
  806. if(!NT_SUCCESS(Status)) {
  807. *ppPropertyOutput = NULL;
  808. if(Status == STATUS_PROPSET_NOT_FOUND ||
  809. Status == STATUS_NOT_FOUND) {
  810. Status = STATUS_SUCCESS;
  811. }
  812. }
  813. return(Status);
  814. }
  815. NTSTATUS
  816. GetProperty(
  817. PFILE_OBJECT pFileObject,
  818. CONST GUID *pguidPropertySet,
  819. ULONG ulPropertyId,
  820. PVOID *ppPropertyOutput
  821. )
  822. {
  823. ULONG BytesReturned;
  824. ULONG cbPropertyInput = sizeof(KSPROPERTY);
  825. PKSPROPERTY pPropertyInput;
  826. NTSTATUS Status;
  827. ASSERT(pguidPropertySet);
  828. ASSERT(pFileObject);
  829. ASSERT(ppPropertyOutput);
  830. //
  831. // Allocate KS Property structure and set its fields.
  832. //
  833. pPropertyInput = (PKSPROPERTY)new BYTE[cbPropertyInput];
  834. if(pPropertyInput == NULL) {
  835. Status = STATUS_INSUFFICIENT_RESOURCES;
  836. goto exit;
  837. }
  838. pPropertyInput->Set = *pguidPropertySet;
  839. pPropertyInput->Id = ulPropertyId;
  840. pPropertyInput->Flags = KSPROPERTY_TYPE_GET;
  841. //
  842. // Send property to FILE_OBJECT and get the actual return buffer size.
  843. // This should always return failure code.
  844. //
  845. AssertFileObject(pFileObject);
  846. Status = KsSynchronousIoControlDevice(
  847. pFileObject,
  848. KernelMode,
  849. IOCTL_KS_PROPERTY,
  850. pPropertyInput,
  851. cbPropertyInput,
  852. NULL,
  853. 0,
  854. &BytesReturned);
  855. //
  856. // SECURITY NOTE:
  857. // KsSynchronousIoControlDevice should never return STATUS_SUCCESS.
  858. //
  859. ASSERT(!NT_SUCCESS(Status));
  860. if(Status != STATUS_BUFFER_OVERFLOW) {
  861. DPF(10, "GetProperty: KsSynchronousIoControlDevice 1 Failed");
  862. goto exit;
  863. }
  864. if(BytesReturned == 0) {
  865. *ppPropertyOutput = NULL;
  866. Status = STATUS_SUCCESS;
  867. goto exit;
  868. }
  869. //
  870. // Allocate memory for output buffer.
  871. //
  872. *ppPropertyOutput = new BYTE[BytesReturned];
  873. if(*ppPropertyOutput == NULL) {
  874. Status = STATUS_INSUFFICIENT_RESOURCES;
  875. goto exit;
  876. }
  877. //
  878. // Send property to FILE_OBJECT again (this time with output buffer).
  879. //
  880. AssertFileObject(pFileObject);
  881. Status = KsSynchronousIoControlDevice(
  882. pFileObject,
  883. KernelMode,
  884. IOCTL_KS_PROPERTY,
  885. pPropertyInput,
  886. cbPropertyInput,
  887. *ppPropertyOutput,
  888. BytesReturned,
  889. &BytesReturned);
  890. if(!NT_SUCCESS(Status)) {
  891. DPF(10, "GetProperty: KsSynchronousIoControlDevice 2 Failed");
  892. delete *ppPropertyOutput;
  893. goto exit;
  894. }
  895. exit:
  896. delete [] pPropertyInput;
  897. if(!NT_SUCCESS(Status)) {
  898. *ppPropertyOutput = NULL;
  899. if(Status == STATUS_PROPSET_NOT_FOUND ||
  900. Status == STATUS_NOT_FOUND) {
  901. Status = STATUS_SUCCESS;
  902. }
  903. }
  904. return(Status);
  905. }
  906. CQueueWorkListData::CQueueWorkListData(
  907. NTSTATUS (*Function)(PVOID Reference1, PVOID Reference2),
  908. PVOID Reference1,
  909. PVOID Reference2
  910. )
  911. {
  912. this->Function = Function;
  913. this->Reference1 = Reference1;
  914. this->Reference2 = Reference2;
  915. }
  916. NTSTATUS
  917. CQueueWorkListData::QueueAsyncList(
  918. )
  919. {
  920. NTSTATUS ntStatus = STATUS_SUCCESS;
  921. ExInterlockedInsertTailList(
  922. &glehQueueWorkList,
  923. &leNext,
  924. &gSpinLockQueueWorkList);
  925. // Schedule the workitem, if it is not already running.
  926. //
  927. if(InterlockedIncrement(&gcQueueWorkList) == 1) {
  928. ntStatus = KsQueueWorkItem(gWorkerObject, &gWorkItem);
  929. }
  930. return ntStatus;
  931. }
  932. VOID
  933. CQueueWorkListData::AsyncWorker(
  934. IN OUT PVOID pReference
  935. )
  936. {
  937. PQUEUE_WORK_LIST_DATA pQueueWorkListData;
  938. PLIST_ENTRY ple;
  939. ::GrabMutex();
  940. while(
  941. (ple = ExInterlockedRemoveHeadList(
  942. &glehQueueWorkList,
  943. &gSpinLockQueueWorkList)) != NULL) {
  944. pQueueWorkListData =
  945. CONTAINING_RECORD(ple, QUEUE_WORK_LIST_DATA, leNext);
  946. Assert(pQueueWorkListData);
  947. (*pQueueWorkListData->Function)
  948. (pQueueWorkListData->Reference1,
  949. pQueueWorkListData->Reference2);
  950. delete pQueueWorkListData;
  951. if(InterlockedDecrement(&gcQueueWorkList) == 0) {
  952. break;
  953. }
  954. }
  955. ::ReleaseMutex();
  956. }
  957. NTSTATUS
  958. QueueWorkList(
  959. NTSTATUS (*Function)(PVOID Reference1, PVOID Reference2),
  960. PVOID Reference1,
  961. PVOID Reference2
  962. )
  963. {
  964. NTSTATUS Status = STATUS_SUCCESS;
  965. PQUEUE_WORK_LIST_DATA pQueueWorkListData = new QUEUE_WORK_LIST_DATA(
  966. Function,
  967. Reference1,
  968. Reference2);
  969. if(pQueueWorkListData == NULL) {
  970. Status = STATUS_INSUFFICIENT_RESOURCES;
  971. goto exit;
  972. }
  973. Status = pQueueWorkListData->QueueAsyncList();
  974. exit:
  975. return(Status);
  976. }
  977. VOID
  978. GetDefaultOrder(
  979. ULONG fulType,
  980. PULONG pulOrder
  981. )
  982. {
  983. if(fulType != 0) {
  984. if(*pulOrder == ORDER_NONE) {
  985. if(fulType & FILTER_TYPE_ENDPOINT) {
  986. *pulOrder = ORDER_ENDPOINT;
  987. return;
  988. }
  989. if(fulType & FILTER_TYPE_VIRTUAL) {
  990. *pulOrder = ORDER_VIRTUAL;
  991. return;
  992. }
  993. if(fulType & FILTER_TYPE_GFX) {
  994. *pulOrder = ORDER_GFX;
  995. return;
  996. }
  997. if(fulType & FILTER_TYPE_INTERFACE_TRANSFORM) {
  998. *pulOrder = ORDER_INTERFACE_TRANSFORM;
  999. return;
  1000. }
  1001. if(fulType & FILTER_TYPE_AEC) {
  1002. *pulOrder = ORDER_AEC;
  1003. return;
  1004. }
  1005. if(fulType & FILTER_TYPE_MIC_ARRAY_PROCESSOR) {
  1006. *pulOrder = ORDER_MIC_ARRAY_PROCESSOR;
  1007. return;
  1008. }
  1009. if(fulType & FILTER_TYPE_SPLITTER) {
  1010. *pulOrder = ORDER_SPLITTER;
  1011. return;
  1012. }
  1013. if(fulType & FILTER_TYPE_MIXER) {
  1014. *pulOrder = ORDER_MIXER;
  1015. return;
  1016. }
  1017. if(fulType & FILTER_TYPE_SYNTHESIZER) {
  1018. *pulOrder = ORDER_SYNTHESIZER;
  1019. return;
  1020. }
  1021. if(fulType & FILTER_TYPE_DRM_DESCRAMBLE) {
  1022. *pulOrder = ORDER_DRM_DESCRAMBLE;
  1023. return;
  1024. }
  1025. if(fulType & FILTER_TYPE_DATA_TRANSFORM) {
  1026. *pulOrder = ORDER_DATA_TRANSFORM;
  1027. return;
  1028. }
  1029. }
  1030. }
  1031. }
  1032. //===========================================================================
  1033. // ISSUE-2001/03/06-alpers
  1034. // This is a temporary solution for GFX glitching problem.
  1035. // In BlackComb time-frame after the right fix is implemented, we should delete
  1036. // this definition and references to it.
  1037. //
  1038. #define STATIC_KSPROPSETID_Frame\
  1039. 0xA60D8368L, 0x5324, 0x4893, 0xB0, 0x20, 0xC4, 0x31, 0xA5, 0x0B, 0xCB, 0xE3
  1040. DEFINE_GUIDSTRUCT("A60D8368-5324-4893-B020-C431A50BCBE3", KSPROPSETID_Frame);
  1041. #define KSPROPSETID_Frame DEFINE_GUIDNAMED(KSPROPSETID_Frame)
  1042. typedef enum {
  1043. KSPROPERTY_FRAME_HOLDING
  1044. } KSPROPERTY_FRAME;
  1045. //===========================================================================
  1046. NTSTATUS
  1047. SetKsFrameHolding(
  1048. PFILE_OBJECT pFileObject
  1049. )
  1050. {
  1051. KSPROPERTY Property;
  1052. NTSTATUS ntStatus;
  1053. ULONG ulBytesReturned;
  1054. BOOL fFrameEnable = TRUE;
  1055. ASSERT(pFileObject);
  1056. //
  1057. // Form the IOCTL packet & send it down
  1058. //
  1059. Property.Set = KSPROPSETID_Frame;
  1060. Property.Id = KSPROPERTY_FRAME_HOLDING;
  1061. Property.Flags = KSPROPERTY_TYPE_SET;
  1062. DPF(60,"Sending KSPROPERTY_FRAME_HOLDING");
  1063. //
  1064. // We actually throw away the status we got back from the device.
  1065. //
  1066. ntStatus = KsSynchronousIoControlDevice(pFileObject,
  1067. KernelMode,
  1068. IOCTL_KS_PROPERTY,
  1069. &Property,
  1070. sizeof(Property),
  1071. &fFrameEnable,
  1072. sizeof(fFrameEnable),
  1073. &ulBytesReturned);
  1074. DPF1(60,"KSPROPERTY_FRAME_HOLDING %s",
  1075. (NT_SUCCESS(ntStatus)) ? "Succeeded" : "Failed");
  1076. return ntStatus;
  1077. } // SetKsFrameHolding
  1078. //---------------------------------------------------------------------------
  1079. #pragma LOCKED_CODE
  1080. //
  1081. // Zero initializes the block.
  1082. //
  1083. void * __cdecl operator new( size_t size )
  1084. {
  1085. PVOID p;
  1086. ASSERT(size != 0);
  1087. ASSERT(size < 0x10000);
  1088. #if defined(USE_ZONES) || defined(DEBUG)
  1089. size += sizeof(ULONGLONG);
  1090. #endif
  1091. #ifdef MEMORY_LIST
  1092. size += sizeof(LIST_ENTRY);
  1093. #endif
  1094. #ifdef USE_ZONES
  1095. if(size <= SMALL_BLOCK_SIZE) {
  1096. if(ExIsFullZone(&gZone)) {
  1097. p = ExAllocatePoolWithTag(PagedPool, 4096, POOLTAG_SYSA); // SYSA
  1098. if(p != NULL) {
  1099. if(!NT_SUCCESS(ExExtendZone(&gZone, p, 4096))) {
  1100. Trap();
  1101. ExFreePool(p);
  1102. DPF(5, "ExExtendZone FAILED");
  1103. return(NULL);
  1104. }
  1105. }
  1106. }
  1107. p = ExAllocateFromZone(&gZone);
  1108. }
  1109. else {
  1110. p = ExAllocatePoolWithTag(PagedPool, size, POOLTAG_SYSA); // SYSA
  1111. }
  1112. #else
  1113. p = ExAllocatePoolWithTag(PagedPool, size, POOLTAG_SYSA); // SYSA
  1114. #endif
  1115. if(p != NULL) {
  1116. RtlZeroMemory(p, size);
  1117. #if defined(USE_ZONES) || defined(DEBUG)
  1118. *((PULONG)p) = size;
  1119. p = ((PULONGLONG)p) + 1;
  1120. #endif
  1121. #ifdef MEMORY_LIST
  1122. ExInterlockedInsertTailList(
  1123. &gleMemoryHead,
  1124. ((PLIST_ENTRY)p),
  1125. &gSpinLockMemoryHead);
  1126. p = ((PLIST_ENTRY)p) + 1;
  1127. #endif
  1128. #ifdef DEBUG
  1129. cbMemoryUsage += size;
  1130. ++cAllocMem;
  1131. if(size <= SMALL_BLOCK_SIZE) {
  1132. ++cAllocMemSmall;
  1133. }
  1134. else if(size <= 64) {
  1135. ++cAllocMem64;
  1136. }
  1137. else if(size <= 128) {
  1138. ++cAllocMem128;
  1139. }
  1140. #endif
  1141. }
  1142. AssertAligned(p);
  1143. return(p);
  1144. }
  1145. //
  1146. // Frees memory
  1147. //
  1148. void __cdecl operator delete( void *p )
  1149. {
  1150. if(p != NULL) {
  1151. #ifdef MEMORY_LIST
  1152. KIRQL OldIrql;
  1153. p = ((PLIST_ENTRY)p) - 1;
  1154. KeAcquireSpinLock(&gSpinLockMemoryHead, &OldIrql);
  1155. RemoveEntryList((PLIST_ENTRY)p);
  1156. KeReleaseSpinLock(&gSpinLockMemoryHead, OldIrql);
  1157. #endif
  1158. #if defined(USE_ZONES) || defined(DEBUG)
  1159. ULONG size;
  1160. AssertAligned(p);
  1161. p = ((PULONGLONG)p) - 1;
  1162. size = *((PULONG)p);
  1163. #endif
  1164. #ifdef DEBUG
  1165. cbMemoryUsage -= size;
  1166. --cAllocMem;
  1167. if(size <= SMALL_BLOCK_SIZE) {
  1168. --cAllocMemSmall;
  1169. }
  1170. else if(size <= 64) {
  1171. --cAllocMem64;
  1172. }
  1173. else if(size <= 128) {
  1174. --cAllocMem128;
  1175. }
  1176. #endif
  1177. #ifdef USE_ZONES
  1178. if(size <= SMALL_BLOCK_SIZE) {
  1179. ExFreeToZone(&gZone, p);
  1180. }
  1181. else {
  1182. ExFreePool(p);
  1183. }
  1184. #else
  1185. ExFreePool(p);
  1186. #endif
  1187. }
  1188. }
  1189. #pragma PAGEABLE_CODE
  1190. //---------------------------------------------------------------------------
  1191. #ifdef DEBUG
  1192. VOID
  1193. DumpPinConnect(
  1194. LONG Level,
  1195. PKSPIN_CONNECT pPinConnect
  1196. )
  1197. {
  1198. DPF1(Level, " PinId: %d", pPinConnect->PinId);
  1199. DPF1(Level, "Interface: %s", DbgIdentifier2Sz(&pPinConnect->Interface));
  1200. DPF1(Level, " Medium: %s", DbgIdentifier2Sz(&pPinConnect->Medium));
  1201. DumpDataFormat(Level, ((PKSDATAFORMAT)(pPinConnect + 1)));
  1202. }
  1203. VOID
  1204. DumpDataFormat(
  1205. LONG Level,
  1206. PKSDATAFORMAT pDataFormat
  1207. )
  1208. {
  1209. DPF2(Level,
  1210. " FormatSize: %02x Flags: %08x",
  1211. pDataFormat->FormatSize,
  1212. pDataFormat->Flags);
  1213. DPF2(Level,
  1214. " SampleSize: %02x Reserved: %08x",
  1215. pDataFormat->SampleSize,
  1216. pDataFormat->Reserved);
  1217. DPF1(Level, "MajorFormat: %s", DbgGuid2Sz(&pDataFormat->MajorFormat));
  1218. DPF1(Level, " SubFormat: %s", DbgGuid2Sz(&pDataFormat->SubFormat));
  1219. DPF1(Level, " Specifier: %s", DbgGuid2Sz(&pDataFormat->Specifier));
  1220. if(IsEqualGUID(
  1221. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX,
  1222. &pDataFormat->Specifier)) {
  1223. DumpWaveFormatEx(
  1224. Level,
  1225. "WaveFmtEx",
  1226. &((PKSDATAFORMAT_WAVEFORMATEX)pDataFormat)->WaveFormatEx);
  1227. }
  1228. if(IsEqualGUID(
  1229. &KSDATAFORMAT_SPECIFIER_DSOUND,
  1230. &pDataFormat->Specifier)) {
  1231. DumpWaveFormatEx(
  1232. Level,
  1233. "DSOUND",
  1234. &((PKSDATAFORMAT_DSOUND)pDataFormat)->BufferDesc.WaveFormatEx);
  1235. }
  1236. }
  1237. VOID
  1238. DumpWaveFormatEx(
  1239. LONG Level,
  1240. PSZ pszSpecifier,
  1241. WAVEFORMATEX *pWaveFormatEx
  1242. )
  1243. {
  1244. DPF8(Level, "%s T %u SR %u CH %u BPS %u ABPS %u BA %u cb %u",
  1245. pszSpecifier,
  1246. pWaveFormatEx->wFormatTag,
  1247. pWaveFormatEx->nSamplesPerSec,
  1248. pWaveFormatEx->nChannels,
  1249. pWaveFormatEx->wBitsPerSample,
  1250. pWaveFormatEx->nAvgBytesPerSec,
  1251. pWaveFormatEx->nBlockAlign,
  1252. pWaveFormatEx->cbSize);
  1253. if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
  1254. DPF3(Level, "VBPS %u CHMASK %08x %s",
  1255. ((PWAVEFORMATEXTENSIBLE)pWaveFormatEx)->Samples.wValidBitsPerSample,
  1256. ((PWAVEFORMATEXTENSIBLE)pWaveFormatEx)->dwChannelMask,
  1257. DbgGuid2Sz(&((PWAVEFORMATEXTENSIBLE)pWaveFormatEx)->SubFormat));
  1258. }
  1259. }
  1260. VOID
  1261. DumpDataRange(
  1262. LONG Level,
  1263. PKSDATARANGE_AUDIO pDataRangeAudio
  1264. )
  1265. {
  1266. DPF2(Level,
  1267. " FormatSize: %02x Flags: %08x",
  1268. pDataRangeAudio->DataRange.FormatSize,
  1269. pDataRangeAudio->DataRange.Flags);
  1270. DPF2(Level,
  1271. " SampleSize: %02x Reserved: %08x",
  1272. pDataRangeAudio->DataRange.SampleSize,
  1273. pDataRangeAudio->DataRange.Reserved);
  1274. DPF1(Level, "MajorFormat: %s",
  1275. DbgGuid2Sz(&pDataRangeAudio->DataRange.MajorFormat));
  1276. DPF1(Level, " SubFormat: %s",
  1277. DbgGuid2Sz(&pDataRangeAudio->DataRange.SubFormat));
  1278. DPF1(Level, " Specifier: %s",
  1279. DbgGuid2Sz(&pDataRangeAudio->DataRange.Specifier));
  1280. if(IsEqualGUID(
  1281. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX,
  1282. &pDataRangeAudio->DataRange.Specifier)) {
  1283. DPF5(Level, "WaveFmtEx: MaxCH %d MaxSR %u MinSR %u MaxBPS %u MinBPS %u",
  1284. pDataRangeAudio->MaximumChannels,
  1285. pDataRangeAudio->MinimumSampleFrequency,
  1286. pDataRangeAudio->MaximumSampleFrequency,
  1287. pDataRangeAudio->MinimumBitsPerSample,
  1288. pDataRangeAudio->MaximumBitsPerSample);
  1289. }
  1290. if(IsEqualGUID(
  1291. &KSDATAFORMAT_SPECIFIER_DSOUND,
  1292. &pDataRangeAudio->DataRange.Specifier)) {
  1293. DPF5(Level, "DSOUND: MaxCH %d MaxSR %u MinSR %u MaxBPS %u MinBPS %u",
  1294. pDataRangeAudio->MaximumChannels,
  1295. pDataRangeAudio->MinimumSampleFrequency,
  1296. pDataRangeAudio->MaximumSampleFrequency,
  1297. pDataRangeAudio->MinimumBitsPerSample,
  1298. pDataRangeAudio->MaximumBitsPerSample);
  1299. }
  1300. }
  1301. PSZ
  1302. DbgUnicode2Sz(
  1303. PWSTR pwstr
  1304. )
  1305. {
  1306. static char sz[256];
  1307. UNICODE_STRING UnicodeString;
  1308. ANSI_STRING AnsiString;
  1309. sz[0] = '\0';
  1310. if(pwstr != NULL) {
  1311. RtlInitUnicodeString(&UnicodeString, pwstr);
  1312. RtlInitAnsiString(&AnsiString, sz);
  1313. AnsiString.MaximumLength = sizeof(sz);
  1314. RtlUnicodeStringToAnsiString(&AnsiString, &UnicodeString, FALSE);
  1315. }
  1316. return(sz);
  1317. }
  1318. PSZ
  1319. DbgIdentifier2Sz(
  1320. PKSIDENTIFIER pIdentifier
  1321. )
  1322. {
  1323. static char sz[256];
  1324. sz[0] = '\0';
  1325. if(pIdentifier != NULL && pIdentifier != INTERNAL_WILDCARD) {
  1326. if(IsEqualGUID(
  1327. &KSMEDIUMSETID_Standard,
  1328. &pIdentifier->Set) &&
  1329. (pIdentifier->Id == KSMEDIUM_STANDARD_DEVIO)) {
  1330. return("KSMEDIUM_STANDARD_DEVIO");
  1331. }
  1332. if(IsEqualGUID(
  1333. &KSINTERFACESETID_Standard,
  1334. &pIdentifier->Set)) {
  1335. switch(pIdentifier->Id) {
  1336. case KSINTERFACE_STANDARD_STREAMING:
  1337. return("KSINTERFACE_STANDARD_STREAMING");
  1338. case KSINTERFACE_STANDARD_LOOPED_STREAMING:
  1339. return("KSINTERFACE_STANDARD_LOOPED_STREAMING");
  1340. case KSINTERFACE_STANDARD_CONTROL:
  1341. return("KSINTERFACE_STANDARD_CONTROL");
  1342. }
  1343. }
  1344. if(IsEqualGUID(
  1345. &KSINTERFACESETID_Media,
  1346. &pIdentifier->Set)) {
  1347. switch(pIdentifier->Id) {
  1348. case KSINTERFACE_MEDIA_MUSIC:
  1349. return("KSINTERFACE_MEDIA_MUSIC");
  1350. case KSINTERFACE_MEDIA_WAVE_BUFFERED:
  1351. return("KSINTERFACE_MEDIA_WAVE_BUFFERED");
  1352. case KSINTERFACE_MEDIA_WAVE_QUEUED:
  1353. return("KSINTERFACE_MEDIA_WAVE_QUEUED");
  1354. }
  1355. }
  1356. if(IsEqualGUID(
  1357. &KSPROPSETID_Pin,
  1358. &pIdentifier->Set)) {
  1359. switch(pIdentifier->Id) {
  1360. case KSPROPERTY_PIN_CINSTANCES:
  1361. return("KSPROPERTY_PIN_CINSTANCES");
  1362. case KSPROPERTY_PIN_CTYPES:
  1363. return("KSPROPERTY_PIN_CTYPES");
  1364. case KSPROPERTY_PIN_DATAFLOW:
  1365. return("KSPROPERTY_PIN_DATAFLOW");
  1366. case KSPROPERTY_PIN_DATARANGES:
  1367. return("KSPROPERTY_PIN_DATARANGES");
  1368. case KSPROPERTY_PIN_DATAINTERSECTION:
  1369. return("KSPROPERTY_PIN_DATAINTERSECTION");
  1370. case KSPROPERTY_PIN_INTERFACES:
  1371. return("KSPROPERTY_PIN_INTERFACES");
  1372. case KSPROPERTY_PIN_MEDIUMS:
  1373. return("KSPROPERTY_PIN_MEDIUMS");
  1374. case KSPROPERTY_PIN_COMMUNICATION:
  1375. return("KSPROPERTY_PIN_COMMUNICATION");
  1376. case KSPROPERTY_PIN_GLOBALCINSTANCES:
  1377. return("KSPROPERTY_PIN_GLOBALCINSTANCES");
  1378. case KSPROPERTY_PIN_NECESSARYINSTANCES:
  1379. return("KSPROPERTY_PIN_NECESSARYINSTANCES");
  1380. case KSPROPERTY_PIN_PHYSICALCONNECTION:
  1381. return("KSPROPERTY_PIN_PHYSICALCONNECTION");
  1382. case KSPROPERTY_PIN_CATEGORY:
  1383. return("KSPROPERTY_PIN_CATEGORY");
  1384. case KSPROPERTY_PIN_NAME:
  1385. return("KSPROPERTY_PIN_NAME");
  1386. case KSPROPERTY_PIN_CONSTRAINEDDATARANGES:
  1387. return("KSPROPERTY_PIN_CONSTRAINEDDATARANGES");
  1388. }
  1389. }
  1390. if(IsEqualGUID(
  1391. &KSPROPSETID_Connection,
  1392. &pIdentifier->Set)) {
  1393. switch(pIdentifier->Id) {
  1394. case KSPROPERTY_CONNECTION_STATE:
  1395. return("KSPROPERTY_CONNECTION_STATE");
  1396. case KSPROPERTY_CONNECTION_PRIORITY:
  1397. return("KSPROPERTY_CONNECTION_PRIORITY");
  1398. case KSPROPERTY_CONNECTION_DATAFORMAT:
  1399. return("KSPROPERTY_CONNECTION_DATAFORMAT");
  1400. case KSPROPERTY_CONNECTION_ALLOCATORFRAMING:
  1401. return("KSPROPERTY_CONNECTION_ALLOCATORFRAMING");
  1402. case KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT:
  1403. return("KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT");
  1404. case KSPROPERTY_CONNECTION_ACQUIREORDERING:
  1405. return("KSPROPERTY_CONNECTION_ACQUIREORDERING");
  1406. case KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX:
  1407. return("KSPROPERTY_CONNECTION_ALLOCATORFRAMING_EX");
  1408. }
  1409. }
  1410. if(IsEqualGUID(
  1411. &KSPROPSETID_Stream,
  1412. &pIdentifier->Set)) {
  1413. switch(pIdentifier->Id) {
  1414. case KSPROPERTY_STREAM_ALLOCATOR:
  1415. return("KSPROPERTY_STREAM_ALLOCATOR");
  1416. case KSPROPERTY_STREAM_MASTERCLOCK:
  1417. return("KSPROPERTY_STREAM_MASTERCLOCK");
  1418. }
  1419. sprintf(sz, "KSPROPSETID_Stream Id: %02x", pIdentifier->Id);
  1420. return(sz);
  1421. }
  1422. if(IsEqualGUID(
  1423. &KSPROPSETID_Clock,
  1424. &pIdentifier->Set)) {
  1425. sprintf(sz, "KSPROPSETID_Clock Id: %02x", pIdentifier->Id);
  1426. return(sz);
  1427. }
  1428. if(IsEqualGUID(
  1429. &KSPROPSETID_StreamAllocator,
  1430. &pIdentifier->Set)) {
  1431. sprintf(sz, "KSPROPSETID_StreamAllocator Id: %02x",
  1432. pIdentifier->Id);
  1433. return(sz);
  1434. }
  1435. if(IsEqualGUID(
  1436. &KSPROPSETID_StreamInterface,
  1437. &pIdentifier->Set)) {
  1438. sprintf(sz, "KSPROPSETID_StreamInterface Id: %02x",
  1439. pIdentifier->Id);
  1440. return(sz);
  1441. }
  1442. if(IsEqualGUID(
  1443. &KSPROPSETID_Topology,
  1444. &pIdentifier->Set)) {
  1445. switch(pIdentifier->Id) {
  1446. case KSPROPERTY_TOPOLOGY_CATEGORIES:
  1447. return("KSPROPERTY_TOPOLOGY_CATEGORIES");
  1448. case KSPROPERTY_TOPOLOGY_NODES:
  1449. return("KSPROPERTY_TOPOLOGY_NODES");
  1450. case KSPROPERTY_TOPOLOGY_CONNECTIONS:
  1451. return("KSPROPERTY_TOPOLOGY_CONNECTIONS");
  1452. case KSPROPERTY_TOPOLOGY_NAME:
  1453. return("KSPROPERTY_TOPOLOGY_NAME");
  1454. default:
  1455. sprintf(sz, "KSPROPSETID_Topology Id: %02x",
  1456. pIdentifier->Id);
  1457. return(sz);
  1458. }
  1459. }
  1460. if(IsEqualGUID(
  1461. &KSPROPSETID_Audio,
  1462. &pIdentifier->Set)) {
  1463. switch(pIdentifier->Id) {
  1464. case KSPROPERTY_AUDIO_VOLUMELEVEL:
  1465. return("KSPROPERTY_AUDIO_VOLUMELEVEL");
  1466. case KSPROPERTY_AUDIO_MUTE:
  1467. return("KSPROPERTY_AUDIO_MUTE");
  1468. case KSPROPERTY_AUDIO_MIX_LEVEL_TABLE:
  1469. return("KSPROPERTY_AUDIO_MIX_LEVEL_TABLE");
  1470. case KSPROPERTY_AUDIO_MIX_LEVEL_CAPS:
  1471. return("KSPROPERTY_AUDIO_MIX_LEVEL_CAPS");
  1472. case KSPROPERTY_AUDIO_MUX_SOURCE:
  1473. return("KSPROPERTY_AUDIO_MUX_SOURCE");
  1474. case KSPROPERTY_AUDIO_BASS:
  1475. return("KSPROPERTY_AUDIO_BASS");
  1476. case KSPROPERTY_AUDIO_MID:
  1477. return("KSPROPERTY_AUDIO_MID");
  1478. case KSPROPERTY_AUDIO_TREBLE:
  1479. return("KSPROPERTY_AUDIO_TREBLE");
  1480. case KSPROPERTY_AUDIO_BASS_BOOST:
  1481. return("KSPROPERTY_AUDIO_BASS_BOOST");
  1482. case KSPROPERTY_AUDIO_AGC:
  1483. return("KSPROPERTY_AUDIO_AGC");
  1484. default:
  1485. sprintf(sz, "KSPROPSETID_Audio Id: %02x", pIdentifier->Id);
  1486. return(sz);
  1487. }
  1488. }
  1489. if(IsEqualGUID(
  1490. &KSPROPSETID_Sysaudio,
  1491. &pIdentifier->Set)) {
  1492. switch(pIdentifier->Id) {
  1493. case KSPROPERTY_SYSAUDIO_DEVICE_COUNT:
  1494. return("KSPROPERTY_SYSAUDIO_DEVICE_COUNT");
  1495. case KSPROPERTY_SYSAUDIO_DEVICE_FRIENDLY_NAME:
  1496. return("KSPROPERTY_SYSAUDIO_DEVICE_FRIENDLY_NAME");
  1497. case KSPROPERTY_SYSAUDIO_DEVICE_INSTANCE:
  1498. return("KSPROPERTY_SYSAUDIO_DEVICE_INSTANCE");
  1499. case KSPROPERTY_SYSAUDIO_DEVICE_INTERFACE_NAME:
  1500. return("KSPROPERTY_SYSAUDIO_DEVICE_INTERFACE_NAME");
  1501. case KSPROPERTY_SYSAUDIO_SELECT_GRAPH:
  1502. return("KSPROPERTY_SYSAUDIO_SELECT_GRAPH");
  1503. case KSPROPERTY_SYSAUDIO_CREATE_VIRTUAL_SOURCE:
  1504. return("KSPROPERTY_SYSAUDIO_CREATE_VIRTUAL_SOURCE");
  1505. case KSPROPERTY_SYSAUDIO_DEVICE_DEFAULT:
  1506. return("KSPROPERTY_SYSAUDIO_DEVICE_DEFAULT");
  1507. case KSPROPERTY_SYSAUDIO_ALWAYS_CREATE_VIRTUAL_SOURCE:
  1508. return("KSPROPERTY_SYSAUDIO_ALWAYS_CREATE_VIRTUAL_SOURCE");
  1509. case KSPROPERTY_SYSAUDIO_ADDREMOVE_LOCK:
  1510. return("KSPROPERTY_SYSAUDIO_ADDREMOVE_LOCK");
  1511. case KSPROPERTY_SYSAUDIO_ADDREMOVE_UNLOCK:
  1512. return("KSPROPERTY_SYSAUDIO_ADDREMOVE_UNLOCK");
  1513. case KSPROPERTY_SYSAUDIO_RENDER_PIN_INSTANCES:
  1514. return("KSPROPERTY_SYSAUDIO_RENDER_PIN_INSTANCES");
  1515. case KSPROPERTY_SYSAUDIO_RENDER_CONNECTION_INDEX:
  1516. return("KSPROPERTY_SYSAUDIO_RENDER_CONNECTION_INDEX");
  1517. default:
  1518. sprintf(sz, "KSPROPSETID_Sysaudio Id: %02x",
  1519. pIdentifier->Id);
  1520. return(sz);
  1521. }
  1522. }
  1523. if(IsEqualGUID(
  1524. &KSEVENTSETID_Connection,
  1525. &pIdentifier->Set)) {
  1526. switch(pIdentifier->Id) {
  1527. case KSEVENT_CONNECTION_POSITIONUPDATE:
  1528. return("KSEVENT_CONNECTION_POSITIONUPDATE");
  1529. case KSEVENT_CONNECTION_DATADISCONTINUITY:
  1530. return("KSEVENT_CONNECTION_DATADISCONTINUITY");
  1531. case KSEVENT_CONNECTION_TIMEDISCONTINUITY:
  1532. return("KSEVENT_CONNECTION_TIMEDISCONTINUITY");
  1533. case KSEVENT_CONNECTION_PRIORITY:
  1534. return("KSEVENT_CONNECTION_PRIORITY");
  1535. case KSEVENT_CONNECTION_ENDOFSTREAM:
  1536. return("KSEVENT_CONNECTION_ENDOFSTREAM");
  1537. }
  1538. }
  1539. if(IsEqualGUID(
  1540. &KSEVENTSETID_Clock,
  1541. &pIdentifier->Set)) {
  1542. switch(pIdentifier->Id) {
  1543. case KSEVENT_CLOCK_INTERVAL_MARK:
  1544. return("KSEVENT_CLOCK_INTERVAL_MARK");
  1545. case KSEVENT_CLOCK_POSITION_MARK:
  1546. return("KSEVENT_CLOCK_POSITION_MARK");
  1547. }
  1548. }
  1549. if(IsEqualGUID(
  1550. &GUID_NULL,
  1551. &pIdentifier->Set)) {
  1552. sprintf(sz, "GUID_NULL Id: %02x", pIdentifier->Id);
  1553. return(sz);
  1554. }
  1555. sprintf(sz, "Set: %s Id: %02x",
  1556. DbgGuid2Sz(&pIdentifier->Set),
  1557. pIdentifier->Id);
  1558. }
  1559. else {
  1560. sprintf(sz, "%08x", (ULONG_PTR)pIdentifier);
  1561. }
  1562. return(sz);
  1563. }
  1564. PSZ
  1565. DbgGuid2Sz(
  1566. GUID *pGuid
  1567. )
  1568. {
  1569. static char sz[256];
  1570. if(pGuid == NULL) {
  1571. return("NO GUID");
  1572. }
  1573. if(IsEqualGUID(
  1574. &GUID_NULL,
  1575. pGuid)) {
  1576. return("GUID_NULL");
  1577. }
  1578. if(IsEqualGUID(
  1579. &KSDATAFORMAT_TYPE_AUDIO,
  1580. pGuid)) {
  1581. return("KSDATAFORMAT_TYPE_AUDIO");
  1582. }
  1583. if(IsEqualGUID(
  1584. &KSDATAFORMAT_SUBTYPE_ANALOG,
  1585. pGuid)) {
  1586. return("KSDATAFORMAT_SUBTYPE_ANALOG");
  1587. }
  1588. if(IsEqualGUID(
  1589. &KSDATAFORMAT_SUBTYPE_PCM,
  1590. pGuid)) {
  1591. return("KSDATAFORMAT_SUBTYPE_PCM");
  1592. }
  1593. if(IsEqualGUID(
  1594. &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT,
  1595. pGuid)) {
  1596. return("KSDATAFORMAT_SUBTYPE_IEEE_FLOAT");
  1597. }
  1598. if(IsEqualGUID(
  1599. &KSDATAFORMAT_TYPE_MUSIC,
  1600. pGuid)) {
  1601. return("KSDATAFORMAT_TYPE_MUSIC");
  1602. }
  1603. if(IsEqualGUID(
  1604. &KSDATAFORMAT_SUBTYPE_MIDI,
  1605. pGuid)) {
  1606. return("KSDATAFORMAT_SUBTYPE_MIDI");
  1607. }
  1608. if(IsEqualGUID(
  1609. &KSDATAFORMAT_SUBTYPE_MIDI_BUS,
  1610. pGuid)) {
  1611. return("KSDATAFORMAT_SUBTYPE_MIDI_BUS");
  1612. }
  1613. if(IsEqualGUID(
  1614. &KSDATAFORMAT_SPECIFIER_DSOUND,
  1615. pGuid)) {
  1616. return("KSDATAFORMAT_SPECIFIER_DSOUND");
  1617. }
  1618. if(IsEqualGUID(
  1619. &KSDATAFORMAT_SPECIFIER_WAVEFORMATEX,
  1620. pGuid)) {
  1621. return("KSDATAFORMAT_SPECIFIER_WAVEFORMATEX");
  1622. }
  1623. if(IsEqualGUID(
  1624. &KSDATAFORMAT_SPECIFIER_NONE,
  1625. pGuid)) {
  1626. return("KSDATAFORMAT_SPECIFIER_NONE");
  1627. }
  1628. if(IsEqualGUID(
  1629. &KSCATEGORY_AUDIO,
  1630. pGuid)) {
  1631. return("KSCATEGORY_AUDIO");
  1632. }
  1633. if(IsEqualGUID(
  1634. &KSNODETYPE_SPEAKER,
  1635. pGuid)) {
  1636. return("KSNODETYPE_SPEAKER");
  1637. }
  1638. if(IsEqualGUID(
  1639. &KSNODETYPE_MICROPHONE,
  1640. pGuid)) {
  1641. return("KSNODETYPE_MICROPHONE");
  1642. }
  1643. if(IsEqualGUID(
  1644. &KSNODETYPE_CD_PLAYER,
  1645. pGuid)) {
  1646. return("KSNODETYPE_CD_PLAYER");
  1647. }
  1648. if(IsEqualGUID(
  1649. &KSNODETYPE_LEGACY_AUDIO_CONNECTOR,
  1650. pGuid)) {
  1651. return("KSNODETYPE_LEGACY_AUDIO_CONNECTOR");
  1652. }
  1653. if(IsEqualGUID(
  1654. &KSNODETYPE_ANALOG_CONNECTOR,
  1655. pGuid)) {
  1656. return("KSNODETYPE_ANALOG_CONNECTOR");
  1657. }
  1658. if(IsEqualGUID(
  1659. &KSCATEGORY_WDMAUD_USE_PIN_NAME,
  1660. pGuid)) {
  1661. return("KSCATEGORY_WDMAUD_USE_PIN_NAME");
  1662. }
  1663. if(IsEqualGUID(
  1664. &KSNODETYPE_LINE_CONNECTOR,
  1665. pGuid)) {
  1666. return("KSNODETYPE_LINE_CONNECTOR");
  1667. }
  1668. if(IsEqualGUID(
  1669. &GUID_TARGET_DEVICE_QUERY_REMOVE,
  1670. pGuid)) {
  1671. return("GUID_TARGET_DEVICE_QUERY_REMOVE");
  1672. }
  1673. if(IsEqualGUID(
  1674. &GUID_TARGET_DEVICE_REMOVE_CANCELLED,
  1675. pGuid)) {
  1676. return("GUID_TARGET_DEVICE_REMOVE_CANCELLED");
  1677. }
  1678. if(IsEqualGUID(
  1679. &GUID_TARGET_DEVICE_REMOVE_COMPLETE,
  1680. pGuid)) {
  1681. return("GUID_TARGET_DEVICE_REMOVE_COMPLETE");
  1682. }
  1683. if(IsEqualGUID(
  1684. &PINNAME_CAPTURE,
  1685. pGuid)) {
  1686. return("PINNAME_CAPTURE");
  1687. }
  1688. if(IsEqualGUID(&KSNODETYPE_DAC, pGuid)) {
  1689. return("KSNODETYPE_DAC");
  1690. }
  1691. if(IsEqualGUID(&KSNODETYPE_ADC, pGuid)) {
  1692. return("KSNODETYPE_ADC");
  1693. }
  1694. if(IsEqualGUID(&KSNODETYPE_SRC, pGuid)) {
  1695. return("KSNODETYPE_SRC");
  1696. }
  1697. if(IsEqualGUID(&KSNODETYPE_SUPERMIX, pGuid)) {
  1698. return("KSNODETYPE_SUPERMIX");
  1699. }
  1700. if(IsEqualGUID( &KSNODETYPE_MUX, pGuid)) {
  1701. return("KSNODETYPE_MUX");
  1702. }
  1703. if(IsEqualGUID( &KSNODETYPE_DEMUX, pGuid)) {
  1704. return("KSNODETYPE_DEMUX");
  1705. }
  1706. if(IsEqualGUID(&KSNODETYPE_SUM, pGuid)) {
  1707. return("KSNODETYPE_SUM");
  1708. }
  1709. if(IsEqualGUID(&KSNODETYPE_MUTE, pGuid)) {
  1710. return("KSNODETYPE_MUTE");
  1711. }
  1712. if(IsEqualGUID(&KSNODETYPE_VOLUME, pGuid)) {
  1713. return("KSNODETYPE_VOLUME");
  1714. }
  1715. if(IsEqualGUID(&KSNODETYPE_TONE, pGuid)) {
  1716. return("KSNODETYPE_TONE");
  1717. }
  1718. if(IsEqualGUID(&KSNODETYPE_AGC, pGuid)) {
  1719. return("KSNODETYPE_AGC");
  1720. }
  1721. if(IsEqualGUID(&KSNODETYPE_SYNTHESIZER, pGuid)) {
  1722. return("KSNODETYPE_SYNTHESIZER");
  1723. }
  1724. if(IsEqualGUID(&KSNODETYPE_SWSYNTH, pGuid)) {
  1725. return("KSNODETYPE_SWSYNTH");
  1726. }
  1727. if(IsEqualGUID(&KSNODETYPE_3D_EFFECTS, pGuid)) {
  1728. return("KSNODETYPE_3D_EFFECTS");
  1729. }
  1730. sprintf(sz, "%08x %04x %04x %02x%02x%02x%02x%02x%02x%02x%02x",
  1731. pGuid->Data1,
  1732. pGuid->Data2,
  1733. pGuid->Data3,
  1734. pGuid->Data4[0],
  1735. pGuid->Data4[1],
  1736. pGuid->Data4[2],
  1737. pGuid->Data4[3],
  1738. pGuid->Data4[4],
  1739. pGuid->Data4[5],
  1740. pGuid->Data4[6],
  1741. pGuid->Data4[7]);
  1742. return(sz);
  1743. }
  1744. #endif // DEBUG
  1745. //---------------------------------------------------------------------------
  1746. // End of File: util.c
  1747. //---------------------------------------------------------------------------