-
Notifications
You must be signed in to change notification settings - Fork 0
/
precomp.h
284 lines (228 loc) · 6.57 KB
/
precomp.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
//+-------------------------------------------------------------------------
//
// TaskMan - NT TaskManager
// Copyright (C) Microsoft
//
// File: Precomp.H
//
// History: Nov-10-95 DavePl Created
//
//--------------------------------------------------------------------------
//
// Warnings turned off to appease our header files
//
#pragma warning(disable:4127) // Conditional expression is constant
#pragma once
#define STRICT
#if DBG
#define DEBUG 1
#endif
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#define SECURITY_WIN32
extern "C"
{
//#include <nt.h>
//#include <ntrtl.h>
//#include <nturtl.h>
//#include <ntexapi.h>
}
#define SEC_ENTRY __stdcall
typedef short CSHORT;
#include <windows.h>
#include <windowsx.h>
#include <Iphlpapi.h>
#include <objbase.h>
//#include <winuserp.h>
#include <commctrl.h>
//#include <comctrlp.h>
#include <shlobj.h>
//#include <shlobjp.h>
#include <shlwapi.h>
//#include <shlwapip.h>
//#include <shlapip.h>
#include <vdmdbg.h>
//#include <ccstock.h>
#include <wtsapi32.h>
//#include <hydrix.h> // internal hydra defines
//#include <msginaexports.h>
#include <strsafe.h>
//#include <TokenUtil.h> // CPrivilegeEnable
//#include <winsta.h> // WinStationGetProcessSid
//#include <utildll.h> // CachedGetUserFromSid
#include <htmlhelp.h>
#include <lmcons.h>
//#include <sspi.h>
#include <secext.h> // for GetUserNameEx
#include <security.h>
#include <powerbase.h>
#include <ntstatus.h>
#include <dwmapi.h>
//#include <ntdef.h>
#include "rtlmir.h"
#include "shundoc.h"
#include "tokenutil.h"
//
// Global data externs
//
#define PWM_TRAYICON WM_USER + 10
#define PWM_ACTIVATE WM_USER + 11
#define DEFSPACING_BASE 3
#define INNERSPACING_BASE 2
#define TOPSPACING_BASE 10
extern long g_DefSpacing;
extern long g_InnerSpacing;
extern long g_TopSpacing;
#define CONTROL_WIDTH_SPACING 13
#define CONTROL_HEIGHT_SPACING 2
extern long g_ControlWidthSpacing;
extern long g_ControlHeightSpacing;
#define MAX_NETWORKCARDS 32 // Maximum number of Network cards (i.e. max number of network graphs)
#define HIST_SIZE 2000 // Number of data points to track in the history windows
extern HINSTANCE g_hInstance;
extern HWND g_hMainWnd;
extern HDESK g_hMainDesktop;
extern DWORD g_cTasks;
extern DWORD g_cProcesses;
extern BYTE g_cProcessors;
extern BYTE g_CPUUsage;
extern __int64 g_PhysMEMUsage;
extern __int64 g_PhysMEMMax;
extern HMENU g_hMenu;
extern BYTE g_CPUUsage;
extern BYTE * g_pCPUHistory[MAXIMUM_PROCESSORS];
extern BYTE * g_pKernelHistory[MAXIMUM_PROCESSORS];
extern BOOL g_fInPopup;
extern WCHAR g_szK[];
extern WCHAR g_szRealtime[];
extern WCHAR g_szNormal[];
extern WCHAR g_szHigh[];
extern WCHAR g_szLow[];
extern WCHAR g_szUnknown[];
extern WCHAR g_szAboveNormal[];
extern WCHAR g_szBelowNormal[];
extern WCHAR g_szHung[];
extern WCHAR g_szRunning[];
extern WCHAR g_szfmtCPUNum[];
extern WCHAR g_szfmtCPU[];
extern WCHAR g_szTotalCPU[];
extern WCHAR g_szKernelCPU[];
extern WCHAR g_szMemUsage[];
extern HICON g_aTrayIcons[];
extern UINT g_cTrayIcons;
class COptions;
extern COptions g_Options;
//
// Assert
//
#ifdef Assert
#undef Assert
#endif
#ifdef DEBUG
#define Assert(x) \
do \
{ \
if ( !(x) ) \
{ \
DEBUG_BREAK; \
} \
} while (0)
#else
#define Assert(x)
#endif
#ifdef ASSERT
#undef ASSERT
#endif
#define ASSERT(x) Assert(x)
//
// Prototypes
//
BYTE InitNetInfo(); // netpage.cpp
void CalcCpuTime(BOOL); // perfpage.cpp
BYTE InitPerfInfo(); // perfpage.cpp
void ReleasePerfInfo(); // perfpage.cpp
void DisplayFailureMsg(HWND hWnd, UINT idTitle, DWORD dwError); // main.cpp
BOOL CreateNewDesktop(); // main.cpp
void ShowRunningInstance();
HMENU LoadPopupMenu(HINSTANCE hinst, UINT id); // main.cpp
BOOL CheckParentDeferrals(UINT uMsg, WPARAM wParam, LPARAM lParam);
void Tray_Notify(HWND hWnd, LPARAM lParam);
void UpdateTrayIcon(HWND hWnd);
#include "taskmgr.h"
#include "resource.h"
#include "pages.h"
#include "ptrarray.h"
/*++ ShiftArrayWorker
Routine Description:
Shifts a section of an array up or down. If shifting
down, the given element is lost. For up, an empty slot
(with an undefined value) is opened.
Arguments:
pArray - Array starting address
cbArraySize - Size of Array (in BYTES)
cElementSize - Size of array elements
iFirstElement - First element to move
Direction - SHIFT_UP or SHIFT_DOWN
Return Value:
None. No error checking either. Should compile out to
a movememory
Notes:
Call this with the ShiftArray macro which does the size
calcs for you
Revision History:
Jan-26-95 Davepl Created
--*/
#define ShiftArray(array, index, direction) \
\
ShiftArrayWorker((LPBYTE) array, sizeof(array), sizeof(array[0]), index, direction)
typedef enum SHIFT_DIRECTION { SHIFT_UP, SHIFT_DOWN };
static inline void ShiftArrayWorker(const LPBYTE pArray,
const size_t cbArraySize,
const size_t cElementSize,
const UINT iFirstElement,
const SHIFT_DIRECTION Direction)
{
ASSERT( ((cbArraySize / cElementSize) * cElementSize) == cbArraySize);
ASSERT( (iFirstElement + 1) * cElementSize <= cbArraySize );
const LPBYTE pFirst = pArray + (iFirstElement * cElementSize);
const LPBYTE pLast = pArray + cbArraySize - cElementSize;
const UINT cBytesToMove = (UINT)(pLast - pFirst);
ASSERT (pLast >= pFirst);
if (cBytesToMove)
{
if (SHIFT_DOWN == Direction)
{
CopyMemory(pFirst, pFirst + cElementSize, cBytesToMove);
}
else if (Direction == SHIFT_UP)
{
CopyMemory(pFirst + cElementSize, pFirst, cBytesToMove);
}
else
{
ASSERT( FALSE );
}
}
}
//////////////////////////////////////////////////////////////////////////////
//
// MACRO
// DEBUG_BREAK
//
// Description:
// Because the system expection handler can hick-up over INT 3s and
// DebugBreak()s, This x86 only macro causes the program to break in the
// right spot.
//
//////////////////////////////////////////////////////////////////////////////
#if defined( _X86_ )
#define DEBUG_BREAK do { _try { _asm int 3 } _except (EXCEPTION_EXECUTE_HANDLER) {;} } while (0)
#else
#define DEBUG_BREAK DebugBreak()
#endif
extern const WCHAR szTaskmanKey[];
#pragma hdrstop