@@ -680,6 +680,7 @@ NTSTATUS SarCreateEndpoint(
680
680
request->name [MAX_ENDPOINT_NAME_LENGTH] = ' \0 ' ;
681
681
request->id [MAX_ENDPOINT_NAME_LENGTH] = ' \0 ' ;
682
682
RtlInitUnicodeString (&endpoint->deviceName , request->name );
683
+ RtlInitUnicodeString (&endpoint->deviceId , request->id );
683
684
status = SarStringDuplicate (
684
685
&endpoint->deviceName , &endpoint->deviceName );
685
686
@@ -688,6 +689,12 @@ NTSTATUS SarCreateEndpoint(
688
689
}
689
690
690
691
deviceNameAllocated = TRUE ;
692
+ status = SarStringDuplicate (
693
+ &endpoint->deviceId , &endpoint->deviceId );
694
+
695
+ if (!NT_SUCCESS (status)) {
696
+ goto err_out;
697
+ }
691
698
692
699
// Windows 10 introduces a 'format cache' which at this time appears to
693
700
// not fully invalidate itself when KSEVENT_PINCAPS_FORMATCHANGE is
@@ -705,24 +712,24 @@ NTSTATUS SarCreateEndpoint(
705
712
RtlUnicodeStringPrintf (&deviceIdBuffer,
706
713
L" %ws_%d_%d_%d" , request->id , request->channelCount ,
707
714
controlContext->sampleRate , controlContext->sampleSize );
708
- status = SarStringDuplicate (&endpoint->deviceId , &deviceIdBuffer);
715
+ status = SarStringDuplicate (
716
+ &endpoint->deviceIdMangled , &deviceIdBuffer);
709
717
710
718
if (!NT_SUCCESS (status)) {
711
719
goto err_out;
712
720
}
713
721
} else {
714
- RtlInitUnicodeString (&endpoint-> deviceId , request-> id );
715
- status = SarStringDuplicate ( &endpoint->deviceId , &endpoint->deviceId );
722
+ status = SarStringDuplicate (
723
+ &endpoint->deviceIdMangled , &endpoint->deviceId );
716
724
717
725
if (!NT_SUCCESS (status)) {
718
726
goto err_out;
719
727
}
720
728
}
721
729
722
- deviceIdAllocated = TRUE ;
723
730
KsAcquireDevice (ksDevice);
724
731
status = KsCreateFilterFactory (
725
- device, endpoint->filterDesc , endpoint->deviceId .Buffer ,
732
+ device, endpoint->filterDesc , endpoint->deviceIdMangled .Buffer ,
726
733
nullptr , KSCREATE_ITEM_FREEONSTOP,
727
734
nullptr , nullptr , &endpoint->filterFactory );
728
735
KsReleaseDevice (ksDevice);
@@ -799,6 +806,10 @@ VOID SarDeleteEndpoint(SarEndpoint *endpoint)
799
806
SarStringFree (&endpoint->deviceId );
800
807
}
801
808
809
+ if (endpoint->deviceIdMangled .Buffer ) {
810
+ SarStringFree (&endpoint->deviceIdMangled );
811
+ }
812
+
802
813
ExFreePoolWithTag (endpoint, SAR_TAG);
803
814
}
804
815
0 commit comments