Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / subsys / smss / smapi.c
1 /* $Id: smapi.c,v 1.8 2002/09/07 15:13:09 chorns Exp $
2 *
3 * Reactos Session Manager
4 *
5 *
6 */
7
8 #define NTOS_USER_MODE
9 #include <ntos.h>
10 #include "smss.h"
11
12 #define NDEBUG
13
14 /* GLOBAL VARIABLES *********************************************************/
15
16 static HANDLE SmApiPort = INVALID_HANDLE_VALUE;
17
18 /* FUNCTIONS ****************************************************************/
19
20
21 VOID STDCALL
22 SmApiThread(HANDLE Port)
23 {
24 NTSTATUS Status;
25 ULONG Unknown;
26 PLPC_MESSAGE Reply = NULL;
27 LPC_MESSAGE Message;
28
29 #ifndef NDEBUG
30 DisplayString(L"SmApiThread: running\n");
31 #endif
32
33 while (TRUE)
34 {
35 #ifndef NDEBUG
36 DisplayString(L"SmApiThread: waiting for message\n");
37 #endif
38
39 Status = NtReplyWaitReceivePort(Port,
40 &Unknown,
41 Reply,
42 &Message);
43 if (NT_SUCCESS(Status))
44 {
45 #ifndef NDEBUG
46 DisplayString(L"SmApiThread: message received\n");
47 #endif
48
49 if (Message.MessageType == LPC_CONNECTION_REQUEST)
50 {
51 // SmHandleConnectionRequest (Port, &Message);
52 Reply = NULL;
53 }
54 else if (Message.MessageType == LPC_DEBUG_EVENT)
55 {
56 // DbgSsHandleKmApiMsg (&Message, 0);
57 Reply = NULL;
58 }
59 else if (Message.MessageType == LPC_PORT_CLOSED)
60 {
61 Reply = NULL;
62 }
63 else
64 {
65 // Reply = &Message;
66 }
67 }
68 }
69 }
70
71
72 NTSTATUS
73 SmCreateApiPort(VOID)
74 {
75 OBJECT_ATTRIBUTES ObjectAttributes;
76 UNICODE_STRING UnicodeString;
77 NTSTATUS Status;
78
79 RtlInitUnicodeStringFromLiteral(&UnicodeString,
80 L"\\SmApiPort");
81 InitializeObjectAttributes(&ObjectAttributes,
82 &UnicodeString,
83 PORT_ALL_ACCESS,
84 NULL,
85 NULL);
86
87 Status = NtCreatePort(&SmApiPort,
88 &ObjectAttributes,
89 0,
90 0,
91 0);
92 if (!NT_SUCCESS(Status))
93 {
94 return(Status);
95 }
96
97 /* Create two threads for "\SmApiPort" */
98 RtlCreateUserThread(NtCurrentProcess(),
99 NULL,
100 FALSE,
101 0,
102 NULL,
103 NULL,
104 (PTHREAD_START_ROUTINE)SmApiThread,
105 (PVOID)SmApiPort,
106 NULL,
107 NULL);
108
109 RtlCreateUserThread(NtCurrentProcess(),
110 NULL,
111 FALSE,
112 0,
113 NULL,
114 NULL,
115 (PTHREAD_START_ROUTINE)SmApiThread,
116 (PVOID)SmApiPort,
117 NULL,
118 NULL);
119
120 return(Status);
121 }
122
123 /* EOF */