Skip to content
Snippets Groups Projects
Commit d6b348f0 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard
Browse files

Ported the ReactOS taskmgr written by Brian Palmer.

parent b613ee7a
No related branches found
No related tags found
No related merge requests found
Showing
with 5777 additions and 1 deletion
......@@ -20035,7 +20035,7 @@ MAKE_LIB_RULES=libs/Makelib.rules
MAKE_PROG_RULES=programs/Makeprog.rules
 
 
ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/amstream/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/secur32/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/version/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/amstream/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3dx8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/secur32/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/version/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile"
 
 
cat >confcache <<\_ACEOF
......@@ -20761,6 +20761,7 @@ do
"programs/rpcss/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/rpcss/Makefile" ;;
"programs/rundll32/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/rundll32/Makefile" ;;
"programs/start/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/start/Makefile" ;;
"programs/taskmgr/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/taskmgr/Makefile" ;;
"programs/uninstaller/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/uninstaller/Makefile" ;;
"programs/view/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/view/Makefile" ;;
"programs/wcmd/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/wcmd/Makefile" ;;
......
......@@ -1679,6 +1679,7 @@ programs/regsvr32/Makefile
programs/rpcss/Makefile
programs/rundll32/Makefile
programs/start/Makefile
programs/taskmgr/Makefile
programs/uninstaller/Makefile
programs/view/Makefile
programs/wcmd/Makefile
......
......@@ -18,6 +18,7 @@ SUBDIRS = \
rpcss \
rundll32 \
start \
taskmgr \
uninstaller \
view \
wcmd \
......@@ -48,6 +49,7 @@ INSTALLSUBDIRS = \
rpcss \
rundll32 \
start \
taskmgr \
uninstaller \
wcmd \
wineboot \
......@@ -98,6 +100,7 @@ SYMLINKS = \
rpcss.exe \
rundll32.exe \
start.exe \
taskmgr.exe \
uninstaller.exe \
view.exe \
wcmd.exe \
......@@ -200,6 +203,9 @@ rundll32.exe$(DLLEXT): rundll32/rundll32.exe$(DLLEXT)
start.exe$(DLLEXT): start/start.exe$(DLLEXT)
$(RM) $@ && $(LN_S) start/start.exe$(DLLEXT) $@
taskmgr.exe$(DLLEXT): taskmgr/taskmgr.exe$(DLLEXT)
$(RM) $@ && $(LN_S) taskmgr/taskmgr.exe$(DLLEXT) $@
uninstaller.exe$(DLLEXT): uninstaller/uninstaller.exe$(DLLEXT)
$(RM) $@ && $(LN_S) uninstaller/uninstaller.exe$(DLLEXT) $@
......@@ -262,6 +268,7 @@ regsvr32/regsvr32.exe$(DLLEXT): regsvr32
rpcss/rpcss.exe$(DLLEXT): rpcss
rundll32/rundll32.exe$(DLLEXT): rundll32
start/start.exe$(DLLEXT): start
taskmgr/taskmgr.exe$(DLLEXT): taskmgr
uninstaller/uninstaller.exe$(DLLEXT): uninstaller
view/view.exe$(DLLEXT): view
wcmd/wcmd.exe$(DLLEXT): wcmd
......
Makefile
font.bmp
taskmgr.exe.dbg.c
taskmgr.ico
taskmgr.res
trayicon.bmp
traymask.bmp
window.ico
windowsm.ico
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = taskmgr.exe
APPMODE = -mwindows
IMPORTS = psapi shell32 comctl32 msvcrt user32 gdi32 advapi32 kernel32
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
EXTRADEFS = -DNO_LIBWINE_PORT
C_SRCS = \
about.c \
affinity.c \
applpage.c \
column.c \
dbgchnl.c \
debug.c \
endproc.c \
graph.c \
graphctl.c \
optnmenu.c \
perfdata.c \
perfpage.c \
priority.c \
proclist.c \
procpage.c \
run.c \
taskmgr.c \
trayicon.c
RC_SRCS = taskmgr.rc
RC_BINSRC = taskmgr.rc
RC_BINARIES = \
font.bmp \
taskmgr.ico \
trayicon.bmp \
traymask.bmp \
window.ico \
windowsm.ico
@MAKE_PROG_RULES@
### Dependencies:
/*
* ReactOS Task Manager
*
* about.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include "taskmgr.h"
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void OnAbout(void)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)AboutDialogWndProc);
}
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hLicenseEditWnd;
TCHAR strLicense[0x1000];
switch (message)
{
case WM_INITDIALOG:
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
SetWindowText(hLicenseEditWnd, strLicense);
return TRUE;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return 0;
}
/*
* ReactOS Task Manager
*
* affinity.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <winnt.h>
#include <stdio.h>
#include "taskmgr.h"
#include "perfdata.h"
HANDLE hProcessAffinityHandle;
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void ProcessPage_OnSetAffinity(void)
{
LV_ITEM lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
memset(&lvitem, 0, sizeof(LV_ITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcessAffinityHandle) {
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
return;
}
DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, (DLGPROC)AffinityDialogWndProc);
if (hProcessAffinityHandle) {
CloseHandle(hProcessAffinityHandle);
hProcessAffinityHandle = NULL;
}
}
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
DWORD dwProcessAffinityMask = 0;
DWORD dwSystemAffinityMask = 0;
TCHAR strErrorText[260];
switch (message) {
case WM_INITDIALOG:
/*
* Get the current affinity mask for the process and
* the number of CPUs present in the system
*/
if (!GetProcessAffinityMask(hProcessAffinityHandle, &dwProcessAffinityMask, &dwSystemAffinityMask)) {
GetLastErrorText(strErrorText, 260);
EndDialog(hDlg, 0);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
}
/*
* Enable a checkbox for each processor present in the system
*/
if (dwSystemAffinityMask & 0x00000001)
EnableWindow(GetDlgItem(hDlg, IDC_CPU0), TRUE);
if (dwSystemAffinityMask & 0x00000002)
EnableWindow(GetDlgItem(hDlg, IDC_CPU1), TRUE);
if (dwSystemAffinityMask & 0x00000004)
EnableWindow(GetDlgItem(hDlg, IDC_CPU2), TRUE);
if (dwSystemAffinityMask & 0x00000008)
EnableWindow(GetDlgItem(hDlg, IDC_CPU3), TRUE);
if (dwSystemAffinityMask & 0x00000010)
EnableWindow(GetDlgItem(hDlg, IDC_CPU4), TRUE);
if (dwSystemAffinityMask & 0x00000020)
EnableWindow(GetDlgItem(hDlg, IDC_CPU5), TRUE);
if (dwSystemAffinityMask & 0x00000040)
EnableWindow(GetDlgItem(hDlg, IDC_CPU6), TRUE);
if (dwSystemAffinityMask & 0x00000080)
EnableWindow(GetDlgItem(hDlg, IDC_CPU7), TRUE);
if (dwSystemAffinityMask & 0x00000100)
EnableWindow(GetDlgItem(hDlg, IDC_CPU8), TRUE);
if (dwSystemAffinityMask & 0x00000200)
EnableWindow(GetDlgItem(hDlg, IDC_CPU9), TRUE);
if (dwSystemAffinityMask & 0x00000400)
EnableWindow(GetDlgItem(hDlg, IDC_CPU10), TRUE);
if (dwSystemAffinityMask & 0x00000800)
EnableWindow(GetDlgItem(hDlg, IDC_CPU11), TRUE);
if (dwSystemAffinityMask & 0x00001000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU12), TRUE);
if (dwSystemAffinityMask & 0x00002000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU13), TRUE);
if (dwSystemAffinityMask & 0x00004000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU14), TRUE);
if (dwSystemAffinityMask & 0x00008000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU15), TRUE);
if (dwSystemAffinityMask & 0x00010000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU16), TRUE);
if (dwSystemAffinityMask & 0x00020000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU17), TRUE);
if (dwSystemAffinityMask & 0x00040000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU18), TRUE);
if (dwSystemAffinityMask & 0x00080000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU19), TRUE);
if (dwSystemAffinityMask & 0x00100000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU20), TRUE);
if (dwSystemAffinityMask & 0x00200000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU21), TRUE);
if (dwSystemAffinityMask & 0x00400000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU22), TRUE);
if (dwSystemAffinityMask & 0x00800000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU23), TRUE);
if (dwSystemAffinityMask & 0x01000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU24), TRUE);
if (dwSystemAffinityMask & 0x02000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU25), TRUE);
if (dwSystemAffinityMask & 0x04000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU26), TRUE);
if (dwSystemAffinityMask & 0x08000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU27), TRUE);
if (dwSystemAffinityMask & 0x10000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU28), TRUE);
if (dwSystemAffinityMask & 0x20000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU29), TRUE);
if (dwSystemAffinityMask & 0x40000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU30), TRUE);
if (dwSystemAffinityMask & 0x80000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU31), TRUE);
/*
* Check each checkbox that the current process
* has affinity with
*/
if (dwProcessAffinityMask & 0x00000001)
SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000002)
SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000004)
SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000008)
SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000010)
SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000020)
SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000040)
SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000080)
SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000100)
SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000200)
SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000400)
SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000800)
SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00001000)
SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00002000)
SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00004000)
SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00008000)
SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00010000)
SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00020000)
SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00040000)
SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00080000)
SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00100000)
SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00200000)
SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00400000)
SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00800000)
SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x01000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x02000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x04000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x08000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x10000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x20000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x40000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x80000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_SETCHECK, BST_CHECKED, 0);
return TRUE;
case WM_COMMAND:
/*
* If the user has cancelled the dialog box
* then just close it
*/
if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
/*
* The user has clicked OK -- so now we have
* to adjust the process affinity mask
*/
if (LOWORD(wParam) == IDOK) {
/*
* First we have to create a mask out of each
* checkbox that the user checked.
*/
if (SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000001;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000002;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000004;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000008;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000010;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000020;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000040;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000080;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000100;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000200;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000400;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000800;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00001000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00002000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00004000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00008000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00010000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00020000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00040000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00080000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00100000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00200000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00400000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00800000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x01000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x02000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x04000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x08000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x10000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x20000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x40000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x80000000;
/*
* Make sure they are giving the process affinity
* with at least one processor. I'd hate to see a
* process that is not in a wait state get deprived
* of it's cpu time.
*/
if (!dwProcessAffinityMask) {
MessageBox(hDlg, _T("The process must have affinity with at least one processor."), _T("Invalid Option"), MB_OK|MB_ICONSTOP);
return TRUE;
}
/*
* Try to set the process affinity
*/
if (!SetProcessAffinityMask(hProcessAffinityHandle, dwProcessAffinityMask)) {
GetLastErrorText(strErrorText, 260);
EndDialog(hDlg, LOWORD(wParam));
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
}
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return 0;
}
This diff is collapsed.
This diff is collapsed.
/*
* ReactOS Task Manager
*
* column.h
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __COLUMN_H
#define __COLUMN_H
#define COLUMN_IMAGENAME 0
#define COLUMN_PID 1
#define COLUMN_USERNAME 2
#define COLUMN_SESSIONID 3
#define COLUMN_CPUUSAGE 4
#define COLUMN_CPUTIME 5
#define COLUMN_MEMORYUSAGE 6
#define COLUMN_PEAKMEMORYUSAGE 7
#define COLUMN_MEMORYUSAGEDELTA 8
#define COLUMN_PAGEFAULTS 9
#define COLUMN_PAGEFAULTSDELTA 10
#define COLUMN_VIRTUALMEMORYSIZE 11
#define COLUMN_PAGEDPOOL 12
#define COLUMN_NONPAGEDPOOL 13
#define COLUMN_BASEPRIORITY 14
#define COLUMN_HANDLECOUNT 15
#define COLUMN_THREADCOUNT 16
#define COLUMN_USEROBJECTS 17
#define COLUMN_GDIOBJECTS 18
#define COLUMN_IOREADS 19
#define COLUMN_IOWRITES 20
#define COLUMN_IOOTHER 21
#define COLUMN_IOREADBYTES 22
#define COLUMN_IOWRITEBYTES 23
#define COLUMN_IOOTHERBYTES 24
extern UINT ColumnDataHints[25];
void ProcessPage_OnViewSelectColumns(void);
void AddColumns(void);
void SaveColumnSettings(void);
void UpdateColumnDataHints(void);
#endif /* __COLUMN_H */
/*
* ReactOS Task Manager
*
* dbgchnl.c
*
* Copyright (C) 2003 - 2004 Eric Pouech
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include <dbghelp.h>
#include "taskmgr.h"
#include "perfdata.h"
#include "column.h"
#include <ctype.h>
/* TODO:
* - the dialog box could be non modal
* - in that case,
* + could refresh channels from time to time
* + set the name of exec (and perhaps its pid) in dialog title
* - get a better UI (replace the 'x' by real tick boxes in list view)
* - enhance visual feedback: the list is large, and it's hard to get the
* right line when clicking on rightmost column (trace for example)
* - get rid of printfs (error reporting) and use real message boxes
* - include the column width settings in the full column management scheme
* - use more global settings (like having a temporary on/off
* setting for a fixme:s or err:s
*/
static BOOL (WINAPI *pSymInitialize)(HANDLE, PSTR, BOOL);
static DWORD (WINAPI *pSymLoadModule)(HANDLE, HANDLE, PSTR, PSTR, DWORD, DWORD);
static BOOL (WINAPI *pSymCleanup)(HANDLE);
static BOOL (WINAPI *pSymFromName)(HANDLE, LPSTR, PSYMBOL_INFO);
BOOL AreDebugChannelsSupported(void)
{
static HANDLE hDbgHelp /* = NULL */;
if (hDbgHelp) return TRUE;
if (!(hDbgHelp = LoadLibrary("dbghelp.dll"))) return FALSE;
pSymInitialize = (void*)GetProcAddress(hDbgHelp, "SymInitialize");
pSymLoadModule = (void*)GetProcAddress(hDbgHelp, "SymLoadModule");
pSymFromName = (void*)GetProcAddress(hDbgHelp, "SymFromName");
pSymCleanup = (void*)GetProcAddress(hDbgHelp, "SymCleanup");
if (!pSymInitialize || !pSymLoadModule || !pSymCleanup || !pSymFromName)
{
FreeLibrary(hDbgHelp);
hDbgHelp = NULL;
return FALSE;
}
return TRUE;
}
static DWORD get_selected_pid(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
for (Index = 0; Index < (ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return 0;
return dwProcessId;
}
static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* user)
{
int j;
char val[2];
LVITEMA lvi;
int index;
HWND hChannelLV = (HWND)user;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.pszText = buffer + 1;
index = ListView_InsertItem(hChannelLV, &lvi);
if (index == -1) return 0;
val[1] = '\0';
for (j = 0; j < 4; j++)
{
val[0] = (buffer[0] & (1 << j)) ? 'x' : ' ';
ListView_SetItemText(hChannelLV, index, j + 1, val);
}
return 1;
}
struct cce_user
{
const char* name; /* channel to look for */
unsigned value, mask; /* how to change channel */
unsigned done; /* number of successful changes */
unsigned notdone; /* number of unsuccessful changes */
};
/******************************************************************
* change_channel_CB
*
* Callback used for changing a given channel attributes
*/
static int change_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* pmt)
{
struct cce_user* user = (struct cce_user*)pmt;
if (!user->name || !strcmp(buffer + 1, user->name))
{
buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask);
if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL))
user->done++;
else
user->notdone++;
}
return 1;
}
void* get_symbol(HANDLE hProcess, char* name, char* lib)
{
char buffer[sizeof(IMAGEHLP_SYMBOL) + 256];
SYMBOL_INFO* si = (SYMBOL_INFO*)buffer;
void* ret = NULL;
if (pSymInitialize(hProcess, NULL, FALSE))
{
si->SizeOfStruct = sizeof(*si);
si->MaxNameLen = sizeof(buffer) - sizeof(IMAGEHLP_SYMBOL);
if (pSymLoadModule(hProcess, NULL, lib, NULL, 0, 0) &&
pSymFromName(hProcess, name, si))
ret = (void*)si->Address;
pSymCleanup(hProcess);
}
return ret;
}
struct dll_option_layout
{
void* next;
void* prev;
char* const* channels;
int nb_channels;
};
typedef int (*EnumChannelCB)(HANDLE, void*, char*, void*);
/******************************************************************
* enum_channel
*
* Enumerates all known channels on process hProcess through callback
* ce.
*/
static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned unique)
{
struct dll_option_layout dol;
int i, j, ret = 1;
void* buf_addr;
unsigned char buffer[32];
void* addr;
const char** cache = NULL;
unsigned num_cache, used_cache;
if (!(addr = get_symbol(hProcess, "first_dll", "libwine.so"))) return -1;
if (unique)
cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(char*));
else
num_cache = 0;
used_cache = 0;
for (;
ret && addr && ReadProcessMemory(hProcess, addr, &dol, sizeof(dol), NULL);
addr = dol.next)
{
for (i = 0; i < dol.nb_channels; i++)
{
if (ReadProcessMemory(hProcess, (void*)(dol.channels + i), &buf_addr, sizeof(buf_addr), NULL) &&
ReadProcessMemory(hProcess, buf_addr, buffer, sizeof(buffer), NULL))
{
if (unique)
{
/* since some channels are defined in multiple compilation units,
* they will appear several times...
* so cache the channel's names we already reported and don't report
* them again
*/
for (j = 0; j < used_cache; j++)
if (!strcmp(cache[j], buffer + 1)) break;
if (j != used_cache) continue;
if (used_cache == num_cache)
cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(char*));
cache[used_cache++] = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(buffer + 1) + 1),
buffer + 1);
}
ret = ce(hProcess, buf_addr, buffer, user);
}
}
}
if (unique)
{
for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (char*)cache[j]);
HeapFree(GetProcessHeap(), 0, cache);
}
return 0;
}
static void DebugChannels_FillList(HWND hChannelLV)
{
HANDLE hProcess;
ListView_DeleteAllItems(hChannelLV);
hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ, FALSE, get_selected_pid());
if (!hProcess) return; /* FIXME messagebox */
SendMessage(hChannelLV, WM_SETREDRAW, FALSE, 0);
enum_channel(hProcess, list_channel_CB, (void*)hChannelLV, TRUE);
SendMessage(hChannelLV, WM_SETREDRAW, TRUE, 0);
CloseHandle(hProcess);
}
static void DebugChannels_OnCreate(HWND hwndDlg)
{
HWND hLV = GetDlgItem(hwndDlg, IDC_DEBUG_CHANNELS_LIST);
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
lvc.pszText = _T("Debug Channel");
lvc.cx = 100;
ListView_InsertColumn(hLV, 0, &lvc);
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_CENTER;
lvc.pszText = _T("Fixme");
lvc.cx = 55;
ListView_InsertColumn(hLV, 1, &lvc);
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_CENTER;
lvc.pszText = _T("Err");
lvc.cx = 55;
ListView_InsertColumn(hLV, 2, &lvc);
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_CENTER;
lvc.pszText = _T("Warn");
lvc.cx = 55;
ListView_InsertColumn(hLV, 3, &lvc);
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_CENTER;
lvc.pszText = _T("Trace");
lvc.cx = 55;
ListView_InsertColumn(hLV, 4, &lvc);
DebugChannels_FillList(hLV);
}
static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam)
{
NMHDR* nmh = (NMHDR*)lParam;
switch (nmh->code)
{
case NM_CLICK:
if (nmh->idFrom == IDC_DEBUG_CHANNELS_LIST)
{
LVHITTESTINFO lhti;
HWND hChannelLV;
HANDLE hProcess;
NMITEMACTIVATE* nmia = (NMITEMACTIVATE*)lParam;
hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, get_selected_pid());
if (!hProcess) return; /* FIXME message box */
lhti.pt = nmia->ptAction;
hChannelLV = GetDlgItem(hDlg, IDC_DEBUG_CHANNELS_LIST);
SendMessage(hChannelLV, LVM_SUBITEMHITTEST, 0, (LPARAM)&lhti);
if (nmia->iSubItem >= 1 && nmia->iSubItem <= 4)
{
TCHAR val[2];
TCHAR name[32];
unsigned bitmask = 1 << (lhti.iSubItem - 1);
struct cce_user user;
ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0]));
ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0]));
user.name = name;
user.value = (val[0] == 'x') ? 0 : bitmask;
user.mask = bitmask;
user.done = user.notdone = 0;
enum_channel(hProcess, change_channel_CB, &user, FALSE);
if (user.done)
{
val[0] ^= ('x' ^ ' ');
ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val);
}
if (user.notdone)
printf("Some channel instance weren't correctly set\n");
}
CloseHandle(hProcess);
}
break;
}
}
static LRESULT CALLBACK DebugChannelsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
DebugChannels_OnCreate(hDlg);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
case WM_NOTIFY:
DebugChannels_OnNotify(hDlg, lParam);
break;
}
return FALSE;
}
void ProcessPage_OnDebugChannels(void)
{
DialogBox(hInst, (LPCTSTR)IDD_DEBUG_CHANNELS_DIALOG, hMainWnd, (DLGPROC)DebugChannelsDlgProc);
}
/*
* ReactOS Task Manager
*
* debug.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
void ProcessPage_OnDebug(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
HKEY hKey;
TCHAR strDebugPath[260];
TCHAR strDebugger[260];
DWORD dwDebuggerSize;
PROCESS_INFORMATION pi;
STARTUPINFO si;
HANDLE hDebugEvent;
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
RegCloseKey(hKey);
return;
}
RegCloseKey(hKey);
hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!hDebugEvent)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hDebugEvent);
}
/*
* ReactOS Task Manager
*
* endproc.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
void ProcessPage_OnEndProcess(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
}
void ProcessPage_OnEndProcessTree(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
}
/*
* ReactOS Task Manager
*
* graph.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
#define BRIGHT_GREEN RGB(0, 255, 0)
#define DARK_GREEN RGB(0, 130, 0)
#define RED RGB(255, 0, 0)
LONG OldGraphWndProc;
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd);
LRESULT CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LONG WindowId;
switch (message)
{
case WM_ERASEBKGND:
return TRUE;
/*
* Filter out mouse & keyboard messages
*/
/* case WM_APPCOMMAND: */
case WM_CAPTURECHANGED:
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MOUSEACTIVATE:
case WM_MOUSEHOVER:
case WM_MOUSELEAVE:
case WM_MOUSEMOVE:
/* case WM_MOUSEWHEEL: */
case WM_NCHITTEST:
case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_NCMBUTTONDBLCLK:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
/* case WM_NCMOUSEHOVER: */
/* case WM_NCMOUSELEAVE: */
case WM_NCMOUSEMOVE:
case WM_NCRBUTTONDBLCLK:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
/* case WM_NCXBUTTONDBLCLK: */
/* case WM_NCXBUTTONDOWN: */
/* case WM_NCXBUTTONUP: */
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
/* case WM_XBUTTONDBLCLK: */
/* case WM_XBUTTONDOWN: */
/* case WM_XBUTTONUP: */
case WM_ACTIVATE:
case WM_CHAR:
case WM_DEADCHAR:
case WM_GETHOTKEY:
case WM_HOTKEY:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_KILLFOCUS:
case WM_SETFOCUS:
case WM_SETHOTKEY:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_NCCALCSIZE:
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
WindowId = GetWindowLong(hWnd, GWL_ID);
switch (WindowId)
{
case IDC_CPU_USAGE_GRAPH:
Graph_DrawCpuUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_GRAPH:
Graph_DrawMemUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_HISTORY_GRAPH:
Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
break;
}
EndPaint(hWnd, &ps);
return 0;
}
/*
* We pass on all non-handled messages
*/
return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam);
}
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
RECT rcBarLeft;
RECT rcBarRight;
TCHAR Text[260];
ULONG CpuUsage;
ULONG CpuKernelUsage;
int nBars;
int nBarsUsed;
/* Bottom bars that are "used", i.e. are bright green, representing used cpu time */
int nBarsUsedKernel;
/* Bottom bars that are "used", i.e. are bright green, representing used cpu kernel time */
int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free cpu time */
int i;
/*
* Get the client area rectangle
*/
GetClientRect(hWnd, &rcClient);
/*
* Fill it with blackness
*/
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/*
* Get the CPU usage
*/
CpuUsage = PerfDataGetProcessorUsage();
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuUsage < 0) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100;
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
/*
* Check and see how many digits it will take
* so we get the indentation right every time.
*/
if (CpuUsage == 100)
{
_stprintf(Text, _T("%d%%"), (int)CpuUsage);
}
else if (CpuUsage < 10)
{
_stprintf(Text, _T(" %d%%"), (int)CpuUsage);
}
else
{
_stprintf(Text, _T(" %d%%"), (int)CpuUsage);
}
/*
* Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text
*/
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - 32) / 2, rcClient.bottom - 11 - 5);
/*
* Now we have to draw the graph
* So first find out how many bars we can fit
*/
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
nBarsUsed = (nBars * CpuUsage) / 100;
if ((CpuUsage) && (nBarsUsed == 0))
{
nBarsUsed = 1;
}
nBarsFree = nBars - nBarsUsed;
if (TaskManagerSettings.ShowKernelTimes)
{
nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100;
nBarsUsed -= (nBarsUsedKernel / 2);
}
else
{
nBarsUsedKernel = 0;
}
/*
* Now draw the bar graph
*/
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
rcBarLeft.right = rcBarLeft.left + 16;
rcBarRight.left = rcBarLeft.left + 17;
rcBarRight.right = rcBarLeft.right + 17;
rcBarLeft.top = rcBarRight.top = 5;
rcBarLeft.bottom = rcBarRight.bottom = 7;
if (nBarsUsed < 0) nBarsUsed = 0;
if (nBarsUsed > nBars) nBarsUsed = nBars;
if (nBarsFree < 0) nBarsFree = 0;
if (nBarsFree > nBars) nBarsFree = nBars;
if (nBarsUsedKernel < 0) nBarsUsedKernel = 0;
if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
/*
* Draw the "free" bars
*/
for (i=0; i<nBarsFree; i++)
{
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
rcBarLeft.top += 3;
rcBarLeft.bottom += 3;
rcBarRight.top += 3;
rcBarRight.bottom += 3;
}
/*
* Draw the "used" bars
*/
for (i=0; i<nBarsUsed; i++)
{
if (nBarsUsed > 5000) nBarsUsed = 5000;
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
rcBarLeft.top += 3;
rcBarLeft.bottom += 3;
rcBarRight.top += 3;
rcBarRight.bottom += 3;
}
/*
* Draw the "used" kernel bars
*/
rcBarLeft.bottom--;
rcBarRight.bottom--;
if (nBarsUsedKernel && nBarsUsedKernel % 2)
{
rcBarLeft.top -= 2;
rcBarLeft.bottom -= 2;
rcBarRight.top -= 2;
rcBarRight.bottom -= 2;
FillSolidRect(hDC, &rcBarLeft, RED);
FillSolidRect(hDC, &rcBarRight, RED);
rcBarLeft.top += 2;
rcBarLeft.bottom += 2;
rcBarRight.top += 2;
rcBarRight.bottom += 2;
nBarsUsedKernel--;
}
for (i=0; i<nBarsUsedKernel; i++)
{
if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
FillSolidRect(hDC, &rcBarLeft, RED);
FillSolidRect(hDC, &rcBarRight, RED);
rcBarLeft.top++;
rcBarLeft.bottom++;
rcBarRight.top++;
rcBarRight.bottom++;
if (i % 2)
{
rcBarLeft.top++;
rcBarLeft.bottom++;
rcBarRight.top++;
rcBarRight.bottom++;
}
}
}
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
RECT rcBarLeft;
RECT rcBarRight;
TCHAR Text[260];
ULONGLONG CommitChargeTotal;
ULONGLONG CommitChargeLimit;
int nBars;
int nBarsUsed = 0;
/* Bottom bars that are "used", i.e. are bright green, representing used memory */
int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free memory */
int i;
/*
* Get the client area rectangle
*/
GetClientRect(hWnd, &rcClient);
/*
* Fill it with blackness
*/
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/*
* Get the memory usage
*/
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
_stprintf(Text, _T("%dK"), (int)CommitChargeTotal);
/*
* Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text
*/
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (_tcslen(Text) * 8)) / 2, rcClient.bottom - 11 - 5);
/*
* Now we have to draw the graph
* So first find out how many bars we can fit
*/
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
if (CommitChargeLimit)
nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100;
nBarsFree = nBars - nBarsUsed;
if (nBarsUsed < 0) nBarsUsed = 0;
if (nBarsUsed > nBars) nBarsUsed = nBars;
if (nBarsFree < 0) nBarsFree = 0;
if (nBarsFree > nBars) nBarsFree = nBars;
/*
* Now draw the bar graph
*/
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
rcBarLeft.right = rcBarLeft.left + 16;
rcBarRight.left = rcBarLeft.left + 17;
rcBarRight.right = rcBarLeft.right + 17;
rcBarLeft.top = rcBarRight.top = 5;
rcBarLeft.bottom = rcBarRight.bottom = 7;
/*
* Draw the "free" bars
*/
for (i=0; i<nBarsFree; i++)
{
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
rcBarLeft.top += 3;
rcBarLeft.bottom += 3;
rcBarRight.top += 3;
rcBarRight.bottom += 3;
}
/*
* Draw the "used" bars
*/
for (i=0; i<nBarsUsed; i++)
{
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
rcBarLeft.top += 3;
rcBarLeft.bottom += 3;
rcBarRight.top += 3;
rcBarRight.bottom += 3;
}
}
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
ULONGLONG CommitChargeLimit;
int i;
static int offset = 0;
if (offset++ >= 10)
offset = 0;
/*
* Get the client area rectangle
*/
GetClientRect(hWnd, &rcClient);
/*
* Fill it with blackness
*/
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/*
* Get the memory usage
*/
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
/*
* Draw the graph background
*
* Draw the horizontal bars
*/
for (i=0; i<rcClient.bottom; i++)
{
if ((i % 11) == 0)
{
/* FillSolidRect2(hDC, 0, i, rcClient.right, 1, DARK_GREEN); */
}
}
/*
* Draw the vertical bars
*/
for (i=11; i<rcClient.right + offset; i++)
{
if ((i % 11) == 0)
{
/* FillSolidRect2(hDC, i - offset, 0, 1, rcClient.bottom, DARK_GREEN); */
}
}
/*
* Draw the memory usage
*/
for (i=rcClient.right; i>=0; i--)
{
}
}
This diff is collapsed.
/*
* ReactOS Task Manager
*
* graphctl.h
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __GRAPH_CTRL_H__
#define __GRAPH_CTRL_H__
#define MAX_PLOTS 4
#define MAX_CTRLS 4
#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Attributes */
public:
void SetXUnits(const char* string);
void SetYUnits(const char* string);
/* Operations */
public:
BOOL Create(DWORD dwStyle, const RECT& rect, HWND hParentWnd, UINT nID=NULL);
#endif
typedef struct
{
int m_nShiftPixels; /* amount to shift with each new point */
int m_nYDecimals;
char m_strXUnitsString[50];
char m_strYUnitsString[50];
COLORREF m_crBackColor; /* background color */
COLORREF m_crGridColor; /* grid color */
COLORREF m_crPlotColor[MAX_PLOTS]; /* data color */
double m_dCurrentPosition[MAX_PLOTS]; /* current position */
double m_dPreviousPosition[MAX_PLOTS]; /* previous position */
/* those were protected fields */
int m_nHalfShiftPixels;
int m_nPlotShiftPixels;
int m_nClientHeight;
int m_nClientWidth;
int m_nPlotHeight;
int m_nPlotWidth;
double m_dLowerLimit; /* lower bounds */
double m_dUpperLimit; /* upper bounds */
double m_dRange;
double m_dVerticalFactor;
HWND m_hWnd;
HWND m_hParentWnd;
HDC m_dcGrid;
HDC m_dcPlot;
HBITMAP m_bitmapOldGrid;
HBITMAP m_bitmapOldPlot;
HBITMAP m_bitmapGrid;
HBITMAP m_bitmapPlot;
HBRUSH m_brushBack;
HPEN m_penPlot[MAX_PLOTS];
RECT m_rectClient;
RECT m_rectPlot;
} TGraphCtrl;
extern LONG OldGraphCtrlWndProc;
double GraphCtrl_AppendPoint(TGraphCtrl* this,
double dNewPoint0, double dNewPoint1,
double dNewPoint2, double dNewPoint3);
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd,
UINT nID);
void GraphCtrl_DrawPoint(TGraphCtrl* this);
void GraphCtrl_InvalidateCtrl(TGraphCtrl* this);
void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc);
void GraphCtrl_Reset(TGraphCtrl* this);
void GraphCtrl_Resize(TGraphCtrl* this);
void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF
color);
void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color);
void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF
color);
void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double
dUpper, int nDecimalPlaces);
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __cplusplus
}
#endif
#endif /* __GRAPH_CTRL_H__ */
/*
* ReactOS Task Manager
*
* optnmenu.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* options.c
*
* Menu item handlers for the options menu.
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include "taskmgr.h"
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the always on top menu item
* and update main window.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.AlwaysOnTop = FALSE;
SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.AlwaysOnTop = TRUE;
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
}
void TaskManager_OnOptionsMinimizeOnUse(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the minimize on use menu item.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.MinimizeOnUse = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.MinimizeOnUse = TRUE;
}
}
void TaskManager_OnOptionsHideWhenMinimized(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the hide when minimized menu item.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.HideWhenMinimized = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.HideWhenMinimized = TRUE;
}
}
void TaskManager_OnOptionsShow16BitTasks(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* FIXME: Currently this is useless because the
* current implemetation doesn't list the 16-bit
* processes. I believe that would require querying
* each ntvdm.exe process for it's children.
*/
/*
* Check or uncheck the show 16-bit tasks menu item
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.Show16BitTasks = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.Show16BitTasks = TRUE;
}
/*
* Refresh the list of processes.
*/
RefreshProcessPage();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment