1 /* $Id: lpc.c,v 1.1 2001/06/17 20:05:09 ea Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ntdll/csr/lpc.c
6 * PURPOSE: CSRSS Client/Server LPC API
10 * File api.c renamed lpc.c. Process/thread code moved
11 * in thread.c. Check added on the LPC port.
14 /* INCLUDES *****************************************************************/
16 #include <ddk/ntddk.h>
17 #include <ntdll/csr.h>
20 #include <csrss/csrss.h>
23 #include <ntdll/ntdll.h>
25 /* GLOBALS *******************************************************************/
27 HANDLE WindowsApiPort
= INVALID_HANDLE_VALUE
;
29 /* FUNCTIONS *****************************************************************/
31 /* Possible CsrClientCallServer (the NT one):
34 CsrClientCallServer(PCSRSS_XXX_REQUEST Request,
35 PCSRSS_XXX_REPLY Reply OPTIONAL,
37 ULONG MaxRequestReplyLength)
39 XXX_REQUEST and XXX_REPLY depend on the CsrApiNumber value and are not LPC
40 objects (the LPC_REQUEST is built here instead).
41 If Reply == NULL, use storage of Request to write the reply.
47 CsrClientCallServer(PCSRSS_API_REQUEST Request
,
48 PCSRSS_API_REPLY Reply OPTIONAL
,
54 if (INVALID_HANDLE_VALUE
== WindowsApiPort
)
56 DbgPrint ("NTDLL.%s: client not connected to CSRSS!\n", __FUNCTION__
);
57 return (STATUS_UNSUCCESSFUL
);
60 // DbgPrint("CsrClientCallServer(Request %x, Reply %x, Length %d, "
61 // "ReplyLength %d)\n", Request, Reply, Length, ReplyLength);
63 Request
->Header
.DataSize
= Length
;
64 Request
->Header
.MessageSize
= sizeof(LPC_MESSAGE_HEADER
) + Length
;
67 Status
= NtRequestWaitReplyPort(WindowsApiPort
,
69 (Reply
?&Reply
->Header
:&Request
->Header
));
71 // DbgPrint("Status %x\n", Status);
77 CsrClientConnectToServer(VOID
)
80 UNICODE_STRING PortName
;
81 ULONG ConnectInfoLength
;
82 CSRSS_API_REQUEST Request
;
83 CSRSS_API_REPLY Reply
;
85 RtlInitUnicodeString(&PortName
, L
"\\Windows\\ApiPort");
86 ConnectInfoLength
= 0;
87 Status
= NtConnectPort(&WindowsApiPort
,
95 if (!NT_SUCCESS(Status
))
100 Request
.Type
= CSRSS_CONNECT_PROCESS
;
101 Status
= CsrClientCallServer(&Request
,
103 sizeof(CSRSS_API_REQUEST
),
104 sizeof(CSRSS_API_REPLY
));
105 if (!NT_SUCCESS(Status
))
109 if (!NT_SUCCESS(Reply
.Status
))
111 return(Reply
.Status
);
113 return(STATUS_SUCCESS
);