[SDK:REACTOS][SVCHOST] Add/complete all missing definitions in the SVCHOST global header. (#4295)

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.
This commit is contained in:
Hermès Bélusca-Maïto 2022-01-17 01:01:57 +01:00
parent 493bb8de46
commit 3d3a5aa02e
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
9 changed files with 137 additions and 73 deletions

View file

@ -28,7 +28,7 @@
#include <wine/debug.h> #include <wine/debug.h>
extern HINSTANCE hDllInstance; extern HINSTANCE hDllInstance;
extern SVCHOST_GLOBALS *lpServiceGlobals; extern PSVCHOST_GLOBAL_DATA lpServiceGlobals;
DWORD DWORD
StartRpcServer(VOID); StartRpcServer(VOID);

View file

@ -31,10 +31,10 @@ void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
DWORD DWORD
StartRpcServer(VOID) StartRpcServer(VOID)
{ {
ULONG Status; NTSTATUS Status;
Status = ((LPSTART_RPC_SERVER)lpServiceGlobals->RpcpStartRpcServer)(L"seclogon", ISeclogon_v1_0_s_ifspec); Status = lpServiceGlobals->StartRpcServer(L"seclogon", ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStartRpcServer returned 0x%08lx\n", Status); TRACE("StartRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status); return RtlNtStatusToDosError(Status);
} }
@ -43,10 +43,10 @@ StartRpcServer(VOID)
DWORD DWORD
StopRpcServer(VOID) StopRpcServer(VOID)
{ {
ULONG Status; NTSTATUS Status;
Status = ((LPSTOP_RPC_SERVER)lpServiceGlobals->RpcpStopRpcServer)(ISeclogon_v1_0_s_ifspec); Status = lpServiceGlobals->StopRpcServer(ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStopRpcServer returned 0x%08lx\n", Status); TRACE("StopRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status); return RtlNtStatusToDosError(Status);
} }

View file

@ -15,7 +15,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(seclogon);
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
HINSTANCE hDllInstance; HINSTANCE hDllInstance;
SVCHOST_GLOBALS *lpServiceGlobals; PSVCHOST_GLOBAL_DATA lpServiceGlobals;
static WCHAR ServiceName[] = L"seclogon"; static WCHAR ServiceName[] = L"seclogon";
@ -112,7 +112,7 @@ ServiceControlHandlerEx(
VOID VOID
WINAPI WINAPI
SvchostPushServiceGlobals( SvchostPushServiceGlobals(
_In_ SVCHOST_GLOBALS *lpGlobals) _In_ PSVCHOST_GLOBAL_DATA lpGlobals)
{ {
TRACE("SvchostPushServiceGlobals(%p)\n", lpGlobals); TRACE("SvchostPushServiceGlobals(%p)\n", lpGlobals);
lpServiceGlobals = lpGlobals; lpServiceGlobals = lpGlobals;

View file

@ -47,7 +47,7 @@ DOMAIN_SID_DATA DomainSidData[8] =
{ &AliasBackupOpsSid, DOMAIN_ALIAS_RID_BACKUP_OPS }, { &AliasBackupOpsSid, DOMAIN_ALIAS_RID_BACKUP_OPS },
}; };
PSVCHOST_GLOBALS g_pSvchostSharedGlobals; PSVCHOST_GLOBAL_DATA g_pSvchostSharedGlobals;
DWORD g_SvchostInitFlag; DWORD g_SvchostInitFlag;
HANDLE g_hHeap; HANDLE g_hHeap;
@ -148,13 +148,13 @@ SvchostBuildSharedGlobals (
g_pSvchostSharedGlobals->AliasBackupOpsSid = AliasBackupOpsSid; g_pSvchostSharedGlobals->AliasBackupOpsSid = AliasBackupOpsSid;
/* Write the pointers to the callbacks */ /* Write the pointers to the callbacks */
g_pSvchostSharedGlobals->RpcpStartRpcServer = RpcpStartRpcServer; g_pSvchostSharedGlobals->StartRpcServer = RpcpStartRpcServer;
g_pSvchostSharedGlobals->RpcpStopRpcServer = RpcpStopRpcServer; g_pSvchostSharedGlobals->StopRpcServer = RpcpStopRpcServer;
g_pSvchostSharedGlobals->RpcpStopRpcServerEx = RpcpStopRpcServerEx; g_pSvchostSharedGlobals->StopRpcServerEx = RpcpStopRpcServerEx;
g_pSvchostSharedGlobals->SvcNetBiosOpen = SvcNetBiosOpen; g_pSvchostSharedGlobals->NetBiosOpen = SvcNetBiosOpen;
g_pSvchostSharedGlobals->SvcNetBiosClose = SvcNetBiosClose; g_pSvchostSharedGlobals->NetBiosClose = SvcNetBiosClose;
g_pSvchostSharedGlobals->SvcNetBiosReset = SvcNetBiosReset; g_pSvchostSharedGlobals->NetBiosReset = SvcNetBiosReset;
g_pSvchostSharedGlobals->SvcRegisterStopCallback = SvcRegisterStopCallback; g_pSvchostSharedGlobals->RegisterStopCallback = SvcRegisterStopCallback;
} }
VOID VOID

View file

@ -81,7 +81,7 @@ RpcpStopRpcServerEx (
NTSTATUS NTSTATUS
NTAPI NTAPI
RpcpAddInterface ( RpcpAddInterface (
_In_ LPCWSTR IfName, _In_ PCWSTR IfName,
_In_ RPC_IF_HANDLE IfSpec _In_ RPC_IF_HANDLE IfSpec
) )
{ {
@ -129,7 +129,7 @@ RpcpAddInterface (
NTSTATUS NTSTATUS
NTAPI NTAPI
RpcpStartRpcServer ( RpcpStartRpcServer (
_In_ LPCWSTR IfName, _In_ PCWSTR IfName,
_In_ RPC_IF_HANDLE IfSpec _In_ RPC_IF_HANDLE IfSpec
) )
{ {

View file

@ -516,8 +516,8 @@ SvchostStopCallback (
DWORD DWORD
WINAPI WINAPI
SvcRegisterStopCallback ( SvcRegisterStopCallback (
_In_ PHANDLE phNewWaitObject, _Out_ PHANDLE phNewWaitObject,
_In_ LPCWSTR ServiceName, _In_ PCWSTR ServiceName,
_In_ HANDLE hObject, _In_ HANDLE hObject,
_In_ PSVCHOST_STOP_CALLBACK pfnStopCallback, _In_ PSVCHOST_STOP_CALLBACK pfnStopCallback,
_In_ PVOID pContext, _In_ PVOID pContext,

View file

@ -39,8 +39,9 @@
// //
typedef VOID typedef VOID
(WINAPI *PSVCHOST_INIT_GLOBALS) ( (WINAPI *PSVCHOST_INIT_GLOBALS) (
_In_ PSVCHOST_GLOBALS Globals _In_ PSVCHOST_GLOBAL_DATA Globals
); );
// //
// Initialization Stages // Initialization Stages
// //
@ -139,7 +140,7 @@ RpcpStopRpcServerEx (
NTSTATUS NTSTATUS
NTAPI NTAPI
RpcpStartRpcServer ( RpcpStartRpcServer (
_In_ LPCWSTR IfName, _In_ PCWSTR IfName,
_In_ RPC_IF_HANDLE IfSpec _In_ RPC_IF_HANDLE IfSpec
); );
@ -189,7 +190,7 @@ SvcNetBiosInit (
VOID VOID
WINAPI WINAPI
SvcNetBiosClose ( SvcNetBiosClose (
VOID VOID
); );
VOID VOID
@ -243,14 +244,14 @@ RegQueryStringA (
DWORD DWORD
WINAPI WINAPI
SvcRegisterStopCallback ( SvcRegisterStopCallback (
_In_ PHANDLE phNewWaitObject, _Out_ PHANDLE phNewWaitObject,
_In_ LPCWSTR ServiceName, _In_ PCWSTR ServiceName,
_In_ HANDLE hObject, _In_ HANDLE hObject,
_In_ PSVCHOST_STOP_CALLBACK pfnStopCallback, _In_ PSVCHOST_STOP_CALLBACK pfnStopCallback,
_In_ PVOID pContext, _In_ PVOID pContext,
_In_ ULONG dwFlags _In_ ULONG dwFlags
); );
extern PSVCHOST_GLOBALS g_pSvchostSharedGlobals; extern PSVCHOST_GLOBAL_DATA g_pSvchostSharedGlobals;
#endif /* _SVCHOST_PCH_ */ #endif /* _SVCHOST_PCH_ */

View file

@ -446,7 +446,7 @@ StopWsdpService()
*/ */
VOID VOID
WINAPI WINAPI
SvchostPushServiceGlobals(SVCHOST_GLOBALS *lpGlobals) SvchostPushServiceGlobals(PSVCHOST_GLOBAL_DATA lpGlobals)
{ {
OutputDebugStringW(L"mswsock SvchostPushServiceGlobals stub called\n"); OutputDebugStringW(L"mswsock SvchostPushServiceGlobals stub called\n");
} }

View file

@ -1,68 +1,131 @@
/* /*
* PROJECT: ReactOS Service Host * PROJECT: ReactOS Service Host
* LICENSE: BSD - See COPYING.ARM in the top level directory * LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: sdk/include/reactos/svc.h
* PURPOSE: Global Header for Service Host * PURPOSE: Global Header for Service Host
* PROGRAMMERS: ReactOS Portable Systems Group * PROGRAMMERS: ReactOS Portable Systems Group
*
* REFERENCES:
* https://www.geoffchappell.com/studies/windows/win32/services/svchost/process/globaldata.htm
*/ */
/* See https://www.geoffchappell.com/studies/windows/win32/services/svchost/process/globaldata.htm?tx=78 */
#ifndef __SVC_H #ifndef __SVC_H
#define __SVC_H #define __SVC_H
#ifndef __RPC_H__ #ifdef __cplusplus
extern "C" {
#endif
#ifndef __RPC_H__ // For RPC_IF_HANDLE
/* Don't include windows.h if we just need rpc.h */
#ifndef RPC_NO_WINDOWS_H
#define RPC_NO_WINDOWS_H
#endif
#include <rpc.h> #include <rpc.h>
#endif // __RPC_H__
#ifndef WINAPI
#define WINAPI __stdcall
#endif
/* Ensure NTSTATUS is defined */
#ifndef _NTDEF_
typedef _Return_type_success_(return >= 0) LONG NTSTATUS, *PNTSTATUS;
#endif #endif
typedef RPC_STATUS /*
(CALLBACK *LPSTART_RPC_SERVER) ( * Entrypoints for starting and stopping an RPC server.
_In_ RPC_WSTR PipeName, */
typedef NTSTATUS
(WINAPI *PSTART_RPC_SERVER)(
_In_ PCWSTR IfName,
_In_ RPC_IF_HANDLE IfSpec); _In_ RPC_IF_HANDLE IfSpec);
typedef RPC_STATUS typedef NTSTATUS
(CALLBACK *LPSTOP_RPC_SERVER) ( (WINAPI *PSTOP_RPC_SERVER)(
_In_ RPC_IF_HANDLE IfSpec); _In_ RPC_IF_HANDLE IfSpec);
// typedef NTSTATUS
// This is the callback that a hosted service can register for stop notification (WINAPI *PSTOP_RPC_SERVER_EX)(
// _In_ RPC_IF_HANDLE IfSpec);
/*
* Entrypoints for NetBIOS service support.
*/
typedef VOID typedef VOID
(CALLBACK *PSVCHOST_STOP_CALLBACK) ( (WINAPI *PNET_BIOS_OPEN)(VOID);
_In_ PVOID lpParameter,
_In_ BOOLEAN TimerOrWaitFired
);
// typedef VOID
// Hosted Services and SvcHost Use this Structure (WINAPI *PNET_BIOS_CLOSE)(VOID);
//
typedef struct _SVCHOST_GLOBALS typedef DWORD
(WINAPI *PNET_BIOS_RESET)(
_In_ UCHAR LanaNum);
/*
* Callback that a hosted service can register for stop notification.
* Alias to (RTL_)WAITORTIMERCALLBACK(FUNC).
*/
/*
typedef VOID
(CALLBACK *PSVCHOST_STOP_CALLBACK)(
_In_ PVOID lpParameter,
_In_ BOOLEAN TimerOrWaitFired);
*/
typedef WAITORTIMERCALLBACK PSVCHOST_STOP_CALLBACK;
#if (_WIN32_WINNT == _WIN32_WINNT_WINXP && NTDDI_VERSION >= NTDDI_WINXPSP2) || \
(NTDDI_VERSION >= NTDDI_WS03SP1)
typedef DWORD
(WINAPI *PREGISTER_STOP_CALLBACK)(
_Out_ PHANDLE phNewWaitObject,
_In_ PCWSTR pszServiceName,
_In_ HANDLE hObject,
_In_ PSVCHOST_STOP_CALLBACK Callback,
_In_ PVOID Context,
_In_ ULONG dwFlags);
#endif
/*
* Hosted Services and SvcHost use this shared global data structure.
*/
typedef struct _SVCHOST_GLOBAL_DATA
{ {
PVOID NullSid; PSID NullSid;
PVOID WorldSid; PSID WorldSid;
PVOID LocalSid; PSID LocalSid;
PVOID NetworkSid; PSID NetworkSid;
PVOID LocalSystemSid; PSID LocalSystemSid;
PVOID LocalServiceSid; PSID LocalServiceSid;
PVOID NetworkServiceSid; PSID NetworkServiceSid;
PVOID BuiltinDomainSid; PSID BuiltinDomainSid;
PVOID AuthenticatedUserSid; PSID AuthenticatedUserSid;
PVOID AnonymousLogonSid; PSID AnonymousLogonSid;
PVOID AliasAdminsSid; PSID AliasAdminsSid;
PVOID AliasUsersSid; PSID AliasUsersSid;
PVOID AliasGuestsSid; PSID AliasGuestsSid;
PVOID AliasPowerUsersSid; PSID AliasPowerUsersSid;
PVOID AliasAccountOpsSid; PSID AliasAccountOpsSid;
PVOID AliasSystemOpsSid; PSID AliasSystemOpsSid;
PVOID AliasPrintOpsSid; PSID AliasPrintOpsSid;
PVOID AliasBackupOpsSid; PSID AliasBackupOpsSid;
PVOID RpcpStartRpcServer;
PVOID RpcpStopRpcServer; /* SvcHost callbacks for RPC server and NetBIOS service support */
PVOID RpcpStopRpcServerEx; PSTART_RPC_SERVER StartRpcServer;
PVOID SvcNetBiosOpen; PSTOP_RPC_SERVER StopRpcServer;
PVOID SvcNetBiosClose; PSTOP_RPC_SERVER_EX StopRpcServerEx;
PVOID SvcNetBiosReset; PNET_BIOS_OPEN NetBiosOpen;
PVOID SvcRegisterStopCallback; PNET_BIOS_CLOSE NetBiosClose;
} SVCHOST_GLOBALS, *PSVCHOST_GLOBALS; PNET_BIOS_RESET NetBiosReset;
#if (_WIN32_WINNT == _WIN32_WINNT_WINXP && NTDDI_VERSION >= NTDDI_WINXPSP2) || \
(NTDDI_VERSION >= NTDDI_WS03SP1)
PREGISTER_STOP_CALLBACK RegisterStopCallback;
#endif
} SVCHOST_GLOBAL_DATA, *PSVCHOST_GLOBAL_DATA;
#ifdef __cplusplus
}
#endif
#endif /* __SVC_H */ #endif /* __SVC_H */