ReactOS 0.4.15-dev-8145-ga541a46
procpage.c File Reference
#include "precomp.h"
#include "proclist.h"
#include <ndk/psfuncs.h>
Include dependency graph for procpage.c:

Go to the source code of this file.

Classes

struct  PROCESS_PAGE_LIST_ITEM
 

Macros

#define CMP(x1, x2)    (x1 < x2 ? -1 : (x1 > x2 ? 1 : 0))
 
#define CONST_STR_LEN(str)   (_countof(str) - 1)
 

Typedefs

typedef struct PROCESS_PAGE_LIST_ITEMLPPROCESS_PAGE_LIST_ITEM
 

Functions

int CALLBACK ProcessPageCompareFunc (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
void AddProcess (ULONG Index)
 
void UpdateProcesses ()
 
void gethmsfromlargeint (LARGE_INTEGER largeint, DWORD *dwHours, DWORD *dwMinutes, DWORD *dwSeconds)
 
void ProcessPageOnNotify (WPARAM wParam, LPARAM lParam)
 
void ProcessPageShowContextMenu (DWORD dwProcessId)
 
BOOL PerfDataGetText (ULONG Index, ULONG ColumnIndex, LPTSTR lpText, ULONG nMaxCount)
 
DWORD WINAPI ProcessPageRefreshThread (void *lpParameter)
 
int ProcessRunning (ULONG ProcessId)
 
void Cleanup (void)
 
int ProcGetIndexByProcessId (DWORD dwProcessId)
 
DWORD GetSelectedProcessId (void)
 
void ProcessPageUpdate (void)
 
INT_PTR CALLBACK ProcessPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
UINT SH_FormatInteger (_In_ LONGLONG Num, _Out_writes_z_(cchResultMax) LPWSTR pwszResult, _In_ UINT cchResultMax)
 
void RefreshProcessPage (void)
 
int largeintcmp (LARGE_INTEGER l1, LARGE_INTEGER l2)
 
static DWORD DevicePathToDosPath (_In_ LPCWSTR lpDevicePath, _Out_writes_to_opt_(dwLength, return) LPWSTR lpDosPath, _In_opt_ DWORD dwLength)
 Maps an NT "\Device\..." path to its Win32 "DOS" equivalent.
 
static DWORD GetProcessExecutablePath (_In_ HANDLE hProcess, _Out_writes_to_opt_(dwLength, return) LPWSTR lpExePath, _In_opt_ DWORD dwLength)
 Retrieves the Win32 path of an executable image, by handle.
 
static DWORD GetProcessExecutablePathById (_In_ DWORD dwProcessId, _Out_writes_to_opt_(dwLength, return) LPWSTR lpExePath, _In_opt_ DWORD dwLength)
 Retrieves the Win32 path of an executable image, by identifier.
 
void ProcessPage_OnProperties (void)
 
void ProcessPage_OnOpenFileLocation (void)
 

Variables

HWND hProcessPage
 
HWND hProcessPageListCtrl
 
HWND hProcessPageHeaderCtrl
 
static HWND hProcessPageEndProcessButton
 
static HWND hProcessPageShowAllProcessesButton
 
BOOL bProcessPageSelectionMade = FALSE
 
static int nProcessPageWidth
 
static int nProcessPageHeight
 
static HANDLE hProcessThread = NULL
 
static DWORD dwProcessThread
 

Macro Definition Documentation

◆ CMP

#define CMP (   x1,
  x2 
)     (x1 < x2 ? -1 : (x1 > x2 ? 1 : 0))

Definition at line 16 of file procpage.c.

◆ CONST_STR_LEN

#define CONST_STR_LEN (   str)    (_countof(str) - 1)

Definition at line 19 of file procpage.c.

Typedef Documentation

◆ LPPROCESS_PAGE_LIST_ITEM

Function Documentation

◆ AddProcess()

void AddProcess ( ULONG  Index)

Definition at line 558 of file procpage.c.

559{
561 int i;
563 BOOL bAlreadyInList = FALSE;
564 ULONG pid;
565
567
568 /* Check to see if it's already in our list */
570 {
571 memset(&item, 0, sizeof(LV_ITEM));
572 item.mask = LVIF_PARAM;
573 item.iItem = i;
576 if (pData->ProcessId == pid)
577 {
578 bAlreadyInList = TRUE;
579 break;
580 }
581 }
582 if (!bAlreadyInList) /* Add */
583 {
585 pData->ProcessId = pid;
586
587 /* Add the item to the list */
588 memset(&item, 0, sizeof(LV_ITEM));
590 item.pszText = LPSTR_TEXTCALLBACK;
592 item.lParam = (LPARAM)pData;
594 }
595}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
if(dx< 0)
Definition: linetemp.h:194
static ATOM item
Definition: dde.c:856
ULONG PerfDataGetProcessId(ULONG Index)
Definition: perfdata.c:489
struct PROCESS_PAGE_LIST_ITEM * LPPROCESS_PAGE_LIST_ITEM
HWND hProcessPageListCtrl
Definition: procpage.c:28
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
#define LPSTR_TEXTCALLBACK
Definition: commctrl.h:2383
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define LVIF_PARAM
Definition: commctrl.h:2311
#define LV_ITEM
Definition: commctrl.h:2337
#define LVIF_TEXT
Definition: commctrl.h:2309
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2394
#define memset(x, y, z)
Definition: compat.h:39
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
LONG_PTR LPARAM
Definition: windef.h:208

Referenced by UpdateProcesses().

◆ Cleanup()

void Cleanup ( void  )

Definition at line 51 of file procpage.c.

52{
53 int i;
57 {
58 memset(&item, 0, sizeof(LV_ITEM));
59 item.mask = LVIF_PARAM;
60 item.iItem = i;
64 }
65}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by GetProcessExecutablePath(), ProcessPage_OnOpenFileLocation(), ProcessPage_OnProperties(), and ProcessPageWndProc().

◆ DevicePathToDosPath()

static DWORD DevicePathToDosPath ( _In_ LPCWSTR  lpDevicePath,
_Out_writes_to_opt_(dwLength, return) LPWSTR  lpDosPath,
_In_opt_ DWORD  dwLength 
)
static

Maps an NT "\Device\..." path to its Win32 "DOS" equivalent.

Parameters
[in]lpDevicePathThe NT device path to convert.
[out]lpDosPathReceives the converted Win32 path.
[in]dwLengthSize of the lpDosPath buffer in characters.
Returns
The number of characters required (if lpDosPath == NULL or dwLength == 0), or actually written in the lpDosPath buffer, including the NULL terminator. Returns 0 in case of failure.

Definition at line 988 of file procpage.c.

