mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:52:59 +00:00
fixed most of the memory leaks
svn path=/trunk/; revision=25363
This commit is contained in:
parent
091af4eeea
commit
013562e393
13 changed files with 133 additions and 107 deletions
|
@ -66,6 +66,7 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
LV_COLUMN column;
|
LV_COLUMN column;
|
||||||
TCHAR szTemp[256];
|
TCHAR szTemp[256];
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
|
HANDLE hRefreshThread = NULL;
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
@ -105,7 +106,7 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
UpdateApplicationListControlViewSetting();
|
UpdateApplicationListControlViewSetting();
|
||||||
|
|
||||||
/* Start our refresh thread */
|
/* Start our refresh thread */
|
||||||
CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, NULL);
|
hRefreshThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
/* Close the event handle, this will make the */
|
/* Close the event handle, this will make the */
|
||||||
/* refresh thread exit when the wait fails */
|
/* refresh thread exit when the wait fails */
|
||||||
CloseHandle(hApplicationPageEvent);
|
CloseHandle(hApplicationPageEvent);
|
||||||
|
CloseHandle(hRefreshThread);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
@ -283,8 +285,8 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
|
||||||
|
|
||||||
if (!hIcon)
|
if (!hIcon)
|
||||||
{
|
{
|
||||||
hIcon = (HICON)GetClassLong(hWnd, bLargeIcon ? GCL_HICON : GCL_HICONSM);
|
hIcon = (HICON)(LONG_PTR)GetClassLongPtr(hWnd, bLargeIcon ? GCL_HICON : GCL_HICONSM);
|
||||||
if (!hIcon) hIcon = (HICON)GetClassLong(hWnd, bLargeIcon ? GCL_HICONSM : GCL_HICON);
|
if (!hIcon) hIcon = (HICON)(LONG_PTR)GetClassLongPtr(hWnd, bLargeIcon ? GCL_HICONSM : GCL_HICON);
|
||||||
if (!hIcon) SendMessageTimeout(hWnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (PDWORD_PTR)xhIcon);
|
if (!hIcon) SendMessageTimeout(hWnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (PDWORD_PTR)xhIcon);
|
||||||
if (!hIcon) SendMessageTimeout(hWnd, WM_GETICON, bLargeIcon ? ICON_SMALL /*0*/ : ICON_BIG /*1*/, 0, 0, 1000, (PDWORD_PTR)xhIcon);
|
if (!hIcon) SendMessageTimeout(hWnd, WM_GETICON, bLargeIcon ? ICON_SMALL /*0*/ : ICON_BIG /*1*/, 0, 0, 1000, (PDWORD_PTR)xhIcon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ INT_PTR CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam,
|
||||||
|
|
||||||
void AddColumns(void)
|
void AddColumns(void)
|
||||||
{
|
{
|
||||||
int size;
|
LRESULT size;
|
||||||
|
|
||||||
if (TaskManagerSettings.Column_ImageName) {
|
if (TaskManagerSettings.Column_ImageName) {
|
||||||
LoadString(hInst, IDS_TAB_IMAGENAME, szTemp, 256);
|
LoadString(hInst, IDS_TAB_IMAGENAME, szTemp, 256);
|
||||||
|
@ -188,7 +188,7 @@ void SaveColumnSettings(void)
|
||||||
HDITEM hditem;
|
HDITEM hditem;
|
||||||
int i;
|
int i;
|
||||||
TCHAR text[260];
|
TCHAR text[260];
|
||||||
int size;
|
LRESULT size;
|
||||||
|
|
||||||
/* Reset column data */
|
/* Reset column data */
|
||||||
for (i=0; i<25; i++)
|
for (i=0; i<25; i++)
|
||||||
|
@ -551,31 +551,31 @@ ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK)
|
||||||
{
|
{
|
||||||
TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_ImageName = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_PID = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_UserName = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_SessionID = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_CPUUsage = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_CPUTime = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_MemoryUsage = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_PeakMemoryUsage = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_MemoryUsageDelta = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_PageFaults = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_PageFaultsDelta = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_VirtualMemorySize = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_PagedPool = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_NonPagedPool = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_BasePriority = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_HandleCount = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_ThreadCount = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_USERObjects = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_GDIObjects = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOReads = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOWrites = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOOther = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOReadBytes = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOWriteBytes = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
|
||||||
TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
|
TaskManagerSettings.Column_IOOtherBytes = (BOOL) SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
|
||||||
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
int nlastBarsUsed = 0;
|
int nlastBarsUsed = 0;
|
||||||
|
|
||||||
LONG OldGraphWndProc;
|
WNDPROC OldGraphWndProc;
|
||||||
|
|
||||||
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
|
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
|
||||||
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
|
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
|
||||||
|
@ -162,7 +162,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
||||||
* Get the CPU usage
|
* Get the CPU usage
|
||||||
*/
|
*/
|
||||||
CpuUsage = PerfDataGetProcessorUsage();
|
CpuUsage = PerfDataGetProcessorUsage();
|
||||||
if (CpuUsage < 0) CpuUsage = 0;
|
if (CpuUsage <= 0) CpuUsage = 0;
|
||||||
if (CpuUsage > 100) CpuUsage = 100;
|
if (CpuUsage > 100) CpuUsage = 100;
|
||||||
|
|
||||||
_stprintf(Text, _T("%d%%"), (int)CpuUsage);
|
_stprintf(Text, _T("%d%%"), (int)CpuUsage);
|
||||||
|
@ -191,8 +191,8 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
||||||
if (TaskManagerSettings.ShowKernelTimes)
|
if (TaskManagerSettings.ShowKernelTimes)
|
||||||
{
|
{
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
if (CpuKernelUsage <= 0) CpuKernelUsage = 0;
|
||||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
if (CpuKernelUsage >= 100) CpuKernelUsage = 100;
|
||||||
nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
|
nBarsUsedKernel = (nBars * CpuKernelUsage) / 100;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
#define DARK_GREEN RGB(0, 130, 0)
|
#define DARK_GREEN RGB(0, 130, 0)
|
||||||
#define RED RGB(255, 0, 0)
|
#define RED RGB(255, 0, 0)
|
||||||
|
|
||||||
extern LONG OldGraphWndProc;
|
extern WNDPROC OldGraphWndProc;
|
||||||
|
|
||||||
INT_PTR CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <precomp.h>
|
#include <precomp.h>
|
||||||
|
|
||||||
LONG OldGraphCtrlWndProc;
|
WNDPROC OldGraphCtrlWndProc;
|
||||||
|
|
||||||
static void GraphCtrl_Init(TGraphCtrl* this)
|
static void GraphCtrl_Init(TGraphCtrl* this)
|
||||||
{
|
{
|
||||||
|
@ -101,8 +101,14 @@ static void GraphCtrl_Init(TGraphCtrl* this)
|
||||||
|
|
||||||
void GraphCtrl_Dispose(TGraphCtrl* this)
|
void GraphCtrl_Dispose(TGraphCtrl* this)
|
||||||
{
|
{
|
||||||
|
int plot;
|
||||||
|
|
||||||
|
for (plot = 0; plot < MAX_PLOTS; plot++)
|
||||||
|
DeleteObject(this->m_penPlot[plot]);
|
||||||
|
|
||||||
/* just to be picky restore the bitmaps for the two memory dc's */
|
/* just to be picky restore the bitmaps for the two memory dc's */
|
||||||
/* (these dc's are being destroyed so there shouldn't be any leaks) */
|
/* (these dc's are being destroyed so there shouldn't be any leaks) */
|
||||||
|
|
||||||
if (this->m_bitmapOldGrid != NULL) SelectObject(this->m_dcGrid, this->m_bitmapOldGrid);
|
if (this->m_bitmapOldGrid != NULL) SelectObject(this->m_dcGrid, this->m_bitmapOldGrid);
|
||||||
if (this->m_bitmapOldPlot != NULL) SelectObject(this->m_dcPlot, this->m_bitmapOldPlot);
|
if (this->m_bitmapOldPlot != NULL) SelectObject(this->m_dcPlot, this->m_bitmapOldPlot);
|
||||||
if (this->m_bitmapGrid != NULL) DeleteObject(this->m_bitmapGrid);
|
if (this->m_bitmapGrid != NULL) DeleteObject(this->m_bitmapGrid);
|
||||||
|
@ -209,6 +215,7 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this, BOOL bResize)
|
||||||
// so create a new bitmap of the appropriate size
|
// so create a new bitmap of the appropriate size
|
||||||
if(this->m_bitmapGrid != NULL)
|
if(this->m_bitmapGrid != NULL)
|
||||||
{
|
{
|
||||||
|
this->m_bitmapGrid = (HBITMAP)SelectObject(this->m_dcGrid, this->m_bitmapOldGrid);
|
||||||
DeleteObject(this->m_bitmapGrid);
|
DeleteObject(this->m_bitmapGrid);
|
||||||
this->m_bitmapGrid = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
|
this->m_bitmapGrid = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
|
||||||
SelectObject(this->m_dcGrid, this->m_bitmapGrid);
|
SelectObject(this->m_dcGrid, this->m_bitmapGrid);
|
||||||
|
@ -341,6 +348,7 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this, BOOL bResize)
|
||||||
// so create a new bitmap of the appropriate size
|
// so create a new bitmap of the appropriate size
|
||||||
if(this->m_bitmapPlot != NULL)
|
if(this->m_bitmapPlot != NULL)
|
||||||
{
|
{
|
||||||
|
this->m_bitmapPlot = (HBITMAP)SelectObject(this->m_dcPlot, this->m_bitmapOldPlot);
|
||||||
DeleteObject(this->m_bitmapPlot);
|
DeleteObject(this->m_bitmapPlot);
|
||||||
this->m_bitmapPlot = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
|
this->m_bitmapPlot = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
|
||||||
SelectObject(this->m_dcPlot, this->m_bitmapPlot);
|
SelectObject(this->m_dcPlot, this->m_bitmapPlot);
|
||||||
|
|
|
@ -85,7 +85,7 @@ typedef struct
|
||||||
RECT m_rectPlot;
|
RECT m_rectPlot;
|
||||||
} TGraphCtrl;
|
} TGraphCtrl;
|
||||||
|
|
||||||
extern LONG OldGraphCtrlWndProc;
|
extern WNDPROC OldGraphCtrlWndProc;
|
||||||
double GraphCtrl_AppendPoint(TGraphCtrl* this,
|
double GraphCtrl_AppendPoint(TGraphCtrl* this,
|
||||||
double dNewPoint0, double dNewPoint1,
|
double dNewPoint0, double dNewPoint1,
|
||||||
double dNewPoint2, double dNewPoint3);
|
double dNewPoint2, double dNewPoint3);
|
||||||
|
|
|
@ -63,6 +63,10 @@ BOOL PerfDataInitialize(void)
|
||||||
|
|
||||||
void PerfDataUninitialize(void)
|
void PerfDataUninitialize(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (pPerfData != NULL)
|
||||||
|
HeapFree(GetProcessHeap(), 0, pPerfData);
|
||||||
|
|
||||||
DeleteCriticalSection(&PerfDataCriticalSection);
|
DeleteCriticalSection(&PerfDataCriticalSection);
|
||||||
|
|
||||||
if (SystemUserSid != NULL)
|
if (SystemUserSid != NULL)
|
||||||
|
@ -121,8 +125,13 @@ void PerfDataRefresh(void)
|
||||||
/* Get processor time information */
|
/* Get processor time information */
|
||||||
SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors);
|
SysProcessorTimeInfo = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)HeapAlloc(GetProcessHeap(), 0, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors);
|
||||||
status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors, &ulSize);
|
status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * SystemBasicInfo.NumberOfProcessors, &ulSize);
|
||||||
|
|
||||||
if (status != NO_ERROR)
|
if (status != NO_ERROR)
|
||||||
|
{
|
||||||
|
if (SysProcessorTimeInfo != NULL)
|
||||||
|
HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get handle information
|
/* Get handle information
|
||||||
* We don't know how much data there is so just keep
|
* We don't know how much data there is so just keep
|
||||||
|
|
|
@ -110,7 +110,9 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
RECT rc;
|
RECT rc;
|
||||||
int nXDifference;
|
int nXDifference;
|
||||||
int nYDifference;
|
int nYDifference;
|
||||||
|
#ifdef RUN_PERF_PAGE
|
||||||
|
HANDLE hRefreshThread = NULL;
|
||||||
|
#endif
|
||||||
/* HDC hdc; */
|
/* HDC hdc; */
|
||||||
/* PAINTSTRUCT ps; */
|
/* PAINTSTRUCT ps; */
|
||||||
|
|
||||||
|
@ -118,6 +120,9 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph);
|
GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph);
|
||||||
GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph);
|
GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph);
|
||||||
|
#ifdef RUN_PERF_PAGE
|
||||||
|
CloseHandle(hRefreshThread);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
@ -187,16 +192,16 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
|
GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
|
||||||
/* Start our refresh thread */
|
/* Start our refresh thread */
|
||||||
#ifdef RUN_PERF_PAGE
|
#ifdef RUN_PERF_PAGE
|
||||||
CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
|
hRefreshThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subclass graph buttons
|
* Subclass graph buttons
|
||||||
*/
|
*/
|
||||||
OldGraphWndProc = SetWindowLongPtr(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (DWORD_PTR)Graph_WndProc);
|
OldGraphWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtr(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG_PTR)Graph_WndProc);
|
||||||
SetWindowLongPtr(hPerformancePageMemUsageGraph, GWL_WNDPROC, (DWORD_PTR)Graph_WndProc);
|
SetWindowLongPtr(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG_PTR)Graph_WndProc);
|
||||||
OldGraphCtrlWndProc = SetWindowLongPtr(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (DWORD_PTR)GraphCtrl_WndProc);
|
OldGraphCtrlWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtr(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
|
||||||
SetWindowLongPtr(hPerformancePageCpuUsageHistoryGraph, GWL_WNDPROC, (DWORD_PTR)GraphCtrl_WndProc);
|
SetWindowLongPtr(hPerformancePageCpuUsageHistoryGraph, GWL_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
@ -420,13 +425,13 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
|
||||||
* Get the CPU usage
|
* Get the CPU usage
|
||||||
*/
|
*/
|
||||||
CpuUsage = PerfDataGetProcessorUsage();
|
CpuUsage = PerfDataGetProcessorUsage();
|
||||||
if (CpuUsage < 0 ) CpuUsage = 0;
|
if (CpuUsage <= 0 ) CpuUsage = 0;
|
||||||
if (CpuUsage > 100) CpuUsage = 100;
|
if (CpuUsage > 100) CpuUsage = 100;
|
||||||
|
|
||||||
if (TaskManagerSettings.ShowKernelTimes)
|
if (TaskManagerSettings.ShowKernelTimes)
|
||||||
{
|
{
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
if (CpuKernelUsage <= 0) CpuKernelUsage = 0;
|
||||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -62,7 +62,7 @@ ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
/*
|
/*
|
||||||
* Get the background brush
|
* Get the background brush
|
||||||
*/
|
*/
|
||||||
hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND);
|
hbrBackground = (HBRUSH)(LONG_PTR) GetClassLongPtr(hWnd, GCL_HBRBACKGROUND);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the clip rect by getting the RECT
|
* Calculate the clip rect by getting the RECT
|
||||||
|
|
|
@ -46,6 +46,7 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
int nXDifference;
|
int nXDifference;
|
||||||
int nYDifference;
|
int nYDifference;
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
|
HANDLE hRefreshThread = NULL;
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
@ -79,10 +80,10 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
/*
|
/*
|
||||||
* Subclass the process list control so we can intercept WM_ERASEBKGND
|
* Subclass the process list control so we can intercept WM_ERASEBKGND
|
||||||
*/
|
*/
|
||||||
OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWL_WNDPROC, (DWORD_PTR)ProcessListWndProc);
|
OldProcessListWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtr(hProcessPageListCtrl, GWL_WNDPROC, (LONG_PTR)ProcessListWndProc);
|
||||||
|
|
||||||
/* Start our refresh thread */
|
/* Start our refresh thread */
|
||||||
CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
|
hRefreshThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
/* Close the event handle, this will make the */
|
/* Close the event handle, this will make the */
|
||||||
/* refresh thread exit when the wait fails */
|
/* refresh thread exit when the wait fails */
|
||||||
CloseHandle(hProcessPageEvent);
|
CloseHandle(hProcessPageEvent);
|
||||||
|
CloseHandle(hRefreshThread);
|
||||||
|
|
||||||
SaveColumnSettings();
|
SaveColumnSettings();
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,7 @@ BOOL OnCreate(HWND hWnd)
|
||||||
nParts[0] = 100;
|
nParts[0] = 100;
|
||||||
nParts[1] = 210;
|
nParts[1] = 210;
|
||||||
nParts[2] = 400;
|
nParts[2] = 400;
|
||||||
SendMessage(hStatusWnd, SB_SETPARTS, 3, (long)nParts);
|
SendMessage(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
||||||
|
|
||||||
/* Create tab pages */
|
/* Create tab pages */
|
||||||
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
|
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
|
||||||
|
@ -596,7 +596,7 @@ BOOL OnCreate(HWND hWnd)
|
||||||
* This function handles all the moving events for the application
|
* This function handles all the moving events for the application
|
||||||
* It moves every child window that needs moving
|
* It moves every child window that needs moving
|
||||||
*/
|
*/
|
||||||
void OnMove( UINT nType, int cx, int cy )
|
void OnMove( WPARAM nType, int cx, int cy )
|
||||||
{
|
{
|
||||||
#ifdef __GNUC__TEST__
|
#ifdef __GNUC__TEST__
|
||||||
MoveWindow(hApplicationPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
MoveWindow(hApplicationPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
||||||
|
@ -609,7 +609,7 @@ void OnMove( UINT nType, int cx, int cy )
|
||||||
* This function handles all the sizing events for the application
|
* This function handles all the sizing events for the application
|
||||||
* It re-sizes every window, and child window that needs re-sizing
|
* It re-sizes every window, and child window that needs re-sizing
|
||||||
*/
|
*/
|
||||||
void OnSize( UINT nType, int cx, int cy )
|
void OnSize( WPARAM nType, int cx, int cy )
|
||||||
{
|
{
|
||||||
int nParts[3];
|
int nParts[3];
|
||||||
int nXDifference;
|
int nXDifference;
|
||||||
|
@ -638,7 +638,7 @@ void OnSize( UINT nType, int cx, int cy )
|
||||||
nParts[0] = bInMenuLoop ? -1 : 100;
|
nParts[0] = bInMenuLoop ? -1 : 100;
|
||||||
nParts[1] = 210;
|
nParts[1] = 210;
|
||||||
nParts[2] = cx;
|
nParts[2] = cx;
|
||||||
SendMessage(hStatusWnd, SB_SETPARTS, bInMenuLoop ? 1 : 3, (long)nParts);
|
SendMessage(hStatusWnd, SB_SETPARTS, bInMenuLoop ? 1 : 3, (LPARAM) (LPINT) nParts);
|
||||||
|
|
||||||
/* Resize the tab control */
|
/* Resize the tab control */
|
||||||
GetWindowRect(hTabWnd, &rc);
|
GetWindowRect(hTabWnd, &rc);
|
||||||
|
@ -814,7 +814,7 @@ void TaskManager_OnEnterMenuLoop(HWND hWnd)
|
||||||
|
|
||||||
/* Update the status bar pane sizes */
|
/* Update the status bar pane sizes */
|
||||||
nParts = -1;
|
nParts = -1;
|
||||||
SendMessage(hStatusWnd, SB_SETPARTS, 1, (long)&nParts);
|
SendMessage(hStatusWnd, SB_SETPARTS, 1, (LPARAM) (LPINT)&nParts);
|
||||||
bInMenuLoop = TRUE;
|
bInMenuLoop = TRUE;
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
|
SendMessage(hStatusWnd, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,7 @@ void TaskManager_OnExitMenuLoop(HWND hWnd)
|
||||||
nParts[0] = 100;
|
nParts[0] = 100;
|
||||||
nParts[1] = 210;
|
nParts[1] = 210;
|
||||||
nParts[2] = rc.right;
|
nParts[2] = rc.right;
|
||||||
SendMessage(hStatusWnd, SB_SETPARTS, 3, (long)nParts);
|
SendMessage(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)_T(""));
|
SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)_T(""));
|
||||||
wsprintf(text, szCpuUsage, PerfDataGetProcessorUsage());
|
wsprintf(text, szCpuUsage, PerfDataGetProcessorUsage());
|
||||||
SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
|
SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
|
||||||
|
@ -969,7 +969,7 @@ void TaskManager_OnTabWndSelChange(void)
|
||||||
hSubMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_WINDOWSMENU));
|
hSubMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_WINDOWSMENU));
|
||||||
|
|
||||||
LoadString(hInst, IDS_MENU_WINDOWS, szTemp, 256);
|
LoadString(hInst, IDS_MENU_WINDOWS, szTemp, 256);
|
||||||
InsertMenu(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT)hSubMenu, szTemp);
|
InsertMenu(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT_PTR) hSubMenu, szTemp);
|
||||||
|
|
||||||
DrawMenuBar(hMainWnd);
|
DrawMenuBar(hMainWnd);
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1028,7 @@ void TaskManager_OnTabWndSelChange(void)
|
||||||
AppendMenu(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, szTemp);
|
AppendMenu(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, szTemp);
|
||||||
|
|
||||||
LoadString(hInst, IDS_MENU_CPUHISTORY, szTemp, 256);
|
LoadString(hInst, IDS_MENU_CPUHISTORY, szTemp, 256);
|
||||||
AppendMenu(hViewMenu, MF_STRING|MF_POPUP, (UINT)hSubMenu, szTemp);
|
AppendMenu(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR) hSubMenu, szTemp);
|
||||||
|
|
||||||
LoadString(hInst, IDS_MENU_SHOWKERNELTIMES, szTemp, 256);
|
LoadString(hInst, IDS_MENU_SHOWKERNELTIMES, szTemp, 256);
|
||||||
AppendMenu(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, szTemp);
|
AppendMenu(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, szTemp);
|
||||||
|
|
|
@ -127,8 +127,8 @@ extern TASKMANAGER_SETTINGS TaskManagerSettings;
|
||||||
/* Foward declarations of functions included in this code module: */
|
/* Foward declarations of functions included in this code module: */
|
||||||
INT_PTR CALLBACK TaskManagerWndProc(HWND, UINT, WPARAM, LPARAM);
|
INT_PTR CALLBACK TaskManagerWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
BOOL OnCreate(HWND hWnd);
|
BOOL OnCreate(HWND hWnd);
|
||||||
void OnSize(UINT nType, int cx, int cy);
|
void OnSize(WPARAM nType, int cx, int cy);
|
||||||
void OnMove(UINT nType, int cx, int cy);
|
void OnMove(WPARAM nType, int cx, int cy);
|
||||||
void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr);
|
void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr);
|
||||||
void FillSolidRect2(HDC hDC, int x, int y, int cx, int cy, COLORREF clr);
|
void FillSolidRect2(HDC hDC, int x, int y, int cx, int cy, COLORREF clr);
|
||||||
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight);
|
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight);
|
||||||
|
|
|
@ -96,7 +96,7 @@ HICON TrayIcon_GetProcessorUsageIcon(void)
|
||||||
* Now that we are done drawing put the
|
* Now that we are done drawing put the
|
||||||
* old bitmap back.
|
* old bitmap back.
|
||||||
*/
|
*/
|
||||||
SelectObject(hDC, hOldBitmap);
|
hBitmap = SelectObject(hDC, hOldBitmap);
|
||||||
hOldBitmap = NULL;
|
hOldBitmap = NULL;
|
||||||
|
|
||||||
iconInfo.fIcon = TRUE;
|
iconInfo.fIcon = TRUE;
|
||||||
|
@ -114,7 +114,7 @@ done:
|
||||||
if (hScreenDC)
|
if (hScreenDC)
|
||||||
ReleaseDC(NULL, hScreenDC);
|
ReleaseDC(NULL, hScreenDC);
|
||||||
if (hOldBitmap)
|
if (hOldBitmap)
|
||||||
SelectObject(hDC, hOldBitmap);
|
hBitmap = SelectObject(hDC, hOldBitmap);
|
||||||
if (hDC)
|
if (hDC)
|
||||||
DeleteDC(hDC);
|
DeleteDC(hDC);
|
||||||
if (hBitmapBrush)
|
if (hBitmapBrush)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue