ReactOS  0.4.13-dev-79-gcd489d8
ctm.c File Reference
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include <ndk/ntndk.h>
#include <epsapi/epsapi.h>
#include "ctm.h"
#include "resource.h"
Include dependency graph for ctm.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define TIMES
 
#define NEW_CONSOLE
 

Functions

voidPsaiMalloc (SIZE_T size)
 
voidPsaiRealloc (void *ptr, SIZE_T size)
 
void PsaiFree (void *ptr)
 
unsigned int GetKeyPressed ()
 
void GetInputOutputHandles ()
 
void RestoreConsole ()
 
void DisplayScreen ()
 
int ProcessKeys (int numEvents)
 
void PerfInit ()
 
void PerfDataRefresh ()
 
unsigned int GetKeyPressed (int events)
 
int _tmain (int argc, char **argv)
 

Variables

HANDLE hStdin
 
HANDLE hStdout
 
HINSTANCE hInst
 
DWORD inConMode
 
DWORD outConMode
 
DWORD columnRightPositions [6]
 
TCHAR lpSeparator [80]
 
TCHAR lpSeparatorUp [80]
 
TCHAR lpSeparatorDown [80]
 
TCHAR lpHeader [80]
 
TCHAR lpMemUnit [3]
 
TCHAR lpIdleProcess [80]
 
TCHAR lpTitle [80]
 
TCHAR lpMenu [80]
 
TCHAR lpEmpty [80]
 
TCHAR KEY_QUIT
 
TCHAR KEY_KILL
 
TCHAR KEY_YES
 
TCHAR KEY_NO
 
int ProcPerScreen = 17
 
int ScreenLines =25
 
ULONG ProcessCountOld = 0
 
ULONG ProcessCount = 0
 
double dbIdleTime
 
double dbKernelTime
 
double dbSystemTime
 
LARGE_INTEGER liOldIdleTime = {{0,0}}
 
LARGE_INTEGER liOldKernelTime = {{0,0}}
 
LARGE_INTEGER liOldSystemTime = {{0,0}}
 
PPERFDATA pPerfDataOld = NULL
 
PPERFDATA pPerfData = NULL
 
int selection =0
 
int scrolled =0
 
int first = 0
 
SYSTEM_BASIC_INFORMATION SystemBasicInfo
 
CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo
 

Macro Definition Documentation

◆ NEW_CONSOLE

#define NEW_CONSOLE

Definition at line 98 of file ctm.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 45 of file ctm.c.

◆ TIMES

#define TIMES

Definition at line 53 of file ctm.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 34 of file ctm.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 35 of file ctm.c.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
char **  argv 
)

Definition at line 617 of file ctm.c.

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');
680  lpSeparatorDown[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 
717  if (GetConsoleMode(hStdout, &outConMode) == 0)
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 
733  PerfDataRefresh();
734  DisplayScreen();
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 
748  RestoreConsole();
749  return 0;
750 }
DWORD columnRightPositions[6]
Definition: ctm.c:62
DWORD inConMode
Definition: ctm.c:59
#define _tprintf
Definition: tchar.h:506
TCHAR lpHeader[80]
Definition: ctm.c:66
#define TRUE
Definition: types.h:120
#define IDS_COLUMN_NUMBER
Definition: resource.h:23
#define IDS_MENU
Definition: resource.h:35
int ProcessKeys(int numEvents)
Definition: ctm.c:286
TCHAR lpMenu[80]
Definition: ctm.c:71
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
const GLint * first
Definition: glext.h:5794
TCHAR lpSeparator[80]
Definition: ctm.c:63
#define IDS_COLUMN_MEM
Definition: resource.h:27
_TCHAR * _tcsncpy(_TCHAR *dst, const _TCHAR *src, size_t n)
Definition: tcsncpy.h:9
TCHAR KEY_KILL
Definition: ctm.c:74
TCHAR KEY_YES
Definition: ctm.c:75
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD outConMode
Definition: ctm.c:60
void PerfInit()
Definition: ctm.c:405
void RestoreConsole()
Definition: ctm.c:131
#define IDS_COLUMN_PF
Definition: resource.h:29
#define IDS_MENU_QUIT
Definition: resource.h:36
#define IDS_YES
Definition: resource.h:16
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define IDS_COLUMN_MEM_UNIT
Definition: resource.h:28
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
TCHAR lpEmpty[80]
Definition: ctm.c:72
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define IDS_NO
Definition: resource.h:17
TCHAR KEY_NO
Definition: ctm.c:75
HANDLE hStdin
Definition: ctm.c:55
char TCHAR
Definition: xmlstorage.h:189
TCHAR lpSeparatorUp[80]
Definition: ctm.c:64
#define _T(x)
Definition: vfdio.h:22
#define IDS_CTM_GENERAL_ERR2
Definition: resource.h:44
TCHAR lpIdleProcess[80]
Definition: ctm.c:68
unsigned long DWORD
Definition: ntddk_ex.h:95
void DisplayScreen()
Definition: ctm.c:141
#define IDS_CTM_GENERAL_ERR3
Definition: resource.h:45
#define IDS_IDLE_PROCESS
Definition: resource.h:3
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1637
void GetInputOutputHandles()
Definition: ctm.c:108
#define IDS_MENU_KILL_PROCESS
Definition: resource.h:37
#define IDS_APP_TITLE
Definition: resource.h:10
HANDLE hStdout
Definition: ctm.c:56
TCHAR lpMemUnit[3]
Definition: ctm.c:67
TCHAR KEY_QUIT
Definition: ctm.c:74
void PerfDataRefresh()
Definition: ctm.c:410
TCHAR lpTitle[80]
Definition: ctm.c:69
HINSTANCE hInst
Definition: ctm.c:57
#define IDS_COLUMN_PID
Definition: resource.h:25
TCHAR lpSeparatorDown[80]
Definition: ctm.c:65
#define IDS_COLUMN_IMAGENAME
Definition: resource.h:24
#define LoadString
Definition: winuser.h:5685
#define IDS_COLUMN_CPU
Definition: resource.h:26
#define IDS_CTM_GENERAL_ERR1
Definition: resource.h:43

◆ DisplayScreen()

void DisplayScreen ( )

Definition at line 141 of file ctm.c.

142 {
143  COORD pos;
144  COORD size;
145  TCHAR lpStr[80];
146  DWORD numChars;
147  int lines;
148  int idx;
151  ScreenLines=size.Y;
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;
255  WriteConsoleOutputCharacter(hStdout, lpStr, 80, pos, &numChars);
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 }
DWORD columnRightPositions[6]
Definition: ctm.c:62
TCHAR lpHeader[80]
Definition: ctm.c:66
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define BACKGROUND_GREEN
Definition: wincon.h:44
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
int ScreenLines
Definition: ctm.c:78
#define WideCharToMultiByte
Definition: compat.h:101
int scrolled
Definition: ctm.c:93
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
TCHAR lpMenu[80]
Definition: ctm.c:71
#define CP_ACP
Definition: compat.h:99
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
const GLint * first
Definition: glext.h:5794
TCHAR lpSeparator[80]
Definition: ctm.c:63
_TCHAR * _tcsncpy(_TCHAR *dst, const _TCHAR *src, size_t n)
Definition: tcsncpy.h:9
int selection
Definition: ctm.c:92
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
TCHAR lpEmpty[80]
Definition: ctm.c:72
unsigned int idx
Definition: utils.c:41
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
ULONG ProcessCount
Definition: ctm.c:80
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
eMaj lines
Definition: tritemp.h:206
char TCHAR
Definition: xmlstorage.h:189
TCHAR lpSeparatorUp[80]
Definition: ctm.c:64
#define _T(x)
Definition: vfdio.h:22
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
PPERFDATA pPerfData
Definition: ctm.c:90
WORD wColor
static const char * ImageName
Definition: image.c:34
GLenum GLsizei len
Definition: glext.h:6722
Definition: bl.h:1338
#define BACKGROUND_BLUE
Definition: wincon.h:43
int ProcPerScreen
Definition: ctm.c:77
#define _stprintf
Definition: utility.h:124
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define FOREGROUND_GREEN
Definition: wincon.h:40
#define FOREGROUND_RED
Definition: wincon.h:41
HANDLE hStdout
Definition: ctm.c:56
TCHAR lpMemUnit[3]
Definition: ctm.c:67
TCHAR lpTitle[80]
Definition: ctm.c:69
#define FOREGROUND_BLUE
Definition: wincon.h:39
#define WriteConsoleOutputCharacter
Definition: wincon.h:777
TCHAR lpSeparatorDown[80]
Definition: ctm.c:65
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo
Definition: ctm.c:97

