30 _In_ HANDLE DeviceHandle
35 BOOLEAN ndisQuerySupported =
FALSE;
36 BOOLEAN adapterNameSupported =
FALSE;
37 BOOLEAN adapterStatsSupported =
FALSE;
38 BOOLEAN adapterLinkStateSupported =
FALSE;
39 BOOLEAN adapterLinkSpeedSupported =
FALSE;
40 PNDIS_OID ndisObjectIdentifiers = NULL;
43 opcode = OID_GEN_SUPPORTED_LIST;
46 ndisObjectIdentifiers = PhAllocate(
sizeof(NDIS_OID) *
PAGE_SIZE);
47 memset(ndisObjectIdentifiers, 0,
sizeof(NDIS_OID) * PAGE_SIZE);
55 IOCTL_NDIS_QUERY_GLOBAL_STATS,
58 ndisObjectIdentifiers,
59 sizeof(NDIS_OID) * PAGE_SIZE
62 ndisQuerySupported =
TRUE;
66 NDIS_OID opcode = ndisObjectIdentifiers[i];
70 case OID_GEN_FRIENDLY_NAME:
71 adapterNameSupported =
TRUE;
73 case OID_GEN_STATISTICS:
74 adapterStatsSupported =
TRUE;
76 case OID_GEN_LINK_STATE:
77 adapterLinkStateSupported =
TRUE;
79 case OID_GEN_LINK_SPEED:
80 adapterLinkSpeedSupported =
TRUE;
86 PhFree(ndisObjectIdentifiers);
88 if (!adapterNameSupported)
89 ndisQuerySupported =
FALSE;
90 if (!adapterStatsSupported)
91 ndisQuerySupported =
FALSE;
92 if (!adapterLinkStateSupported)
93 ndisQuerySupported =
FALSE;
94 if (!adapterLinkSpeedSupported)
95 ndisQuerySupported =
FALSE;
97 return ndisQuerySupported;
101 _In_ HANDLE DeviceHandle,
102 _Out_opt_ PUINT MajorVersion,
103 _Out_opt_ PUINT MinorVersion
108 ULONG versionResult = 0;
111 opcode = OID_GEN_DRIVER_VERSION;
119 IOCTL_NDIS_QUERY_GLOBAL_STATS,
123 sizeof(versionResult)
128 *MajorVersion = HIBYTE(versionResult);
133 *MinorVersion = LOBYTE(versionResult);
148 WCHAR adapterNameBuffer[MAX_PATH] = L
"";
151 opcode = OID_GEN_FRIENDLY_NAME;
154 Context->DeviceHandle,
159 IOCTL_NDIS_QUERY_GLOBAL_STATS,
163 sizeof(adapterNameBuffer)
172 GUID deviceGuid = GUID_NULL;
179 SIZE_T adapterDescriptionLength = 0;
180 WCHAR adapterDescription[NDIS_IF_MAX_STRING_SIZE + 1] = L
"";
182 adapterDescriptionLength =
sizeof(adapterDescription);
195 _In_ HANDLE DeviceHandle,
196 _Out_ PNDIS_STATISTICS_INFO Info
202 NDIS_STATISTICS_INFO result;
205 opcode = OID_GEN_STATISTICS;
207 memset(&result, 0,
sizeof(NDIS_STATISTICS_INFO));
208 result.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
209 result.Header.Revision = NDIS_STATISTICS_INFO_REVISION_1;
210 result.Header.Size = NDIS_SIZEOF_STATISTICS_INFO_REVISION_1;
218 IOCTL_NDIS_QUERY_GLOBAL_STATS,
231 _In_ HANDLE DeviceHandle,
232 _Out_ PNDIS_LINK_STATE State
238 NDIS_LINK_STATE result;
241 opcode = OID_GEN_LINK_STATE;
243 memset(&result, 0,
sizeof(NDIS_LINK_STATE));
244 result.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
245 result.Header.Revision = NDIS_LINK_STATE_REVISION_1;
246 result.Header.Size = NDIS_SIZEOF_LINK_STATE_REVISION_1;
254 IOCTL_NDIS_QUERY_GLOBAL_STATS,
267 _In_ HANDLE DeviceHandle,
268 _Out_ PNDIS_PHYSICAL_MEDIUM Medium
273 NDIS_PHYSICAL_MEDIUM adapterMediaType = NdisPhysicalMediumUnspecified;
276 opcode = OID_GEN_PHYSICAL_MEDIUM_EX;
284 IOCTL_NDIS_QUERY_GLOBAL_STATS,
288 sizeof(adapterMediaType)
291 *Medium = adapterMediaType;
294 if (adapterMediaType != NdisPhysicalMediumUnspecified)
298 opcode = OID_GEN_PHYSICAL_MEDIUM;
299 adapterMediaType = NdisPhysicalMediumUnspecified;
308 IOCTL_NDIS_QUERY_GLOBAL_STATS,
312 sizeof(adapterMediaType)
315 *Medium = adapterMediaType;
318 if (adapterMediaType != NdisPhysicalMediumUnspecified)
328 _In_ HANDLE DeviceHandle,
329 _Out_ PULONG64 LinkSpeed
335 NDIS_CO_LINK_SPEED result;
338 opcode = OID_GEN_LINK_SPEED;
340 memset(&result, 0,
sizeof(NDIS_CO_LINK_SPEED));
348 IOCTL_NDIS_QUERY_GLOBAL_STATS,
361 _In_ HANDLE DeviceHandle,
374 IOCTL_NDIS_QUERY_GLOBAL_STATS,
391 MIB_IF_ROW2 interfaceRow;
393 memset(&interfaceRow, 0,
sizeof(MIB_IF_ROW2));
395 interfaceRow.InterfaceLuid = Context->AdapterEntry->InterfaceLuid;
396 interfaceRow.InterfaceIndex = Context->AdapterEntry->InterfaceIndex;
417 MIB_IFROW interfaceRow;
419 memset(&interfaceRow, 0,
sizeof(MIB_IFROW));
421 interfaceRow.dwIndex = Context->AdapterEntry->InterfaceIndex;
423 GetIfEntry(&interfaceRow);