⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proclist.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/*
 *	Gdi handle viewer
 *
 *	proclist.c
 *
 *	Copyright (C) 2007	Timo Kreuzer <timo <dot> kreuzer <at> web.de>
 *
 *	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;
	(void)ListView_InsertColumn(hListCtrl, 0, &column);

	column.pszText = L"ProcessID";
	column.cx = 90;
	(void)ListView_InsertColumn(hListCtrl, 1, &column);
	ProcessList_Update(hListCtrl);
}

VOID
ProcessList_Update(HWND hListCtrl)
{
	LV_ITEM item;
	DWORD ProcessIds[1024], BytesReturned, cProcesses;
	HANDLE hProcess;
	WCHAR strText[MAX_PATH] = L"<unknown>";
	INT i;

	(void)ListView_DeleteAllItems(hListCtrl);
	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>";
	(void)ListView_InsertItem(hListCtrl, &item);
	item.pszText = strText;
	wsprintf(strText, L"%#08x", 0);
	ListView_SetItemText(hListCtrl, 0, 1, strText);

	if (!EnumProcesses(ProcessIds, sizeof(ProcessIds), &BytesReturned ))
	{
		return;
	}
	cProcesses = BytesReturned / sizeof(DWORD);
	if (cProcesses == 0)
	{
		return;
	}
	for (i = 1; i < cProcesses; i++)
	{
		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 */
//		hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessIds[i]);
		if (hProcess)
		{
			GetModuleBaseName(hProcess, NULL, (LPWSTR)strText, MAX_PATH );
			CloseHandle(hProcess);
		}
		(void)ListView_InsertItem(hListCtrl, &item);

		wsprintf(strText, L"%#08x", ProcessIds[i]);
		ListView_SetItemText(hListCtrl, item.iItem, 1, strText);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -