3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/eventlog/logport.c
24 * PURPOSE: Event logger service
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
32 #define NTOS_MODE_USER
43 /* GLOBALS ******************************************************************/
45 HANDLE PortThreadHandle = NULL;
46 HANDLE ConnectPortHandle = NULL;
47 HANDLE MessagePortHandle = NULL;
50 /* FUNCTIONS ****************************************************************/
55 OBJECT_ATTRIBUTES ObjectAttributes;
56 UNICODE_STRING PortName;
60 ConnectPortHandle = NULL;
61 MessagePortHandle = NULL;
63 RtlInitUnicodeStringFromLiteral(&PortName,
65 InitializeObjectAttributes(&ObjectAttributes,
71 Status = NtCreatePort(&ConnectPortHandle,
76 if (!NT_SUCCESS(Status))
79 Message.DataSize = sizeof(LPC_MESSAGE);
80 Message.MessageSize = 0;
82 Status = NtListenPort(ConnectPortHandle,
84 if (!NT_SUCCESS(Status))
87 Status = NtAcceptConnectPort(&MessagePortHandle,
93 if (!NT_SUCCESS(Status))
96 Status = NtCompleteConnectPort(MessagePortHandle);
97 if (!NT_SUCCESS(Status))
101 if (ConnectPortHandle != NULL)
102 NtClose(ConnectPortHandle);
104 if (MessagePortHandle != NULL)
105 NtClose(MessagePortHandle);
112 ProcessPortMessage(VOID)
114 PLPC_MAX_MESSAGE Request;
116 BOOL ReplyReady = FALSE;
119 Request = HeapAlloc(GetProcessHeap(),
121 sizeof(LPC_MAX_MESSAGE));
123 return(STATUS_NO_MEMORY);
127 Status = NtReplyWaitReceivePort(MessagePortHandle,
129 (ReplyReady)? &Reply : NULL,
130 (PLPC_MESSAGE)Request);
131 if (!NT_SUCCESS(Status))
133 HeapFree(GetProcessHeap(),
140 if (Request->Header.MessageType == LPC_REQUEST)
142 DPRINT1("Received request\n");
146 else if (Request->Header.MessageType == LPC_DATAGRAM)
148 DPRINT1("Received datagram\n");
154 static NTSTATUS STDCALL
155 PortThreadRoutine(PVOID Param)
157 NTSTATUS Status = STATUS_SUCCESS;
159 Status = InitLogPort();
160 if (!NT_SUCCESS(Status))
163 while (!NT_SUCCESS(Status))
165 Status = ProcessPortMessage();
173 StartPortThread(VOID)
177 PortThreadHandle = CreateThread(NULL,
184 return((PortThreadHandle != NULL));