[services] Add the secondary logon service

This commit is contained in:
Eric Kohl 2022-01-16 17:02:01 +01:00
parent c28db81193
commit 43fa9548d3
9 changed files with 341 additions and 1 deletions

View File

@ -9,6 +9,7 @@ add_subdirectory(netlogon)
add_subdirectory(nfsd)
add_subdirectory(rpcss)
add_subdirectory(schedsvc)
add_subdirectory(seclogon)
add_subdirectory(shsvcs)
add_subdirectory(srvsvc)
add_subdirectory(svchost)

View File

@ -0,0 +1,22 @@
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl)
add_rpc_files(server ${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/seclogon.idl)
spec2def(seclogon.dll seclogon.spec ADD_IMPORTLIB)
list(APPEND SOURCE
rpcserver.c
seclogon.c
precomp.h)
add_library(seclogon MODULE
${SOURCE}
seclogon.rc
${CMAKE_CURRENT_BINARY_DIR}/seclogon_s.c
${CMAKE_CURRENT_BINARY_DIR}/seclogon_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/seclogon.def)
set_module_type(seclogon win32dll UNICODE)
target_link_libraries(seclogon wine ${PSEH_LIB})
add_importlibs(seclogon advapi32 rpcrt4 msvcrt kernel32 ntdll)
add_pch(seclogon precomp.h SOURCE)
add_cd_file(TARGET seclogon DESTINATION reactos/system32 FOR all)

View File

@ -0,0 +1,36 @@
/*
* PROJECT: ReactOS Secondary Logon Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Secondary Logon service RPC server
* COPYRIGHT: Eric Kohl 2022 <eric.kohl@reactos.org>
*/
#ifndef _SECLOGON_PCH_
#define _SECLOGON_PCH_
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#include <svc.h>
#include <ndk/rtlfuncs.h>
#include <wine/debug.h>
extern HINSTANCE hDllInstance;
extern SVCHOST_GLOBALS *lpServiceGlobals;
DWORD
StartRpcServer(VOID);
DWORD
StopRpcServer(VOID);
#endif /* _SECLOGON_PCH_ */

View File

@ -0,0 +1,80 @@
/*
* PROJECT: ReactOS Secondary Logon Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Secondary Logon service RPC server
* COPYRIGHT: Eric Kohl 2022 <eric.kohl@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
#include <seclogon_s.h>
WINE_DEFAULT_DEBUG_CHANNEL(seclogon);
/* FUNCTIONS *****************************************************************/
void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
DWORD
StartRpcServer(VOID)
{
ULONG Status;
Status = ((LPSTART_RPC_SERVER)lpServiceGlobals->RpcpStartRpcServer)(L"seclogon", ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStartRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status);
}
DWORD
StopRpcServer(VOID)
{
ULONG Status;
Status = ((LPSTOP_RPC_SERVER)lpServiceGlobals->RpcpStopRpcServer)(ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStopRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status);
}
VOID
__stdcall
SeclCreateProcessWithLogonW(
_In_ handle_t hBinding,
_In_ SECL_REQUEST *pRequest,
_Out_ SECL_RESPONSE *pResponse)
{
TRACE("SeclCreateProcessWithLogonW(%p %p %p)\n", hBinding, pRequest, pResponse);
if (pRequest != NULL)
{
TRACE("Username: '%S'\n", pRequest->Username);
TRACE("Domain: '%S'\n", pRequest->Domain);
TRACE("Password: '%S'\n", pRequest->Password);
TRACE("ApplicationName: '%S'\n", pRequest->ApplicationName);
TRACE("CommandLine: '%S'\n", pRequest->CommandLine);
TRACE("CurrentDirectory: '%S'\n", pRequest->CurrentDirectory);
}
/* FIXME: Logon */
/* FIXME: Create Process */
if (pResponse != NULL)
pResponse->ulError = 4;
}

View File

@ -0,0 +1,181 @@
/*
* PROJECT: ReactOS Secondary Logon Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Secondary Logon service RPC server
* COPYRIGHT: Eric Kohl 2022 <eric.kohl@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
WINE_DEFAULT_DEBUG_CHANNEL(seclogon);
/* GLOBALS ******************************************************************/
HINSTANCE hDllInstance;
SVCHOST_GLOBALS *lpServiceGlobals;
static WCHAR ServiceName[] = L"seclogon";
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
static SERVICE_STATUS ServiceStatus;
/* FUNCTIONS *****************************************************************/
static
VOID
UpdateServiceStatus(
_In_ DWORD dwState)
{
ServiceStatus.dwServiceType = SERVICE_WIN32_SHARE_PROCESS;
ServiceStatus.dwCurrentState = dwState;
if (dwState == SERVICE_PAUSED || dwState == SERVICE_RUNNING)
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SHUTDOWN |
SERVICE_ACCEPT_PAUSE_CONTINUE;
else
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
ServiceControlHandlerEx(
_In_ DWORD dwControl,
_In_ DWORD dwEventType,
_In_ LPVOID lpEventData,
_In_ LPVOID lpContext)
{
TRACE("ServiceControlHandlerEx()\n");
switch (dwControl)
{
case SERVICE_CONTROL_STOP:
TRACE(" SERVICE_CONTROL_STOP received\n");
UpdateServiceStatus(SERVICE_STOP_PENDING);
StopRpcServer();
return ERROR_SUCCESS;
case SERVICE_CONTROL_PAUSE:
TRACE(" SERVICE_CONTROL_PAUSE received\n");
UpdateServiceStatus(SERVICE_PAUSE_PENDING);
StopRpcServer();
UpdateServiceStatus(SERVICE_PAUSED);
return ERROR_SUCCESS;
case SERVICE_CONTROL_CONTINUE:
TRACE(" SERVICE_CONTROL_CONTINUE received\n");
UpdateServiceStatus(SERVICE_CONTINUE_PENDING);
StartRpcServer();
UpdateServiceStatus(SERVICE_RUNNING);
return ERROR_SUCCESS;
case SERVICE_CONTROL_INTERROGATE:
TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
SetServiceStatus(ServiceStatusHandle,
&ServiceStatus);
return ERROR_SUCCESS;
case SERVICE_CONTROL_SHUTDOWN:
TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
UpdateServiceStatus(SERVICE_STOP_PENDING);
StopRpcServer();
return ERROR_SUCCESS;
default :
TRACE(" Control %lu received\n", dwControl);
return ERROR_CALL_NOT_IMPLEMENTED;
}
}
VOID
WINAPI
SvchostPushServiceGlobals(
_In_ SVCHOST_GLOBALS *lpGlobals)
{
TRACE("SvchostPushServiceGlobals(%p)\n", lpGlobals);
lpServiceGlobals = lpGlobals;
}
VOID
WINAPI
SvcEntry_Seclogon(
_In_ INT ArgCount,
_In_ PWSTR *ArgVector)
{
DWORD dwError;
UNREFERENCED_PARAMETER(ArgCount);
UNREFERENCED_PARAMETER(ArgVector);
TRACE("ServiceMain(%d %p)\n", ArgCount, ArgVector);
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandlerEx,
NULL);
if (!ServiceStatusHandle)
{
ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
return;
}
UpdateServiceStatus(SERVICE_START_PENDING);
dwError = StartRpcServer();
if (dwError != ERROR_SUCCESS)
{
ERR("Service stopped (dwError: %lu\n", dwError);
UpdateServiceStatus(SERVICE_STOPPED);
return;
}
UpdateServiceStatus(SERVICE_RUNNING);
}
BOOL
WINAPI
DllMain(
_In_ HINSTANCE hinstDLL,
_In_ DWORD fdwReason,
_In_ PVOID pvReserved)
{
UNREFERENCED_PARAMETER(pvReserved);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
hDllInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/* EOF */

View File

@ -0,0 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "Secondary Logon Service Dll"
#define REACTOS_STR_INTERNAL_NAME "seclogon"
#define REACTOS_STR_ORIGINAL_FILENAME "seclogon.dll"
#include <reactos/version.rc>

View File

@ -0,0 +1,2 @@
@ stdcall SvcEntry_Seclogon(long ptr)
@ stdcall SvchostPushServiceGlobals(ptr)

View File

@ -1818,7 +1818,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,"DcomLaunch","PlugPlay"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","W32Time","winmgmt","wuauserv"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"BITS","DHCP","lanmanserver","lanmanworkstation","Schedule","seclogon","Themes","W32Time","winmgmt","wuauserv"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost","NetworkService",0x00010000,"DnsCache"
; Win32 config

View File

@ -2055,6 +2055,19 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Schedule","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\Schedule\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\schedsvc.dll"
HKLM,"SYSTEM\CurrentControlSet\Services\Schedule\Parameters","ServiceMain",0x00000000,"SchedServiceMain"
; Secondary Logon service
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","DependOnService",0x00010000,"RPCSS"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","Description",0x00000000,"Secondary Logon service"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","DisplayName",0x00000000,"Secondary Logon"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","ErrorControl",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","Group",0x00000000,"SchedulerGroup"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe -k netsvcs"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","ObjectName",0x00000000,"LocalSystem"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","Start",0x00010001,0x00000002
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon","Type",0x00010001,0x00000020
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\seclogon.dll"
HKLM,"SYSTEM\CurrentControlSet\Services\Seclogon\Parameters","ServiceMain",0x00000000,"SvcEntry_Seclogon"
; Spooler service
HKLM,"SYSTEM\CurrentControlSet\Services\Spooler","DependOnService",0x00010000,"RPCSS"
HKLM,"SYSTEM\CurrentControlSet\Services\Spooler","Description",0x00000000,%SPOOLER_SERVICE_DESCRIPTION%