Author: ion
Date: Sun Feb 19 10:12:14 2012
New Revision: 55707
URL:
http://svn.reactos.org/svn/reactos?rev=55707&view=rev
Log:
[CSRSRV]: Properly implement CsrSrvCreateThread now that the worker thread issue is fixed.
CSR_THREAD's are now created for everyone, and CSRSS succesfully duplicates their
thread handle! Also, while connections from unknown threads are still allowed (in case I
missed something), we do warn on the console about these guys now.
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Sun Feb 19
10:12:14 2012
@@ -172,50 +172,46 @@
NTSTATUS Status;
PCSR_PROCESS CsrProcess;
+ /* Get the current CSR thread */
CurrentThread = NtCurrentTeb()->CsrClientThread;
if (!CurrentThread) return STATUS_SUCCESS; // server-to-server
+
+ /* Get the CSR Process for this request */
CsrProcess = CurrentThread->Process;
-
- if (CsrProcess->ClientId.UniqueProcess !=
Request->Data.CreateThreadRequest.ClientId.UniqueProcess)
- {
+ if (CsrProcess->ClientId.UniqueProcess !=
+ Request->Data.CreateThreadRequest.ClientId.UniqueProcess)
+ {
+ /* This is a remote thread request -- is it within the server itself? */
if (Request->Data.CreateThreadRequest.ClientId.UniqueProcess ==
NtCurrentTeb()->ClientId.UniqueProcess)
{
+ /* Accept this without any further work */
return STATUS_SUCCESS;
}
+ /* Get the real CSR Process for the remote thread's process */
Status =
CsrLockProcessByClientId(Request->Data.CreateThreadRequest.ClientId.UniqueProcess,
&CsrProcess);
if (!NT_SUCCESS(Status)) return Status;
}
-
- Status = NtDuplicateObject(CsrProcess->ProcessHandle,
+
+ /* Duplicate the thread handle so we can own it */
+ Status = NtDuplicateObject(CurrentThread->Process->ProcessHandle,
Request->Data.CreateThreadRequest.ThreadHandle,
NtCurrentProcess(),
&ThreadHandle,
0,
0,
DUPLICATE_SAME_ACCESS);
- if (!NT_SUCCESS(Status))
- {
- Status = NtDuplicateObject(CurrentThread->Process->ProcessHandle,
- Request->Data.CreateThreadRequest.ThreadHandle,
- NtCurrentProcess(),
- &ThreadHandle,
- 0,
- 0,
- DUPLICATE_SAME_ACCESS);
- }
-
- Status = STATUS_SUCCESS; // hack
if (NT_SUCCESS(Status))
{
+ /* Call CSRSRV to tell it about the new thread */
Status = CsrCreateThread(CsrProcess,
- ThreadHandle,
-
&Request->Data.CreateThreadRequest.ClientId);
- }
-
- if (CsrProcess != CurrentThread->Process) CsrReleaseProcessLock();
-
+ ThreadHandle,
+ &Request->Data.CreateThreadRequest.ClientId);
+ }
+
+ /* Unlock the process and return */
+ if (CsrProcess != CurrentThread->Process) CsrUnlockProcess(CsrProcess);
return Status;
}
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] Sun Feb 19
10:12:14 2012
@@ -1183,7 +1183,7 @@
Thread = CsrLocateThreadByClientId(&Process,
&Request->Header.ClientId);
if (!Thread)
{
- DPRINT("No thread found for request %lx and clientID
%lx.%lx\n",
+ DPRINT1("No thread found for request %lx and clientID
%lx.%lx\n",
Request->Type & 0xFFFF,
Request->Header.ClientId.UniqueProcess,
Request->Header.ClientId.UniqueThread);