Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ReactOS Task Manager |
| 3 | * |
| 4 | * procpage.c |
| 5 | * |
| 6 | * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org> |
| 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2.1 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ |
| 24 | #include <windows.h> |
| 25 | #include <commctrl.h> |
| 26 | #include <stdlib.h> |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 27 | #include <memory.h> |
| 28 | #include <tchar.h> |
| 29 | #include <stdio.h> |
| 30 | #include <winnt.h> |
| 31 | |
| 32 | #include "taskmgr.h" |
| 33 | #include "perfdata.h" |
| 34 | #include "column.h" |
| 35 | #include <ctype.h> |
| 36 | |
| 37 | HWND hProcessPage; /* Process List Property Page */ |
| 38 | |
| 39 | HWND hProcessPageListCtrl; /* Process ListCtrl Window */ |
| 40 | HWND hProcessPageHeaderCtrl; /* Process Header Control */ |
| 41 | HWND hProcessPageEndProcessButton; /* Process End Process button */ |
| 42 | HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */ |
| 43 | |
| 44 | static int nProcessPageWidth; |
| 45 | static int nProcessPageHeight; |
| 46 | |
| 47 | static HANDLE hProcessPageEvent = NULL; /* When this event becomes signaled then we refresh the process list */ |
| 48 | |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 49 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 50 | static void CommaSeparateNumberString(LPWSTR strNumber, int nMaxCount) |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 51 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 52 | WCHAR temp[260]; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 53 | UINT i, j, k; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 54 | int len = lstrlenW(strNumber); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 55 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 56 | for (i=0; i < len % 3; i++) |
| 57 | temp[i] = strNumber[i]; |
| 58 | for (k=0,j=i; i < len; i++,j++,k++) { |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 59 | if ((k % 3 == 0) && (j > 0)) |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 60 | temp[j++] = ','; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 61 | temp[j] = strNumber[i]; |
| 62 | } |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 63 | temp[j++] = 0; |
| 64 | memcpy(strNumber, temp, min(nMaxCount, j) * sizeof(WCHAR)); |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 65 | } |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 66 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 67 | static void ProcessPageShowContextMenu(DWORD dwProcessId) |
| 68 | { |
| 69 | HMENU hMenu; |
| 70 | HMENU hSubMenu; |
| 71 | HMENU hPriorityMenu; |
| 72 | POINT pt; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 73 | SYSTEM_INFO si; |
| 74 | HANDLE hProcess; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 75 | DWORD dwProcessPriorityClass; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 76 | WCHAR strDebugger[260]; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 77 | DWORD dwDebuggerSize; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 78 | HKEY hKey; |
| 79 | UINT Idx; |
| 80 | static const WCHAR wszAeDebugRegPath[] = { |
| 81 | 'S','o','f','t','w','a','r','e','\\', |
| 82 | 'M','i','c','r','o','s','o','f','t','\\', |
| 83 | 'W','i','n','d','o','w','s',' ','N','T','\\', |
| 84 | 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', |
| 85 | 'A','e','D','e','b','u','g',0}; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 86 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 87 | memset(&si, 0, sizeof(SYSTEM_INFO)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 88 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 89 | GetCursorPos(&pt); |
| 90 | GetSystemInfo(&si); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 91 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 92 | hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT)); |
| 93 | hSubMenu = GetSubMenu(hMenu, 0); |
| 94 | hPriorityMenu = GetSubMenu(hSubMenu, 4); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 95 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 96 | hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId); |
| 97 | dwProcessPriorityClass = GetPriorityClass(hProcess); |
| 98 | CloseHandle(hProcess); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 99 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 100 | if (si.dwNumberOfProcessors < 2) |
| 101 | RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND); |
| 102 | |
| 103 | if (!AreDebugChannelsSupported()) |
| 104 | RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 105 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 106 | switch (dwProcessPriorityClass) { |
| 107 | case REALTIME_PRIORITY_CLASS: |
| 108 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 109 | break; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 110 | case HIGH_PRIORITY_CLASS: |
| 111 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 112 | break; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 113 | case ABOVE_NORMAL_PRIORITY_CLASS: |
| 114 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 115 | break; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 116 | case NORMAL_PRIORITY_CLASS: |
| 117 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND); |
| 118 | break; |
| 119 | case BELOW_NORMAL_PRIORITY_CLASS: |
| 120 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND); |
| 121 | break; |
| 122 | case IDLE_PRIORITY_CLASS: |
| 123 | CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 124 | break; |
| 125 | } |
| 126 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 127 | if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszAeDebugRegPath, 0, KEY_READ, &hKey) == ERROR_SUCCESS) |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 128 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 129 | static const WCHAR wszDebugger[] = {'D','e','b','u','g','g','e','r',0}; |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 130 | dwDebuggerSize = 260; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 131 | if (RegQueryValueExW(hKey, wszDebugger, NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS) |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 132 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 133 | static const WCHAR wszDRWTSN32[] = {'D','R','W','T','S','N','3','2',0}; |
| 134 | for (Idx=0; Idx < lstrlenW(strDebugger); Idx++) |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 135 | strDebugger[Idx] = toupper(strDebugger[Idx]); |
| 136 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 137 | if (wcsstr(strDebugger, wszDRWTSN32)) |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 138 | EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); |
| 139 | } |
| 140 | else |
| 141 | EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); |
| 142 | |
| 143 | RegCloseKey(hKey); |
| 144 | } else { |
| 145 | EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); |
| 146 | } |
| 147 | TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL); |
| 148 | DestroyMenu(hMenu); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Gerald Pfeifer | 2aa11ff | 2010-05-01 16:48:48 +0200 | [diff] [blame] | 151 | static void ProcessPageOnNotify(LPARAM lParam) |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 152 | { |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 153 | LPNMHDR pnmh; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 154 | NMLVDISPINFOW* pnmdi; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 155 | LVITEM lvitem; |
| 156 | ULONG Index; |
| 157 | ULONG ColumnIndex; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 158 | IO_COUNTERS iocounters; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 159 | TIME time; |
| 160 | static const WCHAR wszFmtD[] = {'%','d',0}; |
| 161 | static const WCHAR wszFmt02D[] = {'%','0','2','d',0}; |
| 162 | static const WCHAR wszUnitK[] = {' ','K',0}; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 163 | |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 164 | pnmh = (LPNMHDR) lParam; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 165 | pnmdi = (NMLVDISPINFOW*) lParam; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 166 | |
| 167 | if (pnmh->hwndFrom == hProcessPageListCtrl) |
| 168 | { |
| 169 | switch (pnmh->code) |
| 170 | { |
Alexandre Julliard | d0ee9f9 | 2005-03-02 12:23:20 +0000 | [diff] [blame] | 171 | #if 0 |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 172 | case LVN_ITEMCHANGED: |
| 173 | ProcessPageUpdate(); |
| 174 | break; |
Alexandre Julliard | d0ee9f9 | 2005-03-02 12:23:20 +0000 | [diff] [blame] | 175 | #endif |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 176 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 177 | case LVN_GETDISPINFOW: |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 178 | |
| 179 | if (!(pnmdi->item.mask & LVIF_TEXT)) |
| 180 | break; |
| 181 | |
| 182 | ColumnIndex = pnmdi->item.iSubItem; |
| 183 | Index = pnmdi->item.iItem; |
| 184 | |
| 185 | if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) |
| 186 | PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 187 | if (ColumnDataHints[ColumnIndex] == COLUMN_PID) |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 188 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetProcessId(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 189 | if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) |
| 190 | PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 191 | if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 192 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetSessionId(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 193 | if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 194 | wsprintfW(pnmdi->item.pszText, wszFmt02D, PerfDataGetCPUUsage(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 195 | if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) |
| 196 | { |
| 197 | DWORD dwHours; |
| 198 | DWORD dwMinutes; |
| 199 | DWORD dwSeconds; |
Alexandre Julliard | 903e0b9 | 2005-09-13 11:26:36 +0000 | [diff] [blame] | 200 | ULONGLONG secs; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 201 | static const WCHAR timefmt[] = {'%','d',':','%','0','2','d',':','%','0','2','d',0}; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 202 | |
| 203 | time = PerfDataGetCPUTime(Index); |
Alexandre Julliard | 903e0b9 | 2005-09-13 11:26:36 +0000 | [diff] [blame] | 204 | secs = time.QuadPart / 10000000; |
| 205 | dwHours = secs / 3600; |
| 206 | dwMinutes = (secs % 3600) / 60; |
| 207 | dwSeconds = (secs % 3600) % 60; |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 208 | wsprintfW(pnmdi->item.pszText, timefmt, dwHours, dwMinutes, dwSeconds); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 209 | } |
| 210 | if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) |
| 211 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 212 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetWorkingSetSizeBytes(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 213 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 214 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 215 | } |
| 216 | if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) |
| 217 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 218 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 219 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 220 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 221 | } |
| 222 | if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) |
| 223 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 224 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetWorkingSetSizeDelta(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 225 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 226 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 227 | } |
| 228 | if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) |
| 229 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 230 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPageFaultCount(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 231 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 232 | } |
| 233 | if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) |
| 234 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 235 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPageFaultCountDelta(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 236 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 237 | } |
| 238 | if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) |
| 239 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 240 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetVirtualMemorySizeBytes(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 241 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 242 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 243 | } |
| 244 | if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) |
| 245 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 246 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetPagedPoolUsagePages(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 247 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 248 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 249 | } |
| 250 | if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) |
| 251 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 252 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetNonPagedPoolUsagePages(Index) / 1024); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 253 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 254 | wcscat(pnmdi->item.pszText, wszUnitK); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 255 | } |
| 256 | if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 257 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetBasePriority(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 258 | if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) |
| 259 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 260 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetHandleCount(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 261 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 262 | } |
| 263 | if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) |
| 264 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 265 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetThreadCount(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 266 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 267 | } |
| 268 | if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) |
| 269 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 270 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetUSERObjectCount(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 271 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 272 | } |
| 273 | if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) |
| 274 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 275 | wsprintfW(pnmdi->item.pszText, wszFmtD, PerfDataGetGDIObjectCount(Index)); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 276 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 277 | } |
| 278 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) |
| 279 | { |
| 280 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 281 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.ReadOperationCount); */ |
| 282 | _ui64tow(iocounters.ReadOperationCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 283 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 284 | } |
| 285 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) |
| 286 | { |
| 287 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 288 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.WriteOperationCount); */ |
| 289 | _ui64tow(iocounters.WriteOperationCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 290 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 291 | } |
| 292 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) |
| 293 | { |
| 294 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 295 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.OtherOperationCount); */ |
| 296 | _ui64tow(iocounters.OtherOperationCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 297 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 298 | } |
| 299 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) |
| 300 | { |
| 301 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 302 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.ReadTransferCount); */ |
| 303 | _ui64tow(iocounters.ReadTransferCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 304 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 305 | } |
| 306 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) |
| 307 | { |
| 308 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 309 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.WriteTransferCount); */ |
| 310 | _ui64tow(iocounters.WriteTransferCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 311 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 312 | } |
| 313 | if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) |
| 314 | { |
| 315 | PerfDataGetIOCounters(Index, &iocounters); |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 316 | /* wsprintfW(pnmdi->item.pszText, wszFmtD, iocounters.OtherTransferCount); */ |
| 317 | _ui64tow(iocounters.OtherTransferCount, pnmdi->item.pszText, 10); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 318 | CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); |
| 319 | } |
| 320 | |
| 321 | break; |
| 322 | |
| 323 | case NM_RCLICK: |
| 324 | |
| 325 | for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) |
| 326 | { |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 327 | lvitem.mask = LVIF_STATE; |
| 328 | lvitem.stateMask = LVIS_SELECTED; |
| 329 | lvitem.iItem = Index; |
Francois Gouget | e2a1168 | 2006-10-05 11:02:27 +0200 | [diff] [blame] | 330 | lvitem.iSubItem = 0; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 331 | |
Mike McCormack | 489d613 | 2006-03-17 18:37:41 +0900 | [diff] [blame] | 332 | SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 333 | |
| 334 | if (lvitem.state & LVIS_SELECTED) |
| 335 | break; |
| 336 | } |
| 337 | |
| 338 | if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) && |
| 339 | (PerfDataGetProcessId(Index) != 0)) |
| 340 | { |
| 341 | ProcessPageShowContextMenu(PerfDataGetProcessId(Index)); |
| 342 | } |
| 343 | |
| 344 | break; |
| 345 | |
| 346 | } |
| 347 | } |
| 348 | else if (pnmh->hwndFrom == hProcessPageHeaderCtrl) |
| 349 | { |
| 350 | switch (pnmh->code) |
| 351 | { |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 352 | case HDN_ITEMCLICKW: |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 353 | |
| 354 | /* |
| 355 | * FIXME: Fix the column sorting |
| 356 | * |
| 357 | *ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL); |
| 358 | *bSortAscending = !bSortAscending; |
| 359 | */ |
| 360 | |
| 361 | break; |
| 362 | |
Dylan Smith | fc888d6 | 2009-08-24 00:55:22 -0400 | [diff] [blame] | 363 | case HDN_ITEMCHANGEDW: |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 364 | |
| 365 | UpdateColumnDataHints(); |
| 366 | |
| 367 | break; |
| 368 | |
| 369 | case HDN_ENDDRAG: |
| 370 | |
| 371 | UpdateColumnDataHints(); |
| 372 | |
| 373 | break; |
| 374 | |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | } |
| 379 | |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 380 | void RefreshProcessPage(void) |
| 381 | { |
| 382 | /* Signal the event so that our refresh thread */ |
| 383 | /* will wake up and refresh the process page */ |
| 384 | SetEvent(hProcessPageEvent); |
| 385 | } |
| 386 | |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 387 | static DWORD WINAPI ProcessPageRefreshThread(void *lpParameter) |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 388 | { |
| 389 | ULONG OldProcessorUsage = 0; |
| 390 | ULONG OldProcessCount = 0; |
| 391 | |
Aurimas Fišeras | 88a08f9 | 2009-06-21 16:04:14 +0300 | [diff] [blame] | 392 | WCHAR wszCPU_Usage[255]; |
| 393 | WCHAR wszProcesses[255]; |
| 394 | |
| 395 | LoadStringW(hInst, IDS_STATUS_BAR_CPU_USAGE, wszCPU_Usage, sizeof(wszCPU_Usage)/sizeof(WCHAR)); |
| 396 | LoadStringW(hInst, IDS_STATUS_BAR_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR)); |
| 397 | |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 398 | /* Create the event */ |
Thomas Weidenmueller | 53a0c30 | 2005-09-14 10:29:45 +0000 | [diff] [blame] | 399 | hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, NULL); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 400 | |
| 401 | /* If we couldn't create the event then exit the thread */ |
| 402 | if (!hProcessPageEvent) |
| 403 | return 0; |
| 404 | |
| 405 | while (1) { |
| 406 | DWORD dwWaitVal; |
| 407 | |
| 408 | /* Wait on the event */ |
| 409 | dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE); |
| 410 | |
| 411 | /* If the wait failed then the event object must have been */ |
| 412 | /* closed and the task manager is exiting so exit this thread */ |
| 413 | if (dwWaitVal == WAIT_FAILED) |
| 414 | return 0; |
| 415 | |
| 416 | if (dwWaitVal == WAIT_OBJECT_0) { |
Aurimas Fišeras | 88a08f9 | 2009-06-21 16:04:14 +0300 | [diff] [blame] | 417 | WCHAR text[256]; |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 418 | |
| 419 | /* Reset our event */ |
| 420 | ResetEvent(hProcessPageEvent); |
| 421 | |
| 422 | if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount()) |
| 423 | SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL); |
| 424 | |
| 425 | if (IsWindowVisible(hProcessPage)) |
| 426 | InvalidateRect(hProcessPageListCtrl, NULL, FALSE); |
| 427 | |
| 428 | if (OldProcessorUsage != PerfDataGetProcessorUsage()) { |
| 429 | OldProcessorUsage = PerfDataGetProcessorUsage(); |
Aurimas Fišeras | 88a08f9 | 2009-06-21 16:04:14 +0300 | [diff] [blame] | 430 | wsprintfW(text, wszCPU_Usage, OldProcessorUsage); |
| 431 | SendMessageW(hStatusWnd, SB_SETTEXTW, 1, (LPARAM)text); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 432 | } |
| 433 | if (OldProcessCount != PerfDataGetProcessCount()) { |
| 434 | OldProcessCount = PerfDataGetProcessCount(); |
Aurimas Fišeras | 88a08f9 | 2009-06-21 16:04:14 +0300 | [diff] [blame] | 435 | wsprintfW(text, wszProcesses, OldProcessCount); |
| 436 | SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)text); |
Eric Pouech | d6b348f | 2004-03-23 01:19:54 +0000 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | } |
| 440 | return 0; |
| 441 | } |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 442 | |
| 443 | INT_PTR CALLBACK |
| 444 | ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) |
| 445 | { |
| 446 | RECT rc; |
| 447 | int nXDifference; |
| 448 | int nYDifference; |
| 449 | int cx, cy; |
| 450 | |
| 451 | switch (message) { |
| 452 | case WM_INITDIALOG: |
| 453 | /* |
| 454 | * Save the width and height |
| 455 | */ |
| 456 | GetClientRect(hDlg, &rc); |
| 457 | nProcessPageWidth = rc.right; |
| 458 | nProcessPageHeight = rc.bottom; |
| 459 | |
| 460 | /* Update window position */ |
| 461 | SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); |
| 462 | |
| 463 | /* |
| 464 | * Get handles to the controls |
| 465 | */ |
| 466 | hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST); |
| 467 | hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl); |
| 468 | hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS); |
| 469 | hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES); |
| 470 | |
| 471 | /* |
Aurimas Fišeras | ae62524 | 2009-06-25 22:43:11 +0300 | [diff] [blame] | 472 | * Set the extended window styles for the list control |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 473 | */ |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 474 | SendMessage(hProcessPageListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP); |
| 475 | |
| 476 | AddColumns(); |
| 477 | |
| 478 | /* |
| 479 | * Subclass the process list control so we can intercept WM_ERASEBKGND |
| 480 | */ |
| 481 | OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc); |
| 482 | |
| 483 | /* Start our refresh thread */ |
| 484 | CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL); |
| 485 | |
| 486 | return TRUE; |
| 487 | |
| 488 | case WM_DESTROY: |
| 489 | /* Close the event handle, this will make the */ |
| 490 | /* refresh thread exit when the wait fails */ |
| 491 | CloseHandle(hProcessPageEvent); |
| 492 | |
| 493 | SaveColumnSettings(); |
| 494 | |
| 495 | break; |
| 496 | |
| 497 | case WM_COMMAND: |
| 498 | /* Handle the button clicks */ |
| 499 | switch (LOWORD(wParam)) |
| 500 | { |
| 501 | case IDC_ENDPROCESS: |
| 502 | ProcessPage_OnEndProcess(); |
| 503 | } |
| 504 | break; |
| 505 | |
| 506 | case WM_SIZE: |
| 507 | if (wParam == SIZE_MINIMIZED) |
| 508 | return 0; |
| 509 | |
| 510 | cx = LOWORD(lParam); |
| 511 | cy = HIWORD(lParam); |
| 512 | nXDifference = cx - nProcessPageWidth; |
| 513 | nYDifference = cy - nProcessPageHeight; |
| 514 | nProcessPageWidth = cx; |
| 515 | nProcessPageHeight = cy; |
| 516 | |
| 517 | /* Reposition the application page's controls */ |
| 518 | GetWindowRect(hProcessPageListCtrl, &rc); |
| 519 | cx = (rc.right - rc.left) + nXDifference; |
| 520 | cy = (rc.bottom - rc.top) + nYDifference; |
| 521 | SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); |
| 522 | InvalidateRect(hProcessPageListCtrl, NULL, TRUE); |
| 523 | |
| 524 | GetClientRect(hProcessPageEndProcessButton, &rc); |
| 525 | MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) ); |
| 526 | cx = rc.left + nXDifference; |
| 527 | cy = rc.top + nYDifference; |
| 528 | SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); |
| 529 | InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE); |
| 530 | |
| 531 | GetClientRect(hProcessPageShowAllProcessesButton, &rc); |
| 532 | MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) ); |
| 533 | cx = rc.left; |
| 534 | cy = rc.top + nYDifference; |
| 535 | SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); |
| 536 | InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE); |
| 537 | |
| 538 | break; |
| 539 | |
| 540 | case WM_NOTIFY: |
Gerald Pfeifer | 2aa11ff | 2010-05-01 16:48:48 +0200 | [diff] [blame] | 541 | ProcessPageOnNotify(lParam); |
Francois Gouget | b72013d | 2006-03-21 18:32:40 +0100 | [diff] [blame] | 542 | break; |
| 543 | } |
| 544 | |
| 545 | return 0; |
| 546 | } |