993{
994 DWORD dwRet = 0;
995 WCHAR szDrive[3] = L"?:";
997
998 /* Check if lpDevicePath is a device path */
999 if (_wcsnicmp(lpDevicePath, L"\\Device\\", CONST_STR_LEN(L"\\Device\\")) != 0)
1000 {
1001 return 0;
1002 }
1003
1004 for (szDrive[0] = L'A'; szDrive[0] <= L'`'; szDrive[0]++)
1005 {
1007 {
1008 size_t len = wcslen(szDeviceName);
1009
1010 if (_wcsnicmp(lpDevicePath, szDeviceName, len) == 0)
1011 {
1012 /* Get the required length, including the NULL terminator */
1013 dwRet = _countof(szDrive) + wcslen(lpDevicePath + len);
1014
1015 if (lpDosPath && (dwLength >= dwRet))
1016 {
1017 StringCchPrintfW(lpDosPath, dwLength, L"%s%s",
1018 szDrive, lpDevicePath + len);
1019 }
1020
1021 break;
1022 }
1023 }
1024 }
1025
1026 return dwRet;
1027}
static const WCHAR szDeviceName[]
Definition: provider.c:56
#define MAX_PATH
Definition: compat.h:34
static DWORD DWORD * dwLength
Definition: fusion.c:86
DWORD WINAPI QueryDosDeviceW(LPCWSTR lpDeviceName, LPWSTR lpTargetPath, DWORD ucchMax)
Definition: dosdev.c:542
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define CONST_STR_LEN(str)
Definition: procpage.c:19
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetProcessExecutablePath().

◆ gethmsfromlargeint()

void gethmsfromlargeint ( LARGE_INTEGER  largeint,
DWORD dwHours,
DWORD dwMinutes,
DWORD dwSeconds 
)

Definition at line 733 of file procpage.c.

