2007-02-08 23:29:24 +00:00
|
|
|
/*
|
|
|
|
* Gdi handle viewer
|
|
|
|
*
|
|
|
|
* proclist.c
|
|
|
|
*
|
2007-09-27 22:29:26 +00:00
|
|
|
* Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
|
2007-02-08 23:29:24 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gdihv.h"
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ProcessList_Create(HWND hListCtrl)
|
|
|
|
{
|
|
|
|
LVCOLUMN column;
|
|
|
|
|
|
|
|
column.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH;
|
|
|
|
column.fmt = LVCFMT_LEFT;
|
|
|
|
|
|
|
|
column.pszText = L"Process";
|
|
|
|
column.cx = 90;
|
2007-04-06 14:24:59 +00:00
|
|
|
(void)ListView_InsertColumn(hListCtrl, 0, &column);
|
2007-02-08 23:29:24 +00:00
|
|
|
|
|
|
|
column.pszText = L"ProcessID";
|
|
|
|
column.cx = 90;
|
2007-04-06 14:24:59 +00:00
|
|
|
(void)ListView_InsertColumn(hListCtrl, 1, &column);
|
2007-02-08 23:29:24 +00:00
|
|
|
ProcessList_Update(hListCtrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ProcessList_Update(HWND hListCtrl)
|
|
|
|
{
|
|
|
|
LV_ITEM item;
|
2007-09-27 22:29:26 +00:00
|
|
|
DWORD ProcessIds[1024], BytesReturned;
|
|
|
|
UINT cProcesses;
|
2007-02-08 23:29:24 +00:00
|
|
|
HANDLE hProcess;
|
|
|
|
WCHAR strText[MAX_PATH] = L"<unknown>";
|
|
|
|
INT i;
|
|
|
|
|
2007-04-06 14:24:59 +00:00
|
|
|
(void)ListView_DeleteAllItems(hListCtrl);
|
2007-02-08 23:29:24 +00:00
|
|
|
memset(&item, 0, sizeof(LV_ITEM));
|
|
|
|
item.mask = LVIF_TEXT|LVIF_PARAM;
|
|
|
|
item.pszText = strText;
|
|
|
|
|
|
|
|
/* Insert "kernel" */
|
|
|
|
item.iItem = 0;
|
|
|
|
item.lParam = 0;
|
|
|
|
item.pszText = L"<Kernel>";
|
2007-04-06 14:24:59 +00:00
|
|
|
(void)ListView_InsertItem(hListCtrl, &item);
|
2007-02-08 23:29:24 +00:00
|
|
|
item.pszText = strText;
|
|
|
|
wsprintf(strText, L"%#08x", 0);
|
|
|
|
ListView_SetItemText(hListCtrl, 0, 1, strText);
|
|
|
|
|
2007-09-27 22:29:26 +00:00
|
|
|
/* Insert "deleted" */
|
|
|
|
item.iItem = 1;
|
|
|
|
item.lParam = 1;
|
|
|
|
item.pszText = L"<deleted>";
|
|
|
|
(void)ListView_InsertItem(hListCtrl, &item);
|
|
|
|
item.pszText = strText;
|
2009-03-25 03:48:51 +00:00
|
|
|
wsprintf(strText, L"%#08x", 1);
|
|
|
|
ListView_SetItemText(hListCtrl, 1, 1, strText);
|
|
|
|
|
|
|
|
/* Insert "all" */
|
|
|
|
item.iItem = 2;
|
|
|
|
item.lParam = 2;
|
|
|
|
item.pszText = L"<all>";
|
|
|
|
(void)ListView_InsertItem(hListCtrl, &item);
|
|
|
|
item.pszText = strText;
|
|
|
|
wsprintf(strText, L"%#08x", 2);
|
2007-09-27 22:29:26 +00:00
|
|
|
ListView_SetItemText(hListCtrl, 1, 1, strText);
|
|
|
|
|
2007-02-08 23:29:24 +00:00
|
|
|
if (!EnumProcesses(ProcessIds, sizeof(ProcessIds), &BytesReturned ))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cProcesses = BytesReturned / sizeof(DWORD);
|
2007-09-27 22:29:26 +00:00
|
|
|
if (cProcesses <= 1)
|
2007-02-08 23:29:24 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2007-02-12 04:42:53 +00:00
|
|
|
for (i = 1; i < cProcesses; i++)
|
2007-02-08 23:29:24 +00:00
|
|
|
{
|
|
|
|
wsprintf(strText, L"<unknown>");
|
|
|
|
item.lParam = ProcessIds[i];
|
|
|
|
item.iItem = ListView_GetItemCount(hListCtrl);
|
|
|
|
|
|
|
|
hProcess = 0;
|
|
|
|
/* FIXME: HACK: ROS crashes when using OpenProcess with PROCESS_VM_READ */
|
2007-09-27 22:29:26 +00:00
|
|
|
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessIds[i]);
|
2007-02-08 23:29:24 +00:00
|
|
|
if (hProcess)
|
|
|
|
{
|
|
|
|
GetModuleBaseName(hProcess, NULL, (LPWSTR)strText, MAX_PATH );
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
}
|
2007-04-06 14:24:59 +00:00
|
|
|
(void)ListView_InsertItem(hListCtrl, &item);
|
2007-02-08 23:29:24 +00:00
|
|
|
|
|
|
|
wsprintf(strText, L"%#08x", ProcessIds[i]);
|
|
|
|
ListView_SetItemText(hListCtrl, item.iItem, 1, strText);
|
|
|
|
}
|
|
|
|
}
|