Author: amunger
Date: Wed May 3 08:17:50 2006
New Revision: 21779
URL:
http://svn.reactos.ru/svn/reactos?rev=21779&view=rev
Log:
Move callproc code into own file and reduce unneccessary system calls to dereference
them.
It doesn't fix any bugs but improves performance a bit.
Patch from w3seek, bug 1445.
Added:
trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c
Modified:
trunk/reactos/dll/win32/user32/windows/message.c
trunk/reactos/subsystems/win32/win32k/include/class.h
trunk/reactos/subsystems/win32/win32k/main/dllmain.c
trunk/reactos/subsystems/win32/win32k/ntuser/class.c
trunk/reactos/subsystems/win32/win32k/ntuser/window.c
trunk/reactos/subsystems/win32/win32k/win32k.rbuild
Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/user32/windows/me…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c Wed May 3 08:17:50 2006
@@ -1001,6 +1001,13 @@
}
}
+static BOOL __inline
+IsCallProcHandle(IN WNDPROC lpWndProc)
+{
+ /* FIXME - check for 64 bit architectures... */
+ return ((ULONG_PTR)lpWndProc & 0xFFFF0000) == 0xFFFF0000;
+}
+
/*
* @implemented
@@ -1018,7 +1025,8 @@
if (lpPrevWndFunc == NULL)
lpPrevWndFunc = (WNDPROC)NtUserGetWindowLong(hWnd, GWLP_WNDPROC, TRUE);
- if (!NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc,
+ if (!IsCallProcHandle(lpPrevWndFunc) ||
+ !NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc,
&wpInfo))
{
return IntCallWindowProcA(TRUE, lpPrevWndFunc, hWnd, Msg, wParam, lParam);
@@ -1047,7 +1055,8 @@
if (lpPrevWndFunc == NULL)
lpPrevWndFunc = (WNDPROC)NtUserGetWindowLong(hWnd, GWLP_WNDPROC, FALSE);
- if (!NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc,
+ if (!IsCallProcHandle(lpPrevWndFunc) ||
+ !NtUserDereferenceWndProcHandle((HANDLE)lpPrevWndFunc,
&wpInfo))
{
return IntCallWindowProcW(FALSE, lpPrevWndFunc, hWnd, Msg, wParam, lParam);
Modified: trunk/reactos/subsystems/win32/win32k/include/class.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/class.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/class.h Wed May 3 08:17:50 2006
@@ -3,6 +3,9 @@
#define IS_ATOM(x) \
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
+
+WNDPROC
+GetCallProcHandle(IN PCALLPROC CallProc);
VOID
DestroyCallProc(IN PDESKTOP Desktop,
@@ -17,12 +20,6 @@
IN WNDPROC WndProc,
IN BOOL Unicode,
IN PW32PROCESSINFO pi);
-
-NTSTATUS FASTCALL
-InitClassImpl(VOID);
-
-NTSTATUS FASTCALL
-CleanupClassImpl(VOID);
BOOL
UserGetCallProcInfo(IN HANDLE hCallProc,
Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mai…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c Wed May 3 08:17:50 2006
@@ -425,13 +425,6 @@
return STATUS_UNSUCCESSFUL;
}
- Status = InitClassImpl();
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Failed to initialize window class implementation!\n");
- return STATUS_UNSUCCESSFUL;
- }
-
Status = InitDesktopImpl();
if (!NT_SUCCESS(Status))
{
Added: trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c (added)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/callproc.c Wed May 3 08:17:50 2006
@@ -1,0 +1,156 @@
+/*
+ * ReactOS W32 Subsystem
+ * Copyright (C) 1998 - 2006 ReactOS Team
+ *
+ * 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.
+ */
+/* $Id: class.c 21596 2006-04-15 10:41:58Z greatlrd $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * PURPOSE: Window classes
+ * FILE: subsys/win32k/ntuser/class.c
+ * PROGRAMER: Thomas Weidenmueller <w3seek(a)reactos.com>
+ * REVISION HISTORY:
+ * 06-06-2001 CSH Created
+ */
+/* INCLUDES ******************************************************************/
+
+#include <w32k.h>
+
+#define NDEBUG
+#include <debug.h>
+
+/* CALLPROC ******************************************************************/
+
+WNDPROC
+GetCallProcHandle(IN PCALLPROC CallProc)
+{
+ /* FIXME - check for 64 bit architectures... */
+ return (WNDPROC)((ULONG_PTR)ObmObjectToHandle(CallProc) | 0xFFFF0000);
+}
+
+VOID
+DestroyCallProc(IN PDESKTOP Desktop,
+ IN OUT PCALLPROC CallProc)
+{
+ /* FIXME - use new object manager! */
+ HANDLE Handle = ObmObjectToHandle(CallProc);
+
+ ObmDeleteObject(Handle,
+ otCallProc);
+}
+
+PCALLPROC
+CloneCallProc(IN PDESKTOP Desktop,
+ IN PCALLPROC CallProc)
+{
+ PCALLPROC NewCallProc;
+ HANDLE Handle;
+
+ /* FIXME - use new object manager! */
+ NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable,
+ &Handle,
+ otCallProc,
+ sizeof(CALLPROC));
+ if (NewCallProc != NULL)
+ {
+ NewCallProc->pi = CallProc->pi;
+ NewCallProc->WndProc = CallProc->WndProc;
+ NewCallProc->Unicode = CallProc->Unicode;
+ }
+
+ return NewCallProc;
+}
+
+PCALLPROC
+CreateCallProc(IN PDESKTOP Desktop,
+ IN WNDPROC WndProc,
+ IN BOOL Unicode,
+ IN PW32PROCESSINFO pi)
+{
+ PCALLPROC NewCallProc;
+ HANDLE Handle;
+
+ /* FIXME - use new object manager! */
+ NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable,
+ &Handle,
+ otCallProc,
+ sizeof(CALLPROC));
+ if (NewCallProc != NULL)
+ {
+ NewCallProc->pi = pi;
+ NewCallProc->WndProc = WndProc;
+ NewCallProc->Unicode = Unicode;
+ }
+
+ return NewCallProc;
+}
+
+BOOL
+UserGetCallProcInfo(IN HANDLE hCallProc,
+ OUT PWNDPROC_INFO wpInfo)
+{
+ PCALLPROC CallProc;
+
+ /* NOTE: Accessing the WNDPROC_INFO structure may raise an exception! */
+
+ /* FIXME - use new object manager! */
+ CallProc = UserGetObject(gHandleTable,
+ hCallProc,
+ otCallProc);
+ if (CallProc == NULL)
+ {
+ return FALSE;
+ }
+
+ if (CallProc->pi != GetW32ProcessInfo())
+ {
+ return FALSE;
+ }
+
+ wpInfo->WindowProc = CallProc->WndProc;
+ wpInfo->IsUnicode = CallProc->Unicode;
+
+ return TRUE;
+}
+
+BOOL NTAPI
+NtUserDereferenceWndProcHandle(IN HANDLE wpHandle,
+ OUT PWNDPROC_INFO wpInfo)
+{
+ BOOL Ret = FALSE;
+
+ UserEnterShared();
+
+ _SEH_TRY
+ {
+ ProbeForWrite(wpInfo,
+ sizeof(WNDPROC_INFO),
+ sizeof(ULONG));
+
+ Ret = UserGetCallProcInfo(wpHandle,
+ wpInfo);
+ }
+ _SEH_HANDLE
+ {
+ SetLastWin32Error(_SEH_GetExceptionCode());
+ }
+ _SEH_END;
+
+ UserLeave();
+
+ return Ret;
+}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/class.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/class.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/class.c Wed May 3 08:17:50 2006
@@ -33,106 +33,7 @@
#define NDEBUG
#include <debug.h>
-/* CALLPROC ******************************************************************/
-
-VOID
-DestroyCallProc(IN PDESKTOP Desktop,
- IN OUT PCALLPROC CallProc)
-{
- /* FIXME - use new object manager! */
- HANDLE Handle = ObmObjectToHandle(CallProc);
-
- ObmDeleteObject(Handle,
- otCallProc);
-}
-
-PCALLPROC
-CloneCallProc(IN PDESKTOP Desktop,
- IN PCALLPROC CallProc)
-{
- PCALLPROC NewCallProc;
- HANDLE Handle;
-
- /* FIXME - use new object manager! */
- NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable,
- &Handle,
- otCallProc,
- sizeof(CALLPROC));
- if (NewCallProc != NULL)
- {
- NewCallProc->pi = CallProc->pi;
- NewCallProc->WndProc = CallProc->WndProc;
- NewCallProc->Unicode = CallProc->Unicode;
- }
-
- return NewCallProc;
-}
-
-PCALLPROC
-CreateCallProc(IN PDESKTOP Desktop,
- IN WNDPROC WndProc,
- IN BOOL Unicode,
- IN PW32PROCESSINFO pi)
-{
- PCALLPROC NewCallProc;
- HANDLE Handle;
-
- /* FIXME - use new object manager! */
- NewCallProc = (PCALLPROC)ObmCreateObject(gHandleTable,
- &Handle,
- otCallProc,
- sizeof(CALLPROC));
- if (NewCallProc != NULL)
- {
- NewCallProc->pi = pi;
- NewCallProc->WndProc = WndProc;
- NewCallProc->Unicode = Unicode;
- }
-
- return NewCallProc;
-}
-
-BOOL
-UserGetCallProcInfo(IN HANDLE hCallProc,
- OUT PWNDPROC_INFO wpInfo)
-{
- PCALLPROC CallProc;
-
- /* NOTE: Accessing the WNDPROC_INFO structure may raise an exception! */
-
- /* FIXME - use new object manager! */
- CallProc = UserGetObject(gHandleTable,
- hCallProc,
- otCallProc);
- if (CallProc == NULL)
- {
- return FALSE;
- }
-
- if (CallProc->pi != GetW32ProcessInfo())
- {
- return FALSE;
- }
-
- wpInfo->WindowProc = CallProc->WndProc;
- wpInfo->IsUnicode = CallProc->Unicode;
-
- return TRUE;
-}
-
/* WINDOWCLASS ***************************************************************/
-
-NTSTATUS FASTCALL
-InitClassImpl(VOID)
-{
- return(STATUS_SUCCESS);
-}
-
-NTSTATUS FASTCALL
-CleanupClassImpl(VOID)
-{
- return(STATUS_SUCCESS);
-}
static VOID
IntFreeClassMenuName(IN OUT PWINDOWCLASS Class)
@@ -345,7 +246,7 @@
if (*CallProcPtr != NULL)
{
- return (WNDPROC)ObmObjectToHandle(*CallProcPtr);
+ return GetCallProcHandle(*CallProcPtr);
}
else
{
@@ -392,7 +293,7 @@
Class = Class->Next;
}
- return (WNDPROC)ObmObjectToHandle(NewCallProc);
+ return GetCallProcHandle(NewCallProc);
}
}
}
@@ -2510,33 +2411,4 @@
return(0);
}
-
-BOOL NTAPI
-NtUserDereferenceWndProcHandle(IN HANDLE wpHandle,
- OUT PWNDPROC_INFO wpInfo)
-{
- BOOL Ret = FALSE;
-
- UserEnterShared();
-
- _SEH_TRY
- {
- ProbeForWrite(wpInfo,
- sizeof(WNDPROC_INFO),
- sizeof(ULONG));
-
- Ret = UserGetCallProcInfo(wpHandle,
- wpInfo);
- }
- _SEH_HANDLE
- {
- SetLastWin32Error(_SEH_GetExceptionCode());
- }
- _SEH_END;
-
- UserLeave();
-
- return Ret;
-}
-
/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/window.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c Wed May 3 08:17:50 2006
@@ -509,7 +509,7 @@
{
if (Window->CallProc != NULL)
{
- return (WNDPROC)ObmObjectToHandle(Window->CallProc);
+ return GetCallProcHandle(Window->CallProc);
}
else
{
@@ -536,7 +536,7 @@
NewCallProc);
}
- return (WNDPROC)ObmObjectToHandle((CallProc == NULL ? NewCallProc :
CallProc));
+ return GetCallProcHandle((CallProc == NULL ? NewCallProc : CallProc));
}
}
}
@@ -3464,7 +3464,7 @@
}
}
- Ret = (WNDPROC)ObmObjectToHandle(Window->CallProc2);
+ Ret = GetCallProcHandle(Window->CallProc2);
}
}
Modified: trunk/reactos/subsystems/win32/win32k/win32k.rbuild
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/win…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/win32k.rbuild (original)
+++ trunk/reactos/subsystems/win32/win32k/win32k.rbuild Wed May 3 08:17:50 2006
@@ -84,6 +84,7 @@
<compilationunit name="ntuser.c">
<file>accelerator.c</file>
<file>callback.c</file>
+ <file>callproc.c</file>
<file>caret.c</file>
<file>class.c</file>
<file>clipboard.c</file>