[PATCH] srvsvc: Add LanmanServer stub service.

Dmitry Timoshkov dmitry at baikal.ru
Mon Aug 8 06:48:11 CDT 2022


wine.inf already has an entry for it.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 configure.ac            |  1 +
 dlls/srvsvc/Makefile.in |  5 +++
 dlls/srvsvc/srvsvc.c    | 87 +++++++++++++++++++++++++++++++++++++++++
 dlls/srvsvc/srvsvc.spec |  1 +
 loader/wine.inf.in      |  4 +-
 5 files changed, 96 insertions(+), 2 deletions(-)
 create mode 100644 dlls/srvsvc/Makefile.in
 create mode 100644 dlls/srvsvc/srvsvc.c
 create mode 100644 dlls/srvsvc/srvsvc.spec

diff --git a/configure.ac b/configure.ac
index dd4abd39e32..bec0513c46d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3035,6 +3035,7 @@ WINE_CONFIG_MAKEFILE(dlls/spoolss/tests)
 WINE_CONFIG_MAKEFILE(dlls/sppc)
 WINE_CONFIG_MAKEFILE(dlls/srclient)
 WINE_CONFIG_MAKEFILE(dlls/srvcli)
+WINE_CONFIG_MAKEFILE(dlls/srvsvc)
 WINE_CONFIG_MAKEFILE(dlls/sspicli)
 WINE_CONFIG_MAKEFILE(dlls/stdole2.tlb)
 WINE_CONFIG_MAKEFILE(dlls/stdole32.tlb)
diff --git a/dlls/srvsvc/Makefile.in b/dlls/srvsvc/Makefile.in
new file mode 100644
index 00000000000..f9c68fd12aa
--- /dev/null
+++ b/dlls/srvsvc/Makefile.in
@@ -0,0 +1,5 @@
+MODULE    = srvsvc.dll
+IMPORTS   = advapi32
+
+C_SRCS = \
+	srvsvc.c
diff --git a/dlls/srvsvc/srvsvc.c b/dlls/srvsvc/srvsvc.c
new file mode 100644
index 00000000000..3b2b563bc6c
--- /dev/null
+++ b/dlls/srvsvc/srvsvc.c
@@ -0,0 +1,87 @@
+/*
+ * LanmanServer Service
+ *
+ * Copyright 2022 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winsvc.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(lanman);
+
+static SERVICE_STATUS_HANDLE svc_handle;
+static HANDLE done_event;
+
+static void svc_update_status(DWORD state)
+{
+    SERVICE_STATUS status;
+
+    status.dwServiceType = SERVICE_WIN32;
+    status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
+    status.dwWin32ExitCode = 0;
+    status.dwServiceSpecificExitCode = 0;
+    status.dwCheckPoint = 0;
+    status.dwWaitHint = 0;
+    status.dwCurrentState = state;
+
+    SetServiceStatus(svc_handle, &status);
+}
+
+static void WINAPI svc_handler(DWORD control)
+{
+    TRACE("%#lx\n", control);
+
+    switch (control)
+    {
+    case SERVICE_CONTROL_STOP:
+    case SERVICE_CONTROL_SHUTDOWN:
+        svc_update_status(SERVICE_STOP_PENDING);
+        SetEvent(done_event);
+        break;
+
+    default:
+        svc_update_status(SERVICE_RUNNING);
+        break;
+    }
+}
+
+void WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
+{
+    TRACE("Starting LanmanServer\n");
+
+    svc_handle = RegisterServiceCtrlHandlerW(L"LanmanServer", svc_handler);
+    if (!svc_handle)
+    {
+        ERR("RegisterServiceCtrlHandler error %ld\n", GetLastError());
+        return;
+    }
+
+    svc_update_status(SERVICE_START_PENDING);
+    done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
+
+    svc_update_status(SERVICE_RUNNING);
+    WaitForSingleObject(done_event, INFINITE);
+    CloseHandle(done_event);
+
+    svc_update_status(SERVICE_STOPPED);
+
+    TRACE("Exiting LanmanServer\n");
+}
diff --git a/dlls/srvsvc/srvsvc.spec b/dlls/srvsvc/srvsvc.spec
new file mode 100644
index 00000000000..daa88578f7f
--- /dev/null
+++ b/dlls/srvsvc/srvsvc.spec
@@ -0,0 +1 @@
+@ stdcall -private ServiceMain(long ptr)
diff --git a/loader/wine.inf.in b/loader/wine.inf.in
index e7b435ed0f0..d686e0b4f2f 100644
--- a/loader/wine.inf.in
+++ b/loader/wine.inf.in
@@ -2396,12 +2396,12 @@ Description="Lanman Server"
 DisplayName="Lanman Server"
 ServiceBinary="%11%\svchost.exe -k netsvcs"
 ServiceType=32
-StartType=4
+StartType=3
 ErrorControl=1
 
 [LanmanServerServiceKeys]
 HKR,Parameters,"ServiceDll",,"%11%\srvsvc.dll"
-;; HKLM,%CurrentVersionNT%\SvcHost,"netsvcs",0x00010008,"lanmanserver"
+HKLM,%CurrentVersionNT%\SvcHost,"netsvcs",0x00010008,"lanmanserver"
 
 [FontCacheService]
 AddReg=FontCacheServiceKeys
-- 
2.37.1




More information about the wine-devel mailing list