From 000755de9d296ac3f85cdfc08bbac3b35945bbab Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 9 Aug 2003 07:09:57 +0000 Subject: [PATCH] This implements GetClassInfo It also implements GetClassInfoEx It also implements RealGetWindowClass as best as I can do it right now (i.e. I dont know exactly what makes it different from GetClassName so it just calls GetClassName) And it finishes GetClassName svn path=/trunk/; revision=5474 --- reactos/include/win32k/ntuser.h | 10 +-- reactos/lib/user32/windows/class.c | 107 ++++++++++++++++++-------- reactos/lib/user32/windows/window.c | 4 +- reactos/subsys/win32k/ntuser/class.c | 87 +++++++++++++++++---- reactos/subsys/win32k/ntuser/window.c | 4 +- reactos/tools/depend.mk | 5 +- 6 files changed, 161 insertions(+), 56 deletions(-) diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index 35819ff3b97..c399934b824 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -575,11 +575,11 @@ NtUserGetCaretPos( DWORD Unknown0); DWORD STDCALL -NtUserGetClassInfo(IN LPWSTR ClassName, - IN ULONG InfoClass, - OUT PVOID Info, - IN ULONG InfoLength, - OUT PULONG ReturnedLength); +NtUserGetClassInfo(HINSTANCE hInst, + LPCWSTR str, + LPWNDCLASSEXW wcex, + BOOL Ansi, + DWORD unknown3); DWORD STDCALL diff --git a/reactos/lib/user32/windows/class.c b/reactos/lib/user32/windows/class.c index 198d66a7a9d..6a66c1d8c33 100644 --- a/reactos/lib/user32/windows/class.c +++ b/reactos/lib/user32/windows/class.c @@ -1,4 +1,4 @@ -/* $Id: class.c,v 1.27 2003/08/08 02:57:54 royce Exp $ +/* $Id: class.c,v 1.28 2003/08/09 07:09:57 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -17,22 +17,7 @@ #include /* - * @unimplemented - */ -WINBOOL -STDCALL -GetClassInfoA( - HINSTANCE hInstance, - LPCSTR lpClassName, - LPWNDCLASSA lpWndClass) -{ - UNIMPLEMENTED; - return FALSE; -} - - -/* - * @unimplemented + * @implemented */ WINBOOL STDCALL @@ -41,13 +26,35 @@ GetClassInfoExA( LPCSTR lpszClass, LPWNDCLASSEXA lpwcx) { - UNIMPLEMENTED; - return FALSE; + LPWSTR str; + PUNICODE_STRING str2; + WNDCLASSEXW w; + BOOL retval; + NTSTATUS Status; + Status = HEAP_strdupAtoW (&str, lpszClass, NULL); + if ( !NT_SUCCESS (Status) ) + { + SetLastError (RtlNtStatusToDosError(Status)); + return 0; + } + retval = (BOOL)NtUserGetClassInfo(hinst,str,&w,TRUE,0); + if (str) + { + HEAP_free(str); + } + RtlCopyMemory (&w,lpwcx,sizeof(WNDCLASSEXW)); + if (!IS_INTRESOURCE(w.lpszMenuName)) + { + str = (LPWSTR)w.lpszMenuName; + str2 = (PUNICODE_STRING)str; + lpwcx->lpszMenuName = heap_string_poolA (str2->Buffer, str2->Length); + } + return retval; } /* - * @unimplemented + * @implemented */ WINBOOL STDCALL @@ -56,13 +63,46 @@ GetClassInfoExW( LPCWSTR lpszClass, LPWNDCLASSEXW lpwcx) { - UNIMPLEMENTED; - return FALSE; + LPWSTR str; + PUNICODE_STRING str2; + WNDCLASSEXW w; + WINBOOL retval; + str = HEAP_strdupW (lpszClass, wcslen(lpszClass) ); + retval = (BOOL)NtUserGetClassInfo(hinst,lpszClass,&w,FALSE,0); + if (str) + { + HEAP_free(str); + } + RtlCopyMemory (&w,lpwcx,sizeof(WNDCLASSEXW)); + if (!IS_INTRESOURCE(w.lpszMenuName) ) + { + str = (LPWSTR)w.lpszMenuName; + str2 = (PUNICODE_STRING)str; + lpwcx->lpszMenuName = heap_string_poolW (str2->Buffer, str2->Length); + } + return retval; } /* - * @unimplemented + * @implemented + */ +WINBOOL +STDCALL +GetClassInfoA( + HINSTANCE hInstance, + LPCSTR lpClassName, + LPWNDCLASSA lpWndClass) +{ + WNDCLASSEXA w; + WINBOOL retval; + retval = GetClassInfoExA(hInstance,lpClassName,&w); + RtlCopyMemory (lpWndClass,&w.style,sizeof(WNDCLASSA)); + return retval; +} + +/* + * @implemented */ WINBOOL STDCALL @@ -71,8 +111,11 @@ GetClassInfoW( LPCWSTR lpClassName, LPWNDCLASSW lpWndClass) { - UNIMPLEMENTED; - return FALSE; + WNDCLASSEXW w; + WINBOOL retval; + retval = GetClassInfoExW(hInstance,lpClassName,&w); + RtlCopyMemory (lpWndClass,&w.style,sizeof(WNDCLASSW)); + return retval; } @@ -224,22 +267,22 @@ GetWindowWord(HWND hWnd, int nIndex) } /* - * @unimplemented + * @implemented */ UINT STDCALL RealGetWindowClassW( HWND hwnd, - LPSTR pszType, + LPWSTR pszType, UINT cchType) { - UNIMPLEMENTED; - return 0; + /* FIXME: Implement correct functionality of RealGetWindowClass */ + return GetClassNameW(hwnd,pszType,cchType); } /* - * @unimplemented + * @implemented */ UINT STDCALL @@ -248,8 +291,8 @@ RealGetWindowClassA( LPSTR pszType, UINT cchType) { - UNIMPLEMENTED; - return 0; + /* FIXME: Implement correct functionality of RealGetWindowClass */ + return GetClassNameA(hwnd,pszType,cchType); } /* diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index a674f04d5a1..7534234edec 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.53 2003/08/08 02:57:54 royce Exp $ +/* $Id: window.c,v 1.54 2003/08/09 07:09:57 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -1318,7 +1318,7 @@ IsWindow(HWND hWnd) /* - * @unimplemented + * @implemented */ WINBOOL STDCALL IsWindowUnicode(HWND hWnd) diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c index 9d52fc2aa80..c9b76fd5c43 100644 --- a/reactos/subsys/win32k/ntuser/class.c +++ b/reactos/subsys/win32k/ntuser/class.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: class.c,v 1.25 2003/08/08 02:57:54 royce Exp $ +/* $Id: class.c,v 1.26 2003/08/09 07:09:57 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -151,14 +151,44 @@ ClassReferenceClassByNameOrAtom(PWNDCLASS_OBJECT *Class, } DWORD STDCALL -NtUserGetClassInfo(IN LPWSTR ClassName, - IN ULONG InfoClass, - OUT PVOID Info, - IN ULONG InfoLength, - OUT PULONG ReturnedLength) +NtUserGetClassInfo(HINSTANCE hInst, + LPCWSTR str, + LPWNDCLASSEXW wcex, + BOOL Ansi, + DWORD unknown3) { - UNIMPLEMENTED; - return(0); + PWNDCLASS_OBJECT Class; + NTSTATUS Status; + Status = ClassReferenceClassByNameOrAtom(&Class,(LPWSTR)str); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return 0; + } + if (Class->hInstance != hInst) + { + return 0; + } + wcex->cbSize = sizeof(LPWNDCLASSEXW); + wcex->style = Class->style; + if (Ansi) + { + wcex->lpfnWndProc = Class->lpfnWndProcA; + } + else + { + wcex->lpfnWndProc = Class->lpfnWndProcW; + } + wcex->cbClsExtra = Class->cbClsExtra; + wcex->cbWndExtra = Class->cbWndExtra; + wcex->hInstance = Class->hInstance; + wcex->hIcon = Class->hIcon; + wcex->hCursor = Class->hCursor; + wcex->hbrBackground = Class->hbrBackground; + wcex->lpszMenuName = (LPCWSTR)Class->lpszMenuName; + wcex->lpszClassName = (LPCWSTR)Class->lpszClassName; + wcex->hIconSm = Class->hIconSm; + return 1; } ULONG FASTCALL @@ -166,18 +196,43 @@ W32kGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName, int nMaxCount) { - int length; - LPCWSTR name; + ULONG length; + LPWSTR name; + BOOL free; + PWINSTATION_OBJECT WinStaObject; + NTSTATUS Status; if (IS_ATOM(WindowObject->Class->lpszClassName)) { - /* FIXME find the string from the atom */ - name = L"\0"; - length = wcslen(name); + DPRINT("About to open window station handle (0x%X)\n", + PROCESS_WINDOW_STATION()); + Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(), + KernelMode, + 0, + &WinStaObject); + if (!NT_SUCCESS(Status)) + { + DPRINT("Validation of window station handle (0x%X) failed\n", + PROCESS_WINDOW_STATION()); + return((RTL_ATOM)0); + } + length = 0; + Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,(RTL_ATOM)WindowObject->Class->lpszClassName,NULL,NULL,name,&length); + name = ExAllocatePool(PagedPool,length+1); + free = TRUE; + Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,(RTL_ATOM)WindowObject->Class->lpszClassName,NULL,NULL,name,&length); + if (!NT_SUCCESS(Status)) + { + DPRINT("Validation of window station handle (0x%X) failed\n", + PROCESS_WINDOW_STATION()); + return((RTL_ATOM)0); + } + ObDereferenceObject(WinStaObject); } else { name = WindowObject->Class->lpszClassName->Buffer; length = WindowObject->Class->lpszClassName->Length / sizeof(WCHAR); + free = FALSE; } if (length > nMaxCount) { @@ -185,6 +240,10 @@ W32kGetClassName(struct _WINDOW_OBJECT *WindowObject, } *(lpClassName+length) = 0; wcsncpy(lpClassName,name,length); + if (free) + { + ExFreePool(name); + } return length; } @@ -445,10 +504,12 @@ W32kSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL if (Ansi) { WindowObject->Class->lpfnWndProcA = (WNDPROC)dwNewLong; + WindowObject->Class->lpfnWndProcW = (WNDPROC)0xCCCCCCCC; } else { WindowObject->Class->lpfnWndProcW = (WNDPROC)dwNewLong; + WindowObject->Class->lpfnWndProcA = (WNDPROC)0xCCCCCCCC; } break; } diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 161b37cbf8c..3cac8ae8313 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.81 2003/08/08 02:57:54 royce Exp $ +/* $Id: window.c,v 1.82 2003/08/09 07:09:57 jimtabor Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1828,11 +1828,13 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { OldValue = (LONG) WindowObject->WndProcA; WindowObject->WndProcA = (WNDPROC) NewValue; + WindowObject->WndProcW = (WNDPROC)0xCCCCCCCC; } else { OldValue = (LONG) WindowObject->WndProcW; WindowObject->WndProcW = (WNDPROC) NewValue; + WindowObject->WndProcA = (WNDPROC)0xCCCCCCCC; } break; diff --git a/reactos/tools/depend.mk b/reactos/tools/depend.mk index 79850428e4f..cc9a6d88eaa 100644 --- a/reactos/tools/depend.mk +++ b/reactos/tools/depend.mk @@ -7,9 +7,8 @@ DEP_FILES := $(join $(dir $(DEP_FILTERED)), $(addprefix ., $(notdir $(DEP_FILTER # I (Andrew Greenwood) had to add this to compile under MinGW: -# SEP = / - - +SEP = / + ifneq ($(MAKECMDGOALS),clean) -include $(DEP_FILES) endif