Add .gitattributes and .gitignore files and normalize line endings in the repository...
[reactos.git] / modules / rosapps / applications / devutils / gdihv / handlelist.c
index a1a3a8f..63bf241 100644 (file)
-/*\r
- *     Gdi handle viewer\r
- *\r
- *     handlelist.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
-HandleList_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"Number";\r
-       column.cx = 50;\r
-       (void)ListView_InsertColumn(hListCtrl, 0, &column);\r
-\r
-       column.pszText = L"Index";\r
-       column.cx = 45;\r
-       (void)ListView_InsertColumn(hListCtrl, 1, &column);\r
-\r
-       column.pszText = L"Handle";\r
-       column.cx = 90;\r
-       (void)ListView_InsertColumn(hListCtrl, 2, &column);\r
-\r
-       column.pszText = L"Type";\r
-       column.cx = 80;\r
-       (void)ListView_InsertColumn(hListCtrl, 3, &column);\r
-\r
-       column.pszText = L"Process";\r
-       column.cx = 80;\r
-       (void)ListView_InsertColumn(hListCtrl, 4, &column);\r
-\r
-       column.pszText = L"KernelData";\r
-       column.cx = 80;\r
-       (void)ListView_InsertColumn(hListCtrl, 5, &column);\r
-\r
-       column.pszText = L"UserData";\r
-       column.cx = 80;\r
-       (void)ListView_InsertColumn(hListCtrl, 6, &column);\r
-\r
-       column.pszText = L"Type";\r
-       column.cx = 80;\r
-       (void)ListView_InsertColumn(hListCtrl, 7, &column);\r
-\r
-       HandleList_Update(hListCtrl, 0);\r
-}\r
-\r
-VOID\r
-HandleList_Update(HWND hHandleListCtrl, HANDLE ProcessId)\r
-{\r
-       INT i, index;\r
-       HANDLE handle;\r
-       PGDI_TABLE_ENTRY pEntry;\r
-       LVITEM item;\r
-       TCHAR strText[80];\r
-       TCHAR* str2;\r
-\r
-       (void)ListView_DeleteAllItems(hHandleListCtrl);\r
-       item.mask = LVIF_TEXT|LVIF_PARAM;\r
-       item.pszText = strText;\r
-       item.cchTextMax = 80;\r
-       for (i = 0; i<= GDI_HANDLE_COUNT; i++)\r
-       {\r
-               pEntry = &GdiHandleTable[i];\r
-               if ( ((ProcessId != (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) != 0)) ||\r
-                    ((ProcessId == (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) == 0)) ||\r
-                     (ProcessId == (HANDLE)2) )\r
-               {\r
-                       if (ProcessId == (HANDLE)1 || ProcessId == (HANDLE)2 ||\r
-                           ((LONG)ProcessId & 0xfffc) == ((ULONG)pEntry->ProcessId & 0xfffc))\r
-                       {\r
-                               handle = GDI_HANDLE_CREATE(i, pEntry->Type);\r
-                               index = ListView_GetItemCount(hHandleListCtrl);\r
-                               item.iItem = index;\r
-                               item.iSubItem = 0;\r
-                               item.lParam = (LPARAM)handle;\r
-\r
-                               wsprintf(strText, L"%d", index);\r
-                               (void)ListView_InsertItem(hHandleListCtrl, &item);\r
-\r
-                               wsprintf(strText, L"%d", i);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 1, strText);\r
-\r
-                               wsprintf(strText, L"%#08x", handle);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 2, strText);\r
-\r
-                               str2 = GetTypeName(handle);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 3, str2);\r
-\r
-                               wsprintf(strText, L"%#08x", (UINT)pEntry->ProcessId);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 4, strText);\r
-\r
-                               wsprintf(strText, L"%#08x", (UINT)pEntry->KernelData);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 5, strText);\r
-\r
-                               wsprintf(strText, L"%#08x", (UINT)pEntry->UserData);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 6, strText);\r
-\r
-                               wsprintf(strText, L"%#08x", (UINT)pEntry->Type);\r
-                               ListView_SetItemText(hHandleListCtrl, index, 7, strText);\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-TCHAR*\r
-GetTypeName(HANDLE handle)\r
-{\r
-       TCHAR* strText;\r
-       UINT Type = GDI_HANDLE_GET_TYPE(handle);\r
-\r
-       switch (Type)\r
-       {\r
-               case GDI_OBJECT_TYPE_DC:\r
-                       strText = L"DC";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_REGION:\r
-                       strText = L"Region";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_BITMAP:\r
-                       strText = L"Bitmap";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_PALETTE:\r
-                       strText = L"Palette";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_FONT:\r
-                       strText = L"Font";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_BRUSH:\r
-                       strText = L"Brush";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_EMF:\r
-                       strText = L"EMF";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_PEN:\r
-                       strText = L"Pen";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_EXTPEN:\r
-                       strText = L"ExtPen";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_COLORSPACE:\r
-                       strText = L"ColSpace";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_METADC:\r
-                       strText = L"MetaDC";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_METAFILE:\r
-                       strText = L"Metafile";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_ENHMETAFILE:\r
-                       strText = L"EMF";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_ENHMETADC:\r
-                       strText = L"EMDC";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_MEMDC:\r
-                       strText = L"MemDC";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_DCE:\r
-                       strText = L"DCE";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_PFE:\r
-                       strText = L"PFE";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_DONTCARE:\r
-                       strText = L"anything";\r
-                       break;\r
-               case GDI_OBJECT_TYPE_SILENT:\r
-               default:\r
-                       strText = L"unknown";\r
-                       break;\r
-       }\r
-       return strText;\r
-}\r
+/*
+ *     Gdi handle viewer
+ *
+ *     handlelist.c
+ *
+ *     Copyright (C) 2007      Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
+ *
+ *     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;
+       (void)ListView_InsertColumn(hListCtrl, 0, &column);
+
+       column.pszText = L"Index";
+       column.cx = 45;
+       (void)ListView_InsertColumn(hListCtrl, 1, &column);
+
+       column.pszText = L"Handle";
+       column.cx = 90;
+       (void)ListView_InsertColumn(hListCtrl, 2, &column);
+
+       column.pszText = L"Type";
+       column.cx = 80;
+       (void)ListView_InsertColumn(hListCtrl, 3, &column);
+
+       column.pszText = L"Process";
+       column.cx = 80;
+       (void)ListView_InsertColumn(hListCtrl, 4, &column);
+
+       column.pszText = L"KernelData";
+       column.cx = 80;
+       (void)ListView_InsertColumn(hListCtrl, 5, &column);
+
+       column.pszText = L"UserData";
+       column.cx = 80;
+       (void)ListView_InsertColumn(hListCtrl, 6, &column);
+
+       column.pszText = L"Type";
+       column.cx = 80;
+       (void)ListView_InsertColumn(hListCtrl, 7, &column);
+
+       HandleList_Update(hListCtrl, 0);
+}
+
+VOID
+HandleList_Update(HWND hHandleListCtrl, HANDLE ProcessId)
+{
+       INT i, index;
+       HANDLE handle;
+       PGDI_TABLE_ENTRY pEntry;
+       LVITEM item;
+       TCHAR strText[80];
+       TCHAR* str2;
+
+       (void)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 ( ((ProcessId != (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) != 0)) ||
+                    ((ProcessId == (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) == 0)) ||
+                     (ProcessId == (HANDLE)2) )
+               {
+                       if (ProcessId == (HANDLE)1 || ProcessId == (HANDLE)2 ||
+                           ((LONG)ProcessId & 0xfffc) == ((ULONG)pEntry->ProcessId & 0xfffc))
+                       {
+                               handle = GDI_HANDLE_CREATE(i, pEntry->Type);
+                               index = ListView_GetItemCount(hHandleListCtrl);
+                               item.iItem = index;
+                               item.iSubItem = 0;
+                               item.lParam = (LPARAM)handle;
+
+                               wsprintf(strText, L"%d", index);
+                               (void)ListView_InsertItem(hHandleListCtrl, &item);
+
+                               wsprintf(strText, L"%d", i);
+                               ListView_SetItemText(hHandleListCtrl, index, 1, strText);
+
+                               wsprintf(strText, L"%#08x", handle);
+                               ListView_SetItemText(hHandleListCtrl, index, 2, strText);
+
+                               str2 = GetTypeName(handle);
+                               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);
+
+                               wsprintf(strText, L"%#08x", (UINT)pEntry->Type);
+                               ListView_SetItemText(hHandleListCtrl, index, 7, strText);
+                       }
+               }
+       }
+}
+
+TCHAR*
+GetTypeName(HANDLE handle)
+{
+       TCHAR* strText;
+       UINT Type = GDI_HANDLE_GET_TYPE(handle);
+
+       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_PFE:
+                       strText = L"PFE";
+                       break;
+               case GDI_OBJECT_TYPE_DONTCARE:
+                       strText = L"anything";
+                       break;
+               case GDI_OBJECT_TYPE_SILENT:
+               default:
+                       strText = L"unknown";
+                       break;
+       }
+       return strText;
+}