734{
735#ifdef _MSC_VER
736 *dwHours = (DWORD)(largeint.QuadPart / 36000000000L);
737 *dwMinutes = (DWORD)((largeint.QuadPart % 36000000000L) / 600000000L);
738 *dwSeconds = (DWORD)(((largeint.QuadPart % 36000000000L) % 600000000L) / 10000000L);
739#else
740 *dwHours = (DWORD)(largeint.QuadPart / 36000000000LL);
741 *dwMinutes = (DWORD)((largeint.QuadPart % 36000000000LL) / 600000000LL);
742 *dwSeconds = (DWORD)(((largeint.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
743#endif
744}
#define DWORD
Definition: nt_native.h:44
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by largeintcmp(), and PerfDataGetText().

◆ GetProcessExecutablePath()

static DWORD GetProcessExecutablePath ( _In_ HANDLE  hProcess,
_Out_writes_to_opt_(dwLength, return) LPWSTR  lpExePath,
_In_opt_ DWORD  dwLength 
)
static

Retrieves the Win32 path of an executable image, by handle.

Parameters
[in]hProcessHandle to the executable image; it should be opened with PROCESS_QUERY_INFORMATION access rights.
[out]lpExePathReceives the Win32 image path.
[in]dwLengthSize of the lpExePath buffer in characters.
Returns
The number of characters required (if lpExePath == NULL or dwLength == 0), or actually written in the lpExePath buffer, including the NULL terminator. Returns 0 in case of failure.

Definition at line 1049 of file procpage.c.

1054{
1055 DWORD dwRet = 0;
1057 BYTE StaticBuffer[sizeof(UNICODE_STRING) + (MAX_PATH * sizeof(WCHAR))];
1059 PUNICODE_STRING ExePath;
1060 ULONG SizeNeeded;
1061
1064 StaticBuffer,
1065 /* Reserve a NULL terminator */
1066 sizeof(StaticBuffer) - sizeof(WCHAR),
1067 &SizeNeeded);
1068 if (NT_SUCCESS(Status))
1069 {
1070 ExePath = (PUNICODE_STRING)StaticBuffer;
1071 }
1073 {
1074 /* Allocate the buffer, reserving space for a NULL terminator */
1075 DynamicBuffer = HeapAlloc(GetProcessHeap(), 0, SizeNeeded + sizeof(WCHAR));
1076 if (!DynamicBuffer)
1077 return 0;
1078
1082 SizeNeeded,
1083 &SizeNeeded);
1084 if (!NT_SUCCESS(Status))
1085 goto Cleanup;
1086
1087 ExePath = DynamicBuffer;
1088 }
1089 else
1090 {
1091 return 0;
1092 }
1093
1094 /* Manually NULL-terminate */
1095 ExePath->Buffer[ExePath->Length / sizeof(WCHAR)] = UNICODE_NULL;
1096
1097 /* HACK: Convert device path format into Win32 path format.
1098 * Use ProcessImageFileNameWin32 instead if the kernel supports it. */
1099 dwRet = DevicePathToDosPath(ExePath->Buffer, lpExePath, dwLength);
1100
1101Cleanup:
1103
1104 return dwRet;
1105}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
struct _UNICODE_STRING UNICODE_STRING
Status
Definition: gdiplustypes.h:25
@ ProcessImageFileName
Definition: winternl.h:397
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
static DWORD DevicePathToDosPath(_In_ LPCWSTR lpDevicePath, _Out_writes_to_opt_(dwLength, return) LPWSTR lpDosPath, _In_opt_ DWORD dwLength)
Maps an NT "\Device\..." path to its Win32 "DOS" equivalent.
Definition: procpage.c:988
void Cleanup(void)
Definition: procpage.c:51
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
unsigned char BYTE
Definition: xxhash.c:193

Referenced by GetProcessExecutablePathById().

◆ GetProcessExecutablePathById()

static DWORD GetProcessExecutablePathById ( _In_ DWORD  dwProcessId,
_Out_writes_to_opt_(dwLength, return) LPWSTR  lpExePath,
_In_opt_ DWORD  dwLength 
)
static

Retrieves the Win32 path of an executable image, by identifier.

Parameters
[in]dwProcessIdIdentifier of the running executable image.
[out]lpExePathReceives the Win32 image path.
[in]dwLengthSize of the lpExePath buffer in characters.
Returns
The number of characters required (if lpExePath == NULL or dwLength == 0), or actually written in the lpExePath buffer, including the NULL terminator. Returns 0 in case of failure.

Definition at line 1126 of file procpage.c.

1131{
1132 DWORD dwRet = 0;
1133
1134 if (dwProcessId == 0)
1135 return 0;
1136
1137 /* PID = 4 ("System") */
1138 if (dwProcessId == 4)
1139 {
1140 static const WCHAR szKernelExe[] = L"\\ntoskrnl.exe";
1141 LPWSTR pszSystemDir;
1142 UINT uLength;
1143
1144 uLength = GetSystemDirectoryW(NULL, 0);
1145 if (uLength == 0)
1146 return 0;
1147
1148 pszSystemDir = HeapAlloc(GetProcessHeap(), 0, uLength * sizeof(WCHAR));
1149 if (!pszSystemDir)
1150 return 0;
1151
1152 if (GetSystemDirectoryW(pszSystemDir, uLength) != 0)
1153 {
1154 /* Get the required length, including the NULL terminator */
1155 dwRet = uLength + CONST_STR_LEN(szKernelExe);
1156
1157 if (lpExePath && (dwLength >= dwRet))
1158 {
1159 StringCchPrintfW(lpExePath, dwLength, L"%s%s",
1160 pszSystemDir, szKernelExe);
1161 }
1162 }
1163
1164 HeapFree(GetProcessHeap(), 0, pszSystemDir);
1165 }
1166 else
1167 {
1169
1171 if (hProcess)
1172 {
1173 dwRet = GetProcessExecutablePath(hProcess, lpExePath, dwLength);
1175 }
1176 }
1177
1178 return dwRet;
1179}
#define CloseHandle
Definition: compat.h:739
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
unsigned int UINT
Definition: ndis.h:50
static DWORD GetProcessExecutablePath(_In_ HANDLE hProcess, _Out_writes_to_opt_(dwLength, return) LPWSTR lpExePath, _In_opt_ DWORD dwLength)
Retrieves the Win32 path of an executable image, by handle.
Definition: procpage.c:1049
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ProcessPage_OnOpenFileLocation(), and ProcessPage_OnProperties().

◆ GetSelectedProcessId()

DWORD GetSelectedProcessId ( void  )

Definition at line 88 of file procpage.c.

89{
90 int Index;
91 LVITEM lvitem;
92
94 {
96
97 memset(&lvitem, 0, sizeof(LVITEM));
98
99 lvitem.mask = LVIF_PARAM;
100 lvitem.iItem = Index;
101
103
104 if (lvitem.lParam)
105 return ((LPPROCESS_PAGE_LIST_ITEM)lvitem.lParam)->ProcessId;
106 }
107
108 return 0;
109}
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
#define ListView_GetSelectionMark(hwnd)
Definition: commctrl.h:2789
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define LVITEM
Definition: commctrl.h:2375

Referenced by DoSetPriority(), ProcessPage_OnDebug(), ProcessPage_OnEndProcess(), ProcessPage_OnEndProcessTree(), ProcessPage_OnOpenFileLocation(), ProcessPage_OnProperties(), ProcessPage_OnSetAffinity(), and ProcessPageOnNotify().

◆ largeintcmp()

int largeintcmp ( LARGE_INTEGER  l1,
LARGE_INTEGER  l2 
)

Definition at line 746 of file procpage.c.

747{
748 int ret = 0;
749 DWORD dwHours1;
750 DWORD dwMinutes1;
751 DWORD dwSeconds1;
752 DWORD dwHours2;
753 DWORD dwMinutes2;
754 DWORD dwSeconds2;
755
756 gethmsfromlargeint(l1, &dwHours1, &dwMinutes1, &dwSeconds1);
757 gethmsfromlargeint(l2, &dwHours2, &dwMinutes2, &dwSeconds2);
758 ret = CMP(dwHours1, dwHours2);
759 if (ret == 0)
760 {
761 ret = CMP(dwMinutes1, dwMinutes2);
762 if (ret == 0)
763 {
764 ret = CMP(dwSeconds1, dwSeconds2);
765 }
766 }
767 return ret;
768}
#define CMP(x1, x2)
Definition: procpage.c:16
void gethmsfromlargeint(LARGE_INTEGER largeint, DWORD *dwHours, DWORD *dwMinutes, DWORD *dwSeconds)
Definition: procpage.c:733
int ret

Referenced by ProcessPageCompareFunc().

◆ PerfDataGetText()

BOOL PerfDataGetText ( ULONG  Index,
ULONG  ColumnIndex,
LPTSTR  lpText,
ULONG  nMaxCount 
)

Definition at line 597 of file procpage.c.

598{
599 IO_COUNTERS iocounters;
600
601 switch (ColumnDataHints[ColumnIndex])
602 {
603 case COLUMN_IMAGENAME:
605 return TRUE;
606
607 case COLUMN_PID:
609 return TRUE;
610
611 case COLUMN_USERNAME:
613 return TRUE;
614
617 return TRUE;
618
619 case COLUMN_SESSIONID:
621 return TRUE;
622
623 case COLUMN_CPUUSAGE:
625 return TRUE;
626
627 case COLUMN_CPUTIME:
628 {
630 DWORD dwHours;
631 DWORD dwMinutes;
632 DWORD dwSeconds;
633
635 gethmsfromlargeint(time, &dwHours, &dwMinutes, &dwSeconds);
636 StringCchPrintfW(lpText, nMaxCount, L"%lu:%02lu:%02lu", dwHours, dwMinutes, dwSeconds);
637 return TRUE;
638 }
639
642 StringCchCatW(lpText, nMaxCount, L" K");
643 return TRUE;
644
647 StringCchCatW(lpText, nMaxCount, L" K");
648 return TRUE;
649
652 StringCchCatW(lpText, nMaxCount, L" K");
653 return TRUE;
654
657 return TRUE;
658
661 return TRUE;
662
665 StringCchCatW(lpText, nMaxCount, L" K");
666 return TRUE;
667
668 case COLUMN_PAGEDPOOL:
670 StringCchCatW(lpText, nMaxCount, L" K");
671 return TRUE;
672
675 StringCchCatW(lpText, nMaxCount, L" K");
676 return TRUE;
677
680 return TRUE;
681
684 return TRUE;
685
688 return TRUE;
689
692 return TRUE;
693
696 return TRUE;
697
698 case COLUMN_IOREADS:
699 PerfDataGetIOCounters(Index, &iocounters);
700 SH_FormatInteger(iocounters.ReadOperationCount, lpText, nMaxCount);
701 return TRUE;
702
703 case COLUMN_IOWRITES:
704 PerfDataGetIOCounters(Index, &iocounters);
706 return TRUE;
707
708 case COLUMN_IOOTHER:
709 PerfDataGetIOCounters(Index, &iocounters);
711 return TRUE;
712
714 PerfDataGetIOCounters(Index, &iocounters);
715 SH_FormatInteger(iocounters.ReadTransferCount, lpText, nMaxCount);
716 return TRUE;
717
719 PerfDataGetIOCounters(Index, &iocounters);
720 SH_FormatInteger(iocounters.WriteTransferCount, lpText, nMaxCount);
721 return TRUE;
722
724 PerfDataGetIOCounters(Index, &iocounters);
725 SH_FormatInteger(iocounters.OtherTransferCount, lpText, nMaxCount);
726 return TRUE;
727 }
728
729 return FALSE;
730}
UINT ColumnDataHints[COLUMN_NMAX]
Definition: column.c:11
#define COLUMN_MEMORYUSAGEDELTA
Definition: column.h:19
#define COLUMN_HANDLECOUNT
Definition: column.h:26
#define COLUMN_PAGEFAULTSDELTA
Definition: column.h:21
#define COLUMN_MEMORYUSAGE
Definition: column.h:17
#define COLUMN_COMMANDLINE
Definition: column.h:36
#define COLUMN_IOWRITEBYTES
Definition: column.h:34
#define COLUMN_IOREADS
Definition: column.h:30
#define COLUMN_USEROBJECTS
Definition: column.h:28
#define COLUMN_BASEPRIORITY
Definition: column.h:25
#define COLUMN_PAGEDPOOL
Definition: column.h:23
#define COLUMN_IOWRITES
Definition: column.h:31
#define COLUMN_PEAKMEMORYUSAGE
Definition: column.h:18
#define COLUMN_IOOTHERBYTES
Definition: column.h:35
#define COLUMN_IOOTHER
Definition: column.h:32
#define COLUMN_VIRTUALMEMORYSIZE
Definition: column.h:22
#define COLUMN_PID
Definition: column.h:12
#define COLUMN_CPUTIME
Definition: column.h:16
#define COLUMN_GDIOBJECTS
Definition: column.h:29
#define COLUMN_IMAGENAME
Definition: column.h:11
#define COLUMN_PAGEFAULTS
Definition: column.h:20
#define COLUMN_USERNAME
Definition: column.h:13
#define COLUMN_THREADCOUNT
Definition: column.h:27
#define COLUMN_SESSIONID
Definition: column.h:14
#define COLUMN_IOREADBYTES
Definition: column.h:33
#define COLUMN_CPUUSAGE
Definition: column.h:15
#define COLUMN_NONPAGEDPOOL
Definition: column.h:24
__u16 time
Definition: mkdosfs.c:8
ULONG PerfDataGetPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:788
ULONG PerfDataGetWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:692
ULONG PerfDataGetWorkingSetSizeDelta(ULONG Index)
Definition: perfdata.c:724
ULONG PerfDataGetPageFaultCountDelta(ULONG Index)
Definition: perfdata.c:756
ULONG PerfDataGetPageFaultCount(ULONG Index)
Definition: perfdata.c:740
ULONG PerfDataGetSessionId(ULONG Index)
Definition: perfdata.c:646
LARGE_INTEGER PerfDataGetCPUTime(ULONG Index)
Definition: perfdata.c:678
ULONG PerfDataGetHandleCount(ULONG Index)
Definition: perfdata.c:836
ULONG PerfDataGetCPUUsage(ULONG Index)
Definition: perfdata.c:662
BOOL PerfDataGetCommandLine(ULONG Index, LPWSTR lpCommandLine, ULONG nMaxCount)
Definition: perfdata.c:523
ULONG PerfDataGetThreadCount(ULONG Index)
Definition: perfdata.c:852
ULONG PerfDataGetBasePriority(ULONG Index)
Definition: perfdata.c:820
BOOL PerfDataGetUserName(ULONG Index, LPWSTR lpUserName, ULONG nMaxCount)
Definition: perfdata.c:505
ULONG PerfDataGetUSERObjectCount(ULONG Index)
Definition: perfdata.c:868
ULONG PerfDataGetNonPagedPoolUsagePages(ULONG Index)
Definition: perfdata.c:804
ULONG PerfDataGetVirtualMemorySizeBytes(ULONG Index)
Definition: perfdata.c:772
BOOL PerfDataGetImageName(ULONG Index, LPWSTR lpImageName, ULONG nMaxCount)
Definition: perfdata.c:473
ULONG PerfDataGetPeakWorkingSetSizeBytes(ULONG Index)
Definition: perfdata.c:708
ULONG PerfDataGetGDIObjectCount(ULONG Index)
Definition: perfdata.c:884
BOOL PerfDataGetIOCounters(ULONG Index, PIO_COUNTERS pIoCounters)
Definition: perfdata.c:900
UINT SH_FormatInteger(_In_ LONGLONG Num, _Out_writes_z_(cchResultMax) LPWSTR pwszResult, _In_ UINT cchResultMax)
Definition: procpage.c:315
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
ULONGLONG ReadOperationCount
Definition: pstypes.h:83
ULONGLONG WriteTransferCount
Definition: pstypes.h:87
ULONGLONG WriteOperationCount
Definition: pstypes.h:84
ULONGLONG ReadTransferCount
Definition: pstypes.h:86
ULONGLONG OtherOperationCount
Definition: pstypes.h:85
ULONGLONG OtherTransferCount
Definition: pstypes.h:88
_In_ int nMaxCount
Definition: winuser.h:4877

Referenced by ProcessPageOnNotify().

◆ ProcessPage_OnOpenFileLocation()

void ProcessPage_OnOpenFileLocation ( void  )

Definition at line 1220 of file procpage.c.

1221{
1222 DWORD dwProcessId;
1224 LPWSTR pszExePath;
1225 static const WCHAR szCmdFormat[] = L"/select,\"%s\"";
1226 LPWSTR pszCmdLine = NULL;
1227
1228 dwProcessId = GetSelectedProcessId();
1229
1230 /* Retrieve the image path length */
1231 dwLength = GetProcessExecutablePathById(dwProcessId, NULL, 0);
1232 if (dwLength == 0)
1233 return;
1234
1235 /* Allocate and retrieve the image path */
1236 pszExePath = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
1237 if (!pszExePath)
1238 return;
1239
1240 if (GetProcessExecutablePathById(dwProcessId, pszExePath, dwLength) == 0)
1241 goto Cleanup;
1242
1243 /* Build the shell command line */
1244 dwLength += CONST_STR_LEN(szCmdFormat) - CONST_STR_LEN(L"%s");
1245 pszCmdLine = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
1246 if (!pszCmdLine)
1247 goto Cleanup;
1248
1249 StringCchPrintfW(pszCmdLine, dwLength, szCmdFormat, pszExePath);
1250
1251 /* Call the shell to open the file location and select it. If Explorer shell
1252 * is not available, use ReactOS's alternative file browser instead. */
1253 ShellExecuteW(NULL, L"open",
1254 GetShellWindow() ? L"explorer.exe" : L"filebrowser.exe",
1255 pszCmdLine, NULL, SW_SHOWNORMAL);
1256
1257Cleanup:
1258 HeapFree(GetProcessHeap(), 0, pszCmdLine);
1259 HeapFree(GetProcessHeap(), 0, pszExePath);
1260}
static DWORD GetProcessExecutablePathById(_In_ DWORD dwProcessId, _Out_writes_to_opt_(dwLength, return) LPWSTR lpExePath, _In_opt_ DWORD dwLength)
Retrieves the Win32 path of an executable image, by identifier.
Definition: procpage.c:1126
DWORD GetSelectedProcessId(void)
Definition: procpage.c:88
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2486
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
#define SW_SHOWNORMAL
Definition: winuser.h:770

Referenced by TaskManagerWndProc().

◆ ProcessPage_OnProperties()

void ProcessPage_OnProperties ( void  )

Definition at line 1181 of file procpage.c.

1182{
1183 DWORD dwProcessId;
1185 LPWSTR pszExePath;
1186 SHELLEXECUTEINFOW info = { 0 };
1187
1188 dwProcessId = GetSelectedProcessId();
1189
1190 /* Retrieve the image path length */
1191 dwLength = GetProcessExecutablePathById(dwProcessId, NULL, 0);
1192 if (dwLength == 0)
1193 return;
1194
1195 /* Allocate and retrieve the image path */
1196 pszExePath = HeapAlloc(GetProcessHeap(), 0, dwLength * sizeof(WCHAR));
1197 if (!pszExePath)
1198 return;
1199
1200 if (GetProcessExecutablePathById(dwProcessId, pszExePath, dwLength) == 0)
1201 goto Cleanup;
1202
1203 /* Call the shell to display the file properties */
1204 info.cbSize = sizeof(SHELLEXECUTEINFOW);
1206 info.hwnd = NULL;
1207 info.lpVerb = L"properties";
1208 info.lpFile = pszExePath;
1209 info.lpParameters = L"";
1210 info.lpDirectory = NULL;
1211 info.nShow = SW_SHOW;
1212 info.hInstApp = NULL;
1213
1215
1216Cleanup:
1217 HeapFree(GetProcessHeap(), 0, pszExePath);
1218}
struct _SHELLEXECUTEINFOW SHELLEXECUTEINFOW
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2428
#define SW_SHOW
Definition: winuser.h:775

Referenced by TaskManagerWndProc().

◆ ProcessPageCompareFunc()

int CALLBACK ProcessPageCompareFunc ( LPARAM  lParam1,
LPARAM  lParam2,
LPARAM  lParamSort 
)

Definition at line 770 of file procpage.c.

771{
772 int ret = 0;
775 ULONG IndexParam1;
776 ULONG IndexParam2;
777 WCHAR text1[260];
778 WCHAR text2[260];
779 ULONG l1;
780 ULONG l2;
781 LARGE_INTEGER time1;
782 LARGE_INTEGER time2;
783 IO_COUNTERS iocounters1;
784 IO_COUNTERS iocounters2;
785 ULONGLONG ull1;
786 ULONGLONG ull2;
787
789 Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam1;
790 Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam2;
791 } else {
792 Param1 = (LPPROCESS_PAGE_LIST_ITEM)lParam2;
793 Param2 = (LPPROCESS_PAGE_LIST_ITEM)lParam1;
794 }
795 IndexParam1 = PerfDataGetProcessIndex(Param1->ProcessId);
796 IndexParam2 = PerfDataGetProcessIndex(Param2->ProcessId);
797
799 {
800 PerfDataGetImageName(IndexParam1, text1, _countof(text1));
801 PerfDataGetImageName(IndexParam2, text2, _countof(text2));
802 ret = _wcsicmp(text1, text2);
803 }
805 {
806 l1 = Param1->ProcessId;
807 l2 = Param2->ProcessId;
808 ret = CMP(l1, l2);
809 }
811 {
812 PerfDataGetUserName(IndexParam1, text1, _countof(text1));
813 PerfDataGetUserName(IndexParam2, text2, _countof(text2));
814 ret = _wcsicmp(text1, text2);
815 }
817 {
818 PerfDataGetCommandLine(IndexParam1, text1, _countof(text1));
819 PerfDataGetCommandLine(IndexParam2, text2, _countof(text2));
820 ret = _wcsicmp(text1, text2);
821 }
823 {
824 l1 = PerfDataGetSessionId(IndexParam1);
825 l2 = PerfDataGetSessionId(IndexParam2);
826 ret = CMP(l1, l2);
827 }
829 {
830 l1 = PerfDataGetCPUUsage(IndexParam1);
831 l2 = PerfDataGetCPUUsage(IndexParam2);
832 ret = CMP(l1, l2);
833 }
835 {
836 time1 = PerfDataGetCPUTime(IndexParam1);
837 time2 = PerfDataGetCPUTime(IndexParam2);
838 ret = largeintcmp(time1, time2);
839 }
841 {
842 l1 = PerfDataGetWorkingSetSizeBytes(IndexParam1);
843 l2 = PerfDataGetWorkingSetSizeBytes(IndexParam2);
844 ret = CMP(l1, l2);
845 }
847 {
848 l1 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam1);
849 l2 = PerfDataGetPeakWorkingSetSizeBytes(IndexParam2);
850 ret = CMP(l1, l2);
851 }
853 {
854 l1 = PerfDataGetWorkingSetSizeDelta(IndexParam1);
855 l2 = PerfDataGetWorkingSetSizeDelta(IndexParam2);
856 ret = CMP(l1, l2);
857 }
859 {
860 l1 = PerfDataGetPageFaultCount(IndexParam1);
861 l2 = PerfDataGetPageFaultCount(IndexParam2);
862 ret = CMP(l1, l2);
863 }
865 {
866 l1 = PerfDataGetPageFaultCountDelta(IndexParam1);
867 l2 = PerfDataGetPageFaultCountDelta(IndexParam2);
868 ret = CMP(l1, l2);
869 }
871 {
872 l1 = PerfDataGetVirtualMemorySizeBytes(IndexParam1);
873 l2 = PerfDataGetVirtualMemorySizeBytes(IndexParam2);
874 ret = CMP(l1, l2);
875 }
877 {
878 l1 = PerfDataGetPagedPoolUsagePages(IndexParam1);
879 l2 = PerfDataGetPagedPoolUsagePages(IndexParam2);
880 ret = CMP(l1, l2);
881 }
883 {
884 l1 = PerfDataGetNonPagedPoolUsagePages(IndexParam1);
885 l2 = PerfDataGetNonPagedPoolUsagePages(IndexParam2);
886 ret = CMP(l1, l2);
887 }
889 {
890 l1 = PerfDataGetBasePriority(IndexParam1);
891 l2 = PerfDataGetBasePriority(IndexParam2);
892 ret = CMP(l1, l2);
893 }
895 {
896 l1 = PerfDataGetHandleCount(IndexParam1);
897 l2 = PerfDataGetHandleCount(IndexParam2);
898 ret = CMP(l1, l2);
899 }
901 {
902 l1 = PerfDataGetThreadCount(IndexParam1);
903 l2 = PerfDataGetThreadCount(IndexParam2);
904 ret = CMP(l1, l2);
905 }
907 {
908 l1 = PerfDataGetUSERObjectCount(IndexParam1);
909 l2 = PerfDataGetUSERObjectCount(IndexParam2);
910 ret = CMP(l1, l2);
911 }
913 {
914 l1 = PerfDataGetGDIObjectCount(IndexParam1);
915 l2 = PerfDataGetGDIObjectCount(IndexParam2);
916 ret = CMP(l1, l2);
917 }
919 {
920 PerfDataGetIOCounters(IndexParam1, &iocounters1);
921 PerfDataGetIOCounters(IndexParam2, &iocounters2);
922 ull1 = iocounters1.ReadOperationCount;
923 ull2 = iocounters2.ReadOperationCount;
924 ret = CMP(ull1, ull2);
925 }
927 {
928 PerfDataGetIOCounters(IndexParam1, &iocounters1);
929 PerfDataGetIOCounters(IndexParam2, &iocounters2);
930 ull1 = iocounters1.WriteOperationCount;
931 ull2 = iocounters2.WriteOperationCount;
932 ret = CMP(ull1, ull2);
933 }
935 {
936 PerfDataGetIOCounters(IndexParam1, &iocounters1);
937 PerfDataGetIOCounters(IndexParam2, &iocounters2);
938 ull1 = iocounters1.OtherOperationCount;
939 ull2 = iocounters2.OtherOperationCount;
940 ret = CMP(ull1, ull2);
941 }
943 {
944 PerfDataGetIOCounters(IndexParam1, &iocounters1);
945 PerfDataGetIOCounters(IndexParam2, &iocounters2);
946 ull1 = iocounters1.ReadTransferCount;
947 ull2 = iocounters2.ReadTransferCount;
948 ret = CMP(ull1, ull2);
949 }
951 {
952 PerfDataGetIOCounters(IndexParam1, &iocounters1);
953 PerfDataGetIOCounters(IndexParam2, &iocounters2);
954 ull1 = iocounters1.WriteTransferCount;
955 ull2 = iocounters2.WriteTransferCount;
956 ret = CMP(ull1, ull2);
957 }
959 {
960 PerfDataGetIOCounters(IndexParam1, &iocounters1);
961 PerfDataGetIOCounters(IndexParam2, &iocounters2);
962 ull1 = iocounters1.OtherTransferCount;
963 ull2 = iocounters2.OtherTransferCount;
964 ret = CMP(ull1, ull2);
965 }
966 return ret;
967}
ULONG PerfDataGetProcessIndex(ULONG pid)
Definition: perfdata.c:423
int largeintcmp(LARGE_INTEGER l1, LARGE_INTEGER l2)
Definition: procpage.c:746
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:37
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by ProcessPageOnNotify(), and UpdateProcesses().

