Process Hacker
main.h
Go to the documentation of this file.
1 /*
2  * Process Hacker Extra Plugins -
3  * Network Adapters Plugin
4  *
5  * Copyright (C) 2015 dmex
6  *
7  * This file is part of Process Hacker.
8  *
9  * Process Hacker is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * Process Hacker is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef _NETADAPTER_H_
24 #define _NETADAPTER_H_
25 
26 #pragma comment(lib, "Iphlpapi.lib")
27 
28 #define PLUGIN_NAME L"ProcessHacker.NetAdapters"
29 #define SETTING_NAME_ENABLE_NDIS (PLUGIN_NAME L".EnableNDIS")
30 #define SETTING_NAME_INTERFACE_LIST (PLUGIN_NAME L".InterfaceList")
31 
32 #define CINTERFACE
33 #define COBJMACROS
34 #include <phdk.h>
35 #include <phappresource.h>
36 
37 #include <ws2def.h>
38 #include <ws2ipdef.h>
39 #include <ws2tcpip.h>
40 #include <iphlpapi.h>
41 #include <nldef.h>
42 #include <netioapi.h>
43 
44 #include "resource.h"
45 
48 
49 typedef struct _PH_NETADAPTER_ENTRY
50 {
51  NET_IFINDEX InterfaceIndex;
52  IF_LUID InterfaceLuid;
55 
56 typedef struct _PH_NETADAPTER_CONTEXT
57 {
61 
63 {
64  BOOLEAN HaveFirstSample;
65 
66  //ULONG64 LinkSpeed;
67  ULONG64 InboundValue;
68  ULONG64 OutboundValue;
71 
73  PPH_NETADAPTER_ENTRY AdapterEntry;
74 
78 
79  HANDLE DeviceHandle;
80 
85 
86  PH_CIRCULAR_BUFFER_ULONG64 InboundBuffer;
87  PH_CIRCULAR_BUFFER_ULONG64 OutboundBuffer;
89 
91  _Inout_ PPH_LIST FilterList,
92  _In_ PPH_STRING String
93  );
94 
96  _In_ HWND ParentHandle
97  );
98 
100  _In_ PPH_PLUGIN_SYSINFO_POINTERS Pointers,
101  _In_ PPH_NETADAPTER_ENTRY AdapterInfo
102  );
103 
104 
105 // ndis.c
106 
107 #define BITS_IN_ONE_BYTE 8
108 #define NDIS_UNIT_OF_MEASUREMENT 100
109 
110 typedef ULONG (WINAPI* _GetIfEntry2)(
111  _Inout_ PMIB_IF_ROW2 Row
112  );
113 
114 // dmex: rev
115 typedef ULONG (WINAPI* _GetInterfaceDescriptionFromGuid)(
116  _Inout_ PGUID InterfaceGuid,
117  _Out_opt_ PWSTR InterfaceDescription,
118  _Inout_ PSIZE_T LengthAddress,
119  PVOID Unknown1,
120  PVOID Unknown2
121  );
122 
123 extern HMODULE IphlpHandle;
126 
128  _In_ HANDLE DeviceHandle
129  );
130 
132  _In_ HANDLE DeviceHandle,
133  _Out_opt_ PUINT MajorVersion,
134  _Out_opt_ PUINT MinorVersion
135  );
136 
138  _Inout_ PPH_NETADAPTER_SYSINFO_CONTEXT Context
139  );
140 
142  _In_ HANDLE DeviceHandle,
143  _Out_ PNDIS_STATISTICS_INFO Info
144  );
145 
147  _In_ HANDLE DeviceHandle,
148  _Out_ PNDIS_LINK_STATE State
149  );
150 
152  _In_ HANDLE DeviceHandle,
153  _Out_ PNDIS_PHYSICAL_MEDIUM Medium
154  );
155 
157  _In_ HANDLE DeviceHandle,
158  _Out_ PULONG64 LinkSpeed
159  );
160 
162  _In_ HANDLE DeviceHandle,
163  _In_ NDIS_OID OpCode
164  );
165 
166 MIB_IF_ROW2 QueryInterfaceRowVista(
167  _Inout_ PPH_NETADAPTER_SYSINFO_CONTEXT Context
168  );
169 
170 MIB_IFROW QueryInterfaceRowXP(
171  _Inout_ PPH_NETADAPTER_SYSINFO_CONTEXT Context
172  );
173 
174 #endif _NETADAPTER_H_