-
Notifications
You must be signed in to change notification settings - Fork 12
/
exttools.h
432 lines (341 loc) · 9.77 KB
/
exttools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#ifndef EXTTOOLS_H
#define EXTTOOLS_H
#define PHNT_VERSION PHNT_VISTA
#include <phdk.h>
extern PPH_PLUGIN PluginInstance;
extern LIST_ENTRY EtProcessBlockListHead;
extern LIST_ENTRY EtNetworkBlockListHead;
extern HWND ProcessTreeNewHandle;
extern HWND NetworkTreeNewHandle;
#define PLUGIN_NAME2 L"ProcessHacker.HookTools"
#define SETTING_NAME_HOOK_TREE_LIST_COLUMNS (PLUGIN_NAME2 L".HookTreeListColumns")
#define SETTING_NAME_HOOK_TREE_LIST_SORT (PLUGIN_NAME2 L".HookTreeListSort")
// Process icon
typedef struct _ET_PROCESS_ICON
{
LONG RefCount;
HICON Icon;
} ET_PROCESS_ICON, *PET_PROCESS_ICON;
// Disk item
#define HISTORY_SIZE 60
typedef struct _ET_DISK_ITEM
{
LIST_ENTRY AgeListEntry;
ULONG AddTime;
ULONG FreshTime;
HANDLE ProcessId;
PPH_STRING FileName;
PPH_STRING FileNameWin32;
PPH_STRING ProcessName;
PET_PROCESS_ICON ProcessIcon;
PPH_PROCESS_RECORD ProcessRecord;
ULONG IoPriority;
ULONG ResponseTimeCount;
FLOAT ResponseTimeTotal; // in milliseconds
FLOAT ResponseTimeAverage;
ULONG64 ReadTotal;
ULONG64 WriteTotal;
ULONG64 ReadDelta;
ULONG64 WriteDelta;
ULONG64 ReadAverage;
ULONG64 WriteAverage;
ULONG64 ReadHistory[HISTORY_SIZE];
ULONG64 WriteHistory[HISTORY_SIZE];
ULONG HistoryCount;
ULONG HistoryPosition;
} ET_DISK_ITEM, *PET_DISK_ITEM;
// Disk node
#define ETDSTNC_NAME 0
#define ETDSTNC_FILE 1
#define ETDSTNC_READRATEAVERAGE 2
#define ETDSTNC_WRITERATEAVERAGE 3
#define ETDSTNC_TOTALRATEAVERAGE 4
#define ETDSTNC_IOPRIORITY 5
#define ETDSTNC_RESPONSETIME 6
#define ETDSTNC_MAXIMUM 7
#define ETDSTNC_TYPE 0
#define ETDSTNC_PID 1
#define ETDSTNC_PROCESS 2
#define ETDSTNC_FLAGS 3
#define ETDSTNC_PATH 4
typedef struct _ET_DISK_NODE
{
PH_TREENEW_NODE Node;
PET_DISK_ITEM DiskItem;
PH_STRINGREF TextCache[ETDSTNC_MAXIMUM];
PPH_STRING ProcessNameText;
PPH_STRING ReadRateAverageText;
PPH_STRING WriteRateAverageText;
PPH_STRING TotalRateAverageText;
PPH_STRING ResponseTimeText;
PPH_STRING TooltipText;
} ET_DISK_NODE, *PET_DISK_NODE;
#define ETHKTNC_TYPE 0
#define ETHKTNC_PID 1
#define ETHKTNC_PROCESS 2
#define ETHKTNC_PATH 4
#define ETHKTNC_STARTTIME 5
#define ETHKTNC_RELATIVESTARTTIME 6
#define ETHKTNC_FLAGS 3
#define ETHKTNC_COMMANDLINE 7
#define ETHKTNC_MAXIMUM 8
typedef struct _ET_HOOK_ITEM
{
LIST_ENTRY AgeListEntry;
ULONG AddTime;
ULONG FreshTime;
HANDLE ProcessId;
PPH_STRING FileName;
PPH_STRING FileNameWin32;
PPH_STRING ProcessName;
PET_PROCESS_ICON ProcessIcon;
PPH_PROCESS_RECORD ProcessRecord;
ULONG IoPriority;
ULONG ResponseTimeCount;
FLOAT ResponseTimeTotal; // in milliseconds
FLOAT ResponseTimeAverage;
ULONG64 ReadTotal;
ULONG64 WriteTotal;
ULONG64 ReadDelta;
ULONG64 WriteDelta;
ULONG64 ReadAverage;
ULONG64 WriteAverage;
ULONG64 ReadHistory[HISTORY_SIZE];
ULONG64 WriteHistory[HISTORY_SIZE];
ULONG HistoryCount;
ULONG HistoryPosition;
} ET_HOOK_ITEM, *PET_HOOK_ITEM;
typedef struct _ET_HOOK_NODE
{
PH_TREENEW_NODE Node;
PET_HOOK_ITEM HookItem;
PH_STRINGREF TextCache[ETDSTNC_MAXIMUM];
PPH_STRING ProcessNameText;
PPH_STRING ReadRateAverageText;
PPH_STRING WriteRateAverageText;
PPH_STRING TotalRateAverageText;
PPH_STRING ResponseTimeText;
PPH_STRING TooltipText;
} ET_HOOK_NODE, *PET_HOOK_NODE;
// Process tree columns
#define ETPRTNC_DISKREADS 1
#define ETPRTNC_DISKWRITES 2
#define ETPRTNC_DISKREADBYTES 3
#define ETPRTNC_DISKWRITEBYTES 4
#define ETPRTNC_DISKTOTALBYTES 5
#define ETPRTNC_DISKREADSDELTA 6
#define ETPRTNC_DISKWRITESDELTA 7
#define ETPRTNC_DISKREADBYTESDELTA 8
#define ETPRTNC_DISKWRITEBYTESDELTA 9
#define ETPRTNC_DISKTOTALBYTESDELTA 10
#define ETPRTNC_NETWORKRECEIVES 11
#define ETPRTNC_NETWORKSENDS 12
#define ETPRTNC_NETWORKRECEIVEBYTES 13
#define ETPRTNC_NETWORKSENDBYTES 14
#define ETPRTNC_NETWORKTOTALBYTES 15
#define ETPRTNC_NETWORKRECEIVESDELTA 16
#define ETPRTNC_NETWORKSENDSDELTA 17
#define ETPRTNC_NETWORKRECEIVEBYTESDELTA 18
#define ETPRTNC_NETWORKSENDBYTESDELTA 19
#define ETPRTNC_NETWORKTOTALBYTESDELTA 20
#define ETPRTNC_HARDFAULTS 21
#define ETPRTNC_HARDFAULTSDELTA 22
#define ETPRTNC_PEAKTHREADS 23
#define ETPRTNC_GPU 24
#define ETPRTNC_GPUDEDICATEDBYTES 25
#define ETPRTNC_GPUSHAREDBYTES 26
#define ETPRTNC_DISKREADRATE 27
#define ETPRTNC_DISKWRITERATE 28
#define ETPRTNC_DISKTOTALRATE 29
#define ETPRTNC_NETWORKRECEIVERATE 30
#define ETPRTNC_NETWORKSENDRATE 31
#define ETPRTNC_NETWORKTOTALRATE 32
#define ETPRTNC_MAXIMUM 32
// Network list columns
#define ETNETNC_RECEIVES 1
#define ETNETNC_SENDS 2
#define ETNETNC_RECEIVEBYTES 3
#define ETNETNC_SENDBYTES 4
#define ETNETNC_TOTALBYTES 5
#define ETNETNC_RECEIVESDELTA 6
#define ETNETNC_SENDSDELTA 7
#define ETNETNC_RECEIVEBYTESDELTA 8
#define ETNETNC_SENDBYTESDELTA 9
#define ETNETNC_TOTALBYTESDELTA 10
#define ETNETNC_FIREWALLSTATUS 11
#define ETNETNC_RECEIVERATE 12
#define ETNETNC_SENDRATE 13
#define ETNETNC_TOTALRATE 14
#define ETNETNC_MAXIMUM 14
// Firewall status
typedef enum _ET_FIREWALL_STATUS
{
FirewallUnknownStatus,
FirewallAllowedNotRestricted,
FirewallAllowedRestricted,
FirewallNotAllowedNotRestricted,
FirewallNotAllowedRestricted,
FirewallMaximumStatus
} ET_FIREWALL_STATUS;
// Object extensions
typedef struct _ET_PROCESS_BLOCK
{
LIST_ENTRY ListEntry;
PPH_PROCESS_ITEM ProcessItem;
ULONG64 DiskReadCount;
ULONG64 DiskWriteCount;
ULONG64 NetworkReceiveCount;
ULONG64 NetworkSendCount;
ULONG64 DiskReadRaw;
ULONG64 DiskWriteRaw;
ULONG64 NetworkReceiveRaw;
ULONG64 NetworkSendRaw;
PH_UINT64_DELTA DiskReadDelta;
PH_UINT64_DELTA DiskReadRawDelta;
PH_UINT64_DELTA DiskWriteDelta;
PH_UINT64_DELTA DiskWriteRawDelta;
PH_UINT64_DELTA NetworkReceiveDelta;
PH_UINT64_DELTA NetworkReceiveRawDelta;
PH_UINT64_DELTA NetworkSendDelta;
PH_UINT64_DELTA NetworkSendRawDelta;
PH_UINT64_DELTA GpuRunningTimeDelta;
FLOAT GpuNodeUsage;
ULONG64 GpuDedicatedUsage;
ULONG64 GpuSharedUsage;
PH_UINT32_DELTA HardFaultsDelta;
PH_QUEUED_LOCK TextCacheLock;
PPH_STRING TextCache[ETPRTNC_MAXIMUM + 1];
BOOLEAN TextCacheValid[ETPRTNC_MAXIMUM + 1];
PET_PROCESS_ICON SmallProcessIcon;
} ET_PROCESS_BLOCK, *PET_PROCESS_BLOCK;
typedef struct _ET_NETWORK_BLOCK
{
LIST_ENTRY ListEntry;
PPH_NETWORK_ITEM NetworkItem;
ULONG64 ReceiveCount;
ULONG64 SendCount;
ULONG64 ReceiveRaw;
ULONG64 SendRaw;
union
{
struct
{
PH_UINT64_DELTA ReceiveDelta;
PH_UINT64_DELTA ReceiveRawDelta;
PH_UINT64_DELTA SendDelta;
PH_UINT64_DELTA SendRawDelta;
};
PH_UINT64_DELTA Deltas[4];
};
ET_FIREWALL_STATUS FirewallStatus;
BOOLEAN FirewallStatusValid;
PH_QUEUED_LOCK TextCacheLock;
PPH_STRING TextCache[ETNETNC_MAXIMUM + 1];
BOOLEAN TextCacheValid[ETNETNC_MAXIMUM + 1];
} ET_NETWORK_BLOCK, *PET_NETWORK_BLOCK;
// main
VOID EtInitializeHooksTab(
VOID
);
PET_PROCESS_BLOCK EtGetProcessBlock(
_In_ PPH_PROCESS_ITEM ProcessItem
);
PET_NETWORK_BLOCK EtGetNetworkBlock(
_In_ PPH_NETWORK_ITEM NetworkItem
);
// utils
VOID EtFormatRate(
_In_ ULONG64 ValuePerPeriod,
_Inout_ PPH_STRING *Buffer,
_Out_opt_ PPH_STRINGREF String
);
// etwmon
//BOOLEAN EtEtwEnabled = TRUE;
// etwstat
extern ULONG EtDiskReadCount;
extern ULONG EtDiskWriteCount;
extern ULONG EtNetworkReceiveCount;
extern ULONG EtNetworkSendCount;
extern PH_UINT32_DELTA EtDiskReadDelta;
extern PH_UINT32_DELTA EtDiskWriteDelta;
extern PH_UINT32_DELTA EtNetworkReceiveDelta;
extern PH_UINT32_DELTA EtNetworkSendDelta;
extern PH_UINT32_DELTA EtDiskReadCountDelta;
extern PH_UINT32_DELTA EtDiskWriteCountDelta;
extern PH_UINT32_DELTA EtNetworkReceiveCountDelta;
extern PH_UINT32_DELTA EtNetworkSendCountDelta;
extern PH_CIRCULAR_BUFFER_ULONG EtDiskReadHistory;
extern PH_CIRCULAR_BUFFER_ULONG EtDiskWriteHistory;
extern PH_CIRCULAR_BUFFER_ULONG EtNetworkReceiveHistory;
extern PH_CIRCULAR_BUFFER_ULONG EtNetworkSendHistory;
extern PH_CIRCULAR_BUFFER_ULONG EtMaxDiskHistory;
extern PH_CIRCULAR_BUFFER_ULONG EtMaxNetworkHistory;
VOID EtEtwStatisticsInitialization(
VOID
);
VOID EtEtwStatisticsUninitialization(
VOID
);
// etwdisk
extern BOOLEAN EtDiskEnabled;
extern PPH_OBJECT_TYPE EtDiskItemType;
extern PH_CALLBACK EtDiskItemAddedEvent;
extern PH_CALLBACK EtDiskItemModifiedEvent;
extern PH_CALLBACK EtDiskItemRemovedEvent;
extern PH_CALLBACK EtDiskItemsUpdatedEvent;
VOID EtInitializeDiskInformation(
VOID
);
PET_DISK_ITEM EtCreateDiskItem(
VOID
);
PET_DISK_ITEM EtReferenceDiskItem(
_In_ HANDLE ProcessId,
_In_ PPH_STRING FileName
);
PPH_STRING EtFileObjectToFileName(
_In_ PVOID FileObject
);
// procicon
PET_PROCESS_ICON EtProcIconCreateProcessIcon(
_In_ HICON Icon
);
VOID EtProcIconReferenceProcessIcon(
_Inout_ PET_PROCESS_ICON ProcessIcon
);
VOID EtProcIconDereferenceProcessIcon(
_Inout_ PET_PROCESS_ICON ProcessIcon
);
PET_PROCESS_ICON EtProcIconReferenceSmallProcessIcon(
_Inout_ PET_PROCESS_BLOCK Block
);
VOID EtProcIconNotifyProcessDelete(
_Inout_ PET_PROCESS_BLOCK Block
);
typedef struct _ET_PROCESS_GPU_STATISTICS
{
ULONG SegmentCount;
ULONG NodeCount;
ULONG64 DedicatedCommitted;
ULONG64 SharedCommitted;
ULONG64 BytesAllocated;
ULONG64 BytesReserved;
ULONG64 WriteCombinedBytesAllocated;
ULONG64 WriteCombinedBytesReserved;
ULONG64 CachedBytesAllocated;
ULONG64 CachedBytesReserved;
ULONG64 SectionBytesAllocated;
ULONG64 SectionBytesReserved;
ULONG64 RunningTime;
ULONG64 ContextSwitches;
} ET_PROCESS_GPU_STATISTICS, *PET_PROCESS_GPU_STATISTICS;
// options
VOID EtShowOptionsDialog(
_In_ HWND ParentWindowHandle
);
// thrdact
BOOLEAN EtUiCancelIoThread(
_In_ HWND hWnd,
_In_ PPH_THREAD_ITEM Thread
);
#endif