@@ -917,6 +917,34 @@ LwfOidSubmitRequestFn(
917
917
CXPLAT_THREAD_RETURN (0 );
918
918
}
919
919
920
+ template <typename T>
921
+ static
922
+ unique_malloc_ptr<T>
923
+ LwfOidAllocateAndSubmitRequest (
924
+ _In_ const unique_fnlwf_handle &Handle ,
925
+ _In_ OID_KEY Key,
926
+ _Out_ UINT32 *BytesReturned
927
+ )
928
+ {
929
+ unique_malloc_ptr<T> InformationBuffer;
930
+ UINT32 InformationBufferLength = 0 ;
931
+ FNLWFAPI_STATUS Result;
932
+
933
+ Result = LwfOidSubmitRequest (Handle , Key, &InformationBufferLength, NULL );
934
+ TEST_EQUAL_RET (FNLWFAPI_STATUS_MORE_DATA, Result, InformationBuffer);
935
+ TEST_TRUE_RET (InformationBufferLength > 0 , InformationBuffer);
936
+
937
+ InformationBuffer.reset ((T *)CxPlatAllocNonPaged (InformationBufferLength, POOL_TAG));
938
+ TEST_NOT_NULL_RET (InformationBuffer.get (), InformationBuffer);
939
+
940
+ Result = LwfOidSubmitRequest (Handle , Key, &InformationBufferLength, InformationBuffer.get ());
941
+ TEST_FNLWFAPI_RET (Result, InformationBuffer);
942
+ TEST_TRUE_RET (InformationBufferLength > 0 , InformationBuffer);
943
+ *BytesReturned = InformationBufferLength;
944
+
945
+ return InformationBuffer;
946
+ }
947
+
920
948
static
921
949
bool
922
950
WaitForWfpQuarantine (
@@ -1521,28 +1549,33 @@ MpBasicWatchdog()
1521
1549
static
1522
1550
VOID
1523
1551
MpVerifyPortState (
1524
- _In_ const unique_fnlwf_handle& LwfHandle,
1552
+ _In_ const unique_fnlwf_handle & LwfHandle,
1525
1553
_In_ NDIS_PORT_NUMBER PortNumber,
1526
1554
_In_ BOOLEAN ExpectFound
1527
1555
)
1528
1556
{
1529
1557
OID_KEY OidKey;
1530
- InitializeOidKey (&OidKey, OID_GEN_PORT_STATE, NdisRequestQueryInformation);
1531
- OidKey.PortNumber = PortNumber;
1558
+ InitializeOidKey (&OidKey, OID_GEN_ENUMERATE_PORTS, NdisRequestQueryInformation);
1532
1559
NDIS_PORT_STATE PortState = {0 };
1533
- UINT32 PortStateSize = sizeof (PortState);
1560
+ UINT32 BytesReturned;
1561
+ BOOLEAN Found = FALSE ;
1534
1562
1535
1563
//
1536
1564
// Verify the port state is accurately reported to NDIS components.
1537
1565
//
1538
1566
1539
- FNLWFAPI_STATUS Status = LwfOidSubmitRequest (LwfHandle, OidKey, &PortStateSize, &PortState);
1567
+ auto PortArray =
1568
+ LwfOidAllocateAndSubmitRequest<NDIS_PORT_ARRAY>(LwfHandle, OidKey, &BytesReturned);
1569
+ TEST_NOT_NULL (PortArray.get ());
1540
1570
1541
- if (ExpectFound) {
1542
- TEST_FNLWFAPI (Status);
1543
- } else {
1544
- TEST_NOT_EQUAL (FNLWFAPI_STATUS_SUCCESS, Status);
1571
+ for (UINT64 i = 0 ; i < PortArray->NumberOfPorts ; i++) {
1572
+ const NDIS_PORT_CHARACTERISTICS *PortCharacteristics = (const NDIS_PORT_CHARACTERISTICS *)
1573
+ RTL_PTR_ADD (PortArray.get (), PortArray->OffsetFirstPort + PortArray->ElementSize * i);
1574
+
1575
+ Found |= PortCharacteristics->PortNumber == PortNumber;
1545
1576
}
1577
+
1578
+ TEST_EQUAL (ExpectFound, Found);
1546
1579
}
1547
1580
1548
1581
EXTERN_C
0 commit comments