Added eventlog service stub.
authorEric Kohl <eric.kohl@reactos.org>
Tue, 25 Jun 2002 21:10:14 +0000 (21:10 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 25 Jun 2002 21:10:14 +0000 (21:10 +0000)
svn path=/trunk/; revision=3142

reactos/services/eventlog/eventlog.c [new file with mode: 0644]
reactos/services/eventlog/eventlog.h [new file with mode: 0644]
reactos/services/eventlog/eventlog.rc [new file with mode: 0644]
reactos/services/eventlog/logport.c [new file with mode: 0644]
reactos/services/eventlog/makefile [new file with mode: 0644]

diff --git a/reactos/services/eventlog/eventlog.c b/reactos/services/eventlog/eventlog.c
new file mode 100644 (file)
index 0000000..dab7095
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2002 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: eventlog.c,v 1.1 2002/06/25 21:10:14 ekohl Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/eventlog/eventlog.c
+ * PURPOSE:          Event logging service
+ * PROGRAMMER:       Eric Kohl
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define UNICODE
+
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <windows.h>
+
+#include "eventlog.h"
+
+#define DBG
+#define NDEBUG
+#include <debug.h>
+
+
+
+/* GLOBALS ******************************************************************/
+
+
+
+/* FUNCTIONS *****************************************************************/
+
+void
+PrintString(char* fmt,...)
+{
+  char buffer[512];
+  va_list ap;
+
+  va_start(ap, fmt);
+  vsprintf(buffer, fmt, ap);
+  va_end(ap);
+
+  OutputDebugStringA(buffer);
+}
+
+
+#if 0
+VOID CALLBACK
+ServiceMain(DWORD argc, LPTSTR *argv)
+{
+
+  PrintString("ServiceMain() called\n");
+
+
+  PrintString("ServiceMain() done\n");
+
+}
+#endif
+
+
+int main(int argc, char *argv[])
+{
+//  SERVICE_TABLE_ENTRY ServiceTable[] = {{"EventLog", ServiceMain},{NULL, NULL}};
+
+  HANDLE hEvent;
+//  NTSTATUS Status;
+
+  PrintString("EventLog started\n");
+
+
+
+
+
+//  StartServiceCtrlDispatcher(ServiceTable);
+
+  if (StartPortThread() == FALSE)
+    {
+      PrintString("StartPortThread() failed\n");
+    }
+
+
+
+
+  hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+  WaitForSingleObject(hEvent, INFINITE);
+
+  PrintString("EventLog done\n");
+
+  ExitThread(0);
+  return(0);
+}
+
+/* EOF */
diff --git a/reactos/services/eventlog/eventlog.h b/reactos/services/eventlog/eventlog.h
new file mode 100644 (file)
index 0000000..4cf1559
--- /dev/null
@@ -0,0 +1,12 @@
+
+#ifndef __EVENTLOG_H__
+#define __EVENTLOG_H__
+
+
+BOOL
+StartPortThread(VOID);
+
+
+#endif /* __EVENTLOG_H__ */
+
+/* EOF */
diff --git a/reactos/services/eventlog/eventlog.rc b/reactos/services/eventlog/eventlog.rc
new file mode 100644 (file)
index 0000000..fff9e1d
--- /dev/null
@@ -0,0 +1,38 @@
+#include "../../include/defines.h"
+#include "../../include/reactos/resource.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+       FILEVERSION     RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+       PRODUCTVERSION  RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD      
+       FILEFLAGSMASK   0x3fL
+#ifdef _DEBUG
+       FILEFLAGS       0x1L
+#else
+       FILEFLAGS       0x0L
+#endif
+       FILEOS          0x40004L
+       FILETYPE        0x2L
+       FILESUBTYPE     0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName",       RES_STR_COMPANY_NAME
+            VALUE "FileDescription",   "Event logging service\0"
+            VALUE "FileVersion",       RES_STR_FILE_VERSION
+            VALUE "InternalName",      "EventLog\0"
+            VALUE "LegalCopyright",    RES_STR_LEGAL_COPYRIGHT
+            VALUE "OriginalFilename",  "EventLog.exe\0"
+            VALUE "ProductName",       RES_STR_PRODUCT_NAME
+            VALUE "ProductVersion",    RES_STR_PRODUCT_VERSION
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
diff --git a/reactos/services/eventlog/logport.c b/reactos/services/eventlog/logport.c
new file mode 100644 (file)
index 0000000..d23712d
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2002 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: logport.c,v 1.1 2002/06/25 21:10:14 ekohl Exp $
+ *
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS kernel
+ * FILE:             services/eventlog/logport.c
+ * PURPOSE:          Event logger service
+ * PROGRAMMER:       Eric Kohl
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define UNICODE
+
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <napi/lpc.h>
+#include <windows.h>
+
+#include "eventlog.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* GLOBALS ******************************************************************/
+
+HANDLE PortThreadHandle = NULL;
+HANDLE ConnectPortHandle = NULL;
+HANDLE MessagePortHandle = NULL;
+
+
+/* FUNCTIONS ****************************************************************/
+
+static NTSTATUS
+InitLogPort(VOID)
+{
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  UNICODE_STRING PortName;
+  LPC_MESSAGE Message;
+  NTSTATUS Status;
+
+  ConnectPortHandle = NULL;
+  MessagePortHandle = NULL;
+
+  RtlInitUnicodeString(&PortName,
+                      L"\\ErrorLogPort");
+  InitializeObjectAttributes(&ObjectAttributes,
+                            &PortName,
+                            0,
+                            NULL,
+                            NULL);
+
+  Status = NtCreatePort(&ConnectPortHandle,
+                       &ObjectAttributes,
+                       0,
+                       0x100,
+                       0x2000);
+  if (!NT_SUCCESS(Status))
+    goto ByeBye;
+
+  Message.DataSize = sizeof(LPC_MESSAGE);
+  Message.MessageSize = 0;
+
+  Status = NtListenPort(ConnectPortHandle,
+                       &Message);
+  if (!NT_SUCCESS(Status))
+    goto ByeBye;
+
+  Status = NtAcceptConnectPort(&MessagePortHandle,
+                              0,
+                              &Message,
+                              1,
+                              0,
+                              0);
+  if (!NT_SUCCESS(Status))
+    goto ByeBye;
+
+  Status = NtCompleteConnectPort(MessagePortHandle);
+  if (!NT_SUCCESS(Status))
+    goto ByeBye;
+
+ByeBye:
+  if (ConnectPortHandle != NULL)
+    NtClose(ConnectPortHandle);
+
+  if (MessagePortHandle != NULL)
+    NtClose(MessagePortHandle);
+
+  return(Status);
+}
+
+
+static NTSTATUS
+ProcessPortMessage(VOID)
+{
+  PLPC_MAX_MESSAGE Request;
+  LPC_MESSAGE Reply;
+  BOOL ReplyReady = FALSE;
+  NTSTATUS Status;
+
+  Request = HeapAlloc(GetProcessHeap(),
+                     HEAP_ZERO_MEMORY,
+                     sizeof(LPC_MAX_MESSAGE));
+  if (Request == NULL)
+    return(STATUS_NO_MEMORY);
+
+  while (TRUE)
+    {
+      Status = NtReplyWaitReceivePort(MessagePortHandle,
+                                     0,
+                                     (ReplyReady)? &Reply : NULL,
+                                     (PLPC_MESSAGE)Request);
+      if (!NT_SUCCESS(Status))
+       {
+         HeapFree(GetProcessHeap(),
+                  0,
+                  Request);
+         return(Status);
+       }
+
+      ReplyReady = FALSE;
+      if (Request->Header.MessageType == LPC_REQUEST)
+       {
+         DPRINT1("Received request\n");
+
+         ReplyReady = FALSE;
+       }
+      else if (Request->Header.MessageType == LPC_DATAGRAM)
+       {
+         DPRINT1("Received datagram\n");
+       }
+    }
+}
+
+
+static NTSTATUS STDCALL
+PortThreadRoutine(PVOID Param)
+{
+  NTSTATUS Status = STATUS_SUCCESS;
+
+  Status = InitLogPort();
+  if (!NT_SUCCESS(Status))
+    return(Status);
+
+  while (!NT_SUCCESS(Status))
+    {
+      Status = ProcessPortMessage();
+    }
+
+  return(Status);
+}
+
+
+BOOL
+StartPortThread(VOID)
+{
+  DWORD ThreadId;
+
+  PortThreadHandle = CreateThread(NULL,
+                                 0x1000,
+                                 PortThreadRoutine,
+                                 NULL,
+                                 0,
+                                 &ThreadId);
+
+  return((PortThreadHandle != NULL));
+}
+
+/* EOF */
diff --git a/reactos/services/eventlog/makefile b/reactos/services/eventlog/makefile
new file mode 100644 (file)
index 0000000..bb5bff4
--- /dev/null
@@ -0,0 +1,21 @@
+# $Id: makefile,v 1.1 2002/06/25 21:10:14 ekohl Exp $
+
+PATH_TO_TOP = ../..
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = eventlog
+
+TARGET_INSTALLDIR = system32
+
+TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a 
+
+TARGET_OBJECTS = $(TARGET_NAME).o logport.o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF