[WMISVC]
authorPierre Schweitzer <pierre@reactos.org>
Sun, 15 Feb 2015 17:19:57 +0000 (17:19 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 15 Feb 2015 17:19:57 +0000 (17:19 +0000)
Add a stub for the "Windows Management Infrastructure" service.
This helps the Intel PRO eth card installer to go a bit farther

svn path=/trunk/; revision=66295

reactos/base/services/CMakeLists.txt
reactos/base/services/wmisvc/CMakeLists.txt [new file with mode: 0644]
reactos/base/services/wmisvc/wmisvc.c [new file with mode: 0644]
reactos/base/services/wmisvc/wmisvc.rc [new file with mode: 0644]
reactos/base/services/wmisvc/wmisvc.spec [new file with mode: 0644]
reactos/boot/bootdata/hivesft.inf
reactos/boot/bootdata/hivesys.inf

index 51c0d7d..86f6903 100644 (file)
@@ -10,3 +10,4 @@ add_subdirectory(telnetd)
 add_subdirectory(thmsvc)
 add_subdirectory(umpnpmgr)
 add_subdirectory(wlansvc)
+add_subdirectory(wmisvc)
diff --git a/reactos/base/services/wmisvc/CMakeLists.txt b/reactos/base/services/wmisvc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3c8b8f9
--- /dev/null
@@ -0,0 +1,10 @@
+spec2def(wmisvc.dll wmisvc.spec ADD_IMPORTLIB)
+
+add_library(wmisvc SHARED
+    wmisvc.c
+    wmisvc.rc
+    ${CMAKE_CURRENT_BINARY_DIR}/wmisvc.def)
+
+set_module_type(wmisvc win32dll UNICODE)
+add_importlibs(wmisvc advapi32 msvcrt kernel32 ntdll)
+add_cd_file(TARGET wmisvc DESTINATION reactos/system32/wbem FOR all)
diff --git a/reactos/base/services/wmisvc/wmisvc.c b/reactos/base/services/wmisvc/wmisvc.c
new file mode 100644 (file)
index 0000000..3f464c2
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  ReactOS Services
+ *  Copyright (C) 2015 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.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+/*
+ * COPYRIGHT:        See COPYING in the top level directory
+ * PROJECT:          ReactOS Services
+ * FILE:             base/services/wmisvc/wmisvc.c
+ * PURPOSE:          WMI service
+ * PROGRAMMER:       Pierre Schweitzer
+ */
+
+/* INCLUDES *****************************************************************/
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winreg.h>
+#include <winsvc.h>
+
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ******************************************************************/
+
+static WCHAR ServiceName[] = L"winmgmt";
+
+static SERVICE_STATUS_HANDLE ServiceStatusHandle;
+static SERVICE_STATUS ServiceStatus;
+
+/* FUNCTIONS *****************************************************************/
+
+static VOID
+UpdateServiceStatus(DWORD dwState)
+{
+    ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+    ServiceStatus.dwCurrentState = dwState;
+    ServiceStatus.dwControlsAccepted = 0;
+    ServiceStatus.dwWin32ExitCode = 0;
+    ServiceStatus.dwServiceSpecificExitCode = 0;
+    ServiceStatus.dwCheckPoint = 0;
+
+    if (dwState == SERVICE_START_PENDING ||
+        dwState == SERVICE_STOP_PENDING ||
+        dwState == SERVICE_PAUSE_PENDING ||
+        dwState == SERVICE_CONTINUE_PENDING)
+        ServiceStatus.dwWaitHint = 10000;
+    else
+        ServiceStatus.dwWaitHint = 0;
+
+    SetServiceStatus(ServiceStatusHandle,
+                     &ServiceStatus);
+}
+
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+                      DWORD dwEventType,
+                      LPVOID lpEventData,
+                      LPVOID lpContext)
+{
+    DPRINT1("ServiceControlHandler() called\n");
+
+    switch (dwControl)
+    {
+        case SERVICE_CONTROL_STOP:
+            DPRINT1("  SERVICE_CONTROL_STOP received\n");
+            UpdateServiceStatus(SERVICE_STOPPED);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_PAUSE:
+            DPRINT1("  SERVICE_CONTROL_PAUSE received\n");
+            UpdateServiceStatus(SERVICE_PAUSED);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_CONTINUE:
+            DPRINT1("  SERVICE_CONTROL_CONTINUE received\n");
+            UpdateServiceStatus(SERVICE_RUNNING);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_INTERROGATE:
+            DPRINT1("  SERVICE_CONTROL_INTERROGATE received\n");
+            SetServiceStatus(ServiceStatusHandle,
+                             &ServiceStatus);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_SHUTDOWN:
+            DPRINT1("  SERVICE_CONTROL_SHUTDOWN received\n");
+            UpdateServiceStatus(SERVICE_STOPPED);
+            return ERROR_SUCCESS;
+
+        default :
+            DPRINT1("  Control %lu received\n");
+            return ERROR_CALL_NOT_IMPLEMENTED;
+    }
+}
+
+VOID WINAPI
+ServiceMain(DWORD argc, LPTSTR *argv)
+{
+    UNREFERENCED_PARAMETER(argc);
+    UNREFERENCED_PARAMETER(argv);
+
+    DPRINT1("ServiceMain() called\n");
+
+    ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
+                                                        ServiceControlHandler,
+                                                        NULL);
+    if (!ServiceStatusHandle)
+    {
+        DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
+        return;
+    }
+
+    UpdateServiceStatus(SERVICE_RUNNING);
+
+    do
+    {
+        Sleep(1);
+    } while (1);
+
+    UpdateServiceStatus(SERVICE_STOPPED);
+}
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+        DWORD fdwReason,
+        LPVOID lpvReserved)
+{
+    switch (fdwReason)
+    {
+        case DLL_PROCESS_ATTACH:
+            DisableThreadLibraryCalls(hinstDLL);
+            break;
+
+        case DLL_PROCESS_DETACH:
+            break;
+    }
+
+    return TRUE;
+}
diff --git a/reactos/base/services/wmisvc/wmisvc.rc b/reactos/base/services/wmisvc/wmisvc.rc
new file mode 100644 (file)
index 0000000..ba7e6e2
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION  "WMI Service"
+#define REACTOS_STR_INTERNAL_NAME     "wmisvc"
+#define REACTOS_STR_ORIGINAL_FILENAME "wmisvc.dll"
+#include <reactos/version.rc>
diff --git a/reactos/base/services/wmisvc/wmisvc.spec b/reactos/base/services/wmisvc/wmisvc.spec
new file mode 100644 (file)
index 0000000..1b27fe5
--- /dev/null
@@ -0,0 +1 @@
+@ stdcall ServiceMain(long ptr)
index e322150..07bc535 100644 (file)
@@ -1591,7 +1591,7 @@ HKLM,"SOFTWARE\Microsoft\Ole","EnableRemoteConnect",0x00000000,"N"
 ; SvcHost services
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"PlugPlay"
-HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS"
+HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS",winmgmt"
 
 ; Win32 config
 HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012
index 894aaa3..f9cedd5 100644 (file)
@@ -1943,6 +1943,17 @@ HKLM,"SYSTEM\CurrentControlSet\Services\MSIserver","ObjectName",0x00000000,"Loca
 HKLM,"SYSTEM\CurrentControlSet\Services\MSIserver","Start",0x00010001,0x00000003
 HKLM,"SYSTEM\CurrentControlSet\Services\MSIserver","Type",0x00010001,0x00000020
 
+; WMI service
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","DisplayName",0x00000000,"ReactOS Management Infrastructure"
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Description",0x00000000,"Provides interface to system management information"
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","ErrorControl",0x00010001,0x00000001
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Group",0x00000000,"WMI"
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","ObjectName",0x00000000,"LocalSystem"
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Start",0x00010001,0x00000002
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt","Type",0x00010001,0x00000020
+HKLM,"SYSTEM\CurrentControlSet\Services\winmgmt\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\wbem\wmisvc.dll"
+
 ; Sound Blaster (NT4)
 ;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","Description",0x00000000,"Sound Blaster (NT4)"
 ;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","ErrorControl",0x00010001,0x00000001