2004-01-10 02:14:13 +00:00
|
|
|
/*
|
|
|
|
* ReactOS Task Manager
|
|
|
|
*
|
|
|
|
* procpage.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
2009-06-27 19:16:29 +00:00
|
|
|
* Copyright (C) 2009 Maxime Vernier <maxime.vernier@gmail.com>
|
2004-01-10 02:14:13 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-10-27 10:34:16 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-10 02:14:13 +00:00
|
|
|
*/
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2014-01-13 12:43:06 +00:00
|
|
|
#include "proclist.h"
|
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
#define CMP(x1, x2)\
|
|
|
|
(x1 < x2 ? -1 : (x1 > x2 ? 1 : 0))
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-09-17 16:07:37 +00:00
|
|
|
ULONG ProcessId;
|
2009-06-27 19:16:29 +00:00
|
|
|
} PROCESS_PAGE_LIST_ITEM, *LPPROCESS_PAGE_LIST_ITEM;
|
|
|
|
|
2014-12-15 20:33:26 +00:00
|
|
|
HWND hProcessPage; /* Process List Property Page */
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2014-12-15 20:33:26 +00:00
|
|
|
HWND hProcessPageListCtrl; /* Process ListCtrl Window */
|
2004-01-10 02:14:13 +00:00
|
|
|
HWND hProcessPageHeaderCtrl; /* Process Header Control */
|
2014-12-15 20:33:26 +00:00
|
|
|
HWND hProcessPageEndProcessButton; /* Process End Process button */
|
2004-01-10 02:14:13 +00:00
|
|
|
HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */
|
2014-12-15 20:33:26 +00:00
|
|
|
BOOL bProcessPageSelectionMade = FALSE; /* Is item in ListCtrl selected */
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2007-10-31 23:26:27 +00:00
|
|
|
static int nProcessPageWidth;
|
|
|
|
static int nProcessPageHeight;
|
2010-08-08 03:41:33 +00:00
|
|
|
#ifdef RUN_PROC_PAGE
|
|
|
|
static HANDLE hProcessThread = NULL;
|
|
|
|
static DWORD dwProcessThread;
|
|
|
|
#endif
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
|
|
|
void AddProcess(ULONG Index);
|
|
|
|
void UpdateProcesses();
|
|
|
|
void gethmsfromlargeint(LARGE_INTEGER largeint, DWORD *dwHours, DWORD *dwMinutes, DWORD *dwSeconds);
|
2004-01-10 02:14:13 +00:00
|
|
|
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
|
2014-11-23 20:10:15 +00:00
|
|
|
void CommaSeparateNumberString(LPWSTR strNumber, ULONG nMaxCount);
|
2004-01-10 02:14:13 +00:00
|
|
|
void ProcessPageShowContextMenu(DWORD dwProcessId);
|
2014-11-23 20:10:15 +00:00
|
|
|
BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, ULONG nMaxCount);
|
2004-01-10 02:14:13 +00:00
|
|
|
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter);
|
2009-09-17 16:07:37 +00:00
|
|
|
int ProcessRunning(ULONG ProcessId);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2015-04-12 15:45:40 +00:00
|
|
|
void Cleanup(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
LV_ITEM item;
|
|
|
|
LPPROCESS_PAGE_LIST_ITEM pData;
|
|
|
|
for (i = 0; i < ListView_GetItemCount(hProcessPageListCtrl); i++)
|
|
|
|
{
|
|
|
|
memset(&item, 0, sizeof(LV_ITEM));
|
|
|
|
item.mask = LVIF_PARAM;
|
|
|
|
item.iItem = i;
|
|
|
|
(void)ListView_GetItem(hProcessPageListCtrl, &item);
|
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam;
|
|
|
|
HeapFree(GetProcessHeap(), 0, pData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-08 22:10:45 +00:00
|
|
|
int ProcGetIndexByProcessId(DWORD dwProcessId)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
LVITEM item;
|
|
|
|
LPPROCESS_PAGE_LIST_ITEM pData;
|
|
|
|
|
|
|
|
for (i=0; i<ListView_GetItemCount(hProcessPageListCtrl); i++)
|
|
|
|
{
|
|
|
|
memset(&item, 0, sizeof(LV_ITEM));
|
|
|
|
item.mask = LVIF_PARAM;
|
|
|
|
item.iItem = i;
|
|
|
|
(void)ListView_GetItem(hProcessPageListCtrl, &item);
|
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam;
|
2010-04-10 12:49:41 +00:00
|
|
|
if (pData->ProcessId == dwProcessId)
|
2010-04-08 22:10:45 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
DWORD GetSelectedProcessId(void)
|
|
|
|
{
|
|
|
|
int Index;
|
|
|
|
LVITEM lvitem;
|
|
|
|
|
|
|
|
if(ListView_GetSelectedCount(hProcessPageListCtrl) == 1)
|
|
|
|
{
|
|
|
|
Index = ListView_GetSelectionMark(hProcessPageListCtrl);
|
|
|
|
|
|
|
|
memset(&lvitem, 0, sizeof(LVITEM));
|
|
|
|
|
|
|
|
lvitem.mask = LVIF_PARAM;
|
|
|
|
lvitem.iItem = Index;
|
|
|
|
|
|
|
|
(void)ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
|
|
|
|
|
|
|
if (lvitem.lParam)
|
2010-04-10 12:49:41 +00:00
|
|
|
return ((LPPROCESS_PAGE_LIST_ITEM)lvitem.lParam)->ProcessId;
|
2009-06-28 14:22:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-15 20:33:26 +00:00
|
|
|
void ProcessPageUpdate(void)
|
|
|
|
{
|
|
|
|
/* Enable or disable the "End Process" button */
|
|
|
|
if (ListView_GetSelectedCount(hProcessPageListCtrl))
|
|
|
|
EnableWindow(hProcessPageEndProcessButton, TRUE);
|
|
|
|
else
|
|
|
|
EnableWindow(hProcessPageEndProcessButton, FALSE);
|
|
|
|
}
|
|
|
|
|
2004-10-11 21:08:06 +00:00
|
|
|
INT_PTR CALLBACK
|
|
|
|
ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2007-10-31 23:26:27 +00:00
|
|
|
RECT rc;
|
|
|
|
int nXDifference;
|
|
|
|
int nYDifference;
|
|
|
|
int cx, cy;
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
/*
|
|
|
|
* Save the width and height
|
|
|
|
*/
|
|
|
|
GetClientRect(hDlg, &rc);
|
|
|
|
nProcessPageWidth = rc.right;
|
|
|
|
nProcessPageHeight = rc.bottom;
|
|
|
|
|
|
|
|
/* Update window position */
|
|
|
|
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get handles to the controls
|
|
|
|
*/
|
|
|
|
hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
|
|
|
|
hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
|
|
|
|
hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
|
|
|
|
hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
|
|
|
|
|
|
|
|
/*
|
2009-02-20 21:31:31 +00:00
|
|
|
* Set the title, and extended window styles for the list control
|
2004-01-10 02:14:13 +00:00
|
|
|
*/
|
2007-11-09 15:26:02 +00:00
|
|
|
SetWindowTextW(hProcessPageListCtrl, L"Processes");
|
2006-03-04 17:27:40 +00:00
|
|
|
(void)ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
AddColumns();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Subclass the process list control so we can intercept WM_ERASEBKGND
|
|
|
|
*/
|
2014-10-11 12:39:50 +00:00
|
|
|
OldProcessListWndProc = (WNDPROC)SetWindowLongPtrW(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2010-08-08 03:41:33 +00:00
|
|
|
#ifdef RUN_PROC_PAGE
|
2004-01-10 02:14:13 +00:00
|
|
|
/* Start our refresh thread */
|
2010-08-08 03:41:33 +00:00
|
|
|
hProcessThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread);
|
|
|
|
#endif
|
2014-12-15 20:33:26 +00:00
|
|
|
|
2014-12-15 20:45:38 +00:00
|
|
|
/* Refresh page */
|
2014-12-15 20:33:26 +00:00
|
|
|
ProcessPageUpdate();
|
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
/* Close the event handle, this will make the */
|
|
|
|
/* refresh thread exit when the wait fails */
|
2010-08-08 03:41:33 +00:00
|
|
|
#ifdef RUN_PROC_PAGE
|
|
|
|
EndLocalThread(&hProcessThread, dwProcessThread);
|
|
|
|
#endif
|
2004-01-10 02:14:13 +00:00
|
|
|
SaveColumnSettings();
|
2015-04-12 15:45:40 +00:00
|
|
|
Cleanup();
|
2004-01-10 02:14:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2005-01-02 20:47:34 +00:00
|
|
|
/* Handle the button clicks */
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_ENDPROCESS:
|
|
|
|
ProcessPage_OnEndProcess();
|
|
|
|
}
|
2004-01-10 02:14:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
if (wParam == SIZE_MINIMIZED)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cx = LOWORD(lParam);
|
|
|
|
cy = HIWORD(lParam);
|
|
|
|
nXDifference = cx - nProcessPageWidth;
|
|
|
|
nYDifference = cy - nProcessPageHeight;
|
|
|
|
nProcessPageWidth = cx;
|
|
|
|
nProcessPageHeight = cy;
|
|
|
|
|
|
|
|
/* Reposition the application page's controls */
|
|
|
|
GetWindowRect(hProcessPageListCtrl, &rc);
|
|
|
|
cx = (rc.right - rc.left) + nXDifference;
|
|
|
|
cy = (rc.bottom - rc.top) + nYDifference;
|
|
|
|
SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
InvalidateRect(hProcessPageListCtrl, NULL, TRUE);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
GetClientRect(hProcessPageEndProcessButton, &rc);
|
2014-08-24 17:07:43 +00:00
|
|
|
MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT));
|
2004-01-10 02:14:13 +00:00
|
|
|
cx = rc.left + nXDifference;
|
|
|
|
cy = rc.top + nYDifference;
|
|
|
|
SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
|
|
InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
GetClientRect(hProcessPageShowAllProcessesButton, &rc);
|
2014-08-24 17:07:43 +00:00
|
|
|
MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT));
|
2004-01-10 02:14:13 +00:00
|
|
|
cx = rc.left;
|
|
|
|
cy = rc.top + nYDifference;
|
|
|
|
SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
|
|
|
InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
ProcessPageOnNotify(wParam, lParam);
|
|
|
|
break;
|
2010-12-05 10:27:45 +00:00
|
|
|
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
if (wParam == VK_DELETE)
|
|
|
|
ProcessPage_OnEndProcess();
|
|
|
|
break;
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2007-10-31 23:26:27 +00:00
|
|
|
LPNMHDR pnmh;
|
|
|
|
NMLVDISPINFO* pnmdi;
|
|
|
|
LPNMHEADER pnmhdr;
|
|
|
|
ULONG Index;
|
|
|
|
ULONG ColumnIndex;
|
2009-06-27 19:16:29 +00:00
|
|
|
LPPROCESS_PAGE_LIST_ITEM pData;
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
pnmh = (LPNMHDR) lParam;
|
|
|
|
pnmdi = (NMLVDISPINFO*) lParam;
|
|
|
|
pnmhdr = (LPNMHEADER) lParam;
|
|
|
|
|
|
|
|
if (pnmh->hwndFrom == hProcessPageListCtrl)
|
|
|
|
{
|
|
|
|
switch (pnmh->code)
|
|
|
|
{
|
|
|
|
case LVN_ITEMCHANGED:
|
|
|
|
ProcessPageUpdate();
|
|
|
|
break;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
case LVN_GETDISPINFO:
|
|
|
|
|
|
|
|
if (!(pnmdi->item.mask & LVIF_TEXT))
|
|
|
|
break;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)pnmdi->item.lParam;
|
2010-04-10 12:49:41 +00:00
|
|
|
Index = PerfDataGetProcessIndex(pData->ProcessId);
|
2004-01-10 02:14:13 +00:00
|
|
|
ColumnIndex = pnmdi->item.iSubItem;
|
|
|
|
|
2014-11-23 20:10:15 +00:00
|
|
|
PerfDataGetText(Index, ColumnIndex, pnmdi->item.pszText, (ULONG)pnmdi->item.cchTextMax);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NM_RCLICK:
|
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
ProcessPageShowContextMenu(GetSelectedProcessId());
|
2004-01-10 02:14:13 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-05 10:27:45 +00:00
|
|
|
case LVN_KEYDOWN:
|
|
|
|
|
|
|
|
if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
|
|
|
|
ProcessPage_OnEndProcess();
|
|
|
|
break;
|
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pnmh->hwndFrom == hProcessPageHeaderCtrl)
|
|
|
|
{
|
|
|
|
switch (pnmh->code)
|
|
|
|
{
|
|
|
|
case HDN_ITEMCLICK:
|
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
TaskManagerSettings.SortColumn = ColumnDataHints[pnmhdr->iItem];
|
|
|
|
TaskManagerSettings.SortAscending = !TaskManagerSettings.SortAscending;
|
2009-06-27 19:16:29 +00:00
|
|
|
(void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL);
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HDN_ITEMCHANGED:
|
|
|
|
|
|
|
|
UpdateColumnDataHints();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HDN_ENDDRAG:
|
|
|
|
|
|
|
|
UpdateColumnDataHints();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-23 20:10:15 +00:00
|
|
|
void CommaSeparateNumberString(LPWSTR strNumber, ULONG nMaxCount)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2007-10-31 23:26:27 +00:00
|
|
|
WCHAR temp[260];
|
|
|
|
UINT i, j, k;
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2007-10-31 23:26:27 +00:00
|
|
|
for (i=0,j=0; i<(wcslen(strNumber) % 3); i++, j++)
|
2004-01-10 02:14:13 +00:00
|
|
|
temp[j] = strNumber[i];
|
2007-10-31 23:26:27 +00:00
|
|
|
for (k=0; i<wcslen(strNumber); i++,j++,k++) {
|
2004-01-10 02:14:13 +00:00
|
|
|
if ((k % 3 == 0) && (j > 0))
|
2007-10-31 23:26:27 +00:00
|
|
|
temp[j++] = L',';
|
2004-01-10 02:14:13 +00:00
|
|
|
temp[j] = strNumber[i];
|
|
|
|
}
|
2007-10-31 23:26:27 +00:00
|
|
|
temp[j] = L'\0';
|
|
|
|
wcsncpy(strNumber, temp, nMaxCount);
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessPageShowContextMenu(DWORD dwProcessId)
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hSubMenu;
|
|
|
|
HMENU hPriorityMenu;
|
|
|
|
POINT pt;
|
2007-10-31 23:26:27 +00:00
|
|
|
SYSTEM_INFO si;
|
|
|
|
HANDLE hProcess;
|
2004-01-10 02:14:13 +00:00
|
|
|
DWORD dwProcessPriorityClass;
|
2007-10-31 23:26:27 +00:00
|
|
|
WCHAR strDebugger[260];
|
2004-01-10 02:14:13 +00:00
|
|
|
DWORD dwDebuggerSize;
|
2007-10-31 23:26:27 +00:00
|
|
|
HKEY hKey;
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
memset(&si, 0, sizeof(SYSTEM_INFO));
|
|
|
|
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
GetSystemInfo(&si);
|
|
|
|
|
2007-11-09 15:26:02 +00:00
|
|
|
hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_PROCESS_PAGE_CONTEXT));
|
2004-01-10 02:14:13 +00:00
|
|
|
hSubMenu = GetSubMenu(hMenu, 0);
|
|
|
|
hPriorityMenu = GetSubMenu(hSubMenu, 4);
|
|
|
|
|
|
|
|
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
|
|
|
|
dwProcessPriorityClass = GetPriorityClass(hProcess);
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
|
|
|
|
if (si.dwNumberOfProcessors < 2)
|
|
|
|
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-01-10 02:14:13 +00:00
|
|
|
switch (dwProcessPriorityClass) {
|
|
|
|
case REALTIME_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
case HIGH_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
case ABOVE_NORMAL_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
case NORMAL_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
case BELOW_NORMAL_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
case IDLE_PRIORITY_CLASS:
|
|
|
|
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-11-09 15:26:02 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2016-10-09 20:58:08 +00:00
|
|
|
dwDebuggerSize = sizeof(strDebugger);
|
2007-11-09 15:26:02 +00:00
|
|
|
if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
|
2004-01-10 02:14:13 +00:00
|
|
|
{
|
2008-02-15 19:22:55 +00:00
|
|
|
CharUpper(strDebugger);
|
2007-10-31 23:26:27 +00:00
|
|
|
if (wcsstr(strDebugger, L"DRWTSN32"))
|
2004-01-10 02:14:13 +00:00
|
|
|
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
} else {
|
|
|
|
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
|
|
|
|
}
|
|
|
|
TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefreshProcessPage(void)
|
|
|
|
{
|
2010-08-08 03:41:33 +00:00
|
|
|
#ifdef RUN_PROC_PAGE
|
2004-01-10 02:14:13 +00:00
|
|
|
/* Signal the event so that our refresh thread */
|
|
|
|
/* will wake up and refresh the process page */
|
2010-08-08 03:41:33 +00:00
|
|
|
PostThreadMessage(dwProcessThread, WM_TIMER, 0, 0);
|
|
|
|
#endif
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
|
|
|
|
{
|
2010-08-08 03:41:33 +00:00
|
|
|
MSG msg;
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
while (1) {
|
2010-08-08 03:41:33 +00:00
|
|
|
/* Wait for an the event or application close */
|
|
|
|
if (GetMessage(&msg, NULL, 0, 0) <= 0)
|
2004-01-10 02:14:13 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-08-08 03:41:33 +00:00
|
|
|
if (msg.message == WM_TIMER) {
|
2004-01-10 02:14:13 +00:00
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
UpdateProcesses();
|
2004-01-10 02:14:13 +00:00
|
|
|
|
|
|
|
if (IsWindowVisible(hProcessPage))
|
|
|
|
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
|
|
|
|
|
2014-12-15 20:45:38 +00:00
|
|
|
ProcessPageUpdate();
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-31 23:26:27 +00:00
|
|
|
return 0;
|
2004-01-10 02:14:13 +00:00
|
|
|
}
|
2009-06-27 19:16:29 +00:00
|
|
|
|
|
|
|
void UpdateProcesses()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ULONG l;
|
2010-04-10 12:49:41 +00:00
|
|
|
LV_ITEM item;
|
2009-06-27 19:16:29 +00:00
|
|
|
LPPROCESS_PAGE_LIST_ITEM pData;
|
|
|
|
|
2011-04-29 21:49:37 +00:00
|
|
|
SendMessage(hProcessPageListCtrl, WM_SETREDRAW, FALSE, 0);
|
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
/* Remove old processes */
|
|
|
|
for (i = 0; i < ListView_GetItemCount(hProcessPageListCtrl); i++)
|
|
|
|
{
|
|
|
|
memset(&item, 0, sizeof (LV_ITEM));
|
|
|
|
item.mask = LVIF_PARAM;
|
|
|
|
item.iItem = i;
|
|
|
|
(void)ListView_GetItem(hProcessPageListCtrl, &item);
|
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam;
|
2009-09-17 16:07:37 +00:00
|
|
|
if (!ProcessRunning(pData->ProcessId))
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-08 22:21:17 +00:00
|
|
|
(void)ListView_DeleteItem(hProcessPageListCtrl, i);
|
2009-06-27 19:16:29 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pData);
|
|
|
|
}
|
|
|
|
}
|
2010-04-10 12:49:41 +00:00
|
|
|
|
|
|
|
/* Check for difference in listview process and performance process counts */
|
|
|
|
if (ListView_GetItemCount(hProcessPageListCtrl) != PerfDataGetProcessCount())
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
/* Add new processes by checking against the current items */
|
|
|
|
for (l = 0; l < PerfDataGetProcessCount(); l++)
|
|
|
|
{
|
|
|
|
AddProcess(l);
|
|
|
|
}
|
2009-06-27 19:16:29 +00:00
|
|
|
}
|
2010-04-10 12:49:41 +00:00
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
if (TaskManagerSettings.SortColumn != -1)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
|
|
|
(void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL);
|
|
|
|
}
|
2011-04-29 21:49:37 +00:00
|
|
|
|
|
|
|
SendMessage(hProcessPageListCtrl, WM_SETREDRAW, TRUE, 0);
|
2014-12-15 20:33:26 +00:00
|
|
|
|
|
|
|
/* Select first item if any */
|
2014-12-15 20:45:38 +00:00
|
|
|
if ((ListView_GetNextItem(hProcessPageListCtrl, -1, LVNI_FOCUSED | LVNI_SELECTED) == -1) &&
|
2014-12-15 20:33:26 +00:00
|
|
|
(ListView_GetItemCount(hProcessPageListCtrl) > 0) && !bProcessPageSelectionMade)
|
|
|
|
{
|
|
|
|
ListView_SetItemState(hProcessPageListCtrl, 0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
|
|
|
|
bProcessPageSelectionMade = TRUE;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bProcessPageSelectionMade = FALSE;
|
|
|
|
}
|
|
|
|
*/
|
2009-06-27 19:16:29 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:07:37 +00:00
|
|
|
BOOL ProcessRunning(ULONG ProcessId)
|
|
|
|
{
|
2014-01-19 08:52:21 +00:00
|
|
|
HANDLE hProcess;
|
|
|
|
DWORD exitCode;
|
|
|
|
|
|
|
|
if (ProcessId == 0) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId);
|
|
|
|
if (hProcess == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetExitCodeProcess(hProcess, &exitCode)) {
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
return (exitCode == STILL_ACTIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
return FALSE;
|
2009-09-17 16:07:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
void AddProcess(ULONG Index)
|
|
|
|
{
|
|
|
|
LPPROCESS_PAGE_LIST_ITEM pData;
|
|
|
|
int i;
|
|
|
|
LV_ITEM item;
|
|
|
|
BOOL bAlreadyInList = FALSE;
|
|
|
|
ULONG pid;
|
|
|
|
|
|
|
|
pid = PerfDataGetProcessId(Index);
|
|
|
|
|
|
|
|
/* Check to see if it's already in our list */
|
|
|
|
for (i=0; i<ListView_GetItemCount(hProcessPageListCtrl); i++)
|
|
|
|
{
|
|
|
|
memset(&item, 0, sizeof(LV_ITEM));
|
|
|
|
item.mask = LVIF_PARAM;
|
|
|
|
item.iItem = i;
|
|
|
|
(void)ListView_GetItem(hProcessPageListCtrl, &item);
|
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam;
|
2010-04-10 12:49:41 +00:00
|
|
|
if (pData->ProcessId == pid)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
|
|
|
bAlreadyInList = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!bAlreadyInList) /* Add */
|
|
|
|
{
|
|
|
|
pData = (LPPROCESS_PAGE_LIST_ITEM)HeapAlloc(GetProcessHeap(), 0, sizeof(PROCESS_PAGE_LIST_ITEM));
|
2009-09-17 16:07:37 +00:00
|
|
|
pData->ProcessId = pid;
|
2009-10-27 10:34:16 +00:00
|
|
|
|
2009-06-27 19:16:29 +00:00
|
|
|
/* Add the item to the list */
|
|
|
|
memset(&item, 0, sizeof(LV_ITEM));
|
|
|
|
item.mask = LVIF_TEXT|LVIF_PARAM;
|
|
|
|
item.pszText = LPSTR_TEXTCALLBACK;
|
|
|
|
item.iItem = ListView_GetItemCount(hProcessPageListCtrl);
|
|
|
|
item.lParam = (LPARAM)pData;
|
|
|
|
(void)ListView_InsertItem(hProcessPageListCtrl, &item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-23 20:10:15 +00:00
|
|
|
BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, ULONG nMaxCount)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
|
|
|
IO_COUNTERS iocounters;
|
|
|
|
LARGE_INTEGER time;
|
|
|
|
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME)
|
|
|
|
PerfDataGetImageName(Index, lpText, nMaxCount);
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_PID)
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetProcessId(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME)
|
|
|
|
PerfDataGetUserName(Index, lpText, nMaxCount);
|
2014-11-23 20:10:15 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_COMMANDLINE)
|
|
|
|
PerfDataGetCommandLine(Index, lpText, nMaxCount);
|
2009-06-27 19:16:29 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID)
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetSessionId(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE)
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%02lu", PerfDataGetCPUUsage(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
|
|
|
|
{
|
|
|
|
DWORD dwHours;
|
|
|
|
DWORD dwMinutes;
|
|
|
|
DWORD dwSeconds;
|
|
|
|
|
|
|
|
time = PerfDataGetCPUTime(Index);
|
|
|
|
gethmsfromlargeint(time, &dwHours, &dwMinutes, &dwSeconds);
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu:%02lu:%02lu", dwHours, dwMinutes, dwSeconds);
|
2009-06-27 19:16:29 +00:00
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetWorkingSetSizeBytes(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetWorkingSetSizeDelta(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetPageFaultCount(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetPageFaultCountDelta(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetVirtualMemorySizeBytes(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetPagedPoolUsagePages(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetNonPagedPoolUsagePages(Index) / 1024);
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
wcscat(lpText, L" K");
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY)
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetBasePriority(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetHandleCount(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetThreadCount(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetUSERObjectCount(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS)
|
|
|
|
{
|
2013-03-14 17:47:00 +00:00
|
|
|
wsprintfW(lpText, L"%lu", PerfDataGetGDIObjectCount(Index));
|
2009-06-27 19:16:29 +00:00
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.ReadOperationCount); */
|
|
|
|
_ui64tow(iocounters.ReadOperationCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.WriteOperationCount); */
|
|
|
|
_ui64tow(iocounters.WriteOperationCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.OtherOperationCount); */
|
|
|
|
_ui64tow(iocounters.OtherOperationCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.ReadTransferCount); */
|
|
|
|
_ui64tow(iocounters.ReadTransferCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.WriteTransferCount); */
|
|
|
|
_ui64tow(iocounters.WriteTransferCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES)
|
|
|
|
{
|
|
|
|
PerfDataGetIOCounters(Index, &iocounters);
|
|
|
|
/* wsprintfW(pnmdi->item.pszText, L"%d", iocounters.OtherTransferCount); */
|
|
|
|
_ui64tow(iocounters.OtherTransferCount, lpText, 10);
|
|
|
|
CommaSeparateNumberString(lpText, nMaxCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gethmsfromlargeint(LARGE_INTEGER largeint, DWORD *dwHours, DWORD *dwMinutes, DWORD *dwSeconds)
|
|
|
|
{
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
*dwHours = (DWORD)(largeint.QuadPart / 36000000000L);
|
|
|
|
*dwMinutes = (DWORD)((largeint.QuadPart % 36000000000L) / 600000000L);
|
|
|
|
*dwSeconds = (DWORD)(((largeint.QuadPart % 36000000000L) % 600000000L) / 10000000L);
|
|
|
|
#else
|
|
|
|
*dwHours = (DWORD)(largeint.QuadPart / 36000000000LL);
|
|
|
|
*dwMinutes = (DWORD)((largeint.QuadPart % 36000000000LL) / 600000000LL);
|
|
|
|
*dwSeconds = (DWORD)(((largeint.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int largeintcmp(LARGE_INTEGER l1, LARGE_INTEGER l2)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
DWORD dwHours1;
|
|
|
|
DWORD dwMinutes1;
|
|
|
|
DWORD dwSeconds1;
|
|
|
|
DWORD dwHours2;
|
|
|
|
DWORD dwMinutes2;
|
|
|
|
DWORD dwSeconds2;
|
|
|
|
|
|
|
|
gethmsfromlargeint(l1, &dwHours1, &dwMinutes1, &dwSeconds1);
|
|
|
|
gethmsfromlargeint(l2, &dwHours2, &dwMinutes2, &dwSeconds2);
|
|
|
|
ret = CMP(dwHours1, dwHours2);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
ret = CMP(dwMinutes1, dwMinutes2);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
ret = CMP(dwSeconds1, dwSeconds2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
LPPROCESS_PAGE_LIST_ITEM Param1;
|
|
|
|
LPPROCESS_PAGE_LIST_ITEM Param2;
|
2010-04-10 12:49:41 +00:00
|
|
|
ULONG IndexParam1;
|
|
|
|
ULONG IndexParam2;
|
2009-06-27 19:16:29 +00:00
|
|
|
WCHAR text1[260];
|
|
|
|
WCHAR text2[260];
|
|
|
|
ULONG l1;
|
|
|
|
ULONG l2;
|
|
|
|
LARGE_INTEGER time1;
|
|
|
|
LARGE_INTEGER time2;
|
|
|
|
IO_COUNTERS iocounters1;
|
|
|
|
IO_COUNTERS iocounters2;
|
|
|
|
ULONGLONG ull1;
|
|
|
|
ULONGLONG ull2;
|
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
if (TaskManagerSettings.SortAscending) {
|
2009-06-27 19:16:29 +00:00
|
|
|
Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam1;
|
|
|
|
Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam2;
|
|
|
|
} else {
|
|
|
|
Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam2;
|
|
|
|
Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam1;
|
|
|
|
}
|
2010-04-10 12:49:41 +00:00
|
|
|
IndexParam1 = PerfDataGetProcessIndex(Param1->ProcessId);
|
|
|
|
IndexParam2 = PerfDataGetProcessIndex(Param2->ProcessId);
|
2009-06-27 19:16:29 +00:00
|
|
|
|
2009-06-28 14:22:09 +00:00
|
|
|
if (TaskManagerSettings.SortColumn == COLUMN_IMAGENAME)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetImageName(IndexParam1, text1, sizeof (text1) / sizeof (*text1));
|
|
|
|
PerfDataGetImageName(IndexParam2, text2, sizeof (text2) / sizeof (*text2));
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = _wcsicmp(text1, text2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_PID)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = Param1->ProcessId;
|
|
|
|
l2 = Param2->ProcessId;
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_USERNAME)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetUserName(IndexParam1, text1, sizeof (text1) / sizeof (*text1));
|
|
|
|
PerfDataGetUserName(IndexParam2, text2, sizeof (text2) / sizeof (*text2));
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = _wcsicmp(text1, text2);
|
|
|
|
}
|
2014-11-23 20:10:15 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_COMMANDLINE)
|
|
|
|
{
|
|
|
|
PerfDataGetCommandLine(IndexParam1, text1, sizeof (text1) / sizeof (*text1));
|
|
|
|
PerfDataGetCommandLine(IndexParam2, text2, sizeof (text2) / sizeof (*text2));
|
|
|
|
ret = _wcsicmp(text1, text2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_SESSIONID)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetSessionId(IndexParam1);
|
|
|
|
l2 = PerfDataGetSessionId(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_CPUUSAGE)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetCPUUsage(IndexParam1);
|
|
|
|
l2 = PerfDataGetCPUUsage(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_CPUTIME)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
time1 = PerfDataGetCPUTime(IndexParam1);
|
|
|
|
time2 = PerfDataGetCPUTime(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = largeintcmp(time1, time2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGE)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetWorkingSetSizeBytes(IndexParam1);
|
|
|
|
l2 = PerfDataGetWorkingSetSizeBytes(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_PEAKMEMORYUSAGE)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam1);
|
|
|
|
l2 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_MEMORYUSAGEDELTA)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetWorkingSetSizeDelta(IndexParam1);
|
|
|
|
l2 = PerfDataGetWorkingSetSizeDelta(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTS)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetPageFaultCount(IndexParam1);
|
|
|
|
l2 = PerfDataGetPageFaultCount(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_PAGEFAULTSDELTA)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetPageFaultCountDelta(IndexParam1);
|
|
|
|
l2 = PerfDataGetPageFaultCountDelta(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_VIRTUALMEMORYSIZE)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetVirtualMemorySizeBytes(IndexParam1);
|
|
|
|
l2 = PerfDataGetVirtualMemorySizeBytes(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_PAGEDPOOL)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetPagedPoolUsagePages(IndexParam1);
|
|
|
|
l2 = PerfDataGetPagedPoolUsagePages(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_NONPAGEDPOOL)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetNonPagedPoolUsagePages(IndexParam1);
|
|
|
|
l2 = PerfDataGetNonPagedPoolUsagePages(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_BASEPRIORITY)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetBasePriority(IndexParam1);
|
|
|
|
l2 = PerfDataGetBasePriority(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_HANDLECOUNT)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetHandleCount(IndexParam1);
|
|
|
|
l2 = PerfDataGetHandleCount(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_THREADCOUNT)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetThreadCount(IndexParam1);
|
|
|
|
l2 = PerfDataGetThreadCount(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_USEROBJECTS)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetUSERObjectCount(IndexParam1);
|
|
|
|
l2 = PerfDataGetUSERObjectCount(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_GDIOBJECTS)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
l1 = PerfDataGetGDIObjectCount(IndexParam1);
|
|
|
|
l2 = PerfDataGetGDIObjectCount(IndexParam2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ret = CMP(l1, l2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOREADS)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.ReadOperationCount;
|
|
|
|
ull2 = iocounters2.ReadOperationCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITES)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.WriteOperationCount;
|
|
|
|
ull2 = iocounters2.WriteOperationCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHER)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.OtherOperationCount;
|
|
|
|
ull2 = iocounters2.OtherOperationCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOREADBYTES)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.ReadTransferCount;
|
|
|
|
ull2 = iocounters2.ReadTransferCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOWRITEBYTES)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.WriteTransferCount;
|
|
|
|
ull2 = iocounters2.WriteTransferCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
2009-06-28 14:22:09 +00:00
|
|
|
else if (TaskManagerSettings.SortColumn == COLUMN_IOOTHERBYTES)
|
2009-06-27 19:16:29 +00:00
|
|
|
{
|
2010-04-10 12:49:41 +00:00
|
|
|
PerfDataGetIOCounters(IndexParam1, &iocounters1);
|
|
|
|
PerfDataGetIOCounters(IndexParam2, &iocounters2);
|
2009-06-27 19:16:29 +00:00
|
|
|
ull1 = iocounters1.OtherTransferCount;
|
|
|
|
ull2 = iocounters2.OtherTransferCount;
|
|
|
|
ret = CMP(ull1, ull2);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|