@@ -39,6 +39,7 @@ static BOOLEAN NetworkAdapterQuerySupported(
39
39
BOOLEAN adapterNameSupported = FALSE;
40
40
BOOLEAN adapterStatsSupported = FALSE;
41
41
BOOLEAN adapterLinkStateSupported = FALSE;
42
+ BOOLEAN adapterLinkSpeedSupported = FALSE;
42
43
NDIS_OID ndisObjectIdentifiers [PAGE_SIZE ];
43
44
44
45
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff569642.aspx
@@ -77,6 +78,9 @@ static BOOLEAN NetworkAdapterQuerySupported(
77
78
case OID_GEN_LINK_STATE :
78
79
adapterLinkStateSupported = TRUE;
79
80
break ;
81
+ case OID_GEN_LINK_SPEED :
82
+ adapterLinkSpeedSupported = TRUE;
83
+ break ;
80
84
}
81
85
}
82
86
}
@@ -87,6 +91,8 @@ static BOOLEAN NetworkAdapterQuerySupported(
87
91
ndisQuerySupported = FALSE;
88
92
if (!adapterLinkStateSupported )
89
93
ndisQuerySupported = FALSE;
94
+ if (!adapterLinkSpeedSupported )
95
+ ndisQuerySupported = FALSE;
90
96
91
97
return ndisQuerySupported ;
92
98
}
@@ -317,10 +323,12 @@ static PPH_STRING NetworkAdapterQueryLinkSpeed(
317
323
{
318
324
NDIS_OID opcode ;
319
325
IO_STATUS_BLOCK isb ;
320
- ULONG64 result = 0 ;
326
+ NDIS_CO_LINK_SPEED result ;
321
327
322
328
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff569593.aspx
323
- opcode = OID_GEN_LINK_SPEED ;
329
+ opcode = OID_GEN_LINK_SPEED ; // OID_GEN_CO_LINK_SPEED
330
+
331
+ memset (& result , 0 , sizeof (NDIS_CO_LINK_SPEED ));
324
332
325
333
if (NT_SUCCESS (NtDeviceIoControlFile (
326
334
DeviceHandle ,
@@ -335,32 +343,7 @@ static PPH_STRING NetworkAdapterQueryLinkSpeed(
335
343
sizeof (result )
336
344
)))
337
345
{
338
- return PhFormatSize (result * NDIS_UNIT_OF_MEASUREMENT / BITS_IN_ONE_BYTE , -1 );
339
- }
340
- else
341
- {
342
- NDIS_CO_LINK_SPEED linkSpeed ;
343
-
344
- // https://msdn.microsoft.com/en-us/library/windows/hardware/ff569453.aspx
345
- opcode = OID_GEN_CO_LINK_SPEED ;
346
-
347
- memset (& result , 0 , sizeof (NDIS_CO_LINK_SPEED ));
348
-
349
- if (NT_SUCCESS (NtDeviceIoControlFile (
350
- DeviceHandle ,
351
- NULL ,
352
- NULL ,
353
- NULL ,
354
- & isb ,
355
- IOCTL_NDIS_QUERY_GLOBAL_STATS ,
356
- & opcode ,
357
- sizeof (NDIS_OID ),
358
- & linkSpeed ,
359
- sizeof (linkSpeed )
360
- )))
361
- {
362
- return PhFormatSize (linkSpeed .Outbound * NDIS_UNIT_OF_MEASUREMENT / BITS_IN_ONE_BYTE , -1 );
363
- }
346
+ return PhFormatSize (UInt32x32To64 (result .Outbound , NDIS_UNIT_OF_MEASUREMENT ) / BITS_IN_ONE_BYTE , -1 );
364
347
}
365
348
366
349
return PhReferenceEmptyString ();
@@ -791,13 +774,8 @@ static BOOLEAN NetAdapterSectionCallback(
791
774
792
775
if (context -> DeviceHandle )
793
776
{
794
- if (NetworkAdapterQuerySupported (context -> DeviceHandle ))
795
- {
796
- NetworkAdapterQueryMediaType (context );
797
- NetworkAdapterQueryNdisVersion (context );
798
- }
799
- else
800
- {
777
+ if (!NetworkAdapterQuerySupported (context -> DeviceHandle ))
778
+ {
801
779
NtClose (context -> DeviceHandle );
802
780
context -> DeviceHandle = NULL ;
803
781
}
0 commit comments