Referenced by _tmain().

◆ GetInputOutputHandles()

void GetInputOutputHandles ( )

Definition at line 108 of file ctm.c.

109 {
110 #ifdef NEW_CONSOLE
114 
115  if (SetConsoleActiveScreenBuffer(console) == FALSE)
116  {
119  }
120  else
121  {
122  hStdin = GetStdHandle(STD_INPUT_HANDLE);//console;
123  hStdout = console;
124  }
125 #else
128 #endif
129 }
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1801
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STD_INPUT_HANDLE
Definition: winbase.h:264
HANDLE hStdin
Definition: ctm.c:55
#define GENERIC_READ
Definition: compat.h:124
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
HANDLE hStdout
Definition: ctm.c:56
HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
Definition: console.c:2315

Referenced by _tmain().

◆ GetKeyPressed() [1/2]

unsigned int GetKeyPressed ( )

Referenced by ProcessKeys().

◆ GetKeyPressed() [2/2]

unsigned int GetKeyPressed ( int  events)

Definition at line 596 of file ctm.c.

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 }
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
#define ReadConsoleInput
Definition: wincon.h:766
#define KEY_EVENT
Definition: wincon.h:122
HANDLE hStdin
Definition: ctm.c:55
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE events[2]
Definition: event.c:4

◆ PerfDataRefresh()

void PerfDataRefresh ( void  )

Definition at line 410 of file ctm.c.

