Author: jimtabor
Date: Wed Apr 1 02:02:29 2009
New Revision: 40305
URL:
http://svn.reactos.org/svn/reactos?rev=40305&view=rev
Log:
- Implement NtUserProcessConnect. Moving to client information format for User32.
PPROCESSINFO and PTHREADINFO are references not user land structures.
- Added and removed structure types.
- Tested with old AbiWord, FireFox and explorer.
Modified:
trunk/reactos/dll/win32/user32/include/user32.h
trunk/reactos/dll/win32/user32/misc/dllmain.c
trunk/reactos/dll/win32/user32/misc/misc.c
trunk/reactos/dll/win32/user32/windows/window.c
trunk/reactos/include/reactos/win32k/ntuser.h
trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
trunk/reactos/subsystems/win32/win32k/ntuser/hook.c
trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
Modified: trunk/reactos/dll/win32/user32/include/user32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32.h [iso-8859-1] Wed Apr 1 02:02:29 2009
@@ -48,17 +48,15 @@
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *);
BOOL FASTCALL IsMetaFile(HDC);
-extern PPROCESSINFO g_pi;
-extern PPROCESSINFO g_kpi;
+extern ULONG_PTR g_ulSharedDelta;
extern PSERVERINFO g_psi;
static __inline PVOID
SharedPtrToUser(PVOID Ptr)
{
ASSERT(Ptr != NULL);
- ASSERT(g_pi != NULL);
- ASSERT(g_pi->UserHeapDelta != 0);
- return (PVOID)((ULONG_PTR)Ptr - g_pi->UserHeapDelta);
+ ASSERT(g_ulSharedDelta != 0);
+ return (PVOID)((ULONG_PTR)Ptr - g_ulSharedDelta);
}
static __inline PVOID
@@ -88,9 +86,8 @@
SharedPtrToKernel(PVOID Ptr)
{
ASSERT(Ptr != NULL);
- ASSERT(g_pi != NULL);
- ASSERT(g_pi->UserHeapDelta != 0);
- return (PVOID)((ULONG_PTR)Ptr + g_pi->UserHeapDelta);
+ ASSERT(g_ulSharedDelta != 0);
+ return (PVOID)((ULONG_PTR)Ptr + g_ulSharedDelta);
}
static __inline BOOL
@@ -120,3 +117,4 @@
PWINDOW FASTCALL ValidateHwndNoErr(HWND hwnd);
VOID FASTCALL GetConnected(VOID);
BOOL FASTCALL DefSetText(HWND hWnd, PCWSTR String, BOOL Ansi);
+BOOL FASTCALL TestWindowProcess(PWINDOW);
Modified: trunk/reactos/dll/win32/user32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/dllm…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/dllmain.c [iso-8859-1] Wed Apr 1 02:02:29 2009
@@ -7,15 +7,13 @@
static ULONG User32TlsIndex;
HINSTANCE User32Instance;
+
PUSER_HANDLE_TABLE gHandleTable = NULL;
PUSER_HANDLE_ENTRY gHandleEntries = NULL;
-PPROCESSINFO g_pi = NULL; /* User Mode Pointer */
-PPROCESSINFO g_kpi = NULL; /* Kernel Mode Pointer */
PSERVERINFO g_psi = NULL;
+ULONG_PTR g_ulSharedDelta;
+
WCHAR szAppInit[KEY_LENGTH];
-
-PPROCESSINFO
-GetW32ProcessInfo(VOID);
PUSER32_THREAD_DATA
User32GetThreadData()
@@ -216,6 +214,8 @@
BOOL
Init(VOID)
{
+ USERCONNECT UserCon;
+
/* Set up the kernel callbacks. */
NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] =
(PVOID)User32CallWindowProcFromKernel;
@@ -230,11 +230,15 @@
NtCurrentPeb()->KernelCallbackTable[USER32_CALLBACK_EVENTPROC] =
(PVOID)User32CallEventProcFromKernel;
- g_pi = GetW32ProcessInfo();
- g_kpi = SharedPtrToKernel(g_pi);
- g_psi = SharedPtrToUser(g_pi->psi);
- gHandleTable = SharedPtrToUser(g_pi->UserHandleTable);
+ NtUserProcessConnect( NtCurrentProcess(),
+ &UserCon,
+ sizeof(USERCONNECT));
+
+ g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
+ g_psi = SharedPtrToUser(UserCon.siClient.psi);
+ gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
gHandleEntries = SharedPtrToUser(gHandleTable->handles);
+ //ERR("1 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi,
UserCon.siClient.aheList, g_ulSharedDelta);
/* Allocate an index for user32 thread local data. */
User32TlsIndex = TlsAlloc();
@@ -324,19 +328,20 @@
FASTCALL
GetConnected(VOID)
{
- PPROCESSINFO pi;
+ USERCONNECT UserCon;
if ((PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo == NULL)
NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
- if (g_pi && g_kpi && g_psi) return;
-
- pi = GetW32ProcessInfo();
- if (!g_pi) g_pi = pi;
- if (!g_kpi) g_kpi = SharedPtrToKernel(pi);
- if (!g_psi) g_psi = SharedPtrToUser(pi->psi);
- if (!g_psi) { WARN("Global Share Information has not been initialized!\n");
}
- if (!gHandleTable) gHandleTable = SharedPtrToUser(pi->UserHandleTable);
- if (!gHandleEntries) gHandleEntries = SharedPtrToUser(gHandleTable->handles);
-
-}
+ if (g_psi) return;
+
+ NtUserProcessConnect( NtCurrentProcess(),
+ &UserCon,
+ sizeof(USERCONNECT));
+
+ g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
+ g_psi = SharedPtrToUser(UserCon.siClient.psi);
+ gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
+ gHandleEntries = SharedPtrToUser(gHandleTable->handles);
+// ERR("2 SI 0x%x : HT 0x%x : D 0x%x\n", UserCon.siClient.psi,
UserCon.siClient.aheList, g_ulSharedDelta);
+}
Modified: trunk/reactos/dll/win32/user32/misc/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] Wed Apr 1 02:02:29 2009
@@ -118,21 +118,6 @@
}
return ti;
-}
-
-PPROCESSINFO
-GetW32ProcessInfo(VOID)
-{
- PW32THREADINFO ti;
- PPROCESSINFO pi = NULL;
-
- ti = GetW32ThreadInfo();
- if (ti != NULL)
- {
- pi = ti->pi;
- }
-
- return pi;
}
@@ -279,6 +264,17 @@
}
else
return TRUE;
+}
+
+BOOL
+FASTCALL
+TestWindowProcess(PWINDOW Wnd)
+{
+ if (Wnd->ti == (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo)
+ return TRUE;
+ else
+ return (NtUserQueryWindow(Wnd->hdr.Handle, QUERY_WINDOW_UNIQUE_PROCESS_ID) ==
+ (DWORD)NtCurrentTeb()->ClientId.UniqueProcess );
}
BOOL
@@ -435,7 +431,7 @@
ValidateCallProc(HANDLE hCallProc)
{
PCALLPROC CallProc = ValidateHandle(hCallProc, VALIDATE_TYPE_CALLPROC);
- if (CallProc != NULL && CallProc->pi == g_kpi)
+ if (CallProc != NULL ) //&& CallProc->pi == g_kpi)
return CallProc;
return NULL;
Modified: trunk/reactos/dll/win32/user32/windows/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/w…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Wed Apr 1 02:02:29 2009
@@ -1126,7 +1126,7 @@
_SEH2_TRY
{
- if (Wnd->pi != g_kpi)
+ if (TestWindowProcess( Wnd))// if (Wnd->pi != g_kpi)
{
if (nMaxCount > 0)
{
@@ -1216,7 +1216,7 @@
_SEH2_TRY
{
- if (Wnd->pi != g_kpi)
+ if (TestWindowProcess( Wnd)) //if (Wnd->pi != g_kpi)
{
if (nMaxCount > 0)
{
Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntu…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Wed Apr 1 02:02:29 2009
@@ -347,8 +347,6 @@
UINT RegisteredSysClasses : 1;
- PSERVERINFO psi;
-
} PROCESSINFO, *PPROCESSINFO;
#define CTI_INSENDMESSAGE 0x0002
@@ -413,7 +411,6 @@
PHOOK phkCurrent;
ULONG fsHooks;
CALLBACKWND CallbackWnd;
- ULONG Win32ClientInfo;
DWORD dwHookCurrent;
INT cInDDEMLCallback;
PCLIENTTHREADINFO pClientThreadInfo;
@@ -426,7 +423,8 @@
HKL hKL;
USHORT CodePage;
USHORT achDbcsCF;
- ULONG Win32ClientInfo3[35];
+ MSG msgDbcsCB;
+ ULONG Win32ClientInfo3[29];
} CLIENTINFO, *PCLIENTINFO;
/* Make sure it fits exactly into the TEB */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Wed Apr 1
02:02:29 2009
@@ -188,6 +188,20 @@
}
/* PRIVATE FUNCTIONS **********************************************************/
+
+PVOID
+FASTCALL
+DesktopAlloc(PDESKTOP DesktopObject, SIZE_T Size)
+{
+ return RtlAllocateHeap(DesktopObject->pheapDesktop, HEAP_NO_SERIALIZE, Size);
+}
+
+BOOL
+FASTCALL
+DesktopFree(PDESKTOP DesktopObject, PVOID HeapBase)
+{
+ return RtlFreeHeap(DesktopObject->pheapDesktop, HEAP_NO_SERIALIZE, HeapBase);
+}
NTSTATUS
FASTCALL
@@ -1772,6 +1786,7 @@
{
ti->Desktop = NULL;
}
+ GetWin32ClientInfo()->pDeskInfo = NULL;
}
GetWin32ClientInfo()->ulClientDelta = 0;
@@ -1846,14 +1861,16 @@
/* create a W32THREADINFO structure if not already done, or update it */
ti = GetW32ThreadInfo();
+ GetWin32ClientInfo()->ulClientDelta = DesktopHeapGetUserDelta();
if (ti != NULL)
{
if (ti->Desktop == NULL)
{
- ti->Desktop = DesktopObject->DesktopInfo;
+ ti->Desktop = DesktopObject->DesktopInfo;
+ GetWin32ClientInfo()->pDeskInfo =
+ (PVOID)((ULONG_PTR)ti->Desktop -
GetWin32ClientInfo()->ulClientDelta);
}
}
- GetWin32ClientInfo()->ulClientDelta = DesktopHeapGetUserDelta();
return STATUS_SUCCESS;
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/hook.c [iso-8859-1] Wed Apr 1 02:02:29
2009
@@ -109,6 +109,9 @@
W32Thread = ((PTHREADINFO)Thread->Tcb.Win32Thread);
ASSERT(W32Thread != NULL);
W32Thread->Hooks |= HOOKID_TO_FLAG(HookId);
+
+ GetWin32ClientInfo()->fsHooks = W32Thread->Hooks;
+
if (W32Thread->ThreadInfo != NULL)
W32Thread->ThreadInfo->Hooks = W32Thread->Hooks;
}
@@ -220,6 +223,9 @@
W32Thread = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread);
ASSERT(W32Thread != NULL);
W32Thread->Hooks &= ~HOOKID_TO_FLAG(Hook->HookId);
+
+ GetWin32ClientInfo()->fsHooks = W32Thread->Hooks;
+
if (W32Thread->ThreadInfo != NULL)
W32Thread->ThreadInfo->Hooks = W32Thread->Hooks;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] Wed Apr 1 02:02:29
2009
@@ -460,7 +460,6 @@
pi->hUserHeap = W32Process->HeapMappings.KernelMapping;
pi->UserHeapDelta = (ULONG_PTR)W32Process->HeapMappings.KernelMapping
-
(ULONG_PTR)W32Process->HeapMappings.UserMapping;
- pi->psi = gpsi;
if (InterlockedCompareExchangePointer(&W32Process->ProcessInfo,
pi,
@@ -525,9 +524,9 @@
ProbeForWrite(Teb,
sizeof(TEB),
sizeof(ULONG));
-
+ // FIXME PLEASE! it's a ref pointer and not user data! Use ClientThreadInfo!
Teb->Win32ThreadInfo =
UserHeapAddressToUser(W32Thread->ThreadInfo);
- ci->pClientThreadInfo = &ti->ClientThreadInfo;
+ ci->pClientThreadInfo = &ti->ClientThreadInfo; // FIXME!
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Wed Apr 1
02:02:29 2009
@@ -884,8 +884,33 @@
PUSERCONNECT pUserConnect,
DWORD Size)
{
- UNIMPLEMENTED;
- return 0;
+ NTSTATUS Status = STATUS_SUCCESS;
+ DPRINT("NtUserProcessConnect\n");
+ if (pUserConnect && ( Size == sizeof(USERCONNECT) ))
+ {
+ UserEnterShared();
+ GetW32ThreadInfo();
+ PPROCESSINFO ppi = GetW32ProcessInfo();
+ _SEH2_TRY
+ {
+ pUserConnect->siClient.psi = gpsi;
+ pUserConnect->siClient.aheList = ppi->UserHandleTable;
+ pUserConnect->siClient.ulSharedDelta = ppi->UserHeapDelta;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ }
+ DPRINT("NtUserPC SI 0x%x : HT 0x%x : D 0x%x\n", gpsi,
ppi->UserHandleTable, ppi->UserHeapDelta);
+ UserLeave();
+ return Status;
+ }
+ return STATUS_UNSUCCESSFUL;
}
DWORD