ReactOS  0.4.15-dev-1148-g8a4273b
proclist.c
Go to the documentation of this file.
1 /*
2  * Gdi handle viewer
3  *
4  * proclist.c
5  *
6  * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22 
23 #include "gdihv.h"
24 
25 VOID
27 {
29 
31  column.fmt = LVCFMT_LEFT;
32 
33  column.pszText = L"Process";
34  column.cx = 90;
35  (void)ListView_InsertColumn(hListCtrl, 0, &column);
36 
37  column.pszText = L"ProcessID";
38  column.cx = 90;
39  (void)ListView_InsertColumn(hListCtrl, 1, &column);
40  ProcessList_Update(hListCtrl);
41 }
42 
43 VOID
45 {
46  LV_ITEM item;
47  DWORD ProcessIds[1024], BytesReturned;
48  UINT cProcesses;
50  WCHAR strText[MAX_PATH] = L"<unknown>";
51  INT i;
52 
53  (void)ListView_DeleteAllItems(hListCtrl);
54  memset(&item, 0, sizeof(LV_ITEM));
55  item.mask = LVIF_TEXT|LVIF_PARAM;
56  item.pszText = strText;
57 
58  /* Insert "kernel" */
59  item.iItem = 0;
60  item.lParam = 0;
61  item.pszText = L"<Kernel>";
62  (void)ListView_InsertItem(hListCtrl, &item);
63  item.pszText = strText;
64  wsprintf(strText, L"%#08x", 0);
65  ListView_SetItemText(hListCtrl, 0, 1, strText);
66 
67  /* Insert "deleted" */
68  item.iItem = 1;
69  item.lParam = 1;
70  item.pszText = L"<deleted>";
71  (void)ListView_InsertItem(hListCtrl, &item);
72  item.pszText = strText;
73  wsprintf(strText, L"%#08x", 1);
74  ListView_SetItemText(hListCtrl, 1, 1, strText);
75 
76  /* Insert "all" */
77  item.iItem = 2;
78  item.lParam = 2;
79  item.pszText = L"<all>";
80  (void)ListView_InsertItem(hListCtrl, &item);
81  item.pszText = strText;
82  wsprintf(strText, L"%#08x", 2);
83  ListView_SetItemText(hListCtrl, 1, 1, strText);
84 
85  if (!EnumProcesses(ProcessIds, sizeof(ProcessIds), &BytesReturned ))
86  {
87  return;
88  }
89  cProcesses = BytesReturned / sizeof(DWORD);
90  if (cProcesses <= 1)
91  {
92  return;
93  }
94  for (i = 1; i < cProcesses; i++)
95  {
96  wsprintf(strText, L"<unknown>");
97  item.lParam = ProcessIds[i];
98  item.iItem = ListView_GetItemCount(hListCtrl);
99 
100  hProcess = 0;
101  /* FIXME: HACK: ROS crashes when using OpenProcess with PROCESS_VM_READ */
103  if (hProcess)
104  {
107  }
108  (void)ListView_InsertItem(hListCtrl, &item);
109 
110  wsprintf(strText, L"%#08x", ProcessIds[i]);
111  ListView_SetItemText(hListCtrl, item.iItem, 1, strText);
112  }
113 }
#define LV_ITEM
Definition: commctrl.h:2333
#define CloseHandle
Definition: compat.h:487
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define LVCF_WIDTH
Definition: commctrl.h:2583
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
#define LVCF_TEXT
Definition: commctrl.h:2584
#define LVCFMT_LEFT
Definition: commctrl.h:2594
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:58
#define LVIF_TEXT
Definition: commctrl.h:2305
#define LVCOLUMN
Definition: commctrl.h:2577
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
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
#define FALSE
Definition: types.h:117
VOID ProcessList_Create(HWND hListCtrl)
Definition: proclist.c:26
smooth NULL
Definition: ftsmooth.c:416
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2303
_In_ LPCGUID _In_ SIZE_T _In_ SIZE_T _Out_opt_ PSIZE_T BytesReturned
Definition: potypes.h:549
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
VOID ProcessList_Update(HWND hListCtrl)
Definition: proclist.c:44
#define LVCF_FMT
Definition: commctrl.h:2582
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define GetModuleBaseName
Definition: psapi.h:132
static ATOM item
Definition: dde.c:856
BOOL WINAPI EnumProcesses(DWORD *lpidProcess, DWORD cb, LPDWORD lpcbNeeded)
Definition: psapi.c:458
unsigned int UINT
Definition: ndis.h:50
#define PROCESS_VM_READ
Definition: pstypes.h:153
#define LVIF_PARAM
Definition: commctrl.h:2307
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define wsprintf
Definition: winuser.h:5840
#define memset(x, y, z)
Definition: compat.h:39
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2410