[UPDATES] New stubs for Automatic Updates service and WUSA.exe. Presence of this...
authorDenis Malikov <filedem@gmail.com>
Fri, 2 Feb 2018 22:03:17 +0000 (05:03 +0700)
committerMark Jansen <mark.jansen@reactos.org>
Sun, 19 Aug 2018 17:56:18 +0000 (19:56 +0200)
14 files changed:
base/applications/CMakeLists.txt
base/applications/wusa/CMakeLists.txt [new file with mode: 0644]
base/applications/wusa/res/setup.ico [new file with mode: 0644]
base/applications/wusa/resource.h [new file with mode: 0644]
base/applications/wusa/resource.rc [new file with mode: 0644]
base/applications/wusa/wusa.c [new file with mode: 0644]
base/applications/wusa/wusa.h [new file with mode: 0644]
base/services/CMakeLists.txt
base/services/wuauserv/CMakeLists.txt [new file with mode: 0644]
base/services/wuauserv/wuauserv.c [new file with mode: 0644]
base/services/wuauserv/wuauserv.h [new file with mode: 0644]
base/services/wuauserv/wuauserv.rc [new file with mode: 0644]
base/services/wuauserv/wuauserv.spec [new file with mode: 0644]
boot/bootdata/hivesys.inf

index 4c7677a..87cbdbf 100644 (file)
@@ -43,3 +43,4 @@ add_subdirectory(winhlp32)
 add_subdirectory(winver)
 add_subdirectory(wordpad)
 add_subdirectory(write)
+add_subdirectory(wusa)
diff --git a/base/applications/wusa/CMakeLists.txt b/base/applications/wusa/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ab27e96
--- /dev/null
@@ -0,0 +1,6 @@
+
+add_rc_deps(resource.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/setup.ico)
+add_executable(wusa wusa.c resource.rc)
+set_module_type(wusa win32gui UNICODE)
+add_importlibs(wusa shell32 msvcrt kernel32)
+add_cd_file(TARGET wusa DESTINATION reactos/system32 FOR all)
diff --git a/base/applications/wusa/res/setup.ico b/base/applications/wusa/res/setup.ico
new file mode 100644 (file)
index 0000000..cd786ed
Binary files /dev/null and b/base/applications/wusa/res/setup.ico differ
diff --git a/base/applications/wusa/resource.h b/base/applications/wusa/resource.h
new file mode 100644 (file)
index 0000000..0901b42
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+#define IDI_WUSA 101
diff --git a/base/applications/wusa/resource.rc b/base/applications/wusa/resource.rc
new file mode 100644 (file)
index 0000000..d4141fc
--- /dev/null
@@ -0,0 +1,14 @@
+#include <windef.h>
+
+#include "resource.h"
+
+/* Common resources */
+
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+#define REACTOS_STR_FILE_DESCRIPTION  "ReactOS WUSA stub"
+#define REACTOS_STR_INTERNAL_NAME     "wusa"
+#define REACTOS_STR_ORIGINAL_FILENAME "wusa.exe"
+#include <reactos/version.rc>
+
+IDI_WUSA ICON "res/setup.ico"
diff --git a/base/applications/wusa/wusa.c b/base/applications/wusa/wusa.c
new file mode 100644 (file)
index 0000000..c6a7245
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+* PROJECT:          ReactOS Update Service
+* LICENSE:          GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+* PURPOSE:          Windows Update Stand-Alone installer.
+*                   Stub is required for some application at the installation phase.
+* COPYRIGHT:        Copyright 2018 Denis Malikov (filedem@gmail.com)
+*/
+
+#include "wusa.h"
+
+int
+WINAPI
+wWinMain(HINSTANCE hCurInst,
+         HINSTANCE hPrevInst,
+         LPWSTR lpsCmdLine,
+         int nCmdShow)
+{
+    return 0;
+}
diff --git a/base/applications/wusa/wusa.h b/base/applications/wusa/wusa.h
new file mode 100644 (file)
index 0000000..4b4669d
--- /dev/null
@@ -0,0 +1,4 @@
+#define WIN32_NO_STATUS
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <wchar.h>
index 75b5478..977b5ed 100644 (file)
@@ -15,3 +15,4 @@ add_subdirectory(umpnpmgr)
 add_subdirectory(wkssvc)
 add_subdirectory(wlansvc)
 add_subdirectory(wmisvc)
