be317626033db2e94a263b9fce1c76507162b61f
[reactos.git] / posix / lib / psxdll / misc / init.c
1 /* $Id: init.c,v 1.2 2002/04/10 21:30:21 ea Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS POSIX+ Subsystem
5 * FILE: reactos/subsys/psx/lib/psxdll/misc/init.c
6 * PURPOSE: Client initialization
7 * PROGRAMMER: Emanuele Aliberti
8 * UPDATE HISTORY:
9 * 2001-05-06
10 */
11 #define NTOS_MODE_USER
12 #include <ntos.h>
13 #include <psx/lpcproto.h>
14
15 /* DLL GLOBALS */
16 int * errno = NULL;
17 char *** _environ = NULL;
18 HANDLE ApiPort = INVALID_HANDLE_VALUE;
19 /*
20 * Called by startup code in crt0.o, where real
21 * errno and _environ are actually defined.
22 */
23 VOID STDCALL __PdxInitializeData (int * errno_arg, char *** environ_arg)
24 {
25 errno = errno_arg;
26 _environ = environ_arg;
27 }
28 /*
29 * Called by DLL's entry point when reason==PROCESS_ATTACH.
30 */
31 NTATATUS STDCALL PsxConnectApiPort (VOID)
32 {
33 UNICODE_STRING usApiPortName;
34 LPWSTR wsApiPortName = L"\\"PSX_NS_SUBSYSTEM_DIRECTORY_NAME"\\"PSX_NS_API_PORT_NAME;
35 SECURITY_QUALITY_OF_SERVICE Sqos;
36 ULONG MaxMessageSize = 0;
37 NTSTATUS Status;
38 PSX_CONNECT_PORT_DATA ConnectData;
39 ULONG ConnectDataLength = sizeof ConnectData;
40
41 RtlInitUnicodeString (& usApiPortName, wsApiPortName);
42 RtlZeroMemory (Sqos, sizeof Sqos);
43 ConnectData.ConnectionType = PSX_CONNECTION_TYPE_PROCESS;
44 ConnectData.Version = PSX_LPC_PROTOCOL_VERSION;
45 ConnectData.PortIdentifier = 0;
46 Status = NtConnectPort (
47 & ApiPort,
48 & usApiPortName,
49 & Sqos,
50 NULL,
51 NULL,
52 & MaxMessageSize,
53 & ConnectData,
54 & ConnectDataLength
55 );
56 if (!NT_SUCCESS(Status))
57 {
58 /* TODO: emit a diagnostic message */
59 return Status;
60 }
61 /* TODO: save returned data */
62 return STATUS_SUCCESS;
63 }
64 /* EOF */
65