Author: tkreuzer Date: Fri Feb 9 02:29:24 2007 New Revision: 25755
URL: http://svn.reactos.org/svn/reactos?rev=25755&view=rev Log: A gdi handle viewer. There's currently a hack, to make it work on ROS, OpenProcess() crashes ROS, so currently you will not see the processes names.
Added: trunk/rosapps/devutils/gdihv/ trunk/rosapps/devutils/gdihv/gdi.h trunk/rosapps/devutils/gdihv/gdihv.c trunk/rosapps/devutils/gdihv/gdihv.cbp trunk/rosapps/devutils/gdihv/gdihv.h trunk/rosapps/devutils/gdihv/gdihv.rbuild trunk/rosapps/devutils/gdihv/gdihv.rc trunk/rosapps/devutils/gdihv/handlelist.c trunk/rosapps/devutils/gdihv/handlelist.h trunk/rosapps/devutils/gdihv/mainwnd.c trunk/rosapps/devutils/gdihv/mainwnd.h trunk/rosapps/devutils/gdihv/proclist.c trunk/rosapps/devutils/gdihv/proclist.h trunk/rosapps/devutils/gdihv/resource.h trunk/rosapps/devutils/gdihv/system.ico (with props)
Added: trunk/rosapps/devutils/gdihv/gdi.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdi.h?rev=25... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdi.h (added) +++ trunk/rosapps/devutils/gdihv/gdi.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,64 @@ +typedef struct _GDI_TABLE_ENTRY +{ + PVOID KernelData; /* Points to the kernel mode structure */ + HANDLE ProcessId; /* process id that created the object, 0 for stock objects */ + LONG Type; /* the first 16 bit is the object type including the stock obj flag, the last 16 bits is just the object type */ + PVOID UserData; /* Points to the user mode structure, usually NULL though */ +} GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY; + +typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void); + +/* GDI handle table can hold 0x4000 handles */ +#define GDI_HANDLE_COUNT 0x4000 +#define GDI_GLOBAL_PROCESS (0x0) + +/* Handle Masks and shifts */ +#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1) +#define GDI_HANDLE_TYPE_MASK 0x007f0000 +#define GDI_HANDLE_STOCK_MASK 0x00800000 +#define GDI_HANDLE_REUSE_MASK 0xff000000 +#define GDI_HANDLE_REUSECNT_SHIFT 24 +#define GDI_HANDLE_UPPER_MASK 0xffff0000 + +/* Handle macros */ +#define GDI_HANDLE_CREATE(i, t) \ + ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) & GDI_HANDLE_UPPER_MASK))) + +#define GDI_HANDLE_GET_INDEX(h) \ + (((ULONG_PTR)(h)) & GDI_HANDLE_INDEX_MASK) + +#define GDI_HANDLE_GET_TYPE(h) \ + (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK) + +#define GDI_HANDLE_IS_TYPE(h, t) \ + ((t) == (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)) + +#define GDI_HANDLE_IS_STOCKOBJ(h) \ + (0 != (((ULONG_PTR)(h)) & GDI_HANDLE_STOCK_MASK)) + +#define GDI_HANDLE_SET_STOCKOBJ(h) \ + ((h) = (HANDLE)(((ULONG_PTR)(h)) | GDI_HANDLE_STOCK_MASK)) + +#define GDI_HANDLE_GET_UPPER(h) \ + (((ULONG_PTR)(h)) & GDI_HANDLE_UPPER_MASK) + +#define GDI_OBJECT_TYPE_DC 0x00010000 +#define GDI_OBJECT_TYPE_REGION 0x00040000 +#define GDI_OBJECT_TYPE_BITMAP 0x00050000 +#define GDI_OBJECT_TYPE_PALETTE 0x00080000 +#define GDI_OBJECT_TYPE_FONT 0x000a0000 +#define GDI_OBJECT_TYPE_BRUSH 0x00100000 +#define GDI_OBJECT_TYPE_EMF 0x00210000 +#define GDI_OBJECT_TYPE_PEN 0x00300000 +#define GDI_OBJECT_TYPE_EXTPEN 0x00500000 +#define GDI_OBJECT_TYPE_COLORSPACE 0x00090000 +#define GDI_OBJECT_TYPE_METADC 0x00660000 +#define GDI_OBJECT_TYPE_METAFILE 0x00260000 +#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00460000 +/* Following object types made up for ROS */ +#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000 +#define GDI_OBJECT_TYPE_MEMDC 0x00750000 +#define GDI_OBJECT_TYPE_DCE 0x00770000 +#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000 +/** Not really an object type. Forces GDI_FreeObj to be silent. */ +#define GDI_OBJECT_TYPE_SILENT 0x80000000
Added: trunk/rosapps/devutils/gdihv/gdihv.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdihv.c?rev=... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdihv.c (added) +++ trunk/rosapps/devutils/gdihv/gdihv.c Fri Feb 9 02:29:24 2007 @@ -1,0 +1,50 @@ +/* + * Gdi handle viewer + * + * gdihv.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" + +HINSTANCE g_hInstance; +GDIQUERYPROC GdiQueryHandleTable; +PGDI_TABLE_ENTRY GdiHandleTable = 0; + +int WINAPI WinMain (HINSTANCE hThisInstance, + HINSTANCE hPrevInstance, + LPSTR lpszArgument, + int nStyle) + +{ + g_hInstance = hThisInstance; + + InitCommonControls(); + + GdiQueryHandleTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandle(L"GDI32.DLL"), "GdiQueryTable"); + if(!GdiQueryHandleTable) + { + return -1; + } + GdiHandleTable = GdiQueryHandleTable(); + + DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_MAINWND), HWND_DESKTOP, MainWindow_WndProc, 0); + + /* The program return value is 0 */ + return 0; +}
Added: trunk/rosapps/devutils/gdihv/gdihv.cbp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdihv.cbp?re... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdihv.cbp (added) +++ trunk/rosapps/devutils/gdihv/gdihv.cbp Fri Feb 9 02:29:24 2007 @@ -1,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="5" /> + <Project> + <Option title="gdihv" /> + <Option pch_mode="2" /> + <Option default_target="" /> + <Option compiler="gcc" /> + <Build> + <Target title="Debug"> + <Option output="..\..\..\..\output-i386\modules\rosapps\devutils\gdihv\gdihv.exe" /> + <Option working_dir="..\..\..\..\output-i386\modules\rosapps\devutils\gdihv" /> + <Option object_output="..\..\..\..\obj-i386\modules\rosapps\devutils\gdihv" /> + <Option type="0" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + <Add option="-D__USE_W32API" /> + <Add option="-D_WIN32_IE=0x0501" /> + <Add option="-D_WIN32_WINNT=0x0501" /> + <Add directory="..\..\..\..\include" /> + <Add directory="..\..\..\..\include\crt" /> + <Add directory="..\..\..\..\include\psdk" /> + <Add directory="..\..\..\..\include\ndk" /> + <Add directory="..\..\..\..\include\ddk" /> + </Compiler> + <Linker> + <Add library="user32" /> + <Add library="kernel32" /> + <Add library="comctl32" /> + <Add library="psapi" /> + </Linker> + </Target> + </Build> + <Compiler> + <Add option="-Wall" /> + </Compiler> + <Linker> + <Add library="gdi32" /> + <Add library="user32" /> + <Add library="kernel32" /> + </Linker> + <Unit filename="gdi.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="gdihv.c"> + <Option compilerVar="CC" /> + <Option virtualFolder="source\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="gdihv.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="gdihv.rbuild"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="gdihv.rc"> + <Option compilerVar="WINDRES" /> + <Option virtualFolder="resources\" /> + <Option objectName="gdihv.res" /> + <Option target="Debug" /> + </Unit> + <Unit filename="handlelist.c"> + <Option compilerVar="CC" /> + <Option virtualFolder="source\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="handlelist.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="mainwnd.c"> + <Option compilerVar="CC" /> + <Option virtualFolder="source\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="mainwnd.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="proclist.c"> + <Option compilerVar="CC" /> + <Option virtualFolder="source\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="proclist.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Unit filename="resource.h"> + <Option compilerVar="CPP" /> + <Option compile="0" /> + <Option link="0" /> + <Option virtualFolder="header\" /> + <Option target="Debug" /> + </Unit> + <Extensions /> + </Project> +</CodeBlocks_project_file>
Added: trunk/rosapps/devutils/gdihv/gdihv.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdihv.h?rev=... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdihv.h (added) +++ trunk/rosapps/devutils/gdihv/gdihv.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,22 @@ +#ifndef _GDIHV_H +#define _GDIHV_H + +#define UNICODE + +#define WIN32_NO_STATUS +#include <windows.h> +#include <commctrl.h> +#include <ndk/ntndk.h> +#include <psapi.h> + +#include "gdi.h" +#include "mainwnd.h" +#include "proclist.h" +#include "handlelist.h" + +#include "resource.h" + +extern PGDI_TABLE_ENTRY GdiHandleTable; +extern HINSTANCE g_hInstance; + +#endif //_GDIHV_H
Added: trunk/rosapps/devutils/gdihv/gdihv.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdihv.rbuild... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdihv.rbuild (added) +++ trunk/rosapps/devutils/gdihv/gdihv.rbuild Fri Feb 9 02:29:24 2007 @@ -1,0 +1,15 @@ +<module name="gdihv" type="win32gui" installbase="system32" installname="gdihv.exe"> + <include base="gdihv">.</include> + <define name="__USE_W32API" /> + <define name="_WIN32_IE">0x0501</define> + <define name="_WIN32_WINNT">0x0501</define> + <library>user32</library> + <library>kernel32</library> + <library>comctl32</library> + <library>psapi</library> + <file>gdihv.c</file> + <file>gdihv.rc</file> + <file>mainwnd.c</file> + <file>handlelist.c</file> + <file>proclist.c</file> +</module>
Added: trunk/rosapps/devutils/gdihv/gdihv.rc URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdihv.rc?rev... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdihv.rc (added) +++ trunk/rosapps/devutils/gdihv/gdihv.rc Fri Feb 9 02:29:24 2007 @@ -1,0 +1,18 @@ +#include <windows.h> +#include "resource.h" + +IDI_MAIN ICON "system.ico" + +IDD_MAINWND DIALOGEX 0, 0, 260, 250 +STYLE WS_CAPTION | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX +CAPTION "HandleView" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "Tasks", IDC_PROCESSLIST, "SysListView32", WS_BORDER | WS_TABSTOP | 0x00000001 | LVS_REPORT, 5, 5, 100, 200 + CONTROL "Tasks", IDC_HANDLELIST, "SysListView32", WS_BORDER | WS_TABSTOP | 0x00000001 | LVS_REPORT, 110, 5, 150, 200 + PUSHBUTTON "Refresh handles", IDC_REFRESHHANDLE, 200, 230, 80, 14, WS_CLIPSIBLINGS | WS_TABSTOP + PUSHBUTTON "Refresh processes", IDC_REFRESHPROCESS, 50, 230, 80, 14, WS_CLIPSIBLINGS | WS_TABSTOP + +END + +
Added: trunk/rosapps/devutils/gdihv/handlelist.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/handlelist.c... ============================================================================== --- trunk/rosapps/devutils/gdihv/handlelist.c (added) +++ trunk/rosapps/devutils/gdihv/handlelist.c Fri Feb 9 02:29:24 2007 @@ -1,0 +1,177 @@ +/* + * Gdi handle viewer + * + * handlelist.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 +HandleList_Create(HWND hListCtrl) +{ + LVCOLUMN column; + + column.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH; + column.fmt = LVCFMT_LEFT; + + column.pszText = L"Number"; + column.cx = 50; + ListView_InsertColumn(hListCtrl, 0, &column); + + column.pszText = L"Index"; + column.cx = 50; + ListView_InsertColumn(hListCtrl, 1, &column); + + column.pszText = L"Handle"; + column.cx = 90; + ListView_InsertColumn(hListCtrl, 2, &column); + + column.pszText = L"Type"; + column.cx = 90; + ListView_InsertColumn(hListCtrl, 3, &column); + + column.pszText = L"Process"; + column.cx = 90; + ListView_InsertColumn(hListCtrl, 4, &column); + + column.pszText = L"KernelData"; + column.cx = 90; + ListView_InsertColumn(hListCtrl, 5, &column); + + column.pszText = L"UserData"; + column.cx = 90; + ListView_InsertColumn(hListCtrl, 6, &column); + + HandleList_Update(hListCtrl, 0); +} + +VOID +HandleList_Update(HWND hHandleListCtrl, HANDLE ProcessId) +{ + INT i, index; + PGDI_TABLE_ENTRY pEntry; + LV_ITEM item; + TCHAR strText[80]; + TCHAR* str2; + + ListView_DeleteAllItems(hHandleListCtrl); + item.mask = LVIF_TEXT|LVIF_PARAM; + item.pszText = strText; + item.cchTextMax = 80; + for (i = 0; i<= GDI_HANDLE_COUNT; i++) + { + pEntry = &GdiHandleTable[i]; + if (pEntry->KernelData) + { + if (ProcessId == (HANDLE)-1 || ProcessId == pEntry->ProcessId) + { + index = ListView_GetItemCount(hHandleListCtrl); + item.iItem = index; + item.iSubItem = 0; + + wsprintf(strText, L"%d", index); + ListView_InsertItem(hHandleListCtrl, &item); + + wsprintf(strText, L"%d", i); + ListView_SetItemText(hHandleListCtrl, index, 1, strText); + + wsprintf(strText, L"%#08x", GDI_HANDLE_CREATE(i, pEntry->Type)); + ListView_SetItemText(hHandleListCtrl, index, 2, strText); + + str2 = GetTypeName(pEntry->Type & GDI_HANDLE_TYPE_MASK); + ListView_SetItemText(hHandleListCtrl, index, 3, str2); + + wsprintf(strText, L"%#08x", (UINT)pEntry->ProcessId); + ListView_SetItemText(hHandleListCtrl, index, 4, strText); + + wsprintf(strText, L"%#08x", (UINT)pEntry->KernelData); + ListView_SetItemText(hHandleListCtrl, index, 5, strText); + + wsprintf(strText, L"%#08x", (UINT)pEntry->UserData); + ListView_SetItemText(hHandleListCtrl, index, 6, strText); + } + } + } +} + +TCHAR* +GetTypeName(UINT Type) +{ + TCHAR* strText; + + switch (Type) + { + case GDI_OBJECT_TYPE_DC: + strText = L"DC"; + break; + case GDI_OBJECT_TYPE_REGION: + strText = L"Region"; + break; + case GDI_OBJECT_TYPE_BITMAP: + strText = L"Bitmap"; + break; + case GDI_OBJECT_TYPE_PALETTE: + strText = L"Palette"; + break; + case GDI_OBJECT_TYPE_FONT: + strText = L"Font"; + break; + case GDI_OBJECT_TYPE_BRUSH: + strText = L"Brush"; + break; + case GDI_OBJECT_TYPE_EMF: + strText = L"EMF"; + break; + case GDI_OBJECT_TYPE_PEN: + strText = L"Pen"; + break; + case GDI_OBJECT_TYPE_EXTPEN: + strText = L"ExtPen"; + break; + case GDI_OBJECT_TYPE_COLORSPACE: + strText = L"ColSpace"; + break; + case GDI_OBJECT_TYPE_METADC: + strText = L"MetaDC"; + break; + case GDI_OBJECT_TYPE_METAFILE: + strText = L"Metafile"; + break; + case GDI_OBJECT_TYPE_ENHMETAFILE: + strText = L"EMF"; + break; + case GDI_OBJECT_TYPE_ENHMETADC: + strText = L"EMDC"; + break; + case GDI_OBJECT_TYPE_MEMDC: + strText = L"MemDC"; + break; + case GDI_OBJECT_TYPE_DCE: + strText = L"DCE"; + break; + case GDI_OBJECT_TYPE_DONTCARE: + strText = L"anything"; + break; + case GDI_OBJECT_TYPE_SILENT: + default: + strText = L"unknown"; + break; + } + return strText; +}
Added: trunk/rosapps/devutils/gdihv/handlelist.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/handlelist.h... ============================================================================== --- trunk/rosapps/devutils/gdihv/handlelist.h (added) +++ trunk/rosapps/devutils/gdihv/handlelist.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,4 @@ + +VOID HandleList_Create(HWND hListCtrl); +VOID HandleList_Update(HWND hHandleListCtrl, HANDLE ProcessID); +TCHAR* GetTypeName(UINT Type);
Added: trunk/rosapps/devutils/gdihv/mainwnd.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/mainwnd.c?re... ============================================================================== --- trunk/rosapps/devutils/gdihv/mainwnd.c (added) +++ trunk/rosapps/devutils/gdihv/mainwnd.c Fri Feb 9 02:29:24 2007 @@ -1,0 +1,126 @@ +/* + * Gdi handle viewer + * + * mainwnd.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" + +INT g_Separator; + +INT_PTR CALLBACK +MainWindow_WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + { + RECT rect; + + SendMessage(hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAIN))); + GetClientRect(hMainWnd, &rect); + g_Separator = (rect.right / 2); + HandleList_Create(GetDlgItem(hMainWnd, IDC_HANDLELIST)); + ProcessList_Create(GetDlgItem(hMainWnd, IDC_PROCESSLIST)); + MainWindow_OnSize(hMainWnd); + + break; + } + case WM_SIZE: + { + MainWindow_OnSize(hMainWnd); + break; + } + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + { + EndDialog(hMainWnd, IDOK); + break; + } + case IDC_REFRESHHANDLE: + { + LV_ITEM item; + HWND hProcessListCtrl = GetDlgItem(hMainWnd, IDC_PROCESSLIST); + memset(&item, 0, sizeof(LV_ITEM)); + item.mask = LVIF_PARAM; + item.iItem = ListView_GetSelectionMark(hProcessListCtrl); + ListView_GetItem(hProcessListCtrl, &item); + HandleList_Update(GetDlgItem(hMainWnd, IDC_HANDLELIST), (HANDLE)item.lParam); + break; + } + case IDC_REFRESHPROCESS: + { + ProcessList_Update(GetDlgItem(hMainWnd, IDC_PROCESSLIST)); + break; + } + default: + { + return FALSE; + } + } + break; + } + case WM_NOTIFY: + { + if (((LPNMLISTVIEW)lParam)->hdr.code == LVN_ITEMCHANGED + && (((LPNMLISTVIEW)lParam)->uNewState & LVIS_SELECTED) + && !(((LPNMLISTVIEW)lParam)->uOldState & LVIS_SELECTED)) + { + LV_ITEM item; + memset(&item, 0, sizeof(LV_ITEM)); + item.mask = LVIF_PARAM; + item.iItem = ((LPNMLISTVIEW)lParam)->iItem; + ListView_GetItem(GetDlgItem(hMainWnd, IDC_PROCESSLIST), &item); + HandleList_Update(GetDlgItem(hMainWnd, IDC_HANDLELIST), (HANDLE)item.lParam); + return TRUE; + break; + } + } + default: + { + return FALSE; + } + } + return TRUE; +} + +VOID +MainWindow_OnSize(HWND hMainWnd) +{ + HWND hProcessListctrl, hHandleListCtrl, hProcessRefresh, hHandleRefresh; + RECT rect; + + hProcessListctrl = GetDlgItem(hMainWnd, IDC_PROCESSLIST); + hHandleListCtrl = GetDlgItem(hMainWnd, IDC_HANDLELIST); + hProcessRefresh = GetDlgItem(hMainWnd, IDC_REFRESHPROCESS); + hHandleRefresh = GetDlgItem(hMainWnd, IDC_REFRESHHANDLE); + + GetClientRect(hMainWnd, &rect); + +//g_Separator = (rect.right / 2); + MoveWindow(hProcessListctrl, 5, 5, g_Separator - 5, rect.bottom - 40, TRUE); + MoveWindow(hHandleListCtrl, g_Separator + 5, 5, rect.right - g_Separator - 5, rect.bottom - 40, TRUE); + MoveWindow(hProcessRefresh, g_Separator - 90, rect.bottom - 30, 90, 25, TRUE); + MoveWindow(hHandleRefresh, rect.right - 90, rect.bottom - 30, 90, 25, TRUE); + return; +}
Added: trunk/rosapps/devutils/gdihv/mainwnd.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/mainwnd.h?re... ============================================================================== --- trunk/rosapps/devutils/gdihv/mainwnd.h (added) +++ trunk/rosapps/devutils/gdihv/mainwnd.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,3 @@ + +INT_PTR CALLBACK MainWindow_WndProc(HWND, UINT, WPARAM, LPARAM); +VOID MainWindow_OnSize(HWND hMainWnd);
Added: trunk/rosapps/devutils/gdihv/proclist.c URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/proclist.c?r... ============================================================================== --- trunk/rosapps/devutils/gdihv/proclist.c (added) +++ trunk/rosapps/devutils/gdihv/proclist.c Fri Feb 9 02:29:24 2007 @@ -1,0 +1,94 @@ +/* + * 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; + ListView_InsertColumn(hListCtrl, 0, &column); + + column.pszText = L"ProcessID"; + column.cx = 90; + 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; + + 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>"; + 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 = 0; 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); + } + ListView_InsertItem(hListCtrl, &item); + + wsprintf(strText, L"%#08x", ProcessIds[i]); + ListView_SetItemText(hListCtrl, item.iItem, 1, strText); + } +}
Added: trunk/rosapps/devutils/gdihv/proclist.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/proclist.h?r... ============================================================================== --- trunk/rosapps/devutils/gdihv/proclist.h (added) +++ trunk/rosapps/devutils/gdihv/proclist.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,3 @@ + +VOID ProcessList_Create(HWND hListCtrl); +VOID ProcessList_Update(HWND hListCtrl);
Added: trunk/rosapps/devutils/gdihv/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/resource.h?r... ============================================================================== --- trunk/rosapps/devutils/gdihv/resource.h (added) +++ trunk/rosapps/devutils/gdihv/resource.h Fri Feb 9 02:29:24 2007 @@ -1,0 +1,8 @@ + +#define IDD_MAINWND 1000 +#define IDC_PROCESSLIST 1001 +#define IDC_HANDLELIST 1002 +#define IDC_REFRESHHANDLE 1010 +#define IDC_REFRESHPROCESS 1011 +#define IDI_MAIN 2000 +#define IDI_ARROW 2001
Added: trunk/rosapps/devutils/gdihv/system.ico URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/system.ico?r... ============================================================================== Binary file - no diff available.
Propchange: trunk/rosapps/devutils/gdihv/system.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream