Author: jmorlan
Date: Sat May 22 23:40:20 2010
New Revision: 47313
URL:
http://svn.reactos.org/svn/reactos?rev=47313&view=rev
Log:
[WIN32CSR] Make CsrFreeConsole close the process's console handles.
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
trunk/reactos/subsystems/win32/csrss/include/api.h
trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
trunk/reactos/subsystems/win32/csrss/include/win32csr.h
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] Sat May 22
23:40:20 2010
@@ -148,6 +148,45 @@
NTSTATUS
WINAPI
+CsrReleaseConsole(
+ PCSRSS_PROCESS_DATA ProcessData)
+{
+ ULONG HandleTableSize;
+ PCSRSS_HANDLE HandleTable;
+ PCSRSS_CONSOLE Console;
+ ULONG i;
+
+ /* Close all console handles and detach process from console */
+ RtlEnterCriticalSection(&ProcessData->HandleTableLock);
+ HandleTableSize = ProcessData->HandleTableSize;
+ HandleTable = ProcessData->HandleTable;
+ Console = ProcessData->Console;
+ ProcessData->HandleTableSize = 0;
+ ProcessData->HandleTable = NULL;
+ ProcessData->Console = NULL;
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+
+ for (i = 0; i < HandleTableSize; i++)
+ {
+ if (HandleTable[i].Object != NULL)
+ CsrReleaseObjectByPointer(HandleTable[i].Object);
+ }
+ RtlFreeHeap(CsrssApiHeap, 0, HandleTable);
+
+ if (Console != NULL)
+ {
+ RtlEnterCriticalSection((PRTL_CRITICAL_SECTION)&Console->Header.Lock);
+ RemoveEntryList(&ProcessData->ProcessEntry);
+ RtlLeaveCriticalSection((PRTL_CRITICAL_SECTION)&Console->Header.Lock);
+ CsrReleaseObjectByPointer(&Console->Header);
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_INVALID_PARAMETER;
+}
+
+NTSTATUS
+WINAPI
CsrInsertObject(
PCSRSS_PROCESS_DATA ProcessData,
PHANDLE Handle,
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] Sat May 22
23:40:20 2010
@@ -140,7 +140,6 @@
NTSTATUS WINAPI CsrFreeProcessData(HANDLE Pid)
{
ULONG hash;
- UINT c;
PCSRSS_PROCESS_DATA pProcessData, *pPrevLink;
HANDLE Process;
@@ -158,23 +157,7 @@
{
DPRINT("CsrFreeProcessData pid: %d\n", Pid);
Process = pProcessData->Process;
- if (pProcessData->HandleTable)
- {
- for (c = 0; c < pProcessData->HandleTableSize; c++)
- {
- if (pProcessData->HandleTable[c].Object)
- {
- CsrReleaseObjectByPointer(pProcessData->HandleTable[c].Object);
- }
- }
- RtlFreeHeap(CsrssApiHeap, 0, pProcessData->HandleTable);
- }
- RtlDeleteCriticalSection(&pProcessData->HandleTableLock);
- if (pProcessData->Console)
- {
- RemoveEntryList(&pProcessData->ProcessEntry);
- CsrReleaseObjectByPointer((Object_t *) pProcessData->Console);
- }
+ CsrReleaseConsole(pProcessData);
if (pProcessData->CsrSectionViewBase)
{
NtUnmapViewOfSection(NtCurrentProcess(), pProcessData->CsrSectionViewBase);
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Sat May 22 23:40:20
2010
@@ -335,6 +335,7 @@
Exports.CsrGetObjectProc = CsrGetObject;
Exports.CsrReleaseObjectByPointerProc = CsrReleaseObjectByPointer;
Exports.CsrReleaseObjectProc = CsrReleaseObject;
+ Exports.CsrReleaseConsoleProc = CsrReleaseConsole;
Exports.CsrEnumProcessesProc = CsrEnumProcesses;
if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
&HardErrorProc, &Exports, CsrssApiHeap))
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] Sat May 22 23:40:20
2010
@@ -193,6 +193,7 @@
NTSTATUS NTAPI CsrServerInitialization(ULONG ArgumentCount, PCHAR Arguments[]);
NTSTATUS WINAPI CsrReleaseObjectByPointer(Object_t *Object);
NTSTATUS WINAPI CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
+NTSTATUS WINAPI CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData);
NTSTATUS WINAPI CsrVerifyObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
//hack
Modified: trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/csrplugin.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/csrplugin.h [iso-8859-1] Sat May 22
23:40:20 2010
@@ -33,6 +33,7 @@
typedef NTSTATUS (WINAPI *CSRSS_RELEASE_OBJECT_BY_POINTER_PROC)(Object_t *Object);
typedef NTSTATUS (WINAPI *CSRSS_RELEASE_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessData,
HANDLE Object );
+typedef NTSTATUS (WINAPI *CSRSS_RELEASE_CONSOLE_PROC)(PCSRSS_PROCESS_DATA ProcessData);
typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc,
PVOID Context);
@@ -42,6 +43,7 @@
CSRSS_GET_OBJECT_PROC CsrGetObjectProc;
CSRSS_RELEASE_OBJECT_BY_POINTER_PROC CsrReleaseObjectByPointerProc;
CSRSS_RELEASE_OBJECT_PROC CsrReleaseObjectProc;
+ CSRSS_RELEASE_CONSOLE_PROC CsrReleaseConsoleProc;
CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc;
} CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS;
Modified: trunk/reactos/subsystems/win32/csrss/include/win32csr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/win32csr.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/win32csr.h [iso-8859-1] Sat May 22
23:40:20 2010
@@ -33,6 +33,7 @@
NTSTATUS FASTCALL Win32CsrReleaseObjectByPointer(Object_t *Object);
NTSTATUS FASTCALL Win32CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
HANDLE Object);
+NTSTATUS FASTCALL Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData);
NTSTATUS FASTCALL Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
PVOID Context);
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sat May 22 23:40:20
2010
@@ -369,25 +369,10 @@
CSR_API(CsrFreeConsole)
{
- PCSRSS_CONSOLE Console;
-
-
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- if (ProcessData->Console == NULL)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- Console = ProcessData->Console;
- ProcessData->Console = NULL;
- RemoveEntryList(&ProcessData->ProcessEntry);
- if (0 == InterlockedDecrement(&Console->Header.ReferenceCount))
- {
- ConioDeleteConsole((Object_t *) Console);
- }
- return STATUS_SUCCESS;
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+
+ return Win32CsrReleaseConsole(ProcessData);
}
static VOID FASTCALL
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sat May 22
23:40:20 2010
@@ -167,6 +167,12 @@
}
NTSTATUS FASTCALL
+Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData)
+{
+ return (CsrExports.CsrReleaseConsoleProc)(ProcessData);
+}
+
+NTSTATUS FASTCALL
Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
PVOID Context)
{