411 {
412  LONG status;
413  ULONG ulSize;
414  LPBYTE pBuffer;
415  ULONG Idx, Idx2;
417  PPERFDATA pPDOld;
418 #ifdef EXTRA_INFO
420  HANDLE hProcessToken;
421  TCHAR szTemp[MAX_PATH];
422  DWORD dwSize;
423 #endif
424 #ifdef TIMES
425  LARGE_INTEGER liCurrentKernelTime;
426  LARGE_INTEGER liCurrentIdleTime;
427  LARGE_INTEGER liCurrentTime;
428 #endif
429  PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SysProcessorTimeInfo;
430  SYSTEM_TIMEOFDAY_INFORMATION SysTimeInfo;
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++) {
505  if (pPerfDataOld[Idx2].ProcessId == HandleToUlong(pSPI->UniqueProcessId) &&
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
560  pPerfData[Idx].BasePriority = pSPI->BasePriority;
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]));
571  dwSize = 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 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
struct _PERFDATA * PPERFDATA
#define CloseHandle
Definition: compat.h:398
double dbSystemTime
Definition: ctm.c:84
double dbIdleTime
Definition: ctm.c:82
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1487
#define GetUserName
Definition: winbase.h:3665
#define CP_ACP
Definition: compat.h:99
#define free
Definition: debug_ros.c:5
const GLint * first
Definition: glext.h:5794
#define MB_PRECOMPOSED
Definition: winnls.h:278
#define HandleToUlong(h)
Definition: basetsd.h:79
LARGE_INTEGER liOldSystemTime
Definition: ctm.c:87
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define TOKEN_IMPERSONATE
Definition: setypes.h:873
PSYSTEM_PROCESSES FASTCALL PsaWalkNextProcess(IN PSYSTEM_PROCESSES CurrentProcess)
ULONG CPUUsage
Definition: perfdata.h:37
#define NO_ERROR
Definition: dderror.h:5
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: ctm.c:95
LARGE_INTEGER CreateTime
Definition: extypes.h:887
PPERFDATA pPerfDataOld
Definition: ctm.c:89
LARGE_INTEGER CurrentTime
Definition: extypes.h:846
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
LARGE_INTEGER CreateTime
Definition: ctm.h:54
ULONG NonPagedPoolUsagePages
Definition: perfdata.h:46
WCHAR ImageName[MAX_PATH]
Definition: perfdata.h:33
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
Definition: misc.c:152
ULONG WorkingSetSizeDelta
Definition: perfdata.h:41
ULONG ProcessCount
Definition: ctm.c:80
LARGE_INTEGER liOldKernelTime
Definition: ctm.c:86
PSYSTEM_PROCESSES FASTCALL PsaWalkFirstProcess(IN PSYSTEM_PROCESSES ProcessesAndThreads)
ULONG HandleCount
Definition: perfdata.h:48
char TCHAR
Definition: xmlstorage.h:189
#define SystemTimeInformation
Definition: ctm.h:57
#define TOKEN_QUERY
Definition: setypes.h:874
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG PageFaultCountDelta
Definition: perfdata.h:43
VOID NTAPI PsaFreeCapture(IN PVOID Capture)
Definition: processes.c:188
#define MAX_PATH
Definition: compat.h:26
TCHAR lpIdleProcess[80]
Definition: ctm.c:68
ULONG BasePriority
Definition: perfdata.h:47
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
NTSTATUS NTAPI PsaCaptureProcessesAndThreads(OUT PSYSTEM_PROCESSES *ProcessesAndThreads)
PPERFDATA pPerfData
Definition: ctm.c:90
UNICODE_STRING ImageName
Definition: extypes.h:890
#define TOKEN_DUPLICATE
Definition: setypes.h:872
ULONG WorkingSetSizeBytes
Definition: perfdata.h:39
static const char * ImageName
Definition: image.c:34
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LARGE_INTEGER CPUTime
Definition: perfdata.h:38
ULONG ThreadCount
Definition: perfdata.h:49
ULONG ProcessCountOld
Definition: ctm.c:79
HANDLE ProcessId
Definition: perfdata.h:34
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1257
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
LARGE_INTEGER KernelTime
Definition: extypes.h:889
ULONG PeakWorkingSetSizeBytes
Definition: perfdata.h:40
ULONG PageFaultCount
Definition: perfdata.h:42
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
double dbKernelTime
Definition: ctm.c:83
#define MultiByteToWideChar
Definition: compat.h:100
#define Li2Double(x)
Definition: perfdata.h:29
unsigned int ULONG
Definition: retypes.h:1
LARGE_INTEGER UserTime
Definition: extypes.h:888
#define malloc
Definition: debug_ros.c:4
_Check_return_ long __cdecl labs(_In_ long x)
LARGE_INTEGER KernelTime
Definition: perfdata.h:55
ULONG VirtualMemorySizeBytes
Definition: perfdata.h:44
LARGE_INTEGER liOldIdleTime
Definition: ctm.c:85
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
LARGE_INTEGER UserTime
Definition: perfdata.h:54
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
LONGLONG QuadPart
Definition: typedefs.h:112
ULONG PagedPoolUsagePages
Definition: perfdata.h:45
Definition: ps.c:97

Referenced by _tmain().

◆ PerfInit()

void PerfInit ( )

Definition at line 405 of file ctm.c.

406 {
408 }
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: ctm.c:95
#define SystemBasicInformation
Definition: xboxvmp.h:35

Referenced by _tmain().

◆ ProcessKeys()

int ProcessKeys ( int  numEvents)

Definition at line 286 of file ctm.c.

