Author: ion
Date: Sun Feb 19 18:46:05 2012
New Revision: 55717
URL:
http://svn.reactos.org/svn/reactos?rev=55717&view=rev
Log:
[KERNEL32/CSRSRV]: Handle ExitProcess CSRSS message and implement CsrDestroyProcess to do
so. Also implement CsrDestroyThread for future purposes.
Modified:
trunk/reactos/dll/win32/kernel32/client/proc.c
trunk/reactos/include/reactos/subsys/csrss/csrss.h
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c
trunk/reactos/subsystems/win32/csrss/include/api.h
Modified: trunk/reactos/dll/win32/kernel32/client/proc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Sun Feb 19 18:46:05 2012
@@ -1753,6 +1753,7 @@
LdrShutdownProcess();
/* Notify Base Server of process termination */
+ CsrRequest.Data.TerminateProcessRequest.uExitCode = uExitCode;
CsrClientCallServer(&CsrRequest,
NULL,
MAKE_CSR_API(TERMINATE_PROCESS, CSR_NATIVE),
Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
==============================================================================
--- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Sun Feb 19 18:46:05
2012
@@ -80,7 +80,7 @@
typedef struct
{
- ULONG Dummy;
+ UINT uExitCode;
} CSRSS_TERMINATE_PROCESS, *PCSRSS_TERMINATE_PROCESS;
typedef struct
@@ -713,6 +713,7 @@
{
CSRSS_CREATE_PROCESS CreateProcessRequest;
CSRSS_CREATE_THREAD CreateThreadRequest;
+ CSRSS_TERMINATE_PROCESS TerminateProcessRequest;
CSRSS_CONNECT_PROCESS ConnectRequest;
CSRSS_WRITE_CONSOLE WriteConsoleRequest;
CSRSS_READ_CONSOLE ReadConsoleRequest;
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
18:46:05 2012
@@ -245,26 +245,12 @@
CSR_API(CsrTerminateProcess)
{
- PLIST_ENTRY NextEntry;
- PCSR_THREAD Thread;
-
- LOCK;
-
- NextEntry = ProcessData->ThreadList.Flink;
- while (NextEntry != &ProcessData->ThreadList)
- {
- Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
- NextEntry = NextEntry->Flink;
-
- ASSERT(ProcessStructureListLocked());
- CsrThreadRefcountZero(Thread);
- LOCK;
-
- }
-
- UNLOCK;
- ProcessData->Flags |= CsrProcessTerminated;
- return STATUS_SUCCESS;
+ PCSR_THREAD CsrThread = NtCurrentTeb()->CsrClientThread;
+ ASSERT(CsrThread != NULL);
+
+ /* Remove the CSR_THREADs and CSR_PROCESS */
+ return CsrDestroyProcess(&CsrThread->ClientId,
+
(NTSTATUS)Request->Data.TerminateProcessRequest.uExitCode);
}
CSR_API(CsrConnectProcess)
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/thredsup.c [iso-8859-1] Sun Feb 19
18:46:05 2012
@@ -311,6 +311,75 @@
}
/*++
+ * @name CsrDestroyThread
+ * @implemented NT4
+ *
+ * The CsrDestroyThread routine destroys the CSR Thread corresponding to
+ * a given Thread ID.
+ *
+ * @param Cid
+ * Pointer to the Client ID Structure corresponding to the CSR
+ * Thread which is about to be destroyed.
+ *
+ * @return STATUS_SUCCESS in case of success, STATUS_THREAD_IS_TERMINATING
+ * if the CSR Thread is already terminating.
+ *
+ * @remarks None.
+ *
+ *--*/
+NTSTATUS
+NTAPI
+CsrDestroyThread(IN PCLIENT_ID Cid)
+{
+ CLIENT_ID ClientId = *Cid;
+ PCSR_THREAD CsrThread;
+ PCSR_PROCESS CsrProcess;
+
+ /* Acquire lock */
+ CsrAcquireProcessLock();
+
+ /* Find the thread */
+ CsrThread = CsrLocateThreadByClientId(&CsrProcess,
+ &ClientId);
+
+ /* Make sure we got one back, and that it's not already gone */
+ if (!CsrThread || CsrThread->Flags & CsrThreadTerminated)
+ {
+ /* Release the lock and return failure */
+ CsrReleaseProcessLock();
+ return STATUS_THREAD_IS_TERMINATING;
+ }
+
+ /* Set the terminated flag */
+ CsrThread->Flags |= CsrThreadTerminated;
+
+ /* Acquire the Wait Lock */
+ CsrAcquireWaitLock();
+
+ /* Do we have an active wait block? */
+ if (CsrThread->WaitBlock)
+ {
+ /* Notify waiters of termination */
+ CsrNotifyWaitBlock(CsrThread->WaitBlock,
+ NULL,
+ NULL,
+ NULL,
+ CsrProcessTerminating,
+ TRUE);
+ }
+
+ /* Release the Wait Lock */
+ CsrReleaseWaitLock();
+
+ /* Dereference the thread */
+ CsrLockedDereferenceThread(CsrThread);
+
+ /* Release the Process Lock and return success */
+ CsrReleaseProcessLock();
+ return STATUS_SUCCESS;
+}
+
+/*++
* @name CsrLockedDereferenceThread
*
* The CsrLockedDereferenceThread derefences a CSR Thread while the
Modified: trunk/reactos/subsystems/win32/csrss/include/api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Sun Feb 19 18:46:05
2012
@@ -420,6 +420,10 @@
CsrDestroyProcess(IN PCLIENT_ID Cid,
IN NTSTATUS ExitStatus);
+NTSTATUS
+NTAPI
+CsrDestroyThread(IN PCLIENT_ID Cid);
+
VOID
NTAPI
CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread);