Modified: trunk/reactos/include/ndk/rtltypes.h
Modified: trunk/reactos/include/win32k/ntuser.h
Modified: trunk/reactos/lib/crt/include/internal/file.h
Modified: trunk/reactos/lib/rtl/atom.c
Modified: trunk/reactos/lib/user32/windows/caret.c
Modified: trunk/reactos/lib/user32/windows/class.c
Modified: trunk/reactos/lib/user32/windows/paint.c
Modified: trunk/reactos/lib/user32/windows/window.c
Modified: trunk/reactos/ntoskrnl/rtl/atom.c
Modified: trunk/reactos/subsys/win32k/include/class.h
Modified: trunk/reactos/subsys/win32k/include/desktop.h
Modified: trunk/reactos/subsys/win32k/include/win32.h
Modified: trunk/reactos/subsys/win32k/include/window.h
Modified: trunk/reactos/subsys/win32k/main/dllmain.c
Modified: trunk/reactos/subsys/win32k/ntuser/caret.c
Modified: trunk/reactos/subsys/win32k/ntuser/class.c
Modified: trunk/reactos/subsys/win32k/ntuser/cursoricon.c
Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c
Modified: trunk/reactos/subsys/win32k/ntuser/misc.c
Modified: trunk/reactos/subsys/win32k/ntuser/painting.c
Modified: trunk/reactos/subsys/win32k/ntuser/window.c
Modified: trunk/reactos/subsys/win32k/ntuser/winsta.c
Modified: trunk/reactos/tools/nci/w32ksvc.db
--- trunk/reactos/include/ndk/rtltypes.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/include/ndk/rtltypes.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -107,6 +107,8 @@
#define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo
+#define MAX_ATOM_LEN 255 /* TCHARS not including nullterm */
+
/* List Macros */
static __inline
VOID
--- trunk/reactos/include/win32k/ntuser.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/include/win32k/ntuser.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -212,7 +212,6 @@
#define TWOPARAM_ROUTINE_UNKNOWN 0x54
#define TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS 0x55
#define TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW 0x56
-#define TWOPARAM_ROUTINE_VALIDATERGN 0x57
#define TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID 0x58
#define TWOPARAM_ROUTINE_SETCARETPOS 0x60
#define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61
@@ -894,11 +893,6 @@
DWORD Unknown0,
DWORD Unknown1);
-BOOL
-STDCALL
-NtUserHideCaret(
- HWND hWnd);
-
DWORD
STDCALL
NtUserImpersonateDdeClientWindow(
@@ -935,21 +929,7 @@
LPWSTR lpString,
INT nMaxCount);
-DWORD
-STDCALL
-NtUserInvalidateRect(
-HWND hWnd,
-CONST RECT *lpRect,
-BOOL bErase);
-DWORD
-STDCALL
- NtUserInvalidateRgn(
- HWND hWnd,
- HRGN hRgn,
- BOOL bErase);
-
-
BOOL
STDCALL
NtUserIsClipboardFormatAvailable(
@@ -1575,7 +1555,8 @@
BOOL
STDCALL
NtUserShowCaret(
- HWND hWnd);
+ HWND hWnd,
+ BOOL bShow);
DWORD
STDCALL
@@ -1681,9 +1662,6 @@
DWORD Unknown1,
DWORD Unknown2);
-BOOL STDCALL
-NtUserUpdateWindow( HWND hWnd );
-
DWORD
STDCALL
NtUserUpdateLayeredWindow(
@@ -1715,10 +1693,6 @@
NtUserValidateHandleSecure(
DWORD Unknown0);
-VOID STDCALL
-NtUserValidateRect(HWND Wnd, const RECT* Rect);
-
-
DWORD
STDCALL
NtUserVkKeyScanEx(
--- trunk/reactos/lib/crt/include/internal/file.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/crt/include/internal/file.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -102,7 +102,7 @@
#define fdinfo_bucket_idx(i) ((i) >> FDINFO_ENTRIES_PER_BUCKET_SHIFT)
/* get position inside a bucket (0-31) from an fd */
#define fdinfo_bucket_entry_idx(i) ((i) & (FDINFO_ENTRIES_PER_BUCKET - 1))
-/* get bucket ptr. (ptr. to fist fdinfo inside a bucket) from an fd */
+/* get bucket ptr. (ptr. to first fdinfo inside a bucket) from an fd */
#define fdinfo_bucket(i) ( __pioinfo[fdinfo_bucket_idx(i)])
/* get fdinfo ptr. from an fd */
#define fdinfo(i) (fdinfo_bucket(i) + fdinfo_bucket_entry_idx(i))
--- trunk/reactos/lib/rtl/atom.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/rtl/atom.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -347,6 +347,12 @@
if (HashLink != NULL)
{
ULONG AtomNameLen = wcslen(AtomName);
+
+ if (AtomNameLen > MAX_ATOM_LEN)
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ goto end;
+ }
Entry = RtlpAllocAtomTableEntry(sizeof(RTL_ATOM_TABLE_ENTRY) -
sizeof(Entry->Name) +
@@ -390,7 +396,7 @@
Status = STATUS_OBJECT_NAME_INVALID;
}
}
-
+end:
RtlpUnlockAtomTable(AtomTable);
return Status;
@@ -592,6 +598,8 @@
PULONG NameLength)
{
ULONG Length;
+ BOOL Unlock = FALSE;
+
union
{
/* A RTL_ATOM_TABLE_ENTRY has a "WCHAR Name[1]" entry at the end.
@@ -616,6 +624,7 @@
else
{
RtlpLockAtomTable(AtomTable);
+ Unlock = TRUE;
Entry = RtlpGetAtomEntry(AtomTable,
(ULONG)((USHORT)Atom - 0xC000));
@@ -676,10 +685,7 @@
Status = STATUS_INVALID_HANDLE;
}
- if (NULL != Entry && Entry != &NumberEntry.AtomTableEntry)
- {
- RtlpUnlockAtomTable(AtomTable);
- }
+ if (Unlock) RtlpUnlockAtomTable(AtomTable);
return Status;
}
--- trunk/reactos/lib/user32/windows/caret.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/user32/windows/caret.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -108,7 +108,7 @@
BOOL STDCALL
HideCaret(HWND hWnd)
{
- return (BOOL)NtUserHideCaret(hWnd);
+ return NtUserShowCaret(hWnd, FALSE);
}
@@ -139,7 +139,7 @@
BOOL STDCALL
ShowCaret(HWND hWnd)
{
- return (BOOL)NtUserShowCaret(hWnd);
+ return NtUserShowCaret(hWnd, TRUE);
}
/* EOF */
--- trunk/reactos/lib/user32/windows/class.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/user32/windows/class.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -87,7 +87,14 @@
w.lpszMenuName = (LPCWSTR)&str2;
w.lpszClassName = (LPCWSTR)&str3;
+
+ /* get info about system classes? */
+ if (!hInst) hInst = User32Instance;
+
retval = (BOOL)NtUserGetClassInfo(hInst, str, &w, TRUE, 0);
+
+ w.hInstance = (hInst == User32Instance) ? 0 : hInst;
+
if ( !IS_ATOM(str) )
HEAP_free(str);
--- trunk/reactos/lib/user32/windows/paint.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/user32/windows/paint.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -157,7 +157,7 @@
CONST RECT *lpRect,
BOOL bErase)
{
- return NtUserInvalidateRect( hWnd, lpRect, bErase );
+ return RedrawWindow( hWnd, lpRect, 0, RDW_INVALIDATE | (bErase ? RDW_ERASE : 0) );
}
@@ -171,7 +171,7 @@
HRGN hRgn,
BOOL bErase)
{
- return NtUserInvalidateRgn( hWnd, hRgn, bErase );
+ return RedrawWindow(hWnd, NULL, hRgn, RDW_INVALIDATE | (bErase ? RDW_ERASE : 0) );
}
@@ -224,7 +224,7 @@
UpdateWindow(
HWND hWnd)
{
- return NtUserUpdateWindow( hWnd );
+ return RedrawWindow( hWnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
}
@@ -237,6 +237,8 @@
HWND hWnd,
CONST RECT *lpRect)
{
+ /* FIXME: should RDW_NOCHILDREN be included too? Ros used to,
+ but Wine dont so i removed it... */
return RedrawWindow(hWnd, lpRect, 0, RDW_VALIDATE);
}
@@ -250,7 +252,9 @@
HWND hWnd,
HRGN hRgn)
{
- return NtUserValidateRgn(hWnd, hRgn);
+ /* FIXME: should RDW_NOCHILDREN be included too? Ros used to,
+ but Wine dont so i removed it... */
+ return RedrawWindow( hWnd, NULL, hRgn, RDW_VALIDATE );
}
--- trunk/reactos/lib/user32/windows/window.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/lib/user32/windows/window.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -221,7 +221,7 @@
nHeight,
hWndParent,
hMenu,
- hInstance,
+ hInstance,
lpParam,
SW_SHOW,
FALSE);
@@ -304,7 +304,7 @@
nHeight,
hWndParent,
hMenu,
- hInstance,
+ hInstance,
lpParam,
SW_SHOW,
TRUE);
--- trunk/reactos/ntoskrnl/rtl/atom.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/ntoskrnl/rtl/atom.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -14,6 +14,7 @@
#define NDEBUG
#include <internal/debug.h>
+
/* PROTOTYPES ****************************************************************/
static PRTL_ATOM_TABLE RtlpGetGlobalAtomTable(VOID);
@@ -38,6 +39,12 @@
/* GLOBALS *******************************************************************/
+/* FIXME: this is WRONG! The global atom table should live in the WinSta struct
+ * and accessed thru win32k callouts.
+ * NOTE: There is a session/win32k global atom table also, but its private to
+ * win32k. Its used for RegisterWindowMessage() and for window classes.
+ * -Gunnar
+ */
static PRTL_ATOM_TABLE GlobalAtomTable = NULL;
/* FUNCTIONS *****************************************************************/
--- trunk/reactos/subsys/win32k/include/class.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/include/class.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -7,6 +7,7 @@
typedef struct _WNDCLASS_OBJECT
{
UINT cbSize;
+ LONG refs; /* windows using this class (is 0 after class creation) */
UINT style;
WNDPROC lpfnWndProcA;
WNDPROC lpfnWndProcW;
@@ -21,10 +22,8 @@
HICON hIconSm;
BOOL Unicode;
BOOL Global;
- LIST_ENTRY ListEntry;
+ LIST_ENTRY ListEntry; /* linked into owning process */
PCHAR ExtraData;
- /* list of windows */
- LIST_ENTRY ClassWindowsListHead;
} WNDCLASS_OBJECT, *PWNDCLASS_OBJECT;
NTSTATUS FASTCALL
@@ -33,24 +32,26 @@
NTSTATUS FASTCALL
CleanupClassImpl(VOID);
-#define ClassDereferenceObject(ClassObj) \
- ObmDereferenceObject(ClassObj)
+void FASTCALL DestroyProcessClasses(PW32PROCESS Process );
-BOOL FASTCALL
-ClassReferenceClassByAtom(
- PWNDCLASS_OBJECT* Class,
+inline VOID FASTCALL
+ClassDerefObject(PWNDCLASS_OBJECT Class);
+
+inline VOID FASTCALL
+ClassRefObject(PWNDCLASS_OBJECT Class);
+
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByAtom(
RTL_ATOM Atom,
HINSTANCE hInstance);
-BOOL FASTCALL
-ClassReferenceClassByName(
- PWNDCLASS_OBJECT *Class,
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByName(
LPCWSTR ClassName,
HINSTANCE hInstance);
-BOOL FASTCALL
-ClassReferenceClassByNameOrAtom(
- PWNDCLASS_OBJECT *Class,
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByNameOrAtom(
LPCWSTR ClassNameOrAtom,
HINSTANCE hInstance);
--- trunk/reactos/subsys/win32k/include/desktop.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/include/desktop.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -11,7 +11,7 @@
CSHORT Type;
CSHORT Size;
LIST_ENTRY ListEntry;
- KSPIN_LOCK Lock;
+
UNICODE_STRING Name;
/* Pointer to the associated window station. */
struct _WINSTATION_OBJECT *WindowStation;
--- trunk/reactos/subsys/win32k/include/win32.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/include/win32.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -22,7 +22,7 @@
typedef struct _W32PROCESS
{
- LIST_ENTRY ClassListHead;
+ LIST_ENTRY ClassList;
LIST_ENTRY MenuListHead;
FAST_MUTEX PrivateFontListLock;
LIST_ENTRY PrivateFontListHead;
--- trunk/reactos/subsys/win32k/include/window.h 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/include/window.h 2005-09-24 02:50:02 UTC (rev 18022)
@@ -28,8 +28,6 @@
{
/* Pointer to the window class. */
PWNDCLASS_OBJECT Class;
- /* entry in the window list of the class object */
- LIST_ENTRY ClassListEntry;
/* Extended style. */
DWORD ExStyle;
/* Window name. */
--- trunk/reactos/subsys/win32k/main/dllmain.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/main/dllmain.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -70,7 +70,7 @@
{
DPRINT("Creating W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
- InitializeListHead(&Win32Process->ClassListHead);
+ InitializeListHead(&Win32Process->ClassList);
InitializeListHead(&Win32Process->MenuListHead);
@@ -99,8 +99,10 @@
IntCleanupCurIcons(Process, Win32Process);
IntEngCleanupDriverObjs(Process, Win32Process);
CleanupMonitorImpl();
+
+ /* no process windows should exist at this point, or the function will assert! */
+ DestroyProcessClasses(Win32Process);
-
GDI_CleanupForProcess(Process);
co_IntGraphicsCheck(FALSE);
--- trunk/reactos/subsys/win32k/ntuser/caret.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/ntuser/caret.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -9,17 +9,24 @@
* 10/15/2003 Created
*/
+/* INCLUDES ******************************************************************/
+
#include <w32k.h>
#define NDEBUG
#include <debug.h>
+/* DEFINES *****************************************************************/
+
#define MIN_CARETBLINKRATE 100
#define MAX_CARETBLINKRATE 10000
#define DEFAULT_CARETBLINKRATE 530
#define CARET_REGKEY L"\\Registry\\User\\.Default\\Control Panel\\Desktop"
#define CARET_VALUENAME L"CursorBlinkRate"
+/* FUNCTIONS *****************************************************************/
+
+static
BOOL FASTCALL
co_IntHideCaret(PTHRDCARETINFO CaretInfo)
{
@@ -69,6 +76,7 @@
return TRUE;
}
+static
UINT FASTCALL
IntQueryCaretBlinkRate(VOID)
{
@@ -134,6 +142,7 @@
return (UINT)Val;
}
+static
UINT FASTCALL
IntGetCaretBlinkTime(VOID)
{
@@ -158,6 +167,7 @@
return Ret;
}
+
BOOL FASTCALL
co_IntSetCaretPos(int X, int Y)
{
@@ -197,6 +207,8 @@
return FALSE;
}
+#if 0 //unused
+static
VOID FASTCALL
co_IntDrawCaret(HWND hWnd)
{
@@ -210,9 +222,79 @@
ThreadQueue->CaretInfo->Showing = 1;
}
}
+#endif
+BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL)
+{
+ PUSER_MESSAGE_QUEUE ThreadQueue;
+
+ if (Window) ASSERT_REFS_CO(Window);
+
+ if(Window && Window->OwnerThread != PsGetCurrentThread())
+ {
+ SetLastWin32Error(ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+ ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+ if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
+ {
+ SetLastWin32Error(ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+ if(ThreadQueue->CaretInfo->Visible)
+ {
+ IntKillTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, TRUE);
+
+ co_IntHideCaret(ThreadQueue->CaretInfo);
+ ThreadQueue->CaretInfo->Visible = 0;
+ ThreadQueue->CaretInfo->Showing = 0;
+ }
+
+ return TRUE;
+}
+
+
+BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL)
+{
+ PUSER_MESSAGE_QUEUE ThreadQueue;
+
+ if (Window) ASSERT_REFS_CO(Window);
+
+ if(Window && Window->OwnerThread != PsGetCurrentThread())
+ {
+ SetLastWin32Error(ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+ ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
+
+ if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
+ {
+ SetLastWin32Error(ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+
+ if(!ThreadQueue->CaretInfo->Visible)
+ {
+ ThreadQueue->CaretInfo->Visible = 1;
+ if(!ThreadQueue->CaretInfo->Showing)
+ {
+ co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
+ }
+ IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
+ }
+
+ return TRUE;
+}
+
+
+/* SYSCALLS *****************************************************************/
+
BOOL
STDCALL
NtUserCreateCaret(
@@ -317,110 +399,15 @@
}
-BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL)
-{
- PUSER_MESSAGE_QUEUE ThreadQueue;
- if (Window) ASSERT_REFS_CO(Window);
-
- if(Window && Window->OwnerThread != PsGetCurrentThread())
- {
- SetLastWin32Error(ERROR_ACCESS_DENIED);
- return FALSE;
- }
-
- ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
- if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
- {
- SetLastWin32Error(ERROR_ACCESS_DENIED);
- return FALSE;
- }
-
- if(ThreadQueue->CaretInfo->Visible)
- {
- IntKillTimer((Window ? Window->hSelf : 0), IDCARETTIMER, TRUE);
-
- co_IntHideCaret(ThreadQueue->CaretInfo);
- ThreadQueue->CaretInfo->Visible = 0;
- ThreadQueue->CaretInfo->Showing = 0;
- }
-
- return TRUE;
-}
-
-
BOOL
STDCALL
-NtUserHideCaret(HWND hWnd OPTIONAL)
+NtUserShowCaret(HWND hWnd OPTIONAL, BOOL bShow)
{
PWINDOW_OBJECT Window = NULL;
DECLARE_RETURN(BOOL);
BOOL ret;
- DPRINT("Enter NtUserHideCaret\n");
- UserEnterExclusive();
-
- if(hWnd && !(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(FALSE);
- }
-
- if (Window) UserRefObjectCo(Window);
- ret = co_UserHideCaret(Window);
- if (Window) UserDerefObjectCo(Window);
-
- RETURN(ret);
-
-CLEANUP:
- DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
-BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL)
-{
- PUSER_MESSAGE_QUEUE ThreadQueue;
-
- if (Window) ASSERT_REFS_CO(Window);
-
- if(Window && Window->OwnerThread != PsGetCurrentThread())
- {
- SetLastWin32Error(ERROR_ACCESS_DENIED);
- return FALSE;
- }
-
- ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
-
- if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
- {
- SetLastWin32Error(ERROR_ACCESS_DENIED);
- return FALSE;
- }
-
- if(!ThreadQueue->CaretInfo->Visible)
- {
- ThreadQueue->CaretInfo->Visible = 1;
- if(!ThreadQueue->CaretInfo->Showing)
- {
- co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
- }
- IntSetTimer((Window ? Window->hSelf : 0), IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
- }
-
- return TRUE;
-}
-
-
-BOOL
-STDCALL
-NtUserShowCaret(HWND hWnd OPTIONAL)
-{
- PWINDOW_OBJECT Window = NULL;
- DECLARE_RETURN(BOOL);
- BOOL ret;
-
DPRINT("Enter NtUserShowCaret\n");
UserEnterExclusive();
@@ -430,7 +417,12 @@
}
if (Window) UserRefObjectCo(Window);
- ret = co_UserShowCaret(Window);
+
+ if (bShow)
+ ret = co_UserShowCaret(Window);
+ else
+ ret = co_UserHideCaret(Window);
+
if (Window) UserDerefObjectCo(Window);
RETURN(ret);
--- trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-23 21:46:54 UTC (rev 18021)
+++ trunk/reactos/subsys/win32k/ntuser/class.c 2005-09-24 02:50:02 UTC (rev 18022)
@@ -47,434 +47,222 @@
return(STATUS_SUCCESS);
}
-BOOL FASTCALL
-ClassReferenceClassByAtom(
- PWNDCLASS_OBJECT* Class,
- RTL_ATOM Atom,
- HINSTANCE hInstance)
+
+/* return TRUE if class became destroyed */
+inline VOID FASTCALL
+ClassDerefObject(PWNDCLASS_OBJECT Class)
{
- PWNDCLASS_OBJECT Current, BestMatch = NULL;
- PLIST_ENTRY CurrentEntry;
- PW32PROCESS Process = PsGetWin32Process();
+ ASSERT(Class->refs >= 1);
+ Class->refs--;
+}
- CurrentEntry = Process->ClassListHead.Flink;
- while (CurrentEntry != &Process->ClassListHead)
- {
- Current = CONTAINING_RECORD(CurrentEntry, WNDCLASS_OBJECT, ListEntry);
- if (Current->Atom == Atom && (hInstance == NULL || Current->hInstance == hInstance))
- {
- *Class = Current;
- ObmReferenceObject(Current);
- return TRUE;
- }
+inline VOID FASTCALL
+ClassRefObject(PWNDCLASS_OBJECT Class)
+{
+ ASSERT(Class->refs >= 0);
+ Class->refs++;
+}
- if (Current->Atom == Atom && Current->Global)
- BestMatch = Current;
- CurrentEntry = CurrentEntry->Flink;
- }
+VOID FASTCALL DestroyClass(PWNDCLASS_OBJECT Class)
+{
+ PWINSTATION_OBJECT WinSta;
+ WinSta = PsGetWin32Thread()->Desktop->WindowStation;
+
+ ASSERT(Class->refs == 0);
+ RemoveEntryList(&Class->ListEntry);
+ //FIXME: release ATOM
+ RtlDeleteAtomFromAtomTable(WinSta->AtomTable, Class->Atom);
+ ExFreePool(Class);
+}
- if (BestMatch != NULL)
- {
- *Class = BestMatch;
- ObmReferenceObject(BestMatch);
- return TRUE;
- }
- return FALSE;
-}
-
-BOOL FASTCALL
-ClassReferenceClassByName(
- PWNDCLASS_OBJECT *Class,
- LPCWSTR ClassName,
- HINSTANCE hInstance)
+/* clean all process classes. all process windows must cleaned first!! */
+void FASTCALL DestroyProcessClasses(PW32PROCESS Process )
{
- PWINSTATION_OBJECT WinStaObject;
- NTSTATUS Status;
- BOOL Found;
- RTL_ATOM ClassAtom;
+ PWNDCLASS_OBJECT Class;
- if (!ClassName || !PsGetWin32Thread()->Desktop)
- return FALSE;
-
- WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
-
- Status = RtlLookupAtomInAtomTable(
- WinStaObject->AtomTable,
- (LPWSTR)ClassName,
- &ClassAtom);
-
- if (!NT_SUCCESS(Status))
+ while (!IsListEmpty(&Process->ClassList))
{
- DPRINT1("Failed to lookup class atom!\n");
- return FALSE;
+ Class = CONTAINING_RECORD(RemoveHeadList(&Process->ClassList), WNDCLASS_OBJECT, ListEntry);
+ DestroyClass(Class);
}
-
- Found = ClassReferenceClassByAtom(Class, ClassAtom, hInstance);
-
- return Found;
}
-BOOL FASTCALL
-ClassReferenceClassByNameOrAtom(
- PWNDCLASS_OBJECT *Class,
- LPCWSTR ClassNameOrAtom,
- HINSTANCE hInstance)
-{
- BOOL Found;
- if (IS_ATOM(ClassNameOrAtom))
- Found = ClassReferenceClassByAtom(Class, (RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance);
- else
- Found = ClassReferenceClassByName(Class, ClassNameOrAtom, hInstance);
- return Found;
-}
-DWORD STDCALL
-NtUserGetClassInfo(
- HINSTANCE hInstance,
- LPCWSTR lpClassName,
- LPWNDCLASSEXW lpWndClassEx,
- BOOL Ansi,
- DWORD unknown3)
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByAtom(RTL_ATOM Atom, HINSTANCE hInstance)
{
PWNDCLASS_OBJECT Class;
- RTL_ATOM Atom;
- DECLARE_RETURN(DWORD);
+ PW32PROCESS Process = PsGetWin32Process();
- if (IS_ATOM(lpClassName))
- DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance);
- else
- DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance);
+ LIST_FOR_EACH(Class, &Process->ClassList, WNDCLASS_OBJECT, ListEntry)
+ {
+ if (Class->Atom != Atom) continue;
- UserEnterExclusive();
-
- if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance))
- {
- SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
- RETURN(0);
+ if (!hInstance || Class->Global || Class->hInstance == hInstance) return Class;
}
+
+ return NULL;
+}
- lpWndClassEx->cbSize = sizeof(WNDCLASSEXW);
- lpWndClassEx->style = Class->style;
- if (Ansi)
- lpWndClassEx->lpfnWndProc = Class->lpfnWndProcA;
- else
- lpWndClassEx->lpfnWndProc = Class->lpfnWndProcW;
- lpWndClassEx->cbClsExtra = Class->cbClsExtra;
- lpWndClassEx->cbWndExtra = Class->cbWndExtra;
- /* This is not typo, we're really not going to use Class->hInstance here. */
- lpWndClassEx->hInstance = hInstance;
- lpWndClassEx->hIcon = Class->hIcon;
- lpWndClassEx->hCursor = Class->hCursor;
- lpWndClassEx->hbrBackground = Class->hbrBackground;
- if (Class->lpszMenuName.MaximumLength)
- RtlCopyUnicodeString((PUNICODE_STRING)lpWndClassEx->lpszMenuName, &Class->lpszMenuName);
- else
- lpWndClassEx->lpszMenuName = Class->lpszMenuName.Buffer;
- lpWndClassEx->lpszClassName = lpClassName;
- lpWndClassEx->hIconSm = Class->hIconSm;
- Atom = Class->Atom;
- ObmDereferenceObject(Class);
-
- RETURN(Atom);
-
-CLEANUP:
- DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-ULONG FASTCALL
-IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
- ULONG nMaxCount)
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByName(LPCWSTR ClassName, HINSTANCE hInstance)
{
- ULONG Length;
- LPWSTR Name;
- PWINSTATION_OBJECT WinStaObject;
+ PWINSTATION_OBJECT WinSta;
NTSTATUS Status;
+ RTL_ATOM Atom;
- if(!PsGetWin32Thread()->Desktop)
- {
- return 0;
- }
+ if (!ClassName || !PsGetWin32Thread()->Desktop)
+ return FALSE;
- WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
+ WinSta = PsGetWin32Thread()->Desktop->WindowStation;
- Length = 0;
- Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
- WindowObject->Class->Atom, NULL, NULL,
- NULL, &Length);
- Length += sizeof(WCHAR);
- Name = ExAllocatePoolWithTag(PagedPool, Length, TAG_STRING);
- Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
- WindowObject->Class->Atom, NULL, NULL,
- Name, &Length);
+ Status = RtlLookupAtomInAtomTable(
+ WinSta->AtomTable,
+ (LPWSTR)ClassName,
+ &Atom);
+
if (!NT_SUCCESS(Status))
{
- DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
- return 0;
+ DPRINT1("Failed to lookup class atom!\n");
+ return FALSE;
}
- Length /= sizeof(WCHAR);
- if (Length > nMaxCount)
- {
- Length = nMaxCount;
- }
- wcsncpy(lpClassName, Name, Length);
- /* FIXME: Check buffer size before doing this! */
- *(lpClassName + Length) = 0;
- ExFreePool(Name);
- return Length;
+ return ClassGetClassByAtom(Atom, hInstance);
}
-DWORD STDCALL
-NtUserGetClassName (
- HWND hWnd,
- LPWSTR lpClassName,
- ULONG nMaxCount)
-{
- PWINDOW_OBJECT Window;
- DECLARE_RETURN(DWORD);
- UserEnterShared();
- DPRINT("Enter NtUserGetClassName\n");
-
- if (!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(0);
- }
-
- RETURN( IntGetClassName(Window, lpClassName, nMaxCount));
-
-CLEANUP:
- DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-DWORD STDCALL
-NtUserGetWOWClass(DWORD Unknown0,
- DWORD Unknown1)
+PWNDCLASS_OBJECT FASTCALL
+ClassGetClassByNameOrAtom(LPCWSTR ClassNameOrAtom, HINSTANCE hInstance)
{
- UNIMPLEMENTED;
- return(0);
+ if (!ClassNameOrAtom) return NULL;
+
+ if (IS_ATOM(ClassNameOrAtom))
+ return ClassGetClassByAtom((RTL_ATOM)((ULONG_PTR)ClassNameOrAtom), hInstance);
+ else
+ return ClassGetClassByName(ClassNameOrAtom, hInstance);
}
-PWNDCLASS_OBJECT FASTCALL
-IntCreateClass(
+
+static
+BOOL FASTCALL
+IntRegisterClass(
CONST WNDCLASSEXW *lpwcx,
DWORD Flags,
WNDPROC wpExtra,
PUNICODE_STRING MenuName,
RTL_ATOM Atom)
{
- PWNDCLASS_OBJECT ClassObject;
+ PWNDCLASS_OBJECT Class;
ULONG objectSize;
BOOL Global;
- Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE;
+ ASSERT(lpwcx);
+ ASSERT(Atom);
[truncated at 1000 lines; 1785 more skipped]