Process Hacker
main.c
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 #include "main.h"
24 
31 
32 static VOID NTAPI LoadCallback(
33  _In_opt_ PVOID Parameter,
34  _In_opt_ PVOID Context
35  )
36 {
37  PPH_STRING string = NULL;
38 
40  {
41  if (IphlpHandle = GetModuleHandle(L"iphlpapi.dll"))
42  {
43  GetIfEntry2_I = (_GetIfEntry2)GetProcAddress(IphlpHandle, "GetIfEntry2");
44  GetInterfaceDescriptionFromGuid_I = (_GetInterfaceDescriptionFromGuid)GetProcAddress(IphlpHandle, "NhGetInterfaceDescriptionFromGuid");
45  }
46  }
47 
48  NetworkAdaptersList = PhCreateList(1);
49 
51  LoadAdaptersList(NetworkAdaptersList, string);
52  PhDereferenceObject(string);
53 }
54 
55 static VOID NTAPI UnloadCallback(
56  _In_opt_ PVOID Parameter,
57  _In_opt_ PVOID Context
58  )
59 {
60  NOTHING;
61 }
62 
63 static VOID NTAPI ShowOptionsCallback(
64  _In_opt_ PVOID Parameter,
65  _In_opt_ PVOID Context
66  )
67 {
68  ShowOptionsDialog((HWND)Parameter);
69 }
70 
72  _In_opt_ PVOID Parameter,
73  _In_opt_ PVOID Context
74  )
75 {
77 
78  for (ULONG i = 0; i < NetworkAdaptersList->Count; i++)
79  {
80  PPH_NETADAPTER_ENTRY entry = (PPH_NETADAPTER_ENTRY)NetworkAdaptersList->Items[i];
81 
82  NetAdapterSysInfoInitializing(pluginEntry, entry);
83  }
84 }
85 
87  _In_ HINSTANCE Instance,
88  _In_ ULONG Reason,
89  _Reserved_ PVOID Reserved
90  )
91 {
92  switch (Reason)
93  {
94  case DLL_PROCESS_ATTACH:
95  {
97  PH_SETTING_CREATE settings[] =
98  {
101  };
102 
103  PluginInstance = PhRegisterPlugin(PLUGIN_NAME, Instance, &info);
104 
105  if (!PluginInstance)
106  return FALSE;
107 
108  info->DisplayName = L"Network Adapters";
109  info->Author = L"dmex";
110  info->Description = L"Plugin for monitoring specific network adapter throughput via the System Information window.";
111  info->Url = L"http://processhacker.sf.net/forums/viewtopic.php?t=1820";
112  info->HasOptions = TRUE;
113 
115  PhGetPluginCallback(PluginInstance, PluginCallbackLoad),
116  LoadCallback,
117  NULL,
118  &PluginLoadCallbackRegistration
119  );
121  PhGetPluginCallback(PluginInstance, PluginCallbackUnload),
123  NULL,
124  &PluginUnloadCallbackRegistration
125  );
129  NULL,
130  &PluginShowOptionsCallbackRegistration
131  );
135  NULL,
136  &SystemInformationInitializingCallbackRegistration
137  );
138 
139  PhAddSettings(settings, _countof(settings));
140  }
141  break;
142  }
143 
144  return TRUE;
145 }