- Less STDCALL, more WINAPI/NTAPI/APIENTRY
[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 software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This software 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 GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this software; see the file COPYING.LIB. If not, write
21 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
22 * MA 02139, USA.
23 *
24 * --------------------------------------------------------------------
25 */
26 #include "winsrv.h"
27
28 //#define NDEBUG
29 #include <debug.h>
30
31 HANDLE WinSrvApiPort = NULL;
32
33 /**********************************************************************
34 * NAME PRIVATE
35 * ConStaticServerThread/1
36 */
37 VOID WINAPI ConStaticServerThread (PVOID x)
38 {
39 NTSTATUS Status = STATUS_SUCCESS;
40 PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
41 PPORT_MESSAGE Reply = NULL;
42 ULONG MessageType = 0;
43
44 DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
45
46 MessageType = Request->u2.s2.Type;
47 DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
48 __FUNCTION__, x, MessageType);
49 switch (MessageType)
50 {
51 default:
52 Reply = Request;
53 Status = NtReplyPort (WinSrvApiPort, Reply);
54 break;
55 }
56 }
57
58 /**********************************************************************
59 * NAME PRIVATE
60 * UserStaticServerThread/1
61 */
62 VOID WINAPI UserStaticServerThread (PVOID x)
63 {
64 NTSTATUS Status = STATUS_SUCCESS;
65 PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
66 PPORT_MESSAGE Reply = NULL;
67 ULONG MessageType = 0;
68
69 DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
70
71 MessageType = Request->u2.s2.Type;
72 DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
73 __FUNCTION__, x, MessageType);
74 switch (MessageType)
75 {
76 default:
77 Reply = Request;
78 Status = NtReplyPort (WinSrvApiPort, Reply);
79 break;
80 }
81 }
82
83 /*=====================================================================
84 * PUBLIC API
85 *===================================================================*/
86
87 NTSTATUS WINAPI ConServerDllInitialization (ULONG ArgumentCount,
88 LPWSTR *Argument)
89 {
90 NTSTATUS Status = STATUS_SUCCESS;
91
92 DPRINT("WINSRV: %s called\n", __FUNCTION__);
93
94 // Get the listening port from csrsrv.dll
95 WinSrvApiPort = CsrQueryApiPort ();
96 if (NULL == WinSrvApiPort)
97 {
98 return STATUS_UNSUCCESSFUL;
99 }
100 // Register our message dispatcher
101 Status = CsrAddStaticServerThread (ConStaticServerThread);
102 if (NT_SUCCESS(Status))
103 {
104 //TODO: perform the real console server internal initialization here
105 }
106 return Status;
107 }
108
109 NTSTATUS WINAPI UserServerDllInitialization (ULONG ArgumentCount,
110 LPWSTR *Argument)
111 {
112 NTSTATUS Status = STATUS_SUCCESS;
113
114 DPRINT("WINSRV: %s called\n", __FUNCTION__);
115
116 // Get the listening port from csrsrv.dll
117 WinSrvApiPort = CsrQueryApiPort ();
118 if (NULL == WinSrvApiPort)
119 {
120 return STATUS_UNSUCCESSFUL;
121 }
122 // Register our message dispatcher
123 Status = CsrAddStaticServerThread (UserStaticServerThread);
124 if (NT_SUCCESS(Status))
125 {
126 //TODO: perform the real user server internal initialization here
127 }
128 return Status;
129 }
130
131 /* EOF */