287 {
288  DWORD numChars;
289  TCHAR key;
290  if ((ProcessCount-scrolled < 17) && (ProcessCount > 17))
291  scrolled = 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))
305  WriteConsoleOutputCharacter(hStdout, lpStr, _tcslen(lpStr), pos, &numChars);
306 
307  do {
309  key = GetKeyPressed(pId);
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  {
325  WriteConsoleOutputCharacter(hStdout, lpStr, _tcslen(lpStr), pos, &numChars);
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);
338  WriteConsoleOutputCharacter(hStdout, lpStr, _tcslen(lpStr), pos, &numChars);
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  {
355  if ((selection < ProcPerScreen-1) && (selection < ProcessCount-1))
356  selection++;
357  else if ((selection == ProcPerScreen-1) && (selection+scrolled < ProcessCount-1))
358  scrolled++;
359  }
360  else if (key == VK_PRIOR)
361  {
362  if (scrolled>ProcPerScreen-1)
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 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define IDS_KILL_PROCESS_ERR1
Definition: resource.h:40
int ScreenLines
Definition: ctm.c:78
int scrolled
Definition: ctm.c:93
const GLint * first
Definition: glext.h:5794
TCHAR KEY_KILL
Definition: ctm.c:74
TCHAR KEY_YES
Definition: ctm.c:75
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define VK_DOWN
Definition: winuser.h:2181
#define VK_PRIOR
Definition: winuser.h:2174
int selection
Definition: ctm.c:92
#define VK_NEXT
Definition: winuser.h:2175
#define VK_HOME
Definition: winuser.h:2177
TCHAR lpEmpty[80]
Definition: ctm.c:72
#define VK_UP
Definition: winuser.h:2179
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define IDS_KILL_PROCESS_ERR2
Definition: resource.h:41
ULONG ProcessCount
Definition: ctm.c:80
TCHAR KEY_NO
Definition: ctm.c:75
unsigned int GetKeyPressed()
HANDLE hStdin
Definition: ctm.c:55
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_KILL_PROCESS
Definition: resource.h:39
PPERFDATA pPerfData
Definition: ctm.c:90
BOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE hConsoleInput, LPDWORD lpNumberOfEvents)
Definition: console.c:1637
HKEY key
Definition: reg.c:42
Definition: bl.h:1338
int ProcPerScreen
Definition: ctm.c:77
#define _stprintf
Definition: utility.h:124
HANDLE ProcessId
Definition: perfdata.h:34
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1257
#define PROCESS_TERMINATE
Definition: pstypes.h:149
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1562
HANDLE hStdout
Definition: ctm.c:56
TCHAR KEY_QUIT
Definition: ctm.c:74
HINSTANCE hInst
Definition: ctm.c:57
#define WriteConsoleOutputCharacter
Definition: wincon.h:777
#define VK_END
Definition: winuser.h:2176
#define LoadString
Definition: winuser.h:5685
Definition: path.c:42

Referenced by _tmain().

◆ PsaiFree()

void PsaiFree ( void ptr)

Definition at line 103 of file ctm.c.

103 { free(ptr); }
#define free
Definition: debug_ros.c:5
static PVOID ptr
Definition: dispmode.c:27

Referenced by PsaCaptureProcessesAndThreads(), PsaCaptureSystemModules(), and PsaFreeCapture().

◆ PsaiMalloc()

void* PsaiMalloc ( SIZE_T  size)

Definition at line 101 of file ctm.c.

101 { return malloc(size); }
GLsizeiptr size
Definition: glext.h:5919
#define malloc
Definition: debug_ros.c:4

Referenced by PsaCaptureProcessesAndThreads(), and PsaCaptureSystemModules().

◆ PsaiRealloc()

void* PsaiRealloc ( void ptr,
SIZE_T  size 
)

Definition at line 102 of file ctm.c.

102 { return realloc(ptr, size); }
#define realloc
Definition: debug_ros.c:6
static PVOID ptr
Definition: dispmode.c:27
GLsizeiptr size
Definition: glext.h:5919

◆ RestoreConsole()

void RestoreConsole ( )

Definition at line 131 of file ctm.c.

132 {
135 
136 #ifdef NEW_CONSOLE
138 #endif
139 }
DWORD inConMode
Definition: ctm.c:59
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1801
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
DWORD outConMode
Definition: ctm.c:60
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
HANDLE hStdin
Definition: ctm.c:55
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
HANDLE hStdout
Definition: ctm.c:56

Referenced by _tmain().

Variable Documentation

◆ columnRightPositions

DWORD columnRightPositions[6]

Definition at line 62 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ dbIdleTime

double dbIdleTime

Definition at line 82 of file ctm.c.

Referenced by PerfDataRefresh().

◆ dbKernelTime

double dbKernelTime

Definition at line 83 of file ctm.c.

Referenced by PerfDataRefresh().

◆ dbSystemTime

double dbSystemTime

Definition at line 84 of file ctm.c.

Referenced by PerfDataRefresh().

◆ first

int first = 0

Definition at line 94 of file ctm.c.

◆ hInst

HINSTANCE hInst

Definition at line 57 of file ctm.c.

Referenced by _tmain(), and ProcessKeys().

◆ hStdin

HANDLE hStdin

◆ hStdout

◆ inConMode

DWORD inConMode

Definition at line 59 of file ctm.c.

Referenced by _tmain(), and RestoreConsole().

◆ KEY_KILL

TCHAR KEY_KILL

Definition at line 74 of file ctm.c.

Referenced by _tmain(), and ProcessKeys().

◆ KEY_NO

TCHAR KEY_NO

Definition at line 75 of file ctm.c.

Referenced by _tmain(), and ProcessKeys().

◆ KEY_QUIT

TCHAR KEY_QUIT

Definition at line 74 of file ctm.c.

Referenced by _tmain(), and ProcessKeys().

◆ KEY_YES

TCHAR KEY_YES

Definition at line 75 of file ctm.c.

Referenced by _tmain(), and ProcessKeys().

◆ liOldIdleTime

LARGE_INTEGER liOldIdleTime = {{0,0}}

Definition at line 85 of file ctm.c.

Referenced by PerfDataRefresh().

◆ liOldKernelTime

LARGE_INTEGER liOldKernelTime = {{0,0}}

Definition at line 86 of file ctm.c.

Referenced by PerfDataRefresh().

◆ liOldSystemTime

LARGE_INTEGER liOldSystemTime = {{0,0}}

Definition at line 87 of file ctm.c.

Referenced by PerfDataRefresh().

◆ lpEmpty

TCHAR lpEmpty[80]

Definition at line 72 of file ctm.c.

Referenced by _tmain(), DisplayScreen(), and ProcessKeys().

◆ lpHeader

TCHAR lpHeader

Definition at line 66 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpIdleProcess

TCHAR lpIdleProcess[80]

Definition at line 68 of file ctm.c.

Referenced by _tmain(), and PerfDataRefresh().

◆ lpMemUnit

TCHAR lpMemUnit[3]

Definition at line 67 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpMenu

TCHAR lpMenu[80]

Definition at line 71 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpSeparator

TCHAR lpSeparator[80]

Definition at line 63 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpSeparatorDown

TCHAR lpSeparatorDown[80]

Definition at line 65 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpSeparatorUp

TCHAR lpSeparatorUp[80]

Definition at line 64 of file ctm.c.

Referenced by _tmain(), and DisplayScreen().

◆ lpTitle

◆ outConMode

DWORD outConMode

Definition at line 60 of file ctm.c.

Referenced by _tmain(), and RestoreConsole().

◆ pPerfData

PPERFDATA pPerfData = NULL

Definition at line 90 of file ctm.c.

Referenced by DisplayScreen(), PerfDataRefresh(), and ProcessKeys().

◆ pPerfDataOld

PPERFDATA pPerfDataOld = NULL

Definition at line 89 of file ctm.c.

Referenced by PerfDataRefresh().

◆ ProcessCount

ULONG ProcessCount = 0

Definition at line 80 of file ctm.c.

Referenced by DisplayScreen(), PerfDataRefresh(), and ProcessKeys().

◆ ProcessCountOld

ULONG ProcessCountOld = 0

Definition at line 79 of file ctm.c.

Referenced by PerfDataRefresh().

◆ ProcPerScreen

int ProcPerScreen = 17

Definition at line 77 of file ctm.c.

Referenced by DisplayScreen(), and ProcessKeys().

◆ screenBufferInfo

CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo

Definition at line 97 of file ctm.c.

Referenced by DisplayScreen().

◆ ScreenLines

int ScreenLines =25

Definition at line 78 of file ctm.c.

Referenced by ConWritePaging(), DisplayScreen(), and ProcessKeys().

◆ scrolled

int scrolled =0

Definition at line 93 of file ctm.c.

Referenced by DisplayScreen(), and ProcessKeys().

◆ selection

◆ SystemBasicInfo

SYSTEM_BASIC_INFORMATION SystemBasicInfo

Definition at line 95 of file ctm.c.

Referenced by PerfDataRefresh(), and PerfInit().