- Update address of Free Software Foundation.
[reactos.git] / reactos / subsystems / win / winsrv / init.c
1 /* $Id$
2 *
3 * init.c - ReactOS/Win32 Console+User Enviroment Subsystem Server - Initialization
4 *
5 * ReactOS Operating System
6 *
7 * --------------------------------------------------------------------
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * --------------------------------------------------------------------
24 */
25 #include "winsrv.h"
26
27 //#define NDEBUG
28 #include <debug.h>
29
30 HANDLE WinSrvApiPort = NULL;
31
32 /**********************************************************************
33 * NAME PRIVATE
34 * ConStaticServerThread/1
35 */
36 VOID WINAPI ConStaticServerThread (PVOID x)
37 {
38 NTSTATUS Status = STATUS_SUCCESS;
39 PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
40 PPORT_MESSAGE Reply = NULL;
41 ULONG MessageType = 0;
42
43 DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
44
45 MessageType = Request->u2.s2.Type;
46 DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
47 __FUNCTION__, x, MessageType);
48 switch (MessageType)
49 {
50 default:
51 Reply = Request;
52 Status = NtReplyPort (WinSrvApiPort, Reply);
53 break;
54 }
55 }
56
57 /**********************************************************************
58 * NAME PRIVATE
59 * UserStaticServerThread/1
60 */
61 VOID WINAPI UserStaticServerThread (PVOID x)
62 {
63 NTSTATUS Status = STATUS_SUCCESS;
64 PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
65 PPORT_MESSAGE Reply = NULL;
66 ULONG MessageType = 0;
67
68 DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
69
70 MessageType = Request->u2.s2.Type;
71 DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
72 __FUNCTION__, x, MessageType);
73 switch (MessageType)
74 {
75 default:
76 Reply = Request;
77 Status = NtReplyPort (WinSrvApiPort, Reply);
78 break;
79 }
80 }
81
82 /*=====================================================================
83 * PUBLIC API
84 *===================================================================*/
85
86 NTSTATUS WINAPI ConServerDllInitialization (ULONG ArgumentCount,
87 LPWSTR *Argument)
88 {
89 NTSTATUS Status = STATUS_SUCCESS;
90
91 DPRINT("WINSRV: %s called\n", __FUNCTION__);
92
93 // Get the listening port from csrsrv.dll
94 WinSrvApiPort = CsrQueryApiPort ();
95 if (NULL == WinSrvApiPort)
96 {
97 return STATUS_UNSUCCESSFUL;
98 }
99 // Register our message dispatcher
100 Status = CsrAddStaticServerThread (ConStaticServerThread);
101 if (NT_SUCCESS(Status))
102 {
103 //TODO: perform the real console server internal initialization here
104 }
105 return Status;
106 }
107
108 NTSTATUS WINAPI UserServerDllInitialization (ULONG ArgumentCount,
109 LPWSTR *Argument)
110 {
111 NTSTATUS Status = STATUS_SUCCESS;
112
113 DPRINT("WINSRV: %s called\n", __FUNCTION__);
114
115 // Get the listening port from csrsrv.dll
116 WinSrvApiPort = CsrQueryApiPort ();
117 if (NULL == WinSrvApiPort)
118 {
119 return STATUS_UNSUCCESSFUL;
120 }
121 // Register our message dispatcher
122 Status = CsrAddStaticServerThread (UserStaticServerThread);
123 if (NT_SUCCESS(Status))
124 {
125 //TODO: perform the real user server internal initialization here
126 }
127 return Status;
128 }
129
130 /* EOF */