mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
- Try to get or to allocate the process data structure in ServerApiPortThread.
- Changed the initialization sequence in CsrServerInitialization. svn path=/trunk/; revision=9980
This commit is contained in:
parent
9a64b81079
commit
c973b907c8
3 changed files with 55 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: wapi.c,v 1.36 2004/06/27 12:21:32 weiden Exp $
|
||||
/* $Id: wapi.c,v 1.37 2004/07/03 17:15:02 hbirr Exp $
|
||||
*
|
||||
* reactos/subsys/csrss/api/wapi.c
|
||||
*
|
||||
|
@ -97,8 +97,8 @@ CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Thread_Api2(HANDLE ServerPort)
|
||||
static void STDCALL
|
||||
ClientConnectionThread(HANDLE ServerPort)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
LPC_MAX_MESSAGE LpcReply;
|
||||
|
@ -118,26 +118,31 @@ Thread_Api2(HANDLE ServerPort)
|
|||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
|
||||
NtClose(ServerPort);
|
||||
RtlRosExitUserThread(Status);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (LpcRequest.Header.MessageType == LPC_PORT_CLOSED)
|
||||
{
|
||||
CsrFreeProcessData( (ULONG)LpcRequest.Header.ClientId.UniqueProcess );
|
||||
NtClose(ServerPort);
|
||||
RtlRosExitUserThread(STATUS_SUCCESS);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
Request = (PCSRSS_API_REQUEST)&LpcRequest;
|
||||
Reply = (PCSRSS_API_REPLY)&LpcReply;
|
||||
|
||||
ProcessData = CsrGetProcessData((ULONG)LpcRequest.Header.ClientId.UniqueProcess);
|
||||
if (ProcessData == NULL)
|
||||
{
|
||||
DPRINT1("CSR: Message %d: Unable to find data for process %d\n",
|
||||
LpcRequest.Header.MessageType, (ULONG)LpcRequest.Header.ClientId.UniqueProcess);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
CsrApiCallHandler(ProcessData, Request, Reply);
|
||||
}
|
||||
NtClose(ServerPort);
|
||||
RtlRosExitUserThread(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -148,7 +153,8 @@ Thread_Api2(HANDLE ServerPort)
|
|||
* Handle connection requests from clients to the port
|
||||
* "\Windows\ApiPort".
|
||||
*/
|
||||
void Thread_Api(PVOID PortHandle)
|
||||
void STDCALL
|
||||
ServerApiPortThead(PVOID PortHandle)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
LPC_MAX_MESSAGE Request;
|
||||
|
@ -161,14 +167,14 @@ void Thread_Api(PVOID PortHandle)
|
|||
for (;;)
|
||||
{
|
||||
LPC_SECTION_READ LpcRead;
|
||||
ServerPort = NULL;
|
||||
|
||||
Status = NtListenPort(PortHandle, &Request.Header);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: NtListenPort() failed\n");
|
||||
NtTerminateThread(NtCurrentThread(), Status);
|
||||
break;
|
||||
}
|
||||
|
||||
Status = NtAcceptConnectPort(&ServerPort,
|
||||
PortHandle,
|
||||
NULL,
|
||||
|
@ -178,10 +184,19 @@ void Thread_Api(PVOID PortHandle)
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: NtAcceptConnectPort() failed\n");
|
||||
NtTerminateThread(NtCurrentThread(), Status);
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessData = CsrGetProcessData((ULONG)Request.Header.ClientId.UniqueProcess);
|
||||
ProcessData = CsrCreateProcessData((ULONG)Request.Header.ClientId.UniqueProcess);
|
||||
if (ProcessData == NULL)
|
||||
{
|
||||
DPRINT1("Unable to allocate or find data for process %d\n",
|
||||
(ULONG)Request.Header.ClientId.UniqueProcess);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ProcessData->CsrSectionViewBase = LpcRead.ViewBase;
|
||||
ProcessData->CsrSectionViewSize = LpcRead.ViewSize;
|
||||
|
||||
|
@ -189,7 +204,7 @@ void Thread_Api(PVOID PortHandle)
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: NtCompleteConnectPort() failed\n");
|
||||
NtTerminateThread(NtCurrentThread(), Status);
|
||||
break;
|
||||
}
|
||||
|
||||
Status = RtlCreateUserThread(NtCurrentProcess(),
|
||||
|
@ -198,18 +213,23 @@ void Thread_Api(PVOID PortHandle)
|
|||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(PTHREAD_START_ROUTINE)Thread_Api2,
|
||||
(PTHREAD_START_ROUTINE)ClientConnectionThread,
|
||||
ServerPort,
|
||||
&ServerThread,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: Unable to create server thread\n");
|
||||
NtClose(ServerPort);
|
||||
NtTerminateThread(NtCurrentThread(), Status);
|
||||
break;
|
||||
}
|
||||
NtClose(ServerThread);
|
||||
}
|
||||
if (ServerPort)
|
||||
{
|
||||
NtClose(ServerPort);
|
||||
}
|
||||
NtClose(PortHandle);
|
||||
NtTerminateThread(NtCurrentThread(), Status);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: api.h,v 1.4 2004/01/11 17:31:15 gvg Exp $
|
||||
/* $Id: api.h,v 1.5 2004/07/03 17:15:02 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -96,7 +96,7 @@ NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions
|
|||
VOID FASTCALL CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
|
||||
PCSRSS_API_REQUEST Request,
|
||||
PCSRSS_API_REPLY Reply);
|
||||
VOID Thread_Api(PVOID PortHandle);
|
||||
VOID STDCALL ServerApiPortThead(PVOID PortHandle);
|
||||
VOID Console_Api( DWORD Ignored );
|
||||
|
||||
extern HANDLE CsrssApiHeap;
|
||||
|
@ -107,6 +107,7 @@ VOID STDCALL CsrInitConsoleSupport(VOID);
|
|||
/* api/process.c */
|
||||
VOID STDCALL CsrInitProcessData(VOID);
|
||||
PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId);
|
||||
PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(ULONG ProcessId);
|
||||
NTSTATUS STDCALL CsrFreeProcessData( ULONG Pid );
|
||||
|
||||
/* api/handle.c */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: init.c,v 1.27 2004/05/28 21:33:41 gvg Exp $
|
||||
/* $Id: init.c,v 1.28 2004/07/03 17:15:02 hbirr Exp $
|
||||
*
|
||||
* reactos/subsys/csrss/init.c
|
||||
*
|
||||
|
@ -249,7 +249,6 @@ CsrServerInitialization (
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
CsrIsCsrss( );
|
||||
CsrInitVideo();
|
||||
|
||||
CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
|
||||
|
@ -270,13 +269,6 @@ CsrServerInitialization (
|
|||
return Status;
|
||||
}
|
||||
|
||||
Status = InitWin32Csr();
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: Unable to load usermode dll (Status %x)\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* NEW NAMED PORT: \ApiPort */
|
||||
RtlRosInitUnicodeStringFromLiteral(&PortName, L"\\Windows\\ApiPort");
|
||||
InitializeObjectAttributes(&ObAttributes,
|
||||
|
@ -300,7 +292,7 @@ CsrServerInitialization (
|
|||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(PTHREAD_START_ROUTINE)Thread_Api,
|
||||
(PTHREAD_START_ROUTINE)ServerApiPortThead,
|
||||
ApiPortHandle,
|
||||
NULL,
|
||||
NULL);
|
||||
|
@ -310,6 +302,18 @@ CsrServerInitialization (
|
|||
NtClose(ApiPortHandle);
|
||||
return FALSE;
|
||||
}
|
||||
Status = CsrClientConnectToServer();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CsrClientConnectToServer() failed (Status %x)\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
Status = InitWin32Csr();
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: Unable to load usermode dll (Status %x)\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return CallInitComplete();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue