Fix a typo.
[reactos.git] / reactos / subsys / smss / debug.c
1 /* $Id$
2 *
3 * debug.c - Session Manager debug messages switch and router
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 "smss.h"
27
28 #define NDEBUG
29 #include <debug.h>
30
31
32 /* GLOBALS ***********************************************************/
33
34 HANDLE DbgSsApiPort = (HANDLE) 0;
35 HANDLE DbgUiApiPort = (HANDLE) 0;
36 HANDLE hSmDbgApiPort = (HANDLE) 0;
37
38 /* FUNCTIONS *********************************************************/
39
40 static VOID STDCALL
41 DbgSsApiPortThread (PVOID dummy)
42 {
43 NTSTATUS Status = STATUS_SUCCESS;
44 PORT_MESSAGE Request ;
45
46 RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
47 while (TRUE)
48 {
49 Status = NtListenPort (DbgSsApiPort, & Request);
50 if (!NT_SUCCESS(Status))
51 {
52 DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
53 break;
54 }
55 /* TODO */
56 }
57 NtTerminateThread(NtCurrentThread(),Status);
58 }
59
60 static VOID STDCALL
61 DbgUiApiPortThread (PVOID dummy)
62 {
63 NTSTATUS Status = STATUS_SUCCESS;
64 PORT_MESSAGE Request;
65
66 RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
67 while (TRUE)
68 {
69 Status = NtListenPort (DbgUiApiPort, & Request);
70 if (!NT_SUCCESS(Status))
71 {
72 DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
73 break;
74 }
75 /* TODO */
76 }
77 NtTerminateThread(NtCurrentThread(),Status);
78 }
79
80 static NTSTATUS STDCALL
81 SmpCreatePT (IN OUT PHANDLE hPort,
82 IN LPWSTR wcPortName,
83 IN ULONG ulMaxDataSize,
84 IN ULONG ulMaxMessageSize,
85 IN ULONG ulPoolCharge OPTIONAL,
86 IN VOID (STDCALL * procServingThread)(PVOID) OPTIONAL,
87 IN OUT PHANDLE phServingThread OPTIONAL)
88 {
89 NTSTATUS Status = STATUS_SUCCESS;
90 UNICODE_STRING PortName = {0};
91 OBJECT_ATTRIBUTES ObjectAttributes;
92 HANDLE Thread = (HANDLE) 0;
93 CLIENT_ID Cid = {0, 0};
94
95 RtlInitUnicodeString (& PortName, wcPortName);
96 InitializeObjectAttributes (& ObjectAttributes,
97 & PortName,
98 0,
99 NULL,
100 NULL);
101 Status = NtCreatePort (hPort,
102 & ObjectAttributes,
103 ulMaxDataSize,
104 ulMaxMessageSize,
105 ulPoolCharge);
106 if(STATUS_SUCCESS != Status)
107 {
108 return Status;
109 }
110 /* Create thread for DbgSsApiPort */
111 RtlCreateUserThread(NtCurrentProcess(),
112 NULL,
113 FALSE,
114 0,
115 0,
116 0,
117 (PTHREAD_START_ROUTINE) procServingThread,
118 hPort,
119 & Thread,
120 & Cid);
121 if((HANDLE) 0 == Thread)
122 {
123 NtClose(*hPort);
124 Status = STATUS_UNSUCCESSFUL;
125 }
126 if(NULL != phServingThread)
127 {
128 *phServingThread = Thread;
129 }
130 return Status;
131 }
132
133 NTSTATUS
134 SmInitializeDbgSs (VOID)
135 {
136 NTSTATUS Status = STATUS_SUCCESS;
137 HANDLE hDbgSsApiPortThread = (HANDLE) 0;
138
139
140 DPRINT("SM: %s called\n", __FUNCTION__);
141
142 /* Self register */
143 Status = SmRegisterInternalSubsystem (L"Debug",
144 (USHORT)-1,
145 & hSmDbgApiPort);
146 if (!NT_SUCCESS(Status))
147 {
148 DPRINT1("DBG:%s: SmRegisterInternalSubsystem failed with Status=%08lx\n",
149 __FUNCTION__, Status);
150 return Status;
151 }
152 /* Create the \DbgSsApiPort object (LPC) */
153 Status = SmpCreatePT(& DbgSsApiPort,
154 SM_DBGSS_PORT_NAME,
155 0, /* MaxDataSize */
156 0, /* MaxMessageSize */
157 0, /* PoolCharge */
158 DbgSsApiPortThread,
159 & hDbgSsApiPortThread);
160 if(!NT_SUCCESS(Status))
161 {
162 DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__);
163 return Status;
164 }
165 /* Create the \DbgUiApiPort object (LPC) */
166 Status = SmpCreatePT(& DbgUiApiPort,
167 SM_DBGUI_PORT_NAME,
168 0, /* MaxDataSize */
169 0, /* MaxMessageSize */
170 0, /* PoolCharge */
171 DbgUiApiPortThread,
172 NULL);
173 if(!NT_SUCCESS(Status))
174 {
175 DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__);
176 NtClose (hDbgSsApiPortThread);
177 NtClose (DbgSsApiPort);
178 return Status;
179 }
180 return STATUS_SUCCESS;
181 }
182
183 /* EOF */
184