◆ ProcessPageOnNotify()

void ProcessPageOnNotify ( WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 236 of file procpage.c.

237{
238 LPNMHDR pnmh;
239 NMLVDISPINFO* pnmdi;
240 LPNMHEADER pnmhdr;
241 ULONG Index;
242 ULONG ColumnIndex;
244
245 pnmh = (LPNMHDR) lParam;
246 pnmdi = (NMLVDISPINFO*) lParam;
247 pnmhdr = (LPNMHEADER) lParam;
248
249 if (pnmh->hwndFrom == hProcessPageListCtrl)
250 {
251 switch (pnmh->code)
252 {
253 case LVN_ITEMCHANGED:
255 break;
256
257 case LVN_GETDISPINFO:
258
259 if (!(pnmdi->item.mask & LVIF_TEXT))
260 break;
261
262 pData = (LPPROCESS_PAGE_LIST_ITEM)pnmdi->item.lParam;
263 Index = PerfDataGetProcessIndex(pData->ProcessId);
264 ColumnIndex = pnmdi->item.iSubItem;
265
266 PerfDataGetText(Index, ColumnIndex, pnmdi->item.pszText, (ULONG)pnmdi->item.cchTextMax);
267
268 break;
269
270 case NM_RCLICK:
271
273 break;
274
275 case LVN_KEYDOWN:
276
277 if (((LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE)
279 break;
280
281 }
282 }
283 else if (pnmh->hwndFrom == hProcessPageHeaderCtrl)
284 {
285 switch (pnmh->code)
286 {
287 case HDN_ITEMCLICK:
288
292
293 break;
294
295 case HDN_ITEMCHANGED:
296
298
299 break;
300
301 case HDN_ENDDRAG:
302
304
305 break;
306
307 }
308 }
309}
void UpdateColumnDataHints(void)
Definition: column.c:186
LPARAM lParam
Definition: combotst.c:139
void ProcessPage_OnEndProcess(void)
Definition: endproc.c:15
int CALLBACK ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: procpage.c:770
void ProcessPageUpdate(void)
Definition: procpage.c:111
HWND hProcessPageHeaderCtrl
Definition: procpage.c:29
BOOL PerfDataGetText(ULONG Index, ULONG ColumnIndex, LPTSTR lpText, ULONG nMaxCount)
Definition: procpage.c:597
void ProcessPageShowContextMenu(DWORD dwProcessId)
Definition: procpage.c:375
#define LVN_GETDISPINFO
Definition: commctrl.h:3160
#define NMLVDISPINFO
Definition: commctrl.h:3182
#define HDN_ENDDRAG
Definition: commctrl.h:856
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2703
#define HDN_ITEMCLICK
Definition: commctrl.h:868
#define NM_RCLICK
Definition: commctrl.h:133
#define LVN_KEYDOWN
Definition: commctrl.h:3184
#define HDN_ITEMCHANGED
Definition: commctrl.h:867
#define LVN_ITEMCHANGED
Definition: commctrl.h:3131
#define LPNMHEADER
Definition: commctrl.h:895
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
struct tagNMHDR * LPNMHDR
#define VK_DELETE
Definition: winuser.h:2233

Referenced by ProcessPageWndProc().

◆ ProcessPageRefreshThread()

DWORD WINAPI ProcessPageRefreshThread ( void lpParameter)

Definition at line 457 of file procpage.c.

458{
459 MSG msg;
460
461 while (1) {
462 /* Wait for an the event or application close */
463 if (GetMessage(&msg, NULL, 0, 0) <= 0)
464 return 0;
465
466 if (msg.message == WM_TIMER) {
467
469
472
474 }
475 }
476 return 0;
477}
#define msg(x)
Definition: auth_time.c:54
HWND hProcessPage
Definition: procpage.c:26
void UpdateProcesses()
Definition: procpage.c:479
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define GetMessage
Definition: winuser.h:5790
#define WM_TIMER
Definition: winuser.h:1742
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by ProcessPageWndProc().

◆ ProcessPageShowContextMenu()

void ProcessPageShowContextMenu ( DWORD  dwProcessId)

Definition at line 375 of file procpage.c.

376{
377 HMENU hMenu;
378 HMENU hSubMenu;
379 HMENU hPriorityMenu;
380 POINT pt;
381 SYSTEM_INFO si;
383 DWORD dwProcessPriorityClass;
384 WCHAR strDebugger[260];
385 DWORD dwDebuggerSize;
386 HKEY hKey;
387
388 if (dwProcessId == 0)
389 return;
390
391 memset(&si, 0, sizeof(SYSTEM_INFO));
392
394 GetSystemInfo(&si);
395
397 hSubMenu = GetSubMenu(hMenu, 0);
398 hPriorityMenu = GetSubMenu(hSubMenu, 4);
399
401 dwProcessPriorityClass = GetPriorityClass(hProcess);
403
404 if (si.dwNumberOfProcessors < 2)
406
407 switch (dwProcessPriorityClass) {
410 break;
413 break;
416 break;
419 break;
422 break;
425 break;
426 }
427
428 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
429 {
430 dwDebuggerSize = sizeof(strDebugger);
431 if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
432 {
433 CharUpper(strDebugger);
434 if (wcsstr(strDebugger, L"DRWTSN32"))
436 }
437 else
439
441 } else {
443 }
445 DestroyMenu(hMenu);
446}
#define ID_PROCESS_PAGE_SETPRIORITY_NORMAL
Definition: resource.h:184
#define ID_PROCESS_PAGE_SETPRIORITY_REALTIME
Definition: resource.h:181
#define ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL
Definition: resource.h:185
#define ID_PROCESS_PAGE_DEBUG
Definition: resource.h:179
#define ID_PROCESS_PAGE_SETAFFINITY
Definition: resource.h:180
#define ID_PROCESS_PAGE_SETPRIORITY_LOW
Definition: resource.h:186
#define ID_PROCESS_PAGE_SETPRIORITY_HIGH
Definition: resource.h:182
#define IDR_PROCESS_PAGE_CONTEXT
Definition: resource.h:32
#define ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL
Definition: resource.h:183
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
DWORD WINAPI GetPriorityClass(IN HANDLE hProcess)
Definition: proc.c:1657
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
#define pt(x, y)
Definition: drawing.c:79
HINSTANCE hInst
Definition: dxdiag.c:13
FxAutoRegKey hKey
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
HWND hMainWnd
Definition: magnifier.c:32
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define KEY_READ
Definition: nt_native.h:1023
DWORD dwNumberOfProcessors
Definition: winbase.h:1177
unsigned char * LPBYTE
Definition: typedefs.h:53
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:181
#define REALTIME_PRIORITY_CLASS
Definition: winbase.h:184
#define BELOW_NORMAL_PRIORITY_CLASS
Definition: winbase.h:190
#define HIGH_PRIORITY_CLASS
Definition: winbase.h:183
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:182
#define ABOVE_NORMAL_PRIORITY_CLASS
Definition: winbase.h:191
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2701
#define TPM_TOPALIGN
Definition: winuser.h:2383
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define TPM_LEFTALIGN
Definition: winuser.h:2377
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define TPM_LEFTBUTTON
Definition: winuser.h:2379
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define CharUpper
Definition: winuser.h:5745
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

Referenced by ProcessPageOnNotify().

◆ ProcessPageUpdate()

void ProcessPageUpdate ( void  )

Definition at line 111 of file procpage.c.

112{
113 /* Enable or disable the "End Process" button */
116 else
118}
static HWND hProcessPageEndProcessButton
Definition: procpage.c:30
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by ProcessPageOnNotify(), ProcessPageRefreshThread(), and ProcessPageWndProc().

◆ ProcessPageWndProc()

INT_PTR CALLBACK ProcessPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 121 of file procpage.c.

122{
123 RECT rc;
124 int nXDifference;
125 int nYDifference;
126 int cx, cy;
127
128 switch (message) {
129 case WM_INITDIALOG:
130 /*
131 * Save the width and height
132 */
133 GetClientRect(hDlg, &rc);
136
137 /* Update window position */
139
140 /*
141 * Get handles to the controls
142 */
147
148 /*
149 * Set the title, and extended window styles for the list control
150 */
153
154 AddColumns();
155
156 /*
157 * Subclass the process list control so we can intercept WM_ERASEBKGND
158 */
160
161#ifdef RUN_PROC_PAGE
162 /* Start our refresh thread */
164#endif
165
166 /* Refresh page */
168
169 return TRUE;
170
171 case WM_DESTROY:
172 /* Close the event handle, this will make the */
173 /* refresh thread exit when the wait fails */
174#ifdef RUN_PROC_PAGE
176#endif
178 Cleanup();
179 break;
180
181 case WM_COMMAND:
182 /* Handle the button clicks */
183 switch (LOWORD(wParam))
184 {
185 case IDC_ENDPROCESS:
187 }
188 break;
189
190 case WM_SIZE:
191 if (wParam == SIZE_MINIMIZED)
192 return 0;
193
194 cx = LOWORD(lParam);
195 cy = HIWORD(lParam);
196 nXDifference = cx - nProcessPageWidth;
197 nYDifference = cy - nProcessPageHeight;
200
201 /* Reposition the application page's controls */
203 cx = (rc.right - rc.left) + nXDifference;
204 cy = (rc.bottom - rc.top) + nYDifference;
207
209 MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT));
210 cx = rc.left + nXDifference;
211 cy = rc.top + nYDifference;
214
217 cx = rc.left;
218 cy = rc.top + nYDifference;
221 break;
222
223 case WM_NOTIFY:
225 break;
226
227 case WM_KEYDOWN:
228 if (wParam == VK_DELETE)
230 break;
231 }
232
233 return 0;
234}
WNDPROC OldProcessListWndProc
Definition: proclist.c:12
INT_PTR CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: proclist.c:16
#define IDC_ENDPROCESS
Definition: resource.h:41
#define IDC_SHOWALLPROCESSES
Definition: resource.h:46
#define IDC_PROCESSLIST
Definition: resource.h:42
void SaveColumnSettings(void)
Definition: column.c:90
void AddColumns(void)
Definition: column.c:48
WPARAM wParam
Definition: combotst.c:138
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
Definition: procpage.c:457
static DWORD dwProcessThread
Definition: procpage.c:38
static HWND hProcessPageShowAllProcessesButton
Definition: procpage.c:31
static HANDLE hProcessThread
Definition: procpage.c:37
static int nProcessPageHeight
Definition: procpage.c:35
static int nProcessPageWidth
Definition: procpage.c:34
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
Definition: procpage.c:236
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define ListView_GetHeader(hwnd)
Definition: commctrl.h:2651
#define LVS_EX_HEADERDRAGDROP
Definition: commctrl.h:2733
_Out_opt_ int * cx
Definition: commctrl.h:585
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2734
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2725
#define ListView_GetExtendedListViewStyle(hwndLV)
Definition: commctrl.h:2728
#define WM_NOTIFY
Definition: richedit.h:61
Definition: tftpd.h:60
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
DWORD EndLocalThread(HANDLE *hThread, DWORD dwThread)
Definition: taskmgr.c:1109
#define GWLP_WNDPROC
Definition: treelist.c:66
#define HIWORD(l)
Definition: typedefs.h:247
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_SIZE
Definition: winuser.h:1611
#define SWP_NOMOVE
Definition: winuser.h:1244
#define WM_COMMAND
Definition: winuser.h:1740
#define SWP_NOSIZE
Definition: winuser.h:1245
#define SIZE_MINIMIZED
Definition: winuser.h:2506
#define WM_INITDIALOG
Definition: winuser.h:1739
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SWP_NOOWNERZORDER
Definition: winuser.h:1249
#define WM_DESTROY
Definition: winuser.h:1609
#define WM_KEYDOWN
Definition: winuser.h:1715
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define SWP_NOZORDER
Definition: winuser.h:1247
#define SetWindowLongPtrW
Definition: winuser.h:5346

Referenced by OnCreate().

◆ ProcessRunning()

BOOL ProcessRunning ( ULONG  ProcessId)

Definition at line 535 of file procpage.c.

536{
538 DWORD exitCode;
539
540 if (ProcessId == 0) {
541 return TRUE;
542 }
543
545 if (hProcess == NULL) {
546 return FALSE;
547 }
548
549 if (GetExitCodeProcess(hProcess, &exitCode)) {
551 return (exitCode == STILL_ACTIVE);
552 }
553
555 return FALSE;
556}
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
#define STILL_ACTIVE
Definition: winbase.h:233

Referenced by UpdateProcesses().

◆ ProcGetIndexByProcessId()

int ProcGetIndexByProcessId ( DWORD  dwProcessId)

Definition at line 67 of file procpage.c.

68{
69 int i;
72
74 {
75 memset(&item, 0, sizeof(LV_ITEM));
76 item.mask = LVIF_PARAM;
77 item.iItem = i;
80 if (pData->ProcessId == dwProcessId)
81 {
82 return i;
83 }
84 }
85 return 0;
86}

Referenced by ApplicationPage_OnGotoProcess().

◆ RefreshProcessPage()

void RefreshProcessPage ( void  )

Definition at line 448 of file procpage.c.

449{
450#ifdef RUN_PROC_PAGE
451 /* Signal the event so that our refresh thread */
452 /* will wake up and refresh the process page */
454#endif
455}
#define PostThreadMessage
Definition: winuser.h:5833

Referenced by OnCreate(), TaskManager_OnOptionsShow16BitTasks(), and TaskManagerWndProc().

◆ SH_FormatInteger()

UINT SH_FormatInteger ( _In_ LONGLONG  Num,
_Out_writes_z_(cchResultMax) LPWSTR  pwszResult,
_In_ UINT  cchResultMax 
)

Definition at line 315 of file procpage.c.

319{
320 NUMBERFMTW nf;
321 INT i;
322 INT cchGrouping, cchResult;
323 WCHAR wszNumber[24];
324 WCHAR wszDecimalSep[8], wszThousandSep[8];
325 WCHAR wszGrouping[12];
326
327 /* Print the number in uniform mode */
328 StringCchPrintfW(wszNumber, _countof(wszNumber), L"%I64u", Num);
329
330 /* Get system strings for decimal and thousand separators */
331 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, wszDecimalSep, _countof(wszDecimalSep));
332 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, wszThousandSep, _countof(wszThousandSep));
333
334 /* Initialize format for printing the number in bytes */
335 ZeroMemory(&nf, sizeof(nf));
336 nf.lpDecimalSep = wszDecimalSep;
337 nf.lpThousandSep = wszThousandSep;
338
339 /* Get system string for groups separator */
342 wszGrouping,
343 _countof(wszGrouping));
344
345 /* Convert grouping specs from string to integer */
346 for (i = 0; i < cchGrouping; i++)
347 {
348 WCHAR wch = wszGrouping[i];
349
350 if (wch >= L'0' && wch <= L'9')
351 nf.Grouping = nf.Grouping * 10 + (wch - L'0');
352 else if (wch != L';')
353 break;
354 }
355
356 if ((nf.Grouping % 10) == 0)
357 nf.Grouping /= 10;
358 else
359 nf.Grouping *= 10;
360
361 /* Format the number */
363 0,
364 wszNumber,
365 &nf,
366 pwszResult,
367 cchResultMax);
368 if (!cchResult)
369 return 0;
370
371 /* GetNumberFormatW returns number of characters including UNICODE_NULL */
372 return cchResult - 1;
373}
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
#define LOCALE_USER_DEFAULT
LPWSTR lpDecimalSep
Definition: winnls.h:645
UINT Grouping
Definition: winnls.h:644
LPWSTR lpThousandSep
Definition: winnls.h:646
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_STHOUSAND
Definition: winnls.h:43

