From e6fd75dee043de92df417c86b16f019dc1eac1e8 Mon Sep 17 00:00:00 2001 From: dmex Date: Sat, 3 Sep 2011 16:39:33 +0000 Subject: [PATCH] misc/taskmgr: fixed thread mem leaks (KB104641) git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4616 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- misc/taskmgr/applpage.c | 44 ++++++++------ misc/taskmgr/include/applpage.h | 2 +- misc/taskmgr/include/taskmgr.h | 4 +- misc/taskmgr/perfdata.c | 21 ++++--- misc/taskmgr/perfpage.c | 33 +++++----- misc/taskmgr/procpage.c | 104 ++++++++++++++++++++------------ misc/taskmgr/taskmgr.c | 2 +- 7 files changed, 120 insertions(+), 90 deletions(-) diff --git a/misc/taskmgr/applpage.c b/misc/taskmgr/applpage.c index 7e3b05cfa..9118ccb84 100644 --- a/misc/taskmgr/applpage.c +++ b/misc/taskmgr/applpage.c @@ -23,15 +23,13 @@ #include "taskmgr.h" - - -static HANDLE hApplicationThread = NULL; -static DWORD dwApplicationThread; +static uintptr_t hApplicationThread = NULL; +static UINT dwApplicationThread = NULL; static INT GetSystemColorDepth(VOID) { - DEVMODE pDevMode; - INT ColorDepth; + DEVMODE pDevMode = { 0 }; + INT ColorDepth = 0; pDevMode.dmSize = sizeof(DEVMODE); pDevMode.dmDriverExtra = 0; @@ -41,12 +39,24 @@ static INT GetSystemColorDepth(VOID) switch (pDevMode.dmBitsPerPel) { - case 32: ColorDepth = ILC_COLOR32; break; - case 24: ColorDepth = ILC_COLOR24; break; - case 16: ColorDepth = ILC_COLOR16; break; - case 8: ColorDepth = ILC_COLOR8; break; - case 4: ColorDepth = ILC_COLOR4; break; - default: ColorDepth = ILC_COLOR; break; + case 32: + ColorDepth = ILC_COLOR32; + break; + case 24: + ColorDepth = ILC_COLOR24; + break; + case 16: + ColorDepth = ILC_COLOR16; + break; + case 8: + ColorDepth = ILC_COLOR8; + break; + case 4: + ColorDepth = ILC_COLOR4; + break; + default: + ColorDepth = ILC_COLOR; + break; } return ColorDepth; @@ -110,14 +120,8 @@ INT_PTR CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, UpdateApplicationListControlViewSetting(); /* Start our refresh thread */ - hApplicationThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, &dwApplicationThread); + hApplicationThread = _beginthreadex(NULL, 0, ApplicationPageRefreshThread, NULL, 0, &dwApplicationThread); return TRUE; - - case WM_DESTROY: - /* Close refresh thread */ - EndLocalThread(&hApplicationThread, dwApplicationThread); - break; - case WM_COMMAND: /* Handle the button clicks */ @@ -209,7 +213,7 @@ void UpdateApplicationListControlViewSetting(void) RefreshApplicationPage(); } -DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter) +UINT WINAPI ApplicationPageRefreshThread(void *lpParameter) { MSG msg; INT i; diff --git a/misc/taskmgr/include/applpage.h b/misc/taskmgr/include/applpage.h index 35f5ccdd3..2f8ea2bce 100644 --- a/misc/taskmgr/include/applpage.h +++ b/misc/taskmgr/include/applpage.h @@ -61,7 +61,7 @@ HWND hApplicationPageNewTaskButton; /* Application New Task button * static int nApplicationPageWidth; static int nApplicationPageHeight; static BOOL bSortAscending = TRUE; -DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter); +UINT WINAPI ApplicationPageRefreshThread(void *lpParameter); BOOL noApps; BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam); void AddOrUpdateHwnd(HWND hWnd, WCHAR *szTitle, HICON hIcon, BOOL bHung); diff --git a/misc/taskmgr/include/taskmgr.h b/misc/taskmgr/include/taskmgr.h index 48576dac1..a09919a5f 100644 --- a/misc/taskmgr/include/taskmgr.h +++ b/misc/taskmgr/include/taskmgr.h @@ -30,10 +30,12 @@ #include #include #include +#include #include #include #include #include +#include #include "resource.h" @@ -54,7 +56,6 @@ #include "priority.h" #include "run.h" #include "trayicon.h" -#include #include "ntwin.h" #include "phnt.h" @@ -128,6 +129,5 @@ void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMe void TaskManager_OnViewUpdateSpeed(DWORD); void TaskManager_OnTabWndSelChange(void); LPWSTR GetLastErrorText(LPWSTR lpszBuf, DWORD dwSize); -DWORD EndLocalThread(HANDLE *hThread, DWORD dwThread); INT_PTR CALLBACK NetworkPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/misc/taskmgr/perfdata.c b/misc/taskmgr/perfdata.c index aad7d2bd4..a93f8b017 100644 --- a/misc/taskmgr/perfdata.c +++ b/misc/taskmgr/perfdata.c @@ -257,7 +257,7 @@ void PerfDataRefresh(void) memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION)); HeapFree(GetProcessHeap(), 0, SysHandleInfoData); - for (CurrentKernelTime=0, Idx=0; Idx<(ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) + for (CurrentKernelTime = 0, Idx = 0; Idx < (ULONG)SystemBasicInfo.NumberOfProcessors; Idx++) { CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime); CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].DpcTime); @@ -321,7 +321,7 @@ void PerfDataRefresh(void) /* so that we can establish delta values */ pPDOld = NULL; - for (Idx2=0; Idx2UniqueProcessId) { @@ -330,11 +330,14 @@ void PerfDataRefresh(void) } } - if (pSPI->ImageName.Buffer) { - /* Don't assume a UNICODE_STRING Buffer is zero terminated: */ + if (pSPI->ImageName.Buffer) + { + // Don't assume a UNICODE_STRING Buffer is zero terminated: int len = pSPI->ImageName.Length / 2; - /* Check against max size and allow for terminating zero (already zeroed): */ - if(len >= MAX_PATH)len=MAX_PATH - 1; + // Check against max size and allow for terminating zero (already zeroed): + if(len >= MAX_PATH) + len=MAX_PATH - 1; + wcsncpy(pPerfData[Idx].ImageName, pSPI->ImageName.Buffer, len); } else @@ -389,9 +392,9 @@ void PerfDataRefresh(void) if (hProcess) { - /* don't query the information of the system process. It's possible but - returns Administrators as the owner of the process instead of SYSTEM */ - if (pSPI->UniqueProcessId != (HANDLE)0x4) + //TODO: don't query the information of the system process??? + // It's possible but returns Administrators as the owner of the process instead of SYSTEM + //if (pSPI->UniqueProcessId != (HANDLE)0x4) { if (OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken)) { diff --git a/misc/taskmgr/perfpage.c b/misc/taskmgr/perfpage.c index b9351a1f9..ad1e554d4 100644 --- a/misc/taskmgr/perfpage.c +++ b/misc/taskmgr/perfpage.c @@ -51,15 +51,15 @@ HWND hPerformancePageTotalsHandleCountEdit; /* Total Handles Edit Con HWND hPerformancePageTotalsProcessCountEdit; /* Total Processes Edit Control */ HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */ -static HANDLE hPerformanceThread = NULL; -static DWORD dwPerformanceThread; +static uintptr_t hPerformanceThread = NULL; +static UINT dwPerformanceThread = 0; WNDPROC OldGraphWndProc; -static int nPerformancePageWidth; -static int nPerformancePageHeight; -static int lastX, lastY; -DWORD WINAPI PerformancePageRefreshThread(void *lpParameter); +static int nPerformancePageWidth = 0; +static int nPerformancePageHeight = 0; +static int lastX = 0, lastY = 0; +UINT WINAPI PerformancePageRefreshThread(void *lpParameter); void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos) { @@ -128,8 +128,8 @@ INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, case WM_DESTROY: GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph); GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph); - - EndLocalThread(&hPerformanceThread, dwPerformanceThread); + + //EndLocalThread(&hPerformanceThread, dwPerformanceThread); break; case WM_INITDIALOG: @@ -198,16 +198,14 @@ INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ; /* Start our refresh thread */ - hPerformanceThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, &dwPerformanceThread); + hPerformanceThread = _beginthreadex(NULL, 0, PerformancePageRefreshThread, NULL, 0, &dwPerformanceThread); - /* - * Subclass graph buttons - */ - OldGraphWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); - OldGraphCtrlWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); + // Subclass graph buttons. + OldGraphWndProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); + OldGraphCtrlWndProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); - SetWindowLongPtrW(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); - SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); + SetWindowLongPtr(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); + SetWindowLongPtr(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); return TRUE; case WM_SIZE: @@ -287,6 +285,7 @@ INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, lastY--; } } + AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1); AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2); AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3); @@ -308,7 +307,7 @@ void RefreshPerformancePage(void) PostThreadMessage(dwPerformanceThread, WM_TIMER, 0, 0); } -DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) +UINT WINAPI PerformancePageRefreshThread(void *lpParameter) { ULONG CommitChargeTotal; ULONG CommitChargeLimit; diff --git a/misc/taskmgr/procpage.c b/misc/taskmgr/procpage.c index 3f348a97a..4256d9682 100644 --- a/misc/taskmgr/procpage.c +++ b/misc/taskmgr/procpage.c @@ -38,13 +38,13 @@ HWND hProcessPageHeaderCtrl; /* Process Header Control */ HWND hProcessPageEndProcessButton; /* Process End Process button */ HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */ -static int nProcessPageWidth; -static int nProcessPageHeight; +static int nProcessPageWidth = NULL; +static int nProcessPageHeight = NULL; -static HANDLE hProcessThread = NULL; -static DWORD dwProcessThread; +static uintptr_t hProcessThread = NULL; +static UINT dwProcessThread = NULL; -int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); +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); @@ -52,7 +52,7 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam); void CommaSeparateNumberString(LPWSTR strNumber, int nMaxCount); void ProcessPageShowContextMenu(DWORD dwProcessId); BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCount); -DWORD WINAPI ProcessPageRefreshThread(void *lpParameter); +UINT WINAPI ProcessPageRefreshThread(void *lpParameter); int ProcessRunning(ULONG ProcessId); int ProcGetIndexByProcessId(DWORD dwProcessId) @@ -140,19 +140,14 @@ INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPAR AddColumns(); - /* - * Subclass the process list control so we can intercept WM_ERASEBKGND - */ - OldProcessListWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc); + // Subclass the process list control so we can intercept WM_ERASEBKGND + OldProcessListWndProc = (WNDPROC)(LONG_PTR)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc); - /* Start our refresh thread */ - hProcessThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread); + // Start our refresh thread + hProcessThread = _beginthreadex(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread); break; case WM_DESTROY: SaveColumnSettings(); - /* Close the event handle, this will make the */ - /* refresh thread exit when the wait fails */ - EndLocalThread(&hProcessThread, dwProcessThread); break; case WM_COMMAND: @@ -285,13 +280,13 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam) void CommaSeparateNumberString(LPWSTR strNumber, int nMaxCount) { - WCHAR temp[260]; - UINT i, j, k; + WCHAR temp[260]; + UINT i = 0, j = 0, k = 0; - for (i=0,j=0; i<(wcslen(strNumber) % 3); i++, j++) + for (i = 0, j = 0; i < (wcslen(strNumber) % 3); i++, j++) temp[j] = strNumber[i]; - for (k=0; i 0)) temp[j++] = L','; @@ -387,7 +382,7 @@ void RefreshProcessPage(void) PostThreadMessage(dwProcessThread, WM_TIMER, 0, 0); } -DWORD WINAPI ProcessPageRefreshThread(void *lpParameter) +UINT WINAPI ProcessPageRefreshThread(void *lpParameter) { ULONG OldProcessorUsage = 0, OldProcessCount = 0; WCHAR szCpuUsage[256], szProcesses[256]; @@ -499,21 +494,24 @@ BOOL ProcessRunning(ULONG processId) void AddProcess(ULONG Index) { - LPPROCESS_PAGE_LIST_ITEM pData; - int i; - LV_ITEM item; - BOOL bAlreadyInList = FALSE; - ULONG pid; + LPPROCESS_PAGE_LIST_ITEM pData = { 0 }; + int i = 0; + LV_ITEM item; + BOOL bAlreadyInList = FALSE; + ULONG pid = 0; pid = PerfDataGetProcessId(Index); /* Check to see if it's already in our list */ - for (i=0; iProcessId == pid) { @@ -528,29 +526,36 @@ void AddProcess(ULONG Index) /* 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); + + ListView_InsertItem(hProcessPageListCtrl, &item); } } BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCount) { - IO_COUNTERS iocounters; - LARGE_INTEGER time; + IO_COUNTERS iocounters; + LARGE_INTEGER time; if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) PerfDataGetImageName(Index, lpText, nMaxCount); + if (ColumnDataHints[ColumnIndex] == COLUMN_PID) wsprintfW(lpText, L"%d", PerfDataGetProcessId(Index)); + if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) PerfDataGetUserName(Index, lpText, nMaxCount); + if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) wsprintfW(lpText, L"%d", PerfDataGetSessionId(Index)); + if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) wsprintfW(lpText, L"%02d", PerfDataGetCPUUsage(Index)); + if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) { DWORD dwHours; @@ -559,76 +564,90 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun time = PerfDataGetCPUTime(Index); gethmsfromlargeint(time, &dwHours, &dwMinutes, &dwSeconds); - wsprintfW(lpText, L"%d:%02d:%02d", dwHours, dwMinutes, dwSeconds); + wsprintf(lpText, L"%d:%02d:%02d", dwHours, dwMinutes, dwSeconds); } + if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) { - wsprintfW(lpText, L"%d", PerfDataGetWorkingSetSizeBytes(Index) / 1024); + wsprintf(lpText, L"%d", PerfDataGetWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) { - wsprintfW(lpText, L"%d", PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); + wsprintf(lpText, L"%d", PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) { - wsprintfW(lpText, L"%d", PerfDataGetWorkingSetSizeDelta(Index) / 1024); + wsprintf(lpText, L"%d", PerfDataGetWorkingSetSizeDelta(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) { - wsprintfW(lpText, L"%d", PerfDataGetPageFaultCount(Index)); + wsprintf(lpText, L"%d", PerfDataGetPageFaultCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) { - wsprintfW(lpText, L"%d", PerfDataGetPageFaultCountDelta(Index)); + wsprintf(lpText, L"%d", PerfDataGetPageFaultCountDelta(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) { - wsprintfW(lpText, L"%d", PerfDataGetVirtualMemorySizeBytes(Index) / 1024); + wsprintf(lpText, L"%d", PerfDataGetVirtualMemorySizeBytes(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) { wsprintfW(lpText, L"%d", PerfDataGetPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) { - wsprintfW(lpText, L"%d", PerfDataGetNonPagedPoolUsagePages(Index) / 1024); + wsprintf(lpText, L"%d", PerfDataGetNonPagedPoolUsagePages(Index) / 1024); CommaSeparateNumberString(lpText, nMaxCount); wcscat(lpText, L" K"); } + if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) - wsprintfW(lpText, L"%d", PerfDataGetBasePriority(Index)); + wsprintf(lpText, L"%d", PerfDataGetBasePriority(Index)); + if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) { - wsprintfW(lpText, L"%d", PerfDataGetHandleCount(Index)); + wsprintf(lpText, L"%d", PerfDataGetHandleCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) { wsprintfW(lpText, L"%d", PerfDataGetThreadCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) { wsprintfW(lpText, L"%d", PerfDataGetUSERObjectCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) { wsprintfW(lpText, L"%d", PerfDataGetGDIObjectCount(Index)); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) { PerfDataGetIOCounters(Index, &iocounters); @@ -636,6 +655,7 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun _ui64tow(iocounters.ReadOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) { PerfDataGetIOCounters(Index, &iocounters); @@ -643,6 +663,7 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun _ui64tow(iocounters.WriteOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) { PerfDataGetIOCounters(Index, &iocounters); @@ -650,6 +671,7 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun _ui64tow(iocounters.OtherOperationCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) { PerfDataGetIOCounters(Index, &iocounters); @@ -657,6 +679,7 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun _ui64tow(iocounters.ReadTransferCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) { PerfDataGetIOCounters(Index, &iocounters); @@ -664,6 +687,7 @@ BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, int nMaxCoun _ui64tow(iocounters.WriteTransferCount, lpText, 10); CommaSeparateNumberString(lpText, nMaxCount); } + if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) { PerfDataGetIOCounters(Index, &iocounters); diff --git a/misc/taskmgr/taskmgr.c b/misc/taskmgr/taskmgr.c index 8e0148a14..9af9d14e3 100644 --- a/misc/taskmgr/taskmgr.c +++ b/misc/taskmgr/taskmgr.c @@ -1040,7 +1040,7 @@ LPWSTR GetLastErrorText(LPWSTR lpszBuf, DWORD dwSize) } else { - lpszTemp[lstrlenW(lpszTemp)-2] = L'\0'; /*remove cr and newline character */ + lpszTemp[wcslen(lpszTemp)-2] = L'\0'; /*remove cr and newline character */ wsprintf(lpszBuf, L"%s (0x%x)", lpszTemp, (int)GetLastError()); }