Skip to content

Commit 970db18

Browse files
author
dmex
committed
NetAdaptersPlugin: fixed feature support;
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5731 21ef857c-d57f-4fe0-8362-d861dc6d29cd
1 parent 30a459b commit 970db18

File tree

1 file changed

+13
-35
lines changed
  • 2.x/trunk/plugins-extra/NetAdaptersPlugin

1 file changed

+13
-35
lines changed

2.x/trunk/plugins-extra/NetAdaptersPlugin/graph.c

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static BOOLEAN NetworkAdapterQuerySupported(
3939
BOOLEAN adapterNameSupported = FALSE;
4040
BOOLEAN adapterStatsSupported = FALSE;
4141
BOOLEAN adapterLinkStateSupported = FALSE;
42+
BOOLEAN adapterLinkSpeedSupported = FALSE;
4243
NDIS_OID ndisObjectIdentifiers[PAGE_SIZE];
4344

4445
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff569642.aspx
@@ -77,6 +78,9 @@ static BOOLEAN NetworkAdapterQuerySupported(
7778
case OID_GEN_LINK_STATE:
7879
adapterLinkStateSupported = TRUE;
7980
break;
81+
case OID_GEN_LINK_SPEED:
82+
adapterLinkSpeedSupported = TRUE;
83+
break;
8084
}
8185
}
8286
}
@@ -87,6 +91,8 @@ static BOOLEAN NetworkAdapterQuerySupported(
8791
ndisQuerySupported = FALSE;
8892
if (!adapterLinkStateSupported)
8993
ndisQuerySupported = FALSE;
94+
if (!adapterLinkSpeedSupported)
95+
ndisQuerySupported = FALSE;
9096

9197
return ndisQuerySupported;
9298
}
@@ -317,10 +323,12 @@ static PPH_STRING NetworkAdapterQueryLinkSpeed(
317323
{
318324
NDIS_OID opcode;
319325
IO_STATUS_BLOCK isb;
320-
ULONG64 result = 0;
326+
NDIS_CO_LINK_SPEED result;
321327

322328
// 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));
324332

325333
if (NT_SUCCESS(NtDeviceIoControlFile(
326334
DeviceHandle,
@@ -335,32 +343,7 @@ static PPH_STRING NetworkAdapterQueryLinkSpeed(
335343
sizeof(result)
336344
)))
337345
{
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);
364347
}
365348

366349
return PhReferenceEmptyString();
@@ -791,13 +774,8 @@ static BOOLEAN NetAdapterSectionCallback(
791774

792775
if (context->DeviceHandle)
793776
{
794-
if (NetworkAdapterQuerySupported(context->DeviceHandle))
795-
{
796-
NetworkAdapterQueryMediaType(context);
797-
NetworkAdapterQueryNdisVersion(context);
798-
}
799-
else
800-
{
777+
if (!NetworkAdapterQuerySupported(context->DeviceHandle))
778+
{
801779
NtClose(context->DeviceHandle);
802780
context->DeviceHandle = NULL;
803781
}

0 commit comments

Comments
 (0)