3 * Reactos Session Manager
8 /*#include <ddk/ntddk.h>
9 #include <ntdll/rtl.h>*/
10 #define NTOS_MODE_USER
13 #include <rosrtl/string.h>
18 /* GLOBAL VARIABLES *********************************************************/
20 static HANDLE SmApiPort
= INVALID_HANDLE_VALUE
;
22 /* SM API *******************************************************************/
25 NTSTATUS FASTCALL n (PSM_PORT_MESSAGE Request)
29 DbgPrint("SMSS: %s called\n",__FUNCTION__
);
30 Request
->Status
= STATUS_NOT_IMPLEMENTED
;
31 return STATUS_SUCCESS
;
36 DbgPrint("SMSS: %s called\n",__FUNCTION__
);
37 Request
->Status
= STATUS_NOT_IMPLEMENTED
;
38 return STATUS_SUCCESS
;
42 DbgPrint("SMSS: %s called\n",__FUNCTION__
);
43 Request
->Status
= STATUS_NOT_IMPLEMENTED
;
44 return STATUS_SUCCESS
;
48 typedef NTSTATUS (FASTCALL
* SM_PORT_API
)(PSM_PORT_MESSAGE
);
50 SM_PORT_API SmApi
[] =
52 SmInvalid
, /* unused */
54 SmInvalid
, /* obsolete */
55 SmInvalid
, /* unknown */
60 /**********************************************************************
62 * SmpHandleConnectionRequest/2
65 * Quoted in http://support.microsoft.com/kb/258060/EN-US/
68 SmpHandleConnectionRequest (HANDLE Port
, PSM_PORT_MESSAGE Request
)
70 DbgPrint("SMSS: %s called\n",__FUNCTION__
);
71 return STATUS_SUCCESS
;
74 /**********************************************************************
79 * Entry point for the listener thread of LPC port "\SmApiPort".
82 SmpApiThread(HANDLE Port
)
84 NTSTATUS Status
= STATUS_SUCCESS
;
86 PLPC_MESSAGE Reply
= NULL
;
87 SM_PORT_MESSAGE Request
= {{0}};
89 DbgPrint("SMSS: %s running.\n",__FUNCTION__
);
93 DbgPrint("SMSS: %s: waiting for message\n",__FUNCTION__
);
95 Status
= NtReplyWaitReceivePort(Port
,
98 (PLPC_MESSAGE
) & Request
);
99 if (NT_SUCCESS(Status
))
101 DbgPrint("SMSS: %s: message received\n",__FUNCTION__
);
103 switch (Request
.Header
.MessageType
)
105 case LPC_CONNECTION_REQUEST
:
106 SmpHandleConnectionRequest (Port
, &Request
);
109 case LPC_DEBUG_EVENT
:
110 // DbgSsHandleKmApiMsg (&Request, 0);
113 case LPC_PORT_CLOSED
:
117 if ((Request
.ApiIndex
) &&
118 (Request
.ApiIndex
< (sizeof SmApi
/ sizeof SmApi
[0])))
120 Status
= SmApi
[Request
.ApiIndex
](&Request
);
121 Reply
= (PLPC_MESSAGE
) & Request
;
123 Request
.Status
= STATUS_NOT_IMPLEMENTED
;
124 Reply
= (PLPC_MESSAGE
) & Request
;
132 /* LPC PORT INITIALIZATION **************************************************/
135 /**********************************************************************
142 SmCreateApiPort(VOID
)
144 OBJECT_ATTRIBUTES ObjectAttributes
;
145 UNICODE_STRING UnicodeString
;
148 RtlRosInitUnicodeStringFromLiteral(&UnicodeString
,
150 InitializeObjectAttributes(&ObjectAttributes
,
156 Status
= NtCreatePort(&SmApiPort
,
161 if (!NT_SUCCESS(Status
))
166 /* Create two threads for "\SmApiPort" */
167 RtlCreateUserThread(NtCurrentProcess(),
173 (PTHREAD_START_ROUTINE
)SmpApiThread
,
178 RtlCreateUserThread(NtCurrentProcess(),
184 (PTHREAD_START_ROUTINE
)SmpApiThread
,