Author: ion
Date: Thu Sep 12 08:41:25 2013
New Revision: 60058
URL:
http://svn.reactos.org/svn/reactos?rev=60058&view=rev
Log:
[USER32]: Make ClientThreadSetup return TRUE, and document how initialization should work.
Enable CsrConnectToUser in CSRSRV. Works-4-me(TM).
Modified:
trunk/reactos/subsystems/win32/csrsrv/api.c
trunk/reactos/win32ss/user/user32/misc/desktop.c
trunk/reactos/win32ss/user/user32/misc/dllmain.c
trunk/reactos/win32ss/user/user32/misc/stubs.c
trunk/reactos/win32ss/user/user32/windows/hook.c
Modified: trunk/reactos/subsystems/win32/csrsrv/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrsrv/ap…
==============================================================================
--- trunk/reactos/subsystems/win32/csrsrv/api.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrsrv/api.c [iso-8859-1] Thu Sep 12 08:41:25 2013
@@ -1016,7 +1016,6 @@
NTAPI
CsrConnectToUser(VOID)
{
-#if 0 // FIXME: This code is OK, however it is ClientThreadSetup which sucks.
NTSTATUS Status;
ANSI_STRING DllName;
UNICODE_STRING TempName;
@@ -1073,21 +1072,6 @@
/* Return it */
return CsrThread;
-
-#else
-
- PTEB Teb = NtCurrentTeb();
- PCSR_THREAD CsrThread;
-
- /* Save pointer to this thread in TEB */
- CsrAcquireProcessLock();
- CsrThread = CsrLocateThreadInProcess(NULL, &Teb->ClientId);
- CsrReleaseProcessLock();
- if (CsrThread) Teb->CsrClientThread = CsrThread;
-
- /* Return it */
- return CsrThread;
-#endif
}
/*++
Modified: trunk/reactos/win32ss/user/user32/misc/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/d…
==============================================================================
--- trunk/reactos/win32ss/user/user32/misc/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/misc/desktop.c [iso-8859-1] Thu Sep 12 08:41:25
2013
@@ -128,8 +128,8 @@
int WINAPI
RealGetSystemMetrics(int nIndex)
{
- GetConnected();
-// FIXME("Global Server Data -> %x\n",gpsi);
+ //GetConnected();
+ //FIXME("Global Server Data -> %x\n",gpsi);
if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0;
return gpsi->aiSysMet[nIndex];
}
Modified: trunk/reactos/win32ss/user/user32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/d…
==============================================================================
--- trunk/reactos/win32ss/user/user32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/misc/dllmain.c [iso-8859-1] Thu Sep 12 08:41:25
2013
@@ -208,6 +208,47 @@
User32CallGetCharsetInfo,
};
+/*
+* @unimplemented
+*/
+BOOL
+WINAPI
+ClientThreadSetup(VOID)
+{
+ //
+ // This routine, in Windows, does a lot of what Init does, but in a radically
+ // different way.
+ //
+ // In Windows, because CSRSS's threads have TIF_CSRSSTHREAD set (we have this
+ // flag in ROS but not sure if we use it), the xxxClientThreadSetup callback
+ // isn't made when CSRSS first loads WINSRV.DLL (which loads USER32.DLL).
+ //
+ // However, all the other calls are made as normal, and WINSRV.DLL loads
+ // USER32.dll, the DllMain runs, and eventually the first NtUser system call is
+ // made which initializes Win32k (and initializes the thread, but as mentioned
+ // above, the thread is marked as TIF_CSRSSTHREAD.
+ //
+ // In the DllMain of User32, there is also a CsrClientConnectToServer call to
+ // server 2 (winsrv). When this is done from CSRSS, the "InServer" flag is
set,
+ // so user32 will remember that it's running inside of CSRSS. Also, another
+ // flag, called "FirstThread" is manually set by DllMain.
+ //
+ // Then, WINSRV finishes loading, and CSRSRV starts the API thread/loop. This
+ // code then calls CsrConnectToUser, which calls... ClientThreadStartup. Now
+ // this routine detects that it's in the server process, which means it's
CSRSS
+ // and that the callback never happened. It does some first-time-Win32k connection
+ // initialization and caches a bunch of things -- if it's the first thread. It
also
+ // acquires a critical section to initialize GDI -- and then resets the first thread
+ // flag.
+ //
+ // For now, we'll do none of this, but to support Windows' CSRSRV.DLL which
calls
+ // CsrConnectToUser, we'll pretend we "did something" here. Then the
rest will
+ // continue as normal.
+ //
+ UNIMPLEMENTED;
+ return TRUE;
+}
+
BOOL
Init(VOID)
{
@@ -310,38 +351,12 @@
return TRUE;
}
-
-VOID
-FASTCALL
-GetConnected(VOID)
-{
- USERCONNECT UserCon;
-// ERR("GetConnected\n");
-
- if ((PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo == NULL)
- NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
-
- if (gpsi && g_ppi) return;
-// FIXME HAX: Due to the "Dll Initialization Bug" we have to call this too.
- GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
-
- NtUserProcessConnect( NtCurrentProcess(),
- &UserCon,
- sizeof(USERCONNECT));
-
- g_ppi = GetWin32ClientInfo()->ppi;
- g_ulSharedDelta = UserCon.siClient.ulSharedDelta;
- gpsi = SharedPtrToUser(UserCon.siClient.psi);
- gHandleTable = SharedPtrToUser(UserCon.siClient.aheList);
- gHandleEntries = SharedPtrToUser(gHandleTable->handles);
-
-}
-
NTSTATUS
WINAPI
User32CallClientThreadSetupFromKernel(PVOID Arguments, ULONG ArgumentLength)
{
ERR("GetConnected\n");
+ ClientThreadSetup();
return ZwCallbackReturn(NULL, 0, STATUS_SUCCESS);
}
Modified: trunk/reactos/win32ss/user/user32/misc/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/s…
==============================================================================
--- trunk/reactos/win32ss/user/user32/misc/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/misc/stubs.c [iso-8859-1] Thu Sep 12 08:41:25 2013
@@ -214,17 +214,6 @@
BOOL
WINAPI
GetAccCursorInfo ( PCURSORINFO pci )
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-ClientThreadSetup ( VOID )
{
UNIMPLEMENTED;
return FALSE;
Modified: trunk/reactos/win32ss/user/user32/windows/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/hook.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/hook.c [iso-8859-1] Thu Sep 12 08:41:25
2013
@@ -211,7 +211,7 @@
PHOOK pHook, phkNext;
LRESULT lResult = 0;
- GetConnected();
+ //GetConnected();
ClientInfo = GetWin32ClientInfo();