Author: ion
Date: Mon Oct 30 21:45:22 2006
New Revision: 24680
URL:
http://svn.reactos.org/svn/reactos?rev=24680&view=rev
Log:
- Use Emanuelle's design for SMSS's LPC Code in CSRSS as well so that it can be
portable between ROS LPC and NT LPC.
Modified:
trunk/reactos/subsystems/win32/csrss/api/wapi.c
trunk/reactos/subsystems/win32/csrss/include/api.h
trunk/reactos/subsystems/win32/csrss/init.c
Modified: trunk/reactos/subsystems/win32/csrss/api/wapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/api…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/wapi.c (original)
+++ trunk/reactos/subsystems/win32/csrss/api/wapi.c Mon Oct 30 21:45:22 2006
@@ -118,7 +118,81 @@
CallHardError();
}
-static
+NTSTATUS STDCALL
+CsrpHandleConnectionRequest (PPORT_MESSAGE Request,
+ IN HANDLE hApiListenPort)
+{
+ NTSTATUS Status;
+ HANDLE ServerPort = (HANDLE) 0;
+ PCSRSS_PROCESS_DATA ProcessData = NULL;
+ REMOTE_PORT_VIEW LpcRead;
+ LpcRead.Length = sizeof(LpcRead);
+ ServerPort = NULL;
+
+ DPRINT1("CSR: %s: Handling: %p\n", __FUNCTION__, Request);
+
+ Status = NtAcceptConnectPort(&ServerPort,
+#ifdef NTLPC
+ NULL,
+ Request,
+#else
+ hApiListenPort,
+ NULL,
+#endif
+ TRUE,
+ 0,
+ & LpcRead);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: NtAcceptConnectPort() failed\n");
+ return Status;
+ }
+
+ ProcessData = CsrCreateProcessData(Request->ClientId.UniqueProcess);
+ if (ProcessData == NULL)
+ {
+ DPRINT1("Unable to allocate or find data for process 0x%x\n",
+ Request->ClientId.UniqueProcess);
+ Status = STATUS_UNSUCCESSFUL;
+ return Status;
+ }
+
+ ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
+ ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
+
+ Status = NtCompleteConnectPort(ServerPort);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: NtCompleteConnectPort() failed\n");
+ return Status;
+ }
+
+#if !defined(NTLPC) /* ReactOS LPC */
+ HANDLE ServerThread = (HANDLE) 0;
+ Status = RtlCreateUserThread(NtCurrentProcess(),
+ NULL,
+ FALSE,
+ 0,
+ 0,
+ 0,
+ (PTHREAD_START_ROUTINE)ClientConnectionThread,
+ ServerPort,
+ & ServerThread,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: Unable to create server thread\n");
+ return Status;
+ }
+
+ NtClose(ServerThread);
+#endif
+
+ Status = STATUS_SUCCESS;
+ DPRINT1("CSR: %s done\n", __FUNCTION__);
+ return Status;
+}
+
VOID
STDCALL
ClientConnectionThread(HANDLE ServerPort)
@@ -155,6 +229,13 @@
break;
}
+ if (Request->Header.u2.s2.Type == LPC_CONNECTION_REQUEST)
+ {
+ CsrpHandleConnectionRequest((PPORT_MESSAGE)Request, ServerPort);
+ Reply = NULL;
+ continue;
+ }
+
DPRINT("CSR: Got CSR API: %x [Message Origin: %x]\n",
Request->Type,
Request->Header.ClientId.UniqueProcess);
@@ -205,93 +286,38 @@
* "\Windows\ApiPort".
*/
DWORD STDCALL
-ServerApiPortThread (PVOID PortHandle)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- BYTE RawRequest[sizeof(PORT_MESSAGE) + sizeof(CSR_CONNECTION_INFO)];
- PPORT_MESSAGE Request = (PPORT_MESSAGE)RawRequest;
- HANDLE hApiListenPort = * (PHANDLE) PortHandle;
- HANDLE ServerPort = (HANDLE) 0;
- HANDLE ServerThread = (HANDLE) 0;
- PCSRSS_PROCESS_DATA ProcessData = NULL;
-
- CsrInitProcessData();
-
- DPRINT1("CSR: %s called", __FUNCTION__);
-
- for (;;)
- {
- REMOTE_PORT_VIEW LpcRead;
- LpcRead.Length = sizeof(LpcRead);
- ServerPort = NULL;
-
- Status = NtListenPort (hApiListenPort, Request);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: NtListenPort() failed, status=%x\n", Status);
- break;
- }
- Status = NtAcceptConnectPort(& ServerPort,
-#ifdef NTLPC
- NULL,
- Request,
-#else
- hApiListenPort,
- NULL,
-#endif
- TRUE,
- 0,
- & LpcRead);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: NtAcceptConnectPort() failed\n");
- break;
- }
-
- ProcessData = CsrCreateProcessData(Request->ClientId.UniqueProcess);
- if (ProcessData == NULL)
- {
- DPRINT1("Unable to allocate or find data for process 0x%x\n",
- Request->ClientId.UniqueProcess);
- Status = STATUS_UNSUCCESSFUL;
- break;
- }
-
-
- ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
- ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
-
- Status = NtCompleteConnectPort(ServerPort);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: NtCompleteConnectPort() failed\n");
- break;
- }
-
- Status = RtlCreateUserThread(NtCurrentProcess(),
- NULL,
- FALSE,
- 0,
- 0,
- 0,
- (PTHREAD_START_ROUTINE)ClientConnectionThread,
- ServerPort,
- & ServerThread,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: Unable to create server thread\n");
- break;
- }
- NtClose(ServerThread);
- }
- if (ServerPort)
- {
- NtClose(ServerPort);
- }
- NtClose(PortHandle);
- NtTerminateThread(NtCurrentThread(), Status);
- return 0;
+ServerApiPortThread (HANDLE hApiListenPort)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ BYTE RawRequest[sizeof(PORT_MESSAGE) + sizeof(CSR_CONNECTION_INFO)];
+ PPORT_MESSAGE Request = (PPORT_MESSAGE)RawRequest;
+
+ DPRINT1("CSR: %s called", __FUNCTION__);
+
+ for (;;)
+ {
+ REMOTE_PORT_VIEW LpcRead;
+ LpcRead.Length = sizeof(LpcRead);
+
+ Status = NtListenPort (hApiListenPort, Request);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: NtListenPort() failed, status=%x\n", Status);
+ break;
+ }
+
+ Status = CsrpHandleConnectionRequest(Request, hApiListenPort);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: %s: SmpHandleConnectionRequest failed
(Status=0x%08lx)\n",
+ __FUNCTION__, Status);
+ break;
+ }
+ }
+
+ NtClose(hApiListenPort);
+ NtTerminateThread(NtCurrentThread(), Status);
+ return 0;
}
/**********************************************************************
@@ -304,9 +330,8 @@
* connection request (from the SM).
*/
DWORD STDCALL
-ServerSbApiPortThread (PVOID PortHandle)
-{
- HANDLE hSbApiPortListen = * (PHANDLE) PortHandle;
+ServerSbApiPortThread (HANDLE hSbApiPortListen)
+{
HANDLE hConnectedPort = (HANDLE) 0;
PORT_MESSAGE Request;
PVOID Context = NULL;
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 (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h Mon Oct 30 21:45:22 2006
@@ -104,6 +104,9 @@
DWORD STDCALL ServerApiPortThread (PVOID PortHandle);
DWORD STDCALL ServerSbApiPortThread (PVOID PortHandle);
DWORD STDCALL Console_Api( PVOID unused );
+VOID
+NTAPI
+ClientConnectionThread(HANDLE ServerPort);
extern HANDLE CsrssApiHeap;
Modified: trunk/reactos/subsystems/win32/csrss/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/ini…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/init.c (original)
+++ trunk/reactos/subsystems/win32/csrss/init.c Mon Oct 30 21:45:22 2006
@@ -331,7 +331,7 @@
0,
0,
(PTHREAD_START_ROUTINE) ListenThread,
- Port,
+ *Port,
NULL,
NULL);
return Status;
@@ -528,9 +528,14 @@
{
DPRINT("CSR: %s called\n", __FUNCTION__);
+ CsrInitProcessData();
return CsrpCreateListenPort (L"\\Windows\\ApiPort",
& hApiPort,
+#ifdef NTLPC
+ (PTHREAD_START_ROUTINE)ClientConnectionThread);
+#else
ServerApiPortThread);
+#endif
}
/**********************************************************************