[USER32]: Make ClientThreadSetup return TRUE, and document how initialization should work. Enable CsrConnectToUser in CSRSRV. Works-4-me(TM).

svn path=/trunk/; revision=60058
This commit is contained in:
Alex Ionescu 2013-09-12 08:41:25 +00:00
parent 18bb4e2eaf
commit 951ed16a33
5 changed files with 45 additions and 57 deletions

View file

@ -1016,7 +1016,6 @@ PCSR_THREAD
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 @@ CsrConnectToUser(VOID)
/* 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
}
/*++

View file

@ -128,7 +128,7 @@ LogFontW2A(LPLOGFONTA pA, CONST LOGFONTW *pW)
int WINAPI
RealGetSystemMetrics(int nIndex)
{
GetConnected();
//GetConnected();
//FIXME("Global Server Data -> %x\n",gpsi);
if (nIndex < 0 || nIndex >= SM_CMETRICS) return 0;
return gpsi->aiSysMet[nIndex];

View file

@ -208,6 +208,47 @@ PVOID apfnDispatch[USER32_CALLBACK_MAXIMUM + 1] =
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 @@ DllMain(
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);
}

View file

@ -219,17 +219,6 @@ GetAccCursorInfo ( PCURSORINFO pci )
return FALSE;
}
/*
* @unimplemented
*/
BOOL
WINAPI
ClientThreadSetup ( VOID )
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/

View file

@ -211,7 +211,7 @@ CallNextHookEx(
PHOOK pHook, phkNext;
LRESULT lResult = 0;
GetConnected();
//GetConnected();
ClientInfo = GetWin32ClientInfo();