https://git.reactos.org/?p=reactos.git;a=commitdiff;h=95188553ba5e6212f7e91…
commit 95188553ba5e6212f7e9110fac75f3c35b549cbc
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sat Feb 27 19:07:47 2021 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sat Feb 27 19:07:47 2021 +0100
[WKSSVC] Get version info and authentication package on startup
---
base/services/wkssvc/CMakeLists.txt | 2 +-
base/services/wkssvc/precomp.h | 4 ++
base/services/wkssvc/rpcserver.c | 8 +--
base/services/wkssvc/wkssvc.c | 121 +++++++++++++++++++++++++++---------
4 files changed, 99 insertions(+), 36 deletions(-)
diff --git a/base/services/wkssvc/CMakeLists.txt b/base/services/wkssvc/CMakeLists.txt
index c7bb4c8b41a..8ce12e206bb 100644
--- a/base/services/wkssvc/CMakeLists.txt
+++ b/base/services/wkssvc/CMakeLists.txt
@@ -13,5 +13,5 @@ add_library(wkssvc MODULE
set_module_type(wkssvc win32dll UNICODE)
target_link_libraries(wkssvc wine)
-add_importlibs(wkssvc advapi32 rpcrt4 msvcrt kernel32 ntdll)
+add_importlibs(wkssvc secur32 advapi32 rpcrt4 msvcrt kernel32 ntdll)
add_cd_file(TARGET wkssvc DESTINATION reactos/system32 FOR all)
diff --git a/base/services/wkssvc/precomp.h b/base/services/wkssvc/precomp.h
index be3c7982465..ac6d6e8d0c7 100644
--- a/base/services/wkssvc/precomp.h
+++ b/base/services/wkssvc/precomp.h
@@ -22,6 +22,10 @@
#include <wine/debug.h>
+extern OSVERSIONINFOW VersionInfo;
+extern HANDLE LsaHandle;
+extern ULONG LsaAuthenticationPackage;
+
/* domain.c */
NET_API_STATUS
diff --git a/base/services/wkssvc/rpcserver.c b/base/services/wkssvc/rpcserver.c
index f80461c0608..d95cab57e94 100644
--- a/base/services/wkssvc/rpcserver.c
+++ b/base/services/wkssvc/rpcserver.c
@@ -89,7 +89,6 @@ NetrWkstaGetInfo(
DWORD dwComputerNameLength;
LPCWSTR pszLanRoot = L"";
PWKSTA_INFO pWkstaInfo = NULL;
- OSVERSIONINFOW VersionInfo;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle;
PPOLICY_PRIMARY_DOMAIN_INFO DomainInfo = NULL;
@@ -102,9 +101,6 @@ NetrWkstaGetInfo(
GetComputerNameW(szComputerName, &dwComputerNameLength);
dwComputerNameLength++; /* include NULL terminator */
- VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
- GetVersionExW(&VersionInfo);
-
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
NtStatus = LsaOpenPolicy(NULL,
&ObjectAttributes,
@@ -249,6 +245,10 @@ NetrWkstaUserEnum(
unsigned long *TotalEntries,
unsigned long *ResumeHandle)
{
+ ERR("NetrWkstaUserEnum(%p %p 0x%lx %p %p)\n",
+ ServerName, UserInfo, PreferredMaximumLength, TotalEntries, ResumeHandle);
+
+
UNIMPLEMENTED;
return 0;
}
diff --git a/base/services/wkssvc/wkssvc.c b/base/services/wkssvc/wkssvc.c
index 9feb7bb50e2..d1e5b87840a 100644
--- a/base/services/wkssvc/wkssvc.c
+++ b/base/services/wkssvc/wkssvc.c
@@ -37,6 +37,10 @@ static WCHAR ServiceName[] = L"lanmanworkstation";
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
static SERVICE_STATUS ServiceStatus;
+OSVERSIONINFOW VersionInfo;
+HANDLE LsaHandle = NULL;
+ULONG LsaAuthenticationPackage = 0;
+
/* FUNCTIONS *****************************************************************/
static VOID
@@ -64,6 +68,90 @@ UpdateServiceStatus(DWORD dwState)
&ServiceStatus);
}
+
+static
+DWORD
+ServiceInit(VOID)
+{
+ LSA_STRING ProcessName, PackageName;
+ LSA_OPERATIONAL_MODE Mode;
+ HANDLE hThread;
+ NTSTATUS Status;
+
+ ERR("ServiceInit()\n");
+
+ /* Get the OS version */
+ VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
+ GetVersionExW(&VersionInfo);
+
+ ProcessName.Buffer = "Workstation";
+ ProcessName.Length = strlen(ProcessName.Buffer);
+ ProcessName.MaximumLength = ProcessName.Length + 1;
+
+ Status = LsaRegisterLogonProcess(&ProcessName,
+ &LsaHandle,
+ &Mode);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("LsaRegisterLogonProcess() failed! (Status 0x%08lx)\n", Status);
+ return 1;
+ }
+
+ PackageName.Buffer = MSV1_0_PACKAGE_NAME;
+ PackageName.Length = strlen(PackageName.Buffer);
+ PackageName.MaximumLength = PackageName.Length + 1;
+
+ Status = LsaLookupAuthenticationPackage(LsaHandle,
+ &PackageName,
+ &LsaAuthenticationPackage);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("LsaLookupAuthenticationPackage() failed! (Status 0x%08lx)\n",
Status);
+ return 1;
+ }
+
+ hThread = CreateThread(NULL,
+ 0,
+ (LPTHREAD_START_ROUTINE)RpcThreadRoutine,
+ NULL,
+ 0,
+ NULL);
+
+ if (!hThread)
+ {
+ ERR("Can't create PortThread\n");
+ return GetLastError();
+ }
+ else
+ CloseHandle(hThread);
+
+ /* Report a running workstation service */
+ SetServiceBits(ServiceStatusHandle,
+ SV_TYPE_WORKSTATION,
+ TRUE,
+ TRUE);
+
+ return ERROR_SUCCESS;
+}
+
+
+static
+VOID
+ServiceShutdown(VOID)
+{
+ NTSTATUS Status;
+
+ ERR("ServiceShutdown()\n");
+
+ Status = LsaDeregisterLogonProcess(LsaHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("LsaDeRegisterLogonProcess() failed! (Status 0x%08lx)\n", Status);
+ return;
+ }
+}
+
+
static DWORD WINAPI
ServiceControlHandler(DWORD dwControl,
DWORD dwEventType,
@@ -79,6 +167,7 @@ ServiceControlHandler(DWORD dwControl,
UpdateServiceStatus(SERVICE_STOP_PENDING);
/* Stop listening to incoming RPC messages */
RpcMgmtStopServerListening(NULL);
+ ServiceShutdown();
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
@@ -103,6 +192,7 @@ ServiceControlHandler(DWORD dwControl,
UpdateServiceStatus(SERVICE_STOP_PENDING);
/* Stop listening to incoming RPC messages */
RpcMgmtStopServerListening(NULL);
+ ServiceShutdown();
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
@@ -113,37 +203,6 @@ ServiceControlHandler(DWORD dwControl,
}
-static
-DWORD
-ServiceInit(VOID)
-{
- HANDLE hThread;
-
- hThread = CreateThread(NULL,
- 0,
- (LPTHREAD_START_ROUTINE)RpcThreadRoutine,
- NULL,
- 0,
- NULL);
-
- if (!hThread)
- {
- ERR("Can't create PortThread\n");
- return GetLastError();
- }
- else
- CloseHandle(hThread);
-
- /* Report a running workstation service */
- SetServiceBits(ServiceStatusHandle,
- SV_TYPE_WORKSTATION,
- TRUE,
- TRUE);
-
- return ERROR_SUCCESS;
-}
-
-
VOID WINAPI
ServiceMain(DWORD argc, LPTSTR *argv)
{