Process Hacker
nettools.h
Go to the documentation of this file.
1 /*
2  * Process Hacker ToolStatus -
3  * toolstatus header
4  *
5  * Copyright (C) 2010-2013 wj32
6  * Copyright (C) 2012-2013 dmex
7  *
8  * This file is part of Process Hacker.
9  *
10  * Process Hacker is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * Process Hacker is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef NETTOOLS_H
25 #define NETTOOLS_H
26 
27 #pragma comment(lib, "iphlpapi.lib")
28 #pragma comment(lib, "ws2_32.lib")
29 
30 #define CINTERFACE
31 #define COBJMACROS
32 #include <windowsx.h>
33 #include <phdk.h>
34 #include <phappresource.h>
35 #include <windowsx.h>
36 #include <winsock2.h>
37 #include <ws2tcpip.h>
38 #include <iphlpapi.h>
39 #include <icmpapi.h>
40 
41 #include "resource.h"
42 
43 #define PLUGIN_NAME L"ProcessHacker.NetworkTools"
44 #define SETTING_NAME_TRACERT_WINDOW_POSITION (PLUGIN_NAME L".WindowPosition")
45 #define SETTING_NAME_TRACERT_WINDOW_SIZE (PLUGIN_NAME L".WindowSize")
46 #define SETTING_NAME_PING_WINDOW_POSITION (PLUGIN_NAME L".PingWindowPosition")
47 #define SETTING_NAME_PING_WINDOW_SIZE (PLUGIN_NAME L".PingWindowSize")
48 #define SETTING_NAME_PING_TIMEOUT (PLUGIN_NAME L".PingMaxTimeout")
49 
50 // ICMP Packet Length: (msdn: IcmpSendEcho2/Icmp6SendEcho2)
51 // The buffer must be large enough to hold at least one ICMP_ECHO_REPLY or ICMPV6_ECHO_REPLY structure
52 // + the number of bytes of data specified in the RequestSize parameter.
53 // This buffer should also be large enough to also hold 8 more bytes of data (the size of an ICMP error message)
54 // + space for an IO_STATUS_BLOCK structure.
55 #define ICMP_BUFFER_SIZE(EchoReplyLength, Buffer) (ULONG)(((EchoReplyLength) + (Buffer)->Length) + 8 + sizeof(IO_STATUS_BLOCK))
56 
58 
59 typedef enum _PH_NETWORK_ACTION
60 {
66 
67 // output
68 #define NTM_RECEIVEDTRACE (WM_APP + NETWORK_ACTION_TRACEROUTE)
69 #define NTM_RECEIVEDWHOIS (WM_APP + NETWORK_ACTION_WHOIS)
70 #define NTM_RECEIVEDFINISH (WM_APP + NETWORK_ACTION_FINISH)
71 
73 {
78  PH_CIRCULAR_BUFFER_ULONG PingHistory;
80 
87  HANDLE ProcessHandle;
88  HFONT FontHandle;
89  HICON IconHandle;
90 
95  ULONG PingMinMs;
96  ULONG PingMaxMs;
100 
103  WCHAR IpAddressString[INET6_ADDRSTRLEN];
105 
107  _In_ PVOID Parameter
108  );
109 
111  _In_ PH_NETWORK_ACTION Action,
112  _In_ PPH_NETWORK_ITEM NetworkItem
113  );
114 
115 NTSTATUS NetworkPingThreadStart(
116  _In_ PVOID Parameter
117  );
118 
120  _In_ PVOID Parameter
121  );
122 
123 NTSTATUS NetworkWhoisThreadStart(
124  _In_ PVOID Parameter
125  );
126 
128  _In_opt_ PVOID Parameter,
129  _In_opt_ PVOID Context
130  );
131 
132 INT_PTR CALLBACK NetworkOutputDlgProc(
133  _In_ HWND hwndDlg,
134  _In_ UINT uMsg,
135  _In_ WPARAM wParam,
136  _In_ LPARAM lParam
137  );
138 
139 INT_PTR CALLBACK OptionsDlgProc(
140  _In_ HWND hwndDlg,
141  _In_ UINT uMsg,
142  _In_ WPARAM wParam,
143  _In_ LPARAM lParam
144  );
145 
146 #endif