Referenced by PerfDataGetText().

◆ UpdateProcesses()

void UpdateProcesses ( )

Definition at line 479 of file procpage.c.

480{
481 int i;
482 ULONG l;
485
487
488 /* Remove old processes */
490 {
491 memset(&item, 0, sizeof (LV_ITEM));
492 item.mask = LVIF_PARAM;
493 item.iItem = i;
496 if (!ProcessRunning(pData->ProcessId))
497 {
500 }
501 }
502
503 /* Check for difference in listview process and performance process counts */
505 {
506 /* Add new processes by checking against the current items */
507 for (l = 0; l < PerfDataGetProcessCount(); l++)
508 {
509 AddProcess(l);
510 }
511 }
512
514 {
516 }
517
519
520 /* Select first item if any */
523 {
526 }
527 /*
528 else
529 {
530 bProcessPageSelectionMade = FALSE;
531 }
532 */
533}
r l[0]
Definition: byte_order.h:168
ULONG PerfDataGetProcessCount(void)
Definition: perfdata.c:446
int ProcessRunning(ULONG ProcessId)
Definition: procpage.c:535
BOOL bProcessPageSelectionMade
Definition: procpage.c:32
void AddProcess(ULONG Index)
Definition: procpage.c:558
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define LVNI_FOCUSED
Definition: commctrl.h:2423
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2411
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define SendMessage
Definition: winuser.h:5843
#define WM_SETREDRAW
Definition: winuser.h:1616

