+++ /dev/null
-/*\r
- * Gdi handle viewer\r
- *\r
- * proclist.c\r
- *\r
- * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- */\r
-\r
-#include "gdihv.h"\r
-\r
-VOID\r
-ProcessList_Create(HWND hListCtrl)\r
-{\r
- LVCOLUMN column;\r
-\r
- column.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH;\r
- column.fmt = LVCFMT_LEFT;\r
-\r
- column.pszText = L"Process";\r
- column.cx = 90;\r
- (void)ListView_InsertColumn(hListCtrl, 0, &column);\r
-\r
- column.pszText = L"ProcessID";\r
- column.cx = 90;\r
- (void)ListView_InsertColumn(hListCtrl, 1, &column);\r
- ProcessList_Update(hListCtrl);\r
-}\r
-\r
-VOID\r
-ProcessList_Update(HWND hListCtrl)\r
-{\r
- LV_ITEM item;\r
- DWORD ProcessIds[1024], BytesReturned;\r
- UINT cProcesses;\r
- HANDLE hProcess;\r
- WCHAR strText[MAX_PATH] = L"<unknown>";\r
- INT i;\r
-\r
- (void)ListView_DeleteAllItems(hListCtrl);\r
- memset(&item, 0, sizeof(LV_ITEM));\r
- item.mask = LVIF_TEXT|LVIF_PARAM;\r
- item.pszText = strText;\r
-\r
- /* Insert "kernel" */\r
- item.iItem = 0;\r
- item.lParam = 0;\r
- item.pszText = L"<Kernel>";\r
- (void)ListView_InsertItem(hListCtrl, &item);\r
- item.pszText = strText;\r
- wsprintf(strText, L"%#08x", 0);\r
- ListView_SetItemText(hListCtrl, 0, 1, strText);\r
-\r
- /* Insert "deleted" */\r
- item.iItem = 1;\r
- item.lParam = 1;\r
- item.pszText = L"<deleted>";\r
- (void)ListView_InsertItem(hListCtrl, &item);\r
- item.pszText = strText;\r
- wsprintf(strText, L"%#08x", 1);\r
- ListView_SetItemText(hListCtrl, 1, 1, strText);\r
-\r
- /* Insert "all" */\r
- item.iItem = 2;\r
- item.lParam = 2;\r
- item.pszText = L"<all>";\r
- (void)ListView_InsertItem(hListCtrl, &item);\r
- item.pszText = strText;\r
- wsprintf(strText, L"%#08x", 2);\r
- ListView_SetItemText(hListCtrl, 1, 1, strText);\r
-\r
- if (!EnumProcesses(ProcessIds, sizeof(ProcessIds), &BytesReturned ))\r
- {\r
- return;\r
- }\r
- cProcesses = BytesReturned / sizeof(DWORD);\r
- if (cProcesses <= 1)\r
- {\r
- return;\r
- }\r
- for (i = 1; i < cProcesses; i++)\r
- {\r
- wsprintf(strText, L"<unknown>");\r
- item.lParam = ProcessIds[i];\r
- item.iItem = ListView_GetItemCount(hListCtrl);\r
-\r
- hProcess = 0;\r
- /* FIXME: HACK: ROS crashes when using OpenProcess with PROCESS_VM_READ */\r
- hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessIds[i]);\r
- if (hProcess)\r
- {\r
- GetModuleBaseName(hProcess, NULL, (LPWSTR)strText, MAX_PATH );\r
- CloseHandle(hProcess);\r
- }\r
- (void)ListView_InsertItem(hListCtrl, &item);\r
-\r
- wsprintf(strText, L"%#08x", ProcessIds[i]);\r
- ListView_SetItemText(hListCtrl, item.iItem, 1, strText);\r
- }\r
-}\r