mirror of
https://github.com/reactos/reactos.git
synced 2024-11-10 00:34:39 +00:00
3d3a5aa02e
Following commit 24a727a23
, give a lift to the SVCHOST global header
and add & complete all the missing definitions.
- Based on https://www.geoffchappell.com/studies/windows/win32/services/svchost/process/globaldata.htm
from public debug symbols (e.g. svchost, mswsock, w32time, wscsvc...),
adjust some of our symbols' names.
- Make the header C++-compatible.
- Even if the start/stop RPC server functions return an error code whose
underlying storage type is a 32-bit long, they don't return an RPC
status error code, but an NT status. Thus, use the adequate type
instead.
- The PSVCHOST_STOP_CALLBACK is nothing but a WAITORTIMERCALLBACK function.
- Take the opportunity to fix some of these functions' SAL annotations.
- Remark: "LP" for pointers is old-fashioned Windows, avoid this in NT code.
[MSWSOCK][SECLOGON] Do the minor adjustments. Remove unnecessary function casts.
181 lines
4.6 KiB
C
181 lines
4.6 KiB
C
/*
|
|
* 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;
|
|
PSVCHOST_GLOBAL_DATA 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_ PSVCHOST_GLOBAL_DATA 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 */
|