Author: tkreuzer Date: Fri Sep 28 02:29:26 2007 New Revision: 29261
URL: http://svn.reactos.org/svn/reactos?rev=29261&view=rev Log: gdihv: - add base type mask - change my email - add deleted entries - full row selection
Modified: trunk/rosapps/devutils/gdihv/gdi.h trunk/rosapps/devutils/gdihv/gdihv.c trunk/rosapps/devutils/gdihv/gdihv.rc trunk/rosapps/devutils/gdihv/handlelist.c trunk/rosapps/devutils/gdihv/mainwnd.c trunk/rosapps/devutils/gdihv/mainwnd.h trunk/rosapps/devutils/gdihv/proclist.c
Modified: trunk/rosapps/devutils/gdihv/gdi.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/devutils/gdihv/gdi.h?rev=29... ============================================================================== --- trunk/rosapps/devutils/gdihv/gdi.h (original) +++ trunk/rosapps/devutils/gdihv/gdi.h Fri Sep 28 02:29:26 2007 @@ -9,12 +9,13 @@ typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void);
/* GDI handle table can hold 0x4000 handles */ -#define GDI_HANDLE_COUNT 0x4000 +#define GDI_HANDLE_COUNT 0x10000 #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_BASETYPE_MASK 0x001f0000 #define GDI_HANDLE_STOCK_MASK 0x00800000 #define GDI_HANDLE_REUSE_MASK 0xff000000 #define GDI_HANDLE_REUSECNT_SHIFT 24
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/gdihv.c Fri Sep 28 02:29:26 2007 @@ -3,7 +3,7 @@ * * gdihv.c * - * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> web.de> + * 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
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/gdihv.rc Fri Sep 28 02:29:26 2007 @@ -14,5 +14,3 @@ PUSHBUTTON "Refresh processes", IDC_REFRESHPROCESS, 50, 230, 80, 14, WS_CLIPSIBLINGS | WS_TABSTOP
END - -
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/handlelist.c Fri Sep 28 02:29:26 2007 @@ -3,7 +3,7 @@ * * handlelist.c * - * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> web.de> + * 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 @@ -71,7 +71,7 @@ INT i, index; HANDLE handle; PGDI_TABLE_ENTRY pEntry; - LV_ITEM item; + LVITEM item; TCHAR strText[80]; TCHAR* str2;
@@ -82,13 +82,17 @@ for (i = 0; i<= GDI_HANDLE_COUNT; i++) { pEntry = &GdiHandleTable[i]; - if (pEntry->KernelData) + if ( ((ProcessId != (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) != 0)) || + ((ProcessId == (HANDLE)1) && ((pEntry->Type & GDI_HANDLE_BASETYPE_MASK) == 0)) ) { - if (ProcessId == (HANDLE)-1 || ProcessId == pEntry->ProcessId) + if (ProcessId == (HANDLE)1 || + ProcessId == (HANDLE)((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); @@ -96,7 +100,6 @@ wsprintf(strText, L"%d", i); ListView_SetItemText(hHandleListCtrl, index, 1, strText);
- handle = GDI_HANDLE_CREATE(i, pEntry->Type); wsprintf(strText, L"%#08x", handle); ListView_SetItemText(hHandleListCtrl, index, 2, strText);
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/mainwnd.c Fri Sep 28 02:29:26 2007 @@ -3,7 +3,7 @@ * * mainwnd.c * - * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> web.de> + * 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 @@ -24,6 +24,59 @@
INT g_Separator;
+ +static LRESULT +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 0; +} + + +static LRESULT +MainWnd_OnNotify(HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + LPNMHDR pnmh = (LPNMHDR)lParam; + + switch(pnmh->code) + { + case LVN_ITEMCHANGED: + { + LPNMLISTVIEW pnmlv = (LPNMLISTVIEW)pnmh; + if ((wParam == IDC_PROCESSLIST) + && (pnmlv->uNewState & LVIS_SELECTED) + && !(pnmlv->uOldState & LVIS_SELECTED)) + { + LV_ITEM item; + memset(&item, 0, sizeof(LV_ITEM)); + item.mask = LVIF_PARAM; + item.iItem = pnmlv->iItem; + (void)ListView_GetItem(GetDlgItem(hWnd, IDC_PROCESSLIST), &item); + HandleList_Update(GetDlgItem(hWnd, IDC_HANDLELIST), (HANDLE)item.lParam); + return TRUE; + } + break; + } + } + + return 0; +} + INT_PTR CALLBACK MainWindow_WndProc(HWND hMainWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -34,6 +87,8 @@ RECT rect;
SendMessage(hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAIN))); + (void)ListView_SetExtendedListViewStyle(GetDlgItem(hMainWnd, IDC_PROCESSLIST), LVS_EX_FULLROWSELECT); + (void)ListView_SetExtendedListViewStyle(GetDlgItem(hMainWnd, IDC_HANDLELIST), LVS_EX_FULLROWSELECT); GetClientRect(hMainWnd, &rect); g_Separator = (rect.right / 2); HandleList_Create(GetDlgItem(hMainWnd, IDC_HANDLELIST)); @@ -43,10 +98,8 @@ break; } case WM_SIZE: - { - MainWindow_OnSize(hMainWnd); - break; - } + return MainWindow_OnSize(hMainWnd); + case WM_COMMAND: { switch (LOWORD(wParam)) @@ -80,23 +133,10 @@ } break; } + case WM_NOTIFY: - { - if (((LPNMLISTVIEW)lParam)->hdr.code == LVN_ITEMCHANGED - && (wParam == IDC_PROCESSLIST) - && (((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; - (void)ListView_GetItem(GetDlgItem(hMainWnd, IDC_PROCESSLIST), &item); - HandleList_Update(GetDlgItem(hMainWnd, IDC_HANDLELIST), (HANDLE)item.lParam); - return TRUE; - break; - } - } + return MainWnd_OnNotify(hMainWnd, wParam, lParam); + default: { return FALSE; @@ -105,23 +145,3 @@ 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; -}
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/mainwnd.h Fri Sep 28 02:29:26 2007 @@ -1,3 +1,2 @@
INT_PTR CALLBACK MainWindow_WndProc(HWND, UINT, WPARAM, LPARAM); -VOID MainWindow_OnSize(HWND hMainWnd);
Modified: 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 (original) +++ trunk/rosapps/devutils/gdihv/proclist.c Fri Sep 28 02:29:26 2007 @@ -3,7 +3,7 @@ * * proclist.c * - * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> web.de> + * 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 @@ -44,7 +44,8 @@ ProcessList_Update(HWND hListCtrl) { LV_ITEM item; - DWORD ProcessIds[1024], BytesReturned, cProcesses; + DWORD ProcessIds[1024], BytesReturned; + UINT cProcesses; HANDLE hProcess; WCHAR strText[MAX_PATH] = L"<unknown>"; INT i; @@ -63,12 +64,21 @@ wsprintf(strText, L"%#08x", 0); ListView_SetItemText(hListCtrl, 0, 1, strText);
+ /* Insert "deleted" */ + item.iItem = 1; + item.lParam = 1; + item.pszText = L"<deleted>"; + (void)ListView_InsertItem(hListCtrl, &item); + item.pszText = strText; + wsprintf(strText, L"%#08x",1); + ListView_SetItemText(hListCtrl, 1, 1, strText); + if (!EnumProcesses(ProcessIds, sizeof(ProcessIds), &BytesReturned )) { return; } cProcesses = BytesReturned / sizeof(DWORD); - if (cProcesses == 0) + if (cProcesses <= 1) { return; } @@ -80,7 +90,7 @@
hProcess = 0; /* FIXME: HACK: ROS crashes when using OpenProcess with PROCESS_VM_READ */ -// hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessIds[i]); + hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessIds[i]); if (hProcess) { GetModuleBaseName(hProcess, NULL, (LPWSTR)strText, MAX_PATH );