+add_subdirectory(wuauserv)
diff --git a/base/services/wuauserv/CMakeLists.txt b/base/services/wuauserv/CMakeLists.txt
new file mode 100644 (file)
index 0000000..841d836
--- /dev/null
@@ -0,0 +1,7 @@
+add_library(wuauserv SHARED
+    wuauserv.c
+    wuauserv.rc)
+
+set_module_type(wuauserv win32dll UNICODE)
+add_importlibs(wuauserv advapi32 msvcrt kernel32 ntdll)
+add_cd_file(TARGET wuauserv DESTINATION reactos/system32 FOR all)
diff --git a/base/services/wuauserv/wuauserv.c b/base/services/wuauserv/wuauserv.c
new file mode 100644 (file)
index 0000000..d302169
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+* PROJECT:          ReactOS Update Service
+* LICENSE:          GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+* PURPOSE:          Automatic Updates service stub.
+*                   Stub is required for some application at the installation phase.
+* COPYRIGHT:        Copyright 2018 Denis Malikov (filedem@gmail.com)
+*/
+
+#include "wuauserv.h"
+
+/* GLOBALS ******************************************************************/
+
+static WCHAR ServiceName[] = L"wuauserv";
+
+static SERVICE_STATUS_HANDLE ServiceStatusHandle;
+static SERVICE_STATUS ServiceStatus;
+
+static HANDLE exitEvent = NULL;
+
+/* 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 = 1000;
+    else
+        ServiceStatus.dwWaitHint = 0;
+
+    SetServiceStatus(ServiceStatusHandle,
+                     &ServiceStatus);
+    DPRINT1("WU UpdateServiceStatus() called\n");
+}
+
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+                      DWORD dwEventType,
+                      LPVOID lpEventData,
+                      LPVOID lpContext)
+{
+    switch (dwControl)
+    {
+        case SERVICE_CONTROL_STOP:
+            DPRINT1("WU ServiceControlHandler()  SERVICE_CONTROL_STOP received\n");
+            UpdateServiceStatus(SERVICE_STOPPED);
+            SetEvent(exitEvent);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_PAUSE:
+            DPRINT1("WU ServiceControlHandler()  SERVICE_CONTROL_PAUSE received\n");
+            UpdateServiceStatus(SERVICE_PAUSED);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_CONTINUE:
+            DPRINT1("WU ServiceControlHandler()  SERVICE_CONTROL_CONTINUE received\n");
+            UpdateServiceStatus(SERVICE_RUNNING);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_INTERROGATE:
+            DPRINT1("WU ServiceControlHandler()  SERVICE_CONTROL_INTERROGATE received\n");
+            SetServiceStatus(ServiceStatusHandle,
+                             &ServiceStatus);
+            return ERROR_SUCCESS;
+
+        case SERVICE_CONTROL_SHUTDOWN:
+            DPRINT1("WU ServiceControlHandler()  SERVICE_CONTROL_SHUTDOWN received\n");
+            UpdateServiceStatus(SERVICE_STOPPED);
+            return ERROR_SUCCESS;
+
+        default :
+            DPRINT1("WU ServiceControlHandler()  Control %lu received\n");
+            return ERROR_CALL_NOT_IMPLEMENTED;
+    }
+}
+
+VOID WINAPI
+ServiceMain(DWORD argc, LPTSTR *argv)
+{
+    UNREFERENCED_PARAMETER(argc);
+    UNREFERENCED_PARAMETER(argv);
+
+    DPRINT("WU ServiceMain() called\n");
+    
+    ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
+                                                        ServiceControlHandler,
+                                                        NULL);
+    if (!ServiceStatusHandle)
+    {
+        DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
+        return;
+    }
+
+    UpdateServiceStatus(SERVICE_RUNNING);
+
+    exitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+    WaitForSingleObject(exitEvent, INFINITE);
+    CloseHandle(exitEvent);
+
+    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/base/services/wuauserv/wuauserv.h b/base/services/wuauserv/wuauserv.h
new file mode 100644 (file)
index 0000000..7134c26
--- /dev/null
@@ -0,0 +1,11 @@
+#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>
diff --git a/base/services/wuauserv/wuauserv.rc b/base/services/wuauserv/wuauserv.rc
new file mode 100644 (file)
index 0000000..83feb92
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION  "AutoUpdate Service Stub"
+#define REACTOS_STR_INTERNAL_NAME     "wuauserv"
+#define REACTOS_STR_ORIGINAL_FILENAME "wuauserv.dll"
+#include <reactos/version.rc>
diff --git a/base/services/wuauserv/wuauserv.spec b/base/services/wuauserv/wuauserv.spec
new file mode 100644 (file)
index 0000000..1b27fe5
--- /dev/null
@@ -0,0 +1 @@
+@ stdcall ServiceMain(long ptr)
index 31f50ed..1f58e5c 100644 (file)
@@ -2035,6 +2035,16 @@ 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"
 
+; AutoUpdate Service
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","DisplayName",0x00000000,%WUAUSERV_SERVICE%
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Description",0x00000000,%WUAUSERV_SERVICE_DESCRIPTION%
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ErrorControl",0x00010001,0x00000001
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","ObjectName",0x00000000,"LocalSystem"
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Start",0x00010001,0x00000002
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv","Type",0x00010001,0x00000020
+HKLM,"SYSTEM\CurrentControlSet\Services\wuauserv\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\wuauserv.dll"
+
 ; Sound Blaster (NT4)
 ;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","Description",0x00000000,"Sound Blaster (NT4)"
 ;HKLM,"SYSTEM\CurrentControlSet\Services\sndblst","ErrorControl",0x00010001,0x00000001
@@ -2191,6 +2201,9 @@ THEMES_SERVICE_DESCRIPTION="Themes support"
 WINMGMT_SERVICE="ReactOS Management Infrastructure"
 WINMGMT_SERVICE_DESCRIPTION="Provides interface to system management information."
 
+WUAUSERV_SERVICE="Automatic Updates"
+WUAUSERV_SERVICE_DESCRIPTION="AutoUpdate Service stub."
+
 WLANSVC_SERVICE="WLAN Service"
 WLANSVC_SERVICE_DESCRIPTION="WLAN Service"