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);
Author: ion
Date: Sun Feb 19 10:00:47 2012
New Revision: 55705
URL: http://svn.reactos.org/svn/reactos?rev=55705&view=rev
Log:
[CSRSRV]: Take a refernece to the client thread since we are dereffing it...
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
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:00:47 2012
@@ -1189,6 +1189,7 @@
Request->Header.ClientId.UniqueThread);
}
//DPRINT1("Thread found: %p %p\n", Thread, Process);
+ if (Thread) CsrLockedReferenceThread(Thread);
if (Thread) NtCurrentTeb()->CsrClientThread = Thread;
Author: ion
Date: Sun Feb 19 09:54:41 2012
New Revision: 55703
URL: http://svn.reactos.org/svn/reactos?rev=55703&view=rev
Log:
[CSRSRV2]: Bugfix, don't dereference the thread instead of referencing it!
Modified:
trunk/reactos/subsystems/csr/csrsrv/api.c
Modified: trunk/reactos/subsystems/csr/csrsrv/api.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/csr/csrsrv/api.…
==============================================================================
--- trunk/reactos/subsystems/csr/csrsrv/api.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/csr/csrsrv/api.c [iso-8859-1] Sun Feb 19 09:54:41 2012
@@ -720,7 +720,7 @@
}
/* We got an API Request */
- CsrDereferenceThread(CsrThread);
+ CsrLockedReferenceThread(CsrThread);
CsrReleaseProcessLock();
/* This is an API call, get the Server ID */
Author: ion
Date: Sun Feb 19 07:22:37 2012
New Revision: 55700
URL: http://svn.reactos.org/svn/reactos?rev=55700&view=rev
Log:
[CSRSRV]: Fix scenario when a new thread is being created from within CSRSRV and it could not register itself due to the new server-to-server support. Fixes CTRL-C and using the "X" button in a console window to close it, which had regressed since the server-to-server commit.
Modified:
trunk/reactos/subsystems/csr/csrsrv/api.c
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
Modified: trunk/reactos/subsystems/csr/csrsrv/api.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/csr/csrsrv/api.…
==============================================================================
--- trunk/reactos/subsystems/csr/csrsrv/api.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/csr/csrsrv/api.c [iso-8859-1] Sun Feb 19 07:22:37 2012
@@ -1227,7 +1227,7 @@
_SEH2_TRY
{
/* Call the API and get the result */
- Status = (ServerDll->DispatchTable[ApiId])(ReceiveMsg, &Reply);
+ Status = ServerDll->DispatchTable[ApiId](ReceiveMsg, &Reply);
/* Return the result, no matter what it is */
ReplyMsg->Status = Status;
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 07:22:37 2012
@@ -173,6 +173,7 @@
PCSR_PROCESS CsrProcess;
CurrentThread = NtCurrentTeb()->CsrClientThread;
+ if (!CurrentThread) return STATUS_SUCCESS; // server-to-server
CsrProcess = CurrentThread->Process;
if (CsrProcess->ClientId.UniqueProcess != Request->Data.CreateThreadRequest.ClientId.UniqueProcess)