3 * debug.c - Session Manager debug messages switch and router
5 * ReactOS Operating System
7 * --------------------------------------------------------------------
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.
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.
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,
24 * --------------------------------------------------------------------
32 /* GLOBALS ***********************************************************/
34 HANDLE DbgSsApiPort
= (HANDLE
) 0;
35 HANDLE DbgUiApiPort
= (HANDLE
) 0;
36 HANDLE hSmDbgApiPort
= (HANDLE
) 0;
38 /* FUNCTIONS *********************************************************/
41 DbgSsApiPortThread (PVOID dummy
)
43 NTSTATUS Status
= STATUS_SUCCESS
;
44 PORT_MESSAGE Request
;
46 RtlZeroMemory(&Request
, sizeof(PORT_MESSAGE
));
49 Status
= NtListenPort (DbgSsApiPort
, & Request
);
50 if (!NT_SUCCESS(Status
))
52 DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__
, Status
);
57 NtTerminateThread(NtCurrentThread(),Status
);
61 DbgUiApiPortThread (PVOID dummy
)
63 NTSTATUS Status
= STATUS_SUCCESS
;
66 RtlZeroMemory(&Request
, sizeof(PORT_MESSAGE
));
69 Status
= NtListenPort (DbgUiApiPort
, & Request
);
70 if (!NT_SUCCESS(Status
))
72 DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__
, Status
);
77 NtTerminateThread(NtCurrentThread(),Status
);
80 static NTSTATUS STDCALL
81 SmpCreatePT (IN OUT PHANDLE hPort
,
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
)
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};
95 RtlInitUnicodeString (& PortName
, wcPortName
);
96 InitializeObjectAttributes (& ObjectAttributes
,
101 Status
= NtCreatePort (hPort
,
106 if(STATUS_SUCCESS
!= Status
)
110 /* Create thread for DbgSsApiPort */
111 RtlCreateUserThread(NtCurrentProcess(),
117 (PTHREAD_START_ROUTINE
) procServingThread
,
121 if((HANDLE
) 0 == Thread
)
124 Status
= STATUS_UNSUCCESSFUL
;
126 if(NULL
!= phServingThread
)
128 *phServingThread
= Thread
;
134 SmInitializeDbgSs (VOID
)
136 NTSTATUS Status
= STATUS_SUCCESS
;
137 HANDLE hDbgSsApiPortThread
= (HANDLE
) 0;
140 DPRINT("SM: %s called\n", __FUNCTION__
);
143 Status
= SmRegisterInternalSubsystem (L
"Debug",
146 if (!NT_SUCCESS(Status
))
148 DPRINT1("DBG:%s: SmRegisterInternalSubsystem failed with Status=%08lx\n",
149 __FUNCTION__
, Status
);
152 /* Create the \DbgSsApiPort object (LPC) */
153 Status
= SmpCreatePT(& DbgSsApiPort
,
156 0, /* MaxMessageSize */
159 & hDbgSsApiPortThread
);
160 if(!NT_SUCCESS(Status
))
162 DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__
);
165 /* Create the \DbgUiApiPort object (LPC) */
166 Status
= SmpCreatePT(& DbgUiApiPort
,
169 0, /* MaxMessageSize */
173 if(!NT_SUCCESS(Status
))
175 DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__
);
176 NtClose (hDbgSsApiPortThread
);
177 NtClose (DbgSsApiPort
);
180 return STATUS_SUCCESS
;