ReactOS 0.4.15-dev-7788-g1ad9096
ctm.c
Go to the documentation of this file.
1/* Console Task Manager
2
3 ctm.c - main program file
4
5 Written by: Aleksey Bragin (aleksey@reactos.org)
6
7 Most of the code dealing with getting system parameters is taken from
8 ReactOS Task Manager written by Brian Palmer (brianp@reactos.org)
9
10 Localization features added by Hervé Poussineau (hpoussin@reactos.org)
11
12 History:
13 24 October 2004 - added localization features
14 09 April 2003 - v0.1, fixed bugs, added features, ported to mingw
15 20 March 2003 - v0.03, works good under ReactOS, and allows process
16 killing
17 18 March 2003 - Initial version 0.01, doesn't work under RectOS
18
19 This program is free software; you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation; either version 2 of the License, or
22 (at your option) any later version.
23
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with this program; if not, write to the Free Software
31 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
32
33
34#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows //headers
35#define WIN32_NO_STATUS
36#include <windows.h>
37
38#include <stdlib.h>
39#include <malloc.h>
40#include <memory.h>
41#include <tchar.h>
42#include <process.h>
43#include <stdio.h>
44
45#define NTOS_MODE_USER
46#include <ndk/ntndk.h>
47
48#include <epsapi/epsapi.h>
49
50#include "ctm.h"
51#include "resource.h"
52
53#define TIMES
54
58
61
70TCHAR lpHeader[80];
73
76
77int ProcPerScreen = 17; // 17 processess are displayed on one page
81
88
89PPERFDATA pPerfDataOld = NULL; // Older perf data (saved to establish delta values)
90PPERFDATA pPerfData = NULL; // Most recent copy of perf data
91
93int scrolled=0; // offset from which process start showing
94int first = 0; // first time in DisplayScreen
96
98#define NEW_CONSOLE
99
100// Functions that are needed by epsapi
101void *PsaiMalloc(SIZE_T size) { return malloc(size); }
102void *PsaiRealloc(void *ptr, SIZE_T size) { return realloc(ptr, size); }
103void PsaiFree(void *ptr) { free(ptr); }
104
105// Prototypes
106unsigned int GetKeyPressed();
107
109{
110#ifdef NEW_CONSOLE
114
115 if (SetConsoleActiveScreenBuffer(console) == FALSE)
116 {
119 }
120 else
121 {
123 hStdout = console;
124 }
125#else
128#endif
129}
130
132{
135
136#ifdef NEW_CONSOLE
138#endif
139}
140
142{
143 COORD pos;
144 COORD size;
145 TCHAR lpStr[80];
147 int lines;
148 int idx;
153 if (first == 0)
154 {
155 // Header
156 pos.X = 1; pos.Y = 1;
158
159 pos.X = 1; pos.Y = 2;
161
162 pos.X = 1; pos.Y = 3;
164
165 pos.X = 1; pos.Y = 4;
166 if (scrolled)
168 else
170
171 // Footer
172 pos.X = 1; pos.Y = ScreenLines-2;
175 else
177
178 // Menu
179 pos.X = 1; pos.Y = ScreenLines-1;
182
183 first = 1;
184 }
185
186 // Processess
188 if (lines > ProcPerScreen)
190 for (idx=0; idx<ProcPerScreen; idx++)
191 {
192 int i;
193 SIZE_T len;
194 TCHAR lpNumber[5];
195 TCHAR lpPid[8];
196 TCHAR lpCpu[6];
197 TCHAR lpMemUsg[12];
198 TCHAR lpPageFaults[15];
199 WORD wColor;
200
201 for (i = 0; i < 80; i++)
202 lpStr[i] = _T(' ');
203
204 // data
205 if (idx < lines && scrolled + idx < ProcessCount)
206 {
207
208 // number
209 _stprintf(lpNumber, _T("%3d"), idx+scrolled);
210 _tcsncpy(&lpStr[2], lpNumber, 3);
211
212 // image name
213#ifdef _UNICODE
215#else
217 imgName, MAX_PATH, NULL, NULL);
218 len = strlen(imgName);
219#endif
220 if (len > columnRightPositions[1])
221 {
223 }
224#ifdef _UNICODE
226#else
227 strncpy(&lpStr[columnRightPositions[0]+3], imgName, len);
228#endif
229
230 // PID
231 _stprintf(lpPid, _T("%6ld"), pPerfData[scrolled+idx].ProcessId);
232 _tcsncpy(&lpStr[columnRightPositions[2] - 6], lpPid, 6);
233
234#ifdef TIMES
235 // CPU
236 _stprintf(lpCpu, _T("%3d%%"), pPerfData[scrolled+idx].CPUUsage);
237 _tcsncpy(&lpStr[columnRightPositions[3] - 4], lpCpu, 4);
238#endif
239
240 // Mem usage
241 _stprintf(lpMemUsg, _T("%6ld %s"), pPerfData[scrolled+idx].WorkingSetSizeBytes / 1024, lpMemUnit);
242 _tcsncpy(&lpStr[columnRightPositions[4] - 9], lpMemUsg, 9);
243
244 // Page Fault
245 _stprintf(lpPageFaults, _T("%12ld"), pPerfData[scrolled+idx].PageFaultCount);
246 _tcsncpy(&lpStr[columnRightPositions[5] - 12], lpPageFaults, 12);
247 }
248
249 // columns
250 lpStr[0] = _T(' ');
251 lpStr[1] = _T('|');
252 for (i = 0; i < 6; i++)
253 lpStr[columnRightPositions[i] + 1] = _T('|');
254 pos.X = 0; pos.Y = 5+idx;
256
257 // Attributes now...
258 pos.X = columnRightPositions[0] + 1; pos.Y = 5+idx;
259 if (selection == idx)
260 {
265 }
266 else
267 {
272 }
273
275 hStdout, // screen buffer handle
276 wColor, // color to fill with
277 columnRightPositions[1] - 4, // number of cells to fill
278 pos, // first cell to write to
279 &numChars); // actual number written
280 }
281
282 return;
283}
284
285// returns TRUE if exiting
286int ProcessKeys(int numEvents)
287{
289 TCHAR key;
290 if ((ProcessCount-scrolled < 17) && (ProcessCount > 17))
292
293 key = GetKeyPressed(numEvents);
294 if (key == KEY_QUIT)
295 return TRUE;
296 else if (key == KEY_KILL)
297 {
298 // user wants to kill some process, get his acknowledgement
299 DWORD pId;
300 COORD pos;
301 TCHAR lpStr[100];
302
303 pos.X = 1; pos.Y =ScreenLines-1;
304 if (LoadString(hInst, IDS_KILL_PROCESS, lpStr, 100))
306
307 do {
310 } while (key != KEY_YES && key != KEY_NO);
311
312 if (key == KEY_YES)
313 {
317
318 if (hProcess)
319 {
320 if (!TerminateProcess(hProcess, 0))
321 {
322 if (LoadString(hInst, IDS_KILL_PROCESS_ERR1, lpStr, 80))
323 {
326 }
327 Sleep(1000);
328 }
329
331 }
332 else
333 {
334 if (LoadString(hInst, IDS_KILL_PROCESS_ERR2, lpStr, 80))
335 {
337 _stprintf(lpStr, lpStr, pId);
339 }
340 Sleep(1000);
341 }
342 }
343
344 first = 0;
345 }
346 else if (key == VK_UP)
347 {
348 if (selection > 0)
349 selection--;
350 else if ((selection == 0) && (scrolled > 0))
351 scrolled--;
352 }
353 else if (key == VK_DOWN)
354 {
356 selection++;
357 else if ((selection == ProcPerScreen-1) && (selection+scrolled < ProcessCount-1))
358 scrolled++;
359 }
360 else if (key == VK_PRIOR)
361 {
364 else
365 {
366 scrolled=0; //First
367 selection=0;
368 }
369 //selection=0;
370 }
371 else if (key == VK_NEXT)
372 {
375 {
378 }
379
380 //selection=ProcPerScreen-1;
381 if (ProcessCount<=ProcPerScreen) //If there are less process than fits on the screen
382 {
383 scrolled=0;
385 }
386 }
387 else if (key == VK_HOME)
388 {
389 selection=0;
390 scrolled=0;
391 }
392 else if (key == VK_END)
393 {
396 if (ProcessCount<=ProcPerScreen) //If there are less process than fits on the screen
397 {
398 scrolled=0;
400 }
401 }
402 return FALSE;
403}
404
406{
408}
409
411{
412 LONG status;
413 ULONG ulSize;
415 ULONG Idx, Idx2;
417 PPERFDATA pPDOld;
418#ifdef EXTRA_INFO
420 HANDLE hProcessToken;
421 TCHAR szTemp[MAX_PATH];
423#endif
424#ifdef TIMES
425 LARGE_INTEGER liCurrentKernelTime;
426 LARGE_INTEGER liCurrentIdleTime;
427 LARGE_INTEGER liCurrentTime;
428#endif
431
432#ifdef TIMES
433 // Get new system time
434 status = NtQuerySystemInformation(SystemTimeInformation, &SysTimeInfo, sizeof(SysTimeInfo), 0);
435 if (status != NO_ERROR)
436 return;
437#endif
438 // Get processor information
441
442
443 // Get process information
445
446#ifdef TIMES
447 liCurrentKernelTime.QuadPart = 0;
448 liCurrentIdleTime.QuadPart = 0;
449 for (Idx=0; Idx<SystemBasicInfo.NumberOfProcessors; Idx++) {
450 liCurrentKernelTime.QuadPart += SysProcessorTimeInfo[Idx].KernelTime.QuadPart;
451 liCurrentKernelTime.QuadPart += SysProcessorTimeInfo[Idx].DpcTime.QuadPart;
452 liCurrentKernelTime.QuadPart += SysProcessorTimeInfo[Idx].InterruptTime.QuadPart;
453 liCurrentIdleTime.QuadPart += SysProcessorTimeInfo[Idx].IdleTime.QuadPart;
454 }
455
456 // If it's a first call - skip idle time calcs
457 if (liOldIdleTime.QuadPart != 0) {
458 // CurrentValue = NewValue - OldValue
459 liCurrentTime.QuadPart = liCurrentIdleTime.QuadPart - liOldIdleTime.QuadPart;
460 dbIdleTime = Li2Double(liCurrentTime);
461 liCurrentTime.QuadPart = liCurrentKernelTime.QuadPart - liOldKernelTime.QuadPart;
462 dbKernelTime = Li2Double(liCurrentTime);
463 liCurrentTime.QuadPart = SysTimeInfo.CurrentTime.QuadPart - liOldSystemTime.QuadPart;
464 dbSystemTime = Li2Double(liCurrentTime);
465
466 // CurrentCpuIdle = IdleTime / SystemTime
469
470 // CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors
471 dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors;// + 0.5;
472 dbKernelTime = 100.0 - dbKernelTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors;// + 0.5;
473 }
474
475 // Store new CPU's idle and system time
476 liOldIdleTime = liCurrentIdleTime;
477 liOldSystemTime = SysTimeInfo.CurrentTime;
478 liOldKernelTime = liCurrentKernelTime;
479#endif
480
481 // Determine the process count
482 // We loop through the data we got from PsaCaptureProcessesAndThreads
483 // and count how many structures there are (until PsaWalkNextProcess
484 // returns NULL)
486 ProcessCount = 0;
488 while (pSPI) {
489 ProcessCount++;
490 pSPI = PsaWalkNextProcess(pSPI);
491 }
492
493 // Now alloc a new PERFDATA array and fill in the data
494 if (pPerfDataOld) {
496 }
500 for (Idx=0; Idx<ProcessCount; Idx++) {
501 // Get the old perf data for this process (if any)
502 // so that we can establish delta values
503 pPDOld = NULL;
504 for (Idx2=0; Idx2<ProcessCountOld; Idx2++) {
506 /* check also for the creation time, a new process may have an id of an old one */
508 pPDOld = &pPerfDataOld[Idx2];
509 break;
510 }
511 }
512
513 // Clear out process perf data structure
514 memset(&pPerfData[Idx], 0, sizeof(PERFDATA));
515
516 if (pSPI->ImageName.Buffer) {
517 wcsncpy(pPerfData[Idx].ImageName, pSPI->ImageName.Buffer, pSPI->ImageName.Length / sizeof(WCHAR));
518 pPerfData[Idx].ImageName[pSPI->ImageName.Length / sizeof(WCHAR)] = 0;
519 }
520 else
521 {
522#ifdef _UNICODE
524#else
526#endif
527 }
528
530 pPerfData[Idx].CreateTime = pSPI->CreateTime;
531
532 if (pPDOld) {
533#ifdef TIMES
534 double CurTime = Li2Double(pSPI->KernelTime) + Li2Double(pSPI->UserTime);
535 double OldTime = Li2Double(pPDOld->KernelTime) + Li2Double(pPDOld->UserTime);
536 double CpuTime = (CurTime - OldTime) / dbSystemTime;
537 CpuTime = CpuTime * 100.0 / (double)SystemBasicInfo.NumberOfProcessors; // + 0.5;
538
539 pPerfData[Idx].CPUUsage = (ULONG)CpuTime;
540#else
541 pPerfData[Idx].CPUUsage = 0;
542#endif
543 }
544
548 if (pPDOld)
550 else
553 if (pPDOld)
555 else
561 pPerfData[Idx].HandleCount = pSPI->HandleCount;
563 //pPerfData[Idx].SessionId = pSPI->SessionId;
564
565#ifdef EXTRA_INFO
567 if (hProcess) {
569 ImpersonateLoggedOnUser(hProcessToken);
570 memset(szTemp, 0, sizeof(TCHAR[MAX_PATH]));
572 GetUserName(szTemp, &dwSize);
573#ifndef UNICODE
574 MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTemp, -1, pPerfData[Idx].UserName, MAX_PATH);
575#endif
576 RevertToSelf();
577 CloseHandle(hProcessToken);
578 }
580 }
581#endif
582#ifdef TIMES
585#endif
586 pSPI = PsaWalkNextProcess(pSPI);
587 }
589
590 free(SysProcessorTimeInfo);
592 first = 0;
593}
594
595// Code partly taken from slw32tty.c from mc/slang
596unsigned int GetKeyPressed(int events)
597{
598 DWORD bytesRead;
600 int i;
601
602
603 for (i=0; i<events; i++)
604 {
605 if (!ReadConsoleInput(hStdin, &record, 1, &bytesRead)) {
606 return 0;
607 }
608
609 if (record.EventType == KEY_EVENT && record.Event.KeyEvent.bKeyDown)
610 return record.Event.KeyEvent.wVirtualKeyCode;//.uChar.AsciiChar;
611 }
612
613 return 0;
614}
615
616
617int _tmain(int argc, char **argv)
618{
619 int i;
620 TCHAR lpStr[80];
621
622 for (i = 0; i < 80; i++)
623 lpEmpty[i] = lpHeader[i] = _T(' ');
624 lpEmpty[79] = _T('\0');
625
626 /* Initialize global variables */
627 hInst = 0 /* FIXME: which value? [used with LoadString(hInst, ..., ..., ...)] */;
628
629 if (LoadString(hInst, IDS_COLUMN_NUMBER, lpStr, 80))
630 {
631 columnRightPositions[0] = _tcslen(lpStr) + 3;
632 _tcsncpy(&lpHeader[2], lpStr, _tcslen(lpStr));
633 }
634 if (LoadString(hInst, IDS_COLUMN_IMAGENAME, lpStr, 80))
635 {
637 _tcsncpy(&lpHeader[columnRightPositions[0] + 2], lpStr, _tcslen(lpStr));
638 }
639 if (LoadString(hInst, IDS_COLUMN_PID, lpStr, 80))
640 {
642 _tcsncpy(&lpHeader[columnRightPositions[1] + 2], lpStr, _tcslen(lpStr));
643 }
644 if (LoadString(hInst, IDS_COLUMN_CPU, lpStr, 80))
645 {
647 _tcsncpy(&lpHeader[columnRightPositions[2] + 2], lpStr, _tcslen(lpStr));
648 }
649 if (LoadString(hInst, IDS_COLUMN_MEM, lpStr, 80))
650 {
652 _tcsncpy(&lpHeader[columnRightPositions[3] + 2], lpStr, _tcslen(lpStr));
653 }
654 if (LoadString(hInst, IDS_COLUMN_PF, lpStr, 80))
655 {
657 _tcsncpy(&lpHeader[columnRightPositions[4] + 2], lpStr, _tcslen(lpStr));
658 }
659
660 for (i = 0; i < columnRightPositions[5]; i++)
661 {
662 lpSeparator[i] = _T('-');
663 lpSeparatorUp[i] = _T('^');
664 lpSeparatorDown[i] = _T('v');
665 }
666 lpHeader[0] = _T('|');
667 lpSeparator[0] = _T('+');
668 lpSeparatorUp[0] = _T('^');
669 lpSeparatorDown[0] = _T('v');
670 for (i = 0; i < 6; i++)
671 {
676 }
677 lpHeader[columnRightPositions[5] + 1] = _T('\0');
678 lpSeparator[columnRightPositions[5] + 1] = _T('\0');
679 lpSeparatorUp[columnRightPositions[5] + 1] = _T('\0');
681
682
684 lpTitle[0] = _T('\0');
686 lpMemUnit[0] = _T('\0');
687 if (!LoadString(hInst, IDS_MENU, lpMenu, 80))
688 lpMenu[0] = _T('\0');
690 lpIdleProcess[0] = _T('\0');
691
692 if (LoadString(hInst, IDS_MENU_QUIT, lpStr, 2))
693 KEY_QUIT = lpStr[0];
694 if (LoadString(hInst, IDS_MENU_KILL_PROCESS, lpStr, 2))
695 KEY_KILL = lpStr[0];
696 if (LoadString(hInst, IDS_YES, lpStr, 2))
697 KEY_YES = lpStr[0];
698 if (LoadString(hInst, IDS_NO, lpStr, 2))
699 KEY_NO = lpStr[0];
700
702
704 {
705 if (LoadString(hInst, IDS_CTM_GENERAL_ERR1, lpStr, 80))
706 _tprintf(lpStr);
707 return -1;
708 }
709
710 if (GetConsoleMode(hStdin, &inConMode) == 0)
711 {
712 if (LoadString(hInst, IDS_CTM_GENERAL_ERR2, lpStr, 80))
713 _tprintf(lpStr);
714 return -1;
715 }
716
718 {
719 if (LoadString(hInst, IDS_CTM_GENERAL_ERR3, lpStr, 80))
720 _tprintf(lpStr);
721 return -1;
722 }
723
724 SetConsoleMode(hStdin, 0); //FIXME: Should check for error!
725 SetConsoleMode(hStdout, 0); //FIXME: Should check for error!
726
727 PerfInit();
728
729 while (1)
730 {
731 DWORD numEvents;
732
735
736 /* WaitForSingleObject for console handles is not implemented in ROS */
739
740 if (numEvents > 0)
741 {
742 if (ProcessKeys(numEvents) == TRUE)
743 break;
744 first = 0;
745 }
746 }
747
749 return 0;
750}
static int argc
Definition: ServiceArgs.c:12
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define IDS_YES
Definition: resource.h:16
#define IDS_NO
Definition: resource.h:17
#define IDS_APP_TITLE
Definition: resource.h:10
#define IDS_IDLE_PROCESS
Definition: resource.h:10
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
WORD wColor
#define HandleToUlong(h)
Definition: basetsd.h:79
#define BACKGROUND_GREEN
Definition: blue.h:66
#define BACKGROUND_BLUE
Definition: blue.h:65
#define FOREGROUND_GREEN
Definition: blue.h:62
#define FOREGROUND_BLUE
Definition: blue.h:61
#define FOREGROUND_RED
Definition: blue.h:63
HANDLE hStdout
Definition: ctm.c:56
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: ctm.c:95
TCHAR lpIdleProcess[80]
Definition: ctm.c:68
int ScreenLines
Definition: ctm.c:78
TCHAR lpHeader[80]
Definition: ctm.c:66
TCHAR KEY_QUIT
Definition: ctm.c:74
PPERFDATA pPerfData
Definition: ctm.c:90
LARGE_INTEGER liOldKernelTime
Definition: ctm.c:86
DWORD columnRightPositions[6]
Definition: ctm.c:62
void PsaiFree(void *ptr)
Definition: ctm.c:103
void * PsaiMalloc(SIZE_T size)
Definition: ctm.c:101
HANDLE hStdin
Definition: ctm.c:55
TCHAR lpTitle[80]
Definition: ctm.c:69
int scrolled
Definition: ctm.c:93
DWORD outConMode
Definition: ctm.c:60
double dbIdleTime
Definition: ctm.c:82
PPERFDATA pPerfDataOld
Definition: ctm.c:89
HINSTANCE hInst
Definition: ctm.c:57
TCHAR lpSeparator[80]
Definition: ctm.c:63
void PerfInit()
Definition: ctm.c:405
CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo
Definition: ctm.c:97
TCHAR lpMemUnit[3]
Definition: ctm.c:67
TCHAR lpEmpty[80]
Definition: ctm.c:72
TCHAR lpSeparatorDown[80]
Definition: ctm.c:65
void * PsaiRealloc(void *ptr, SIZE_T size)
Definition: ctm.c:102
TCHAR KEY_KILL
Definition: ctm.c:74
ULONG ProcessCountOld
Definition: ctm.c:79
TCHAR lpSeparatorUp[80]
Definition: ctm.c:64
int ProcessKeys(int numEvents)
Definition: ctm.c:286
void GetInputOutputHandles()
Definition: ctm.c:108
int ProcPerScreen
Definition: ctm.c:77
void DisplayScreen()
Definition: ctm.c:141
unsigned int GetKeyPressed()
double dbKernelTime
Definition: ctm.c:83
double dbSystemTime
Definition: ctm.c:84
DWORD inConMode
Definition: ctm.c:59
void PerfDataRefresh()
Definition: ctm.c:410
LARGE_INTEGER liOldIdleTime
Definition: ctm.c:85
void RestoreConsole()
Definition: ctm.c:131
TCHAR lpMenu[80]
Definition: ctm.c:71
ULONG ProcessCount
Definition: ctm.c:80
TCHAR KEY_NO
Definition: ctm.c:75
LARGE_INTEGER liOldSystemTime
Definition: ctm.c:87
int selection
Definition: ctm.c:92
TCHAR KEY_YES
Definition: ctm.c:75
#define SystemTimeInformation
Definition: ctm.h:57
#define NO_ERROR
Definition: dderror.h:5
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
Definition: console.c:2313
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1799
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1635
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
unsigned long DWORD
Definition: ntddk_ex.h:95
@ SystemBasicInformation
Definition: ntddk_ex.h:11
@ SystemProcessorPerformanceInformation
Definition: ntddk_ex.h:19
unsigned short WORD
Definition: ntddk_ex.h:93
PWDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER pId
USHORT numChars
GLsizeiptr size
Definition: glext.h:5919
const GLint * first
Definition: glext.h:5794
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ long __cdecl labs(_In_ long x)
#define _tcsncpy
Definition: tchar.h:1410
#define _tmain
Definition: tchar.h:497
#define _tprintf
Definition: tchar.h:506
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PROCESS_TERMINATE
Definition: pstypes.h:157
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define _stprintf
Definition: utility.h:124
#define IDS_CTM_GENERAL_ERR2
Definition: resource.h:44
#define IDS_CTM_GENERAL_ERR3
Definition: resource.h:45
#define IDS_MENU_KILL_PROCESS
Definition: resource.h:37
#define IDS_CTM_GENERAL_ERR1
Definition: resource.h:43
#define IDS_COLUMN_PF
Definition: resource.h:29
#define IDS_COLUMN_CPU
Definition: resource.h:26
#define IDS_KILL_PROCESS_ERR1
Definition: resource.h:40
#define IDS_COLUMN_IMAGENAME
Definition: resource.h:24
#define IDS_MENU
Definition: resource.h:35
#define IDS_COLUMN_MEM_UNIT
Definition: resource.h:28
#define IDS_COLUMN_MEM
Definition: resource.h:27
#define IDS_KILL_PROCESS_ERR2
Definition: resource.h:41
#define IDS_COLUMN_PID
Definition: resource.h:25
#define IDS_MENU_QUIT
Definition: resource.h:36
#define IDS_COLUMN_NUMBER
Definition: resource.h:23
#define IDS_KILL_PROCESS
Definition: resource.h:39
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess(IN PSYSTEM_PROCESSES CurrentProcess)
NTSTATUS NTAPI PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESSES *ProcessesAndThreads)
PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess(IN PSYSTEM_PROCESSES ProcessesAndThreads)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
HANDLE events[2]
Definition: event.c:4
static const char * ImageName
Definition: image.c:34
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define argv
Definition: mplay32.c:18
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
long LONG
Definition: pedump.c:60
#define Li2Double(x)
Definition: perfdata.h:11
struct _PERFDATA * PPERFDATA
PVOID pBuffer
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define memset(x, y, z)
Definition: compat.h:39
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
Definition: bl.h:1338
ULONG PageFaultCountDelta
Definition: perfdata.h:25
LARGE_INTEGER UserTime
Definition: perfdata.h:36
LARGE_INTEGER CPUTime
Definition: perfdata.h:20
ULONG WorkingSetSizeDelta
Definition: perfdata.h:23
ULONG CPUUsage
Definition: perfdata.h:19
LARGE_INTEGER KernelTime
Definition: perfdata.h:37
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:28
WCHAR ImageName[MAX_PATH]
Definition: perfdata.h:15
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:26
ULONG PagedPoolUsagePages
Definition: perfdata.h:27
LARGE_INTEGER CreateTime
Definition: ctm.h:54
ULONG ThreadCount
Definition: perfdata.h:31
ULONG PageFaultCount
Definition: perfdata.h:24
ULONG HandleCount
Definition: perfdata.h:30
HANDLE ProcessId
Definition: perfdata.h:16
ULONG WorkingSetSizeBytes
Definition: perfdata.h:21
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:22
ULONG BasePriority
Definition: perfdata.h:29
LARGE_INTEGER UserTime
Definition: extypes.h:900
UNICODE_STRING ImageName
Definition: extypes.h:902
LARGE_INTEGER CreateTime
Definition: extypes.h:899
LARGE_INTEGER KernelTime
Definition: extypes.h:901
LARGE_INTEGER CurrentTime
Definition: extypes.h:858
Definition: copy.c:22
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
eMaj lines
Definition: tritemp.h:206
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
#define _T(x)
Definition: vfdio.h:22
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267
#define GetUserName
Definition: winbase.h:3786
BOOL WINAPI RevertToSelf(void)
Definition: security.c:1608
#define WriteConsoleOutputCharacter
Definition: wincon.h:789
#define ReadConsoleInput
Definition: wincon.h:778
#define KEY_EVENT
Definition: wincon.h:128
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define MB_PRECOMPOSED
Definition: winnls.h:281
#define VK_UP
Definition: winuser.h:2225
#define VK_NEXT
Definition: winuser.h:2221
#define VK_END
Definition: winuser.h:2222
#define VK_HOME
Definition: winuser.h:2223
#define LoadString
Definition: winuser.h:5819
#define VK_DOWN
Definition: winuser.h:2227
#define VK_PRIOR
Definition: winuser.h:2220
#define TOKEN_DUPLICATE
Definition: setypes.h:926
#define TOKEN_QUERY
Definition: setypes.h:928
#define TOKEN_IMPERSONATE
Definition: setypes.h:927
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _tcslen
Definition: xmlstorage.h:198