Referenced by ProcessPageRefreshThread().

Variable Documentation

◆ bProcessPageSelectionMade

BOOL bProcessPageSelectionMade = FALSE

Definition at line 32 of file procpage.c.

Referenced by UpdateProcesses().

◆ dwProcessThread

DWORD dwProcessThread
static

Definition at line 38 of file procpage.c.

Referenced by ProcessPageWndProc(), and RefreshProcessPage().

◆ hProcessPage

HWND hProcessPage

◆ hProcessPageEndProcessButton

HWND hProcessPageEndProcessButton
static

Definition at line 30 of file procpage.c.

Referenced by ProcessPageUpdate(), and ProcessPageWndProc().

◆ hProcessPageHeaderCtrl

◆ hProcessPageListCtrl

◆ hProcessPageShowAllProcessesButton

HWND hProcessPageShowAllProcessesButton
static

Definition at line 31 of file procpage.c.

Referenced by ProcessPageWndProc().

◆ hProcessThread

HANDLE hProcessThread = NULL
static

Definition at line 37 of file procpage.c.

Referenced by ProcessPageWndProc().

◆ nProcessPageHeight

int nProcessPageHeight
static

Definition at line 35 of file procpage.c.

Referenced by ProcessPageWndProc().

◆ nProcessPageWidth

int nProcessPageWidth
static

Definition at line 34 of file procpage.c.

Referenced by ProcessPageWndProc().