From a55677b029b8189ae11db8190299fc8cd13a43bd Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Wed, 19 Nov 2003 12:25:03 +0000 Subject: [PATCH] 1. implemented GetGuiResources() 2. modified test app guithreadinfo to display additional information about the current process using GetGuiResources() svn path=/trunk/; revision=6705 --- .../apps/tests/guithreadinfo/guithreadinfo.c | 19 ++++-- reactos/include/defines.h | 4 ++ reactos/include/funcs.h | 7 +++ reactos/include/napi/win32.h | 2 + reactos/include/win32k/ntuser.h | 4 +- reactos/lib/user32/Makefile | 5 +- reactos/lib/user32/misc/stubs.c | 16 +---- reactos/subsys/win32k/ntuser/misc.c | 58 ++++++++++++++++++- reactos/subsys/win32k/ntuser/stubs.c | 13 +---- reactos/subsys/win32k/objects/gdiobj.c | 40 ++++++++++++- 10 files changed, 127 insertions(+), 41 deletions(-) diff --git a/reactos/apps/tests/guithreadinfo/guithreadinfo.c b/reactos/apps/tests/guithreadinfo/guithreadinfo.c index 466e4814ef1..8e8da78b0cf 100644 --- a/reactos/apps/tests/guithreadinfo/guithreadinfo.c +++ b/reactos/apps/tests/guithreadinfo/guithreadinfo.c @@ -92,20 +92,27 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE "); TextOut(hDC, 10, 10, str, strlen(str)); - wsprintf(str, "hwndActive == %04x", gti.hwndActive); + wsprintf(str, "hwndActive == %08X", gti.hwndActive); TextOut(hDC, 10, 30, str, strlen(str)); - wsprintf(str, "hwndFocus == %04x", gti.hwndFocus); + wsprintf(str, "hwndFocus == %08X", gti.hwndFocus); TextOut(hDC, 10, 50, str, strlen(str)); - wsprintf(str, "hwndCapture == %04x", gti.hwndCapture); + wsprintf(str, "hwndCapture == %08X", gti.hwndCapture); TextOut(hDC, 10, 70, str, strlen(str)); - wsprintf(str, "hwndMenuOwner == %04x", gti.hwndMenuOwner); + wsprintf(str, "hwndMenuOwner == %08X", gti.hwndMenuOwner); TextOut(hDC, 10, 90, str, strlen(str)); - wsprintf(str, "hwndMoveSize == %04x", gti.hwndMoveSize); + wsprintf(str, "hwndMoveSize == %08X", gti.hwndMoveSize); TextOut(hDC, 10, 110, str, strlen(str)); - wsprintf(str, "hwndCaret == %04x", gti.hwndCaret); + wsprintf(str, "hwndCaret == %08X", gti.hwndCaret); TextOut(hDC, 10, 130, str, strlen(str)); wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom); TextOut(hDC, 10, 150, str, strlen(str)); + + wsprintf(str, "GetGuiResources for the current process: %08X", GetCurrentProcess()); + TextOut(hDC, 10, 180, str, strlen(str)); + wsprintf(str, "GetGuiResources: GR_GDIOBJECTS == %04X", GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS)); + TextOut(hDC, 10, 200, str, strlen(str)); + wsprintf(str, "GetGuiResources: GR_USEROBJECTS == %04x", GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS)); + TextOut(hDC, 10, 220, str, strlen(str)); EndPaint(hWnd, &ps); break; diff --git a/reactos/include/defines.h b/reactos/include/defines.h index 7e7c8f00a25..c0d7b05b954 100644 --- a/reactos/include/defines.h +++ b/reactos/include/defines.h @@ -1569,6 +1569,10 @@ extern "C" { #define GM_COMPATIBLE (1) #define GM_ADVANCED (2) +/* GetGuiResources */ +#define GR_GDIOBJECTS (0) +#define GR_USEROBJECTS (1) + /* GetGUIThreadInfo */ #define GUI_CARETBLINKING (1) #define GUI_INMOVESIZE (2) diff --git a/reactos/include/funcs.h b/reactos/include/funcs.h index 912bef17460..31d8ca2aafe 100644 --- a/reactos/include/funcs.h +++ b/reactos/include/funcs.h @@ -9327,6 +9327,13 @@ GetWindowThreadProcessId( LPDWORD lpdwProcessId); +DWORD +STDCALL +GetGuiResources( + HANDLE hProcess, + DWORD uiFlags); + + WINBOOL STDCALL GetGUIThreadInfo( diff --git a/reactos/include/napi/win32.h b/reactos/include/napi/win32.h index e1c564acee5..843cb5cd27b 100644 --- a/reactos/include/napi/win32.h +++ b/reactos/include/napi/win32.h @@ -18,6 +18,8 @@ typedef struct _W32PROCESS LIST_ENTRY MenuListHead; struct _KBDTABLES* KeyboardLayout; struct _WINSTATION_OBJECT* WindowStation; + WORD GDIObjects; + WORD UserObjects; } W32PROCESS, *PW32PROCESS; PW32THREAD STDCALL diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index 1109b79f740..75d379f9b1e 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -694,8 +694,8 @@ NtUserGetForegroundWindow(VOID); DWORD STDCALL NtUserGetGuiResources( - DWORD Unknown0, - DWORD Unknown1); + HANDLE hProcess, + DWORD uiFlags); BOOL STDCALL diff --git a/reactos/lib/user32/Makefile b/reactos/lib/user32/Makefile index 18d0facbc37..983450fa06c 100644 --- a/reactos/lib/user32/Makefile +++ b/reactos/lib/user32/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.29 2003/11/07 19:13:01 sedwards Exp $ +# $Id: Makefile,v 1.30 2003/11/19 12:25:03 weiden Exp $ PATH_TO_TOP = ../.. @@ -50,7 +50,8 @@ MISC_OBJECTS = \ misc/resources.o \ misc/object.o \ misc/timer.o \ - misc/strpool.o + misc/strpool.o \ + misc/misc.o WINDOWS_OBJECTS = \ windows/caret.o \ diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index 1933b233935..dcfdcb9b5e8 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.50 2003/11/09 18:38:09 navaraf Exp $ +/* $Id: stubs.c,v 1.51 2003/11/19 12:25:03 weiden Exp $ * * COPYRIGHT: See COPYING WINBOOLthe top level directory * PROJECT: ReactOS user32.dll @@ -127,20 +127,6 @@ CopyImage( } -/* - * @unimplemented - */ -DWORD -STDCALL -GetGuiResources( - HANDLE hProcess, - DWORD uiFlags) -{ - UNIMPLEMENTED; - return 0; -} - - /* * @unimplemented */ diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index 6e279262251..3334e54d929 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.24 2003/11/18 23:33:31 weiden Exp $ +/* $Id: misc.c,v 1.25 2003/11/19 12:25:03 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -513,3 +513,59 @@ NtUserGetGUIThreadInfo( return TRUE; } + +DWORD +STDCALL +NtUserGetGuiResources( + HANDLE hProcess, + DWORD uiFlags) +{ + PEPROCESS Process; + PW32PROCESS W32Process; + NTSTATUS Status; + DWORD Ret = 0; + + Status = ObReferenceObjectByHandle(hProcess, + PROCESS_QUERY_INFORMATION, + PsProcessType, + ExGetPreviousMode(), + (PVOID*)&Process, + NULL); + + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return 0; + } + + W32Process = Process->Win32Process; + if(!W32Process) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return 0; + } + + switch(uiFlags) + { + case GR_GDIOBJECTS: + { + Ret = (DWORD)W32Process->GDIObjects; + break; + } + case GR_USEROBJECTS: + { + Ret = (DWORD)W32Process->UserObjects; + break; + } + default: + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + break; + } + } + + ObDereferenceObject(Process); + + return Ret; +} + diff --git a/reactos/subsys/win32k/ntuser/stubs.c b/reactos/subsys/win32k/ntuser/stubs.c index 9982a924831..7238b9c24ae 100644 --- a/reactos/subsys/win32k/ntuser/stubs.c +++ b/reactos/subsys/win32k/ntuser/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.36 2003/11/18 23:33:31 weiden Exp $ +/* $Id: stubs.c,v 1.37 2003/11/19 12:25:03 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -525,17 +525,6 @@ NtUserGetCPD( return 0; } -DWORD -STDCALL -NtUserGetGuiResources( - DWORD Unknown0, - DWORD Unknown1) -{ - UNIMPLEMENTED - - return 0; -} - DWORD STDCALL NtUserGetImeHotKey( diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index 226669cf668..385cbb37412 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.49 2003/11/08 14:58:34 gvg Exp $ + * $Id: gdiobj.c,v 1.50 2003/11/19 12:25:03 weiden Exp $ * */ @@ -237,6 +237,7 @@ GDIOBJ_iGetNextOpenHandleIndex (void) HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) { + PW32PROCESS W32Process; PGDIOBJHDR newObject; WORD Index; @@ -265,6 +266,12 @@ GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) newObject->lockfile = NULL; newObject->lockline = 0; HandleTable->Handles[Index] = newObject; + + W32Process = PsGetCurrentProcess()->Win32Process; + if(W32Process) + { + W32Process->GDIObjects++; + } return GDI_HANDLE_CREATE(Index, ObjectType); } @@ -287,6 +294,7 @@ GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) BOOL STDCALL GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType, DWORD Flag) { + PW32PROCESS W32Process; PGDIOBJHDR objectHeader; PGDIOBJ Obj; BOOL bRet = TRUE; @@ -327,6 +335,12 @@ GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType, DWORD Flag) ExFreePool(objectHeader); HandleTable->Handles[GDI_HANDLE_GET_INDEX(hObj)] = NULL; + + W32Process = PsGetCurrentProcess()->Win32Process; + if(W32Process) + { + W32Process->GDIObjects--; + } return bRet; } @@ -420,6 +434,9 @@ GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj) VOID FASTCALL GDIOBJ_MarkObjectGlobal(HGDIOBJ ObjectHandle) { + PEPROCESS Process; + PW32PROCESS W32Process; + NTSTATUS Status; PGDIOBJHDR ObjHdr; DPRINT("GDIOBJ_MarkObjectGlobal handle 0x%08x\n", ObjectHandle); @@ -428,7 +445,17 @@ GDIOBJ_MarkObjectGlobal(HGDIOBJ ObjectHandle) { return; } - + + Status = PsLookupProcessByProcessId((PVOID)ObjHdr->hProcessId, &Process); + if(NT_SUCCESS(Status)) + { + W32Process = Process->Win32Process; + if(W32Process) + { + W32Process->GDIObjects--; + } + } + ObjHdr->hProcessId = GDI_GLOBAL_PROCESS; } @@ -442,6 +469,7 @@ GDIOBJ_MarkObjectGlobal(HGDIOBJ ObjectHandle) VOID FASTCALL GDIOBJ_UnmarkObjectGlobal(HGDIOBJ ObjectHandle) { + PW32PROCESS W32Process; PGDIOBJHDR ObjHdr; DPRINT("GDIOBJ_MarkObjectGlobal handle 0x%08x\n", ObjectHandle); @@ -450,7 +478,13 @@ GDIOBJ_UnmarkObjectGlobal(HGDIOBJ ObjectHandle) { return; } - + + W32Process = PsGetCurrentProcess()->Win32Process; + if(W32Process) + { + W32Process->GDIObjects++; + } + ObjHdr->hProcessId = PsGetCurrentProcessId(); }