- Fix KiDispatchException to unmask KI_EXCEPTION_INTERNAL when setting the exception...
[reactos.git] / rosapps / devutils / gdihv / handlelist.c
1 /*
2 * Gdi handle viewer
3 *
4 * handlelist.c
5 *
6 * Copyright (C) 2007 Timo kreuzer <timo <dot> kreuzer <at> web.de>
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
26 HandleList_Create(HWND hListCtrl)
27 {
28 LVCOLUMN column;
29
30 column.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH;
31 column.fmt = LVCFMT_LEFT;
32
33 column.pszText = L"Number";
34 column.cx = 50;
35 ListView_InsertColumn(hListCtrl, 0, &column);
36
37 column.pszText = L"Index";
38 column.cx = 50;
39 ListView_InsertColumn(hListCtrl, 1, &column);
40
41 column.pszText = L"Handle";
42 column.cx = 90;
43 ListView_InsertColumn(hListCtrl, 2, &column);
44
45 column.pszText = L"Type";
46 column.cx = 90;
47 ListView_InsertColumn(hListCtrl, 3, &column);
48
49 column.pszText = L"Process";
50 column.cx = 90;
51 ListView_InsertColumn(hListCtrl, 4, &column);
52
53 column.pszText = L"KernelData";
54 column.cx = 90;
55 ListView_InsertColumn(hListCtrl, 5, &column);
56
57 column.pszText = L"UserData";
58 column.cx = 90;
59 ListView_InsertColumn(hListCtrl, 6, &column);
60
61 HandleList_Update(hListCtrl, 0);
62 }
63
64 VOID
65 HandleList_Update(HWND hHandleListCtrl, HANDLE ProcessId)
66 {
67 INT i, index;
68 PGDI_TABLE_ENTRY pEntry;
69 LV_ITEM item;
70 TCHAR strText[80];
71 TCHAR* str2;
72
73 ListView_DeleteAllItems(hHandleListCtrl);
74 item.mask = LVIF_TEXT|LVIF_PARAM;
75 item.pszText = strText;
76 item.cchTextMax = 80;
77 for (i = 0; i<= GDI_HANDLE_COUNT; i++)
78 {
79 pEntry = &GdiHandleTable[i];
80 if (pEntry->KernelData)
81 {
82 if (ProcessId == (HANDLE)-1 || ProcessId == pEntry->ProcessId)
83 {
84 index = ListView_GetItemCount(hHandleListCtrl);
85 item.iItem = index;
86 item.iSubItem = 0;
87
88 wsprintf(strText, L"%d", index);
89 ListView_InsertItem(hHandleListCtrl, &item);
90
91 wsprintf(strText, L"%d", i);
92 ListView_SetItemText(hHandleListCtrl, index, 1, strText);
93
94 wsprintf(strText, L"%#08x", GDI_HANDLE_CREATE(i, pEntry->Type));
95 ListView_SetItemText(hHandleListCtrl, index, 2, strText);
96
97 str2 = GetTypeName(pEntry->Type & GDI_HANDLE_TYPE_MASK);
98 ListView_SetItemText(hHandleListCtrl, index, 3, str2);
99
100 wsprintf(strText, L"%#08x", (UINT)pEntry->ProcessId);
101 ListView_SetItemText(hHandleListCtrl, index, 4, strText);
102
103 wsprintf(strText, L"%#08x", (UINT)pEntry->KernelData);
104 ListView_SetItemText(hHandleListCtrl, index, 5, strText);
105
106 wsprintf(strText, L"%#08x", (UINT)pEntry->UserData);
107 ListView_SetItemText(hHandleListCtrl, index, 6, strText);
108 }
109 }
110 }
111 }
112
113 TCHAR*
114 GetTypeName(UINT Type)
115 {
116 TCHAR* strText;
117
118 switch (Type)
119 {
120 case GDI_OBJECT_TYPE_DC:
121 strText = L"DC";
122 break;
123 case GDI_OBJECT_TYPE_REGION:
124 strText = L"Region";
125 break;
126 case GDI_OBJECT_TYPE_BITMAP:
127 strText = L"Bitmap";
128 break;
129 case GDI_OBJECT_TYPE_PALETTE:
130 strText = L"Palette";
131 break;
132 case GDI_OBJECT_TYPE_FONT:
133 strText = L"Font";
134 break;
135 case GDI_OBJECT_TYPE_BRUSH:
136 strText = L"Brush";
137 break;
138 case GDI_OBJECT_TYPE_EMF:
139 strText = L"EMF";
140 break;
141 case GDI_OBJECT_TYPE_PEN:
142 strText = L"Pen";
143 break;
144 case GDI_OBJECT_TYPE_EXTPEN:
145 strText = L"ExtPen";
146 break;
147 case GDI_OBJECT_TYPE_COLORSPACE:
148 strText = L"ColSpace";
149 break;
150 case GDI_OBJECT_TYPE_METADC:
151 strText = L"MetaDC";
152 break;
153 case GDI_OBJECT_TYPE_METAFILE:
154 strText = L"Metafile";
155 break;
156 case GDI_OBJECT_TYPE_ENHMETAFILE:
157 strText = L"EMF";
158 break;
159 case GDI_OBJECT_TYPE_ENHMETADC:
160 strText = L"EMDC";
161 break;
162 case GDI_OBJECT_TYPE_MEMDC:
163 strText = L"MemDC";
164 break;
165 case GDI_OBJECT_TYPE_DCE:
166 strText = L"DCE";
167 break;
168 case GDI_OBJECT_TYPE_DONTCARE:
169 strText = L"anything";
170 break;
171 case GDI_OBJECT_TYPE_SILENT:
172 default:
173 strText = L"unknown";
174 break;
175 }
176 return strText;
177 }