
Windows Service Internals
Article Overview and Navigation
This document provides a comprehensive technical deep dive into Windows Service internals. Navigate through the sections below to explore specific aspects of service architecture, lifecycle, and diagnostics:
- I. Core Terminology and Foundational Concepts: Defines the fundamental building blocks of Windows Services, including the SCM, Service Control Dispatcher, ServiceMain function, service types, start types, error control levels, service states, Service SIDs, security descriptors, dependencies, trigger events,
svchost.exe, and service groups. - II. Service Start Triggers and System Lifecycle Integration: Details how services are initiated, focusing on critical registry configurations for startup, the impact of service type on early boot loading, the role of service group order, dependency handling by the SCM, service trigger configurations, and the integration of service initiation with Windows boot phases.
- III. Windows Service Architecture Internals: Examines the Service Control Manager (
services.exe) in depth, contrasts own-process versus shared-process service models, delves intosvchost.exeinternals (rationale, command-line syntax, registry configuration, and internal service management), and provides a comprehensive look at the service configuration registry and its parameters. - IV. Detailed Service Start Lifecycle and Initialization Sequence: Provides a step-by-step breakdown of the service start process, from boot/system start drivers to SCM initialization, auto-start service processing (for both own-process and shared-process services), demand-start services, and post-start communication, highlighting SCM actions, service responses, and common failure points with associated error codes.
- V. Differentiating Service Types: Initiation and Operational Nuances: Explores the key differences in initiation, lifecycle management, SCM communication, and operational contexts between user-mode services (
SERVICE_WIN32_OWN_PROCESS,SERVICE_WIN32_SHARE_PROCESS), kernel-mode drivers (SERVICE_KERNEL_DRIVER,SERVICE_FILE_SYSTEM_DRIVER), and the effectively deprecated interactive services (SERVICE_INTERACTIVE_PROCESS), including security implications. - VI. Service Diagnostics and Troubleshooting: Offers advanced techniques for diagnosing service failures, including methods for identifying specific services within shared
svchost.exeinstances (Task Manager, command line, PowerShell, Process Explorer, Resource Monitor) and analyzing common service failure signatures via System and Application event logs, correlating SCM Event IDs and Win32 error codes to specific lifecycle failures.
I. Core Terminology and Foundational Concepts
This section defines fundamental components and concepts of the Windows Service architecture. Definitions are concise, targeting an expert audience, and elaborate on nuances critical for advanced understanding and troubleshooting.
Service Control Manager (SCM)
Definition: The Service Control Manager (services.exe) is a critical system process initiated by wininit.exe during the user-mode phase of system boot.1 It functions as an RPC server, centralizing the management and control of all Windows services and drivers that are configured to interact with it.3
Key Responsibilities:
- Maintaining the persistent database of installed services and their configurations, primarily stored within the
HKLM\SYSTEM\CurrentControlSet\Servicesregistry hive.3 - Initiating the startup of services, encompassing auto-start, demand-start, and trigger-start user-mode services, as well as interacting with kernel-mode drivers.3
- Providing mechanisms for enumerating installed services and querying their current operational status and configuration.3
- Brokering control requests (e.g., start, stop, pause, continue, interrogate, shutdown, user-defined codes) from client applications or other system components to running services.3
- Managing exclusive access to the service database via locking mechanisms during configuration modifications to ensure data integrity.3
The SCM's role as the central orchestrator means that its proper functioning and the integrity of its database are paramount for system stability.
Service Control Dispatcher
Definition: An essential component residing within each service process. The main thread of a service executable invokes the StartServiceCtrlDispatcher() API, which establishes a connection to the SCM and transforms that thread into the Service Control Dispatcher thread for the process.4 This call is blocking and does not return until all services hosted in the process have terminated.4
Function:
- Manages an array of
SERVICE_TABLE_ENTRYstructures. Each entry maps a service name (for shared processes) to its correspondingServiceMainentry point function.4 - Upon receiving a start directive from the SCM for a specific service within its process, the dispatcher creates a new thread and executes the registered
ServiceMainfunction for that service on this new thread.4 - Relays control codes received from the SCM over the established communication channel to the appropriate service's registered control handler function (
HandlerEx).7
The dispatcher serves as the SCM's primary interface into the service process. A failure of the service process to connect to the SCM via StartServiceCtrlDispatcher() in a timely manner (default 30 seconds, configurable via ServicesPipeTimeout) is a common startup failure, resulting in Win32 error 1053 (ERROR_SERVICE_REQUEST_TIMEOUT) and SCM Event ID 7009.4
ServiceMain function
Definition: The designated entry point for a specific service's execution logic. It is invoked by the Service Control Dispatcher on a newly created, dedicated thread when the SCM issues a start command for that service.6
Key Tasks:
- Initialize any global variables or service-wide state.
- Crucially, and immediately, call
RegisterServiceCtrlHandlerEx()to register aHandlerExfunction with the SCM. This registration provides the SCM with a callback to send control requests to the service. The returned service status handle is used for all subsequent status updates.6 - Perform all service-specific initialization. If initialization is lengthy (expected to exceed approximately one second), the service must call
SetServiceStatus()to reportSERVICE_START_PENDING, providing adwWaitHint(estimated time in milliseconds for the next update or completion) and an initialdwCheckPointvalue. This status must be periodically updated with incrementingdwCheckPointvalues and newdwWaitHintsif initialization continues.6 - Upon successful completion of all initialization tasks,
ServiceMainmust callSetServiceStatus()to reportSERVICE_RUNNINGand specify the control codes it is prepared to accept via thedwControlsAcceptedmember of theSERVICE_STATUSstructure.6 - Enter its main processing loop, respond to events, or, if work is entirely event-driven through worker threads or the control handler, it may perform minimal work here. However,
ServiceMainmust not exit unless the service is transitioning to a stopped state.6 - If an error occurs that prevents the service from running, or when the service is stopping, it should call
SetServiceStatus()to reportSERVICE_STOP_PENDING(if cleanup is lengthy) followed bySERVICE_STOPPED. ThedwWin32ExitCodeanddwServiceSpecificExitCodemembers ofSERVICE_STATUSmust be set to communicate the reason for the stop.6
The diligent and correct implementation of ServiceMain, particularly its interaction with SetServiceStatus, is vital for robust service behavior and accurate reporting to the SCM. Deviations often result in SCM-logged errors such as 1053 (ERROR_SERVICE_REQUEST_TIMEOUT), 1066 (ERROR_SERVICE_SPECIFIC_ERROR), or 1067 (ERROR_PROCESS_ABORTED).
Service Control Handler (HandlerEx function)
Definition: An application-defined callback function, registered by a service's ServiceMain function through the RegisterServiceCtrlHandlerEx() API. This handler is invoked by the process's Service Control Dispatcher thread when the SCM forwards a control request to the service.7
Function: Responsible for processing various control codes, including standard controls like SERVICE_CONTROL_STOP, SERVICE_CONTROL_PAUSE, SERVICE_CONTROL_CONTINUE, SERVICE_CONTROL_SHUTDOWN, and SERVICE_CONTROL_INTERROGATE, as well as extended controls (e.g., SERVICE_CONTROL_DEVICEEVENT, SERVICE_CONTROL_TRIGGEREVENT) and custom-defined control codes.7 Upon handling a control that changes the service's state, the HandlerEx function must call SetServiceStatus() to notify the SCM of the new state.8
Constraints: The HandlerEx function must execute and return control to the dispatcher promptly, typically within 30 seconds.8 For operations that require extended processing time (e.g., graceful shutdown), the handler should report a pending state (e.g., SERVICE_STOP_PENDING with a dwWaitHint), spawn a worker thread to perform the lengthy task, and then return. The system imposes specific timeouts for shutdown, such as the WaitToKillServiceTimeout registry value (HKLM\SYSTEM\CurrentControlSet\Control), which defaults to approximately 20 seconds but can be overridden.7
A non-responsive or improperly implemented HandlerEx can lead to SCM timeouts (e.g., Event ID 7011 during stop attempts) and result in the SCM forcibly terminating the service process.
Service Types
The dwServiceType parameter, specified during service creation with CreateService and stored in the service's registry configuration, dictates its fundamental nature and interaction with the system.13
SERVICE_WIN32_OWN_PROCESS(0x00000010): The service executes within its own dedicated process. This model offers maximum isolation for the service but can lead to higher aggregate resource consumption if many such services are deployed.13SERVICE_WIN32_SHARE_PROCESS(0x00000020): The service shares a process, typically an instance ofsvchost.exe, with one or more other services. This model conserves system resources by reducing the number of active processes but introduces inter-service dependencies within the shared process; a fault in one service can potentially affect others in the same process.13SERVICE_KERNEL_DRIVER(0x00000001): Represents a kernel-mode device driver. These are loaded and managed primarily by the I/O Manager and PnP Manager, not directly launched by SCM in the same way as user-mode services.13SERVICE_FILE_SYSTEM_DRIVER(0x00000002): Represents a kernel-mode file system driver or a file system filter driver. Similar to kernel drivers, these are managed by the I/O system.13SERVICE_ADAPTER(0x00000004): Reserved for system use.13 This type is not intended for third-party service development.SERVICE_RECOGNIZER_DRIVER(0x00000008): Reserved for system use.13 Historically related to file system recognizer drivers, which are largely superseded by PnP mechanisms for file systems.-
SERVICE_INTERACTIVE_PROCESS(0x00000100):- Implications: This flag, when combined with
SERVICE_WIN32_OWN_PROCESSorSERVICE_WIN32_SHARE_PROCESSand if the service runs under the LocalSystem account, historically allowed the service to interact directly with the user's desktop by creating UI elements.13 - Deprecation: This service type is effectively deprecated due to Session 0 isolation, a security enhancement introduced in Windows Vista.15 All services run in Session 0, which is isolated from interactive user sessions. Consequently, any UI created by a service, even if marked as interactive, will not be visible to any logged-on user. The
NoInteractiveServicesregistry value (HKLM\SYSTEM\CurrentControlSet\Control\Windows), which controls this behavior, defaults to 1 (disallowing interactive services).15 UsingSERVICE_INTERACTIVE_PROCESSis strongly discouraged due to security risks (e.g., shatter attacks) and its non-functional nature on modern Windows systems. Alternative IPC mechanisms must be used for service-to-application communication.
- Implications: This flag, when combined with
Service Start Types
The dwStartType parameter, specified during service creation and stored in the registry, defines when and how a service is initiated.13
SERVICE_BOOT_START(0): Indicates a driver critical for system boot, loaded by the OS loader (e.g.,winload.exeorwinload.efi) very early in the boot sequence, before the kernel is fully operational.17SERVICE_SYSTEM_START(1): Indicates a driver essential for system operation, started by the I/O Manager (specificallyIoInitSystem) during kernel initialization, after boot-start drivers have loaded.17SERVICE_AUTO_START(2): A service configured to be started automatically by the SCM after the SCM itself has initialized and processed service group orders and dependencies. This is common for many user-mode services.17 Such services can also be marked forDelayedAutostart.SERVICE_DEMAND_START(3): (Also known as Manual start) A service that is started only when explicitly requested via an API call toStartService(), as a result of a dependency from another starting service, or by a configured service trigger event.17SERVICE_DISABLED(4): The service is disabled and cannot be started by any means until its start type is changed.17
The choice of start type significantly impacts system boot time, resource utilization, and service availability.
ErrorControl levels
The dwErrorControl parameter, set during service creation, dictates the action the system takes if the service fails to start during boot.13
SERVICE_ERROR_IGNORE(0): The startup program (OS loader or SCM) ignores the failure and continues system startup without logging an error in the event log specifically for this failure, though the service itself might log its own errors.13SERVICE_ERROR_NORMAL(1): The startup program logs the error in the System event log but continues with the system startup. The user is typically notified with a message like "At least one service or device failed during startup" before logon.13SERVICE_ERROR_SEVERE(2): The startup program logs the error in the System event log. If the system is currently booting with the Last Known Good Configuration (LKGC), startup continues. Otherwise, the system automatically attempts to restart using the LKGC.13SERVICE_ERROR_CRITICAL(3): The startup program logs the error in the System event log (if possible). If the system is booting with the LKGC, the startup operation fails (potentially leading to a non-bootable state if the driver is essential). Otherwise, the system automatically attempts to restart using the LKGC. If the service also fails to start under LKGC withSERVICE_ERROR_CRITICAL, the boot process may halt.13
ErrorControl levels are crucial for system resilience, especially for drivers and services vital for system operation.
Service States
Services transition through various states during their lifecycle, reported to the SCM via SetServiceStatus(). The SCM uses this information for management and reporting.22
SERVICE_STOPPED(0x00000001): The service is not running. This is the initial state before starting and the final state after a successful stop.SERVICE_START_PENDING(0x00000002): The service is in the process of starting.ServiceMainreports this state during its initialization phase.SERVICE_STOP_PENDING(0x00000003): The service is in the process of stopping. TheHandlerExfunction reports this state when handling a stop request that requires time.SERVICE_RUNNING(0x00000004): The service has completed its initialization and is currently operational.SERVICE_CONTINUE_PENDING(0x00000005): The service is resuming from a paused state.SERVICE_PAUSE_PENDING(0x00000006): The service is in the process of pausing.SERVICE_PAUSED(0x00000007): The service is currently paused but remains loaded in memory and can accept control requests (e.g., to continue or stop).
Accurate and timely state reporting by services is essential. Failure to do so can lead to SCM timeouts, incorrect status display in management tools, and problems during system shutdown or service control operations.
Service Security Identifier (Service SID) and ServiceSidType
Service SIDs enhance the security model for services by enabling more granular access control.24
Service SID: A unique, per-service Security Identifier automatically generated by the system. The format is NT SERVICE\<ServiceName> (e.g., NT SERVICE\MyService).24 This allows resources (files, registry keys, etc.) to be ACL'd specifically for access by a particular service, rather than relying on the broader permissions of built-in accounts like LocalSystem, LocalService, or NetworkService.
ServiceSidType: A REG_DWORD value stored in HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\ServiceSidType. It controls how the Service SID is incorporated into the service's process token when the service starts.24
SERVICE_SID_TYPE_NONE(0): The Service SID is not added to the process token. This is primarily for backward compatibility.SERVICE_SID_TYPE_UNRESTRICTED(1): The Service SID is added to the process token as a regular, enabled group SID. The service can then leverage this SID to access resources ACL'd for it.24SERVICE_SID_TYPE_RESTRICTED(3): This provides the most stringent isolation. The Service SID is added to the process token as an enabled group SID and is also added to the list of restricting SIDs in the token. This means the service process can only access objects that grant permissions to this specific Service SID, the World SID (S-1-1-0), its logon SID, or the write-restricted SID (S-1-5-33). Access granted to other groups the service account might belong to (like Authenticated Users or even LocalService itself if applicable) is effectively filtered out by the restricting SIDs unless also explicitly granted to one of the allowed SIDs.24
The evolution towards Service SIDs, especially SERVICE_SID_TYPE_RESTRICTED, reflects a significant advancement in applying the principle of least privilege to system services, thereby reducing the potential attack surface if a service is compromised.
Service Security Descriptors (DACLs on service objects)
Each service object managed by the SCM is a securable object, possessing a security descriptor that governs access to the service object itself.26
Definition: A security descriptor associated with each service object in the SCM's database. A key component of this security descriptor is the Discretionary Access Control List (DACL).
Function: The DACL on a service object contains Access Control Entries (ACEs) that specify which users or groups are granted or denied specific access rights to manage or query that service. These rights include permissions such as SERVICE_START, SERVICE_STOP, SERVICE_PAUSE_CONTINUE, SERVICE_QUERY_CONFIG, SERVICE_CHANGE_CONFIG, SERVICE_USER_DEFINED_CONTROL, and DELETE.29
Management: The security descriptor of a service object can be programmatically queried using the QueryServiceObjectSecurity function and modified using the SetServiceObjectSecurity function, provided the calling process has the necessary permissions (e.g., READ_CONTROL to query, WRITE_DAC to modify the DACL).28
Properly configured DACLs on service objects are crucial for system security, preventing unauthorized users or processes from starting, stopping, or reconfiguring services, which could lead to denial of service or elevation of privilege.
Service Dependencies: DependOnService, DependOnGroup
Services can declare dependencies on other services or groups of services, ensuring an orderly startup sequence.13
Definition: These are registry values located under HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName> that specify prerequisites that must be met before the SCM attempts to start the service.
DependOnService(REG_MULTI_SZ): Contains a list of one or more specific service names (e.g.,RpcSs,LanmanWorkstation). All services listed here must be running before the current service can be started.13DependOnGroup(REG_MULTI_SZ): Contains a list of one or more service group names. Group names in this list must be prefixed with theSC_GROUP_IDENTIFIERcharacter (+), e.g.,+NetBIOSGroup,+TDI.13 For each group listed, at least one member service of that group must be running before the current service can be started. The SCM attempts to start all members of a depended-upon group before evaluating this condition.13
Format: Both DependOnService and DependOnGroup values are of type REG_MULTI_SZ. This data type stores an array of null-terminated strings, with the entire array being terminated by an additional (empty) null-terminated string.31
SCM Handling: The SCM reads these dependency lists and constructs a dependency graph. It then traverses this graph to start services in an order that satisfies all declared dependencies. If a required dependency cannot be started (e.g., it is disabled, fails to start, or is missing), the dependent service will also fail to start. Circular dependencies are also detected and prevent service startup.
Failures in dependency resolution are a common source of service startup problems, often indicated by SCM Event ID 7001 (ERROR_SERVICE_DEPENDENCY_FAIL).33
Service Trigger Events
Service Triggers allow services to be started or stopped dynamically in response to specific system events, rather than being tied to boot-time or manual initiation.16
Definition: A mechanism enabling a service to register for notification of certain system events. Upon occurrence of a registered event, the SCM can automatically start or stop the service. Examples of trigger events include the arrival of a device of a specific interface class (e.g., a USB storage device), the availability of a network IP address, a firewall port being opened or closed, or a custom event generated by an Event Tracing for Windows (ETW) provider.35
Configuration: Service triggers are configured programmatically using the ChangeServiceConfig2 function with the SERVICE_CONFIG_TRIGGER_INFO option, which takes a SERVICE_TRIGGER_INFO structure. This structure contains an array of SERVICE_TRIGGER structures, each defining a specific trigger (type, action, subtype GUID, and optional data items).35 This configuration is stored persistently in the HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\TriggerInfo registry value as REG_BINARY data. The exact binary layout is an internal serialization of these C structures.
Operational Effect: The SCM monitors for the configured trigger events. When a matching event occurs, the SCM performs the specified action (start or stop the service). If a service is started by a trigger, its ServiceMain function receives SERVICE_TRIGGER_STARTED_ARGUMENT as argv.35
Trigger-start services offer improved system performance and resource efficiency by allowing services to run only when their functionality is actively needed. Troubleshooting services that use triggers involves verifying the TriggerInfo configuration and confirming that the expected trigger events are indeed occurring and being correctly processed by the SCM.
svchost.exe (generic host process)
svchost.exe is a cornerstone of the Windows service architecture, enabling multiple services to share a single process.37
Definition: A generic host process provided by the operating system, designed to execute services that are implemented as dynamic-link libraries (DLLs). This applies to services with the SERVICE_WIN32_SHARE_PROCESS type.37
Rationale:
- Resource Pooling: Significantly reduces the overall number of processes running on the system compared to each service running in its own process. This conserves system resources such as memory and CPU context-switching overhead.37
- Security Boundary Consolidation: Services with similar security requirements (e.g., those running under the LocalService or NetworkService accounts) can be grouped into a single
svchost.exeinstance, simplifying security management and reducing the number of distinct security contexts.37 - Reduced System Overhead: Fewer processes lead to less management overhead for the kernel in terms of process and thread tracking, handle tables, etc.37
Beginning with Windows 10 version 1703, on systems with more than 3.5 GB of RAM, many services previously grouped in svchost.exe were refactored to run in their own svchost.exe instance to improve reliability and diagnosability, indicating a shift in the trade-off when resources are less constrained.37
Operation: Multiple instances of svchost.exe typically run concurrently on a system. Each instance hosts a specific group of services. The grouping of services into svchost.exe instances is primarily defined in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost registry key.37
Understanding svchost.exe behavior, its command-line parameters, and its registry configuration is essential for diagnosing issues related to shared services, as a problem within one hosted service or the svchost.exe instance itself can affect all services within that instance.
Service Groups
Service groups are logical collections of services used primarily for controlling startup order and, in the context of svchost.exe, for defining which services share a common host process.21
Definition: A named collection of services.
Startup Ordering: The HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List registry value (a REG_MULTI_SZ) contains an ordered list of service group names. During system startup, the SCM processes these groups in the specified order. Services belonging to groups listed earlier (and their dependencies) are generally started before services in groups listed later. This mechanism is critical for managing boot-time dependencies between different sets of services.21 Individual services are assigned to a load order group via the lpLoadOrderGroup parameter of CreateService or ChangeServiceConfig, which populates the Group value in the service's registry key.
svchost.exe Grouping: The HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost registry key defines distinct groups specifically for svchost.exe hosting. Each named value under this key (e.g., netsvcs, LocalService, DcomLaunch) represents a svchost group, and its REG_MULTI_SZ data lists the service names that belong to that group and will be hosted in a common svchost.exe instance.37 These group names are used with the svchost.exe -k <GroupName> command line.
Service groups are fundamental for ensuring an orderly system initialization and for structuring the hosting environment of shared services.
The interconnectedness of these components is evident. For example, the SCM (a SERVICE_WIN32_OWN_PROCESS) relies on its registry configuration to identify SERVICE_AUTO_START services. If such a service is of type SERVICE_WIN32_SHARE_PROCESS, the SCM uses the ImagePath (pointing to svchost.exe) and the Svchost registry key to determine the correct svchost.exe group. The svchost.exe process then uses the ServiceDll parameter and the Service Control Dispatcher mechanism to load and run the actual service code, which in turn must implement ServiceMain and HandlerEx correctly. A failure at any point in this chain can lead to service startup issues.
II. Service Start Triggers and System Lifecycle Integration
This section details the registry configurations and system mechanisms that govern how and when services are initiated, linking them to the broader Windows boot and operational lifecycle.
Registry Keys for Start Configuration:
The primary configuration for service startup behavior is stored in the Windows Registry, predominantly under the service's specific key.
-
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Start: (REG_DWORD)18Significance: This value is fundamental as it dictates the phase of system startup or the condition under which a service or driver is loaded and initiated.
Values:
- 0 (
SERVICE_BOOT_START): Loaded by the operating system loader (e.g.,winload.exeorwinload.efi) during the earliest stages of boot, before the kernel is fully initialized. These are typically drivers essential for accessing the boot disk and initializing basic hardware.18 - 1 (
SERVICE_SYSTEM_START): Loaded by the I/O subsystem (specifically,IoInitSystemas part of kernel initialization) after boot-start drivers are loaded but before user-mode processes (like SCM) begin. These are often critical system drivers (e.g., file systems, PnP bus drivers) not strictly required for the initial bootstrap but necessary for core OS functionality.18 - 2 (
SERVICE_AUTO_START): Started by the Service Control Manager (services.exe) after the SCM itself has initialized during the user-mode phase of boot. This is the default for many user-mode services that need to be available shortly after the system is up.18 These services can also be configured for delayed auto-start. - 3 (
SERVICE_DEMAND_STARTor Manual): Started by the SCM only when explicitly requested via theStartService()API call, as a result of a dependency from another starting service, or when triggered by a configured service trigger event.18 - 4 (
SERVICE_DISABLED): The service is disabled and cannot be started by any means until this value is changed.18
An incorrect
Startvalue is a frequent cause of misconfiguration, leading to services not initiating as expected or, in the case of critical drivers, potential system boot failures. - 0 (
-
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Type: (REG_DWORD)13Impact on early boot loading for driver types: This value, in conjunction with the
Startvalue, determines the loading mechanism.- For services of type
SERVICE_KERNEL_DRIVER(0x1) orSERVICE_FILE_SYSTEM_DRIVER(0x2), if theirStarttype isSERVICE_BOOT_START(0), they are loaded by the OS loader.17 - If their
Starttype isSERVICE_SYSTEM_START(1), they are loaded by the kernel's I/O Manager (viaIoInitSystem) and the Plug and Play Manager during kernel initialization.17
This distinction is crucial because it ensures that fundamental drivers are available at the correct stage of the boot process, well before the SCM initializes and starts user-mode services.
- For services of type
-
HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List: (REG_MULTI_SZ)21Role: This value contains an ordered list of service group names. During the startup of
SERVICE_AUTO_STARTservices, the SCM processes these groups sequentially. Services belonging to groups listed earlier in thisList(and their resolved dependencies) are generally prioritized for startup over services in groups listed later.21This mechanism is vital for managing the high-level startup order of automatic services, ensuring that foundational services (e.g., networking prerequisites) are active before dependent application-level services attempt to start. Corruption or misconfiguration of this list can lead to widespread service start failures due to unresolved inter-group dependencies.
-
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\DependOnServiceandDependOnGroup: (REG_MULTI_SZ)13Data Type & Format: Both values are of type
REG_MULTI_SZ. They contain one or more null-terminated strings, with the list itself terminated by an additional null character.DependOnServicelists explicit service names.DependOnGrouplists group names, which must be prefixed withSC_GROUP_IDENTIFIER(the + character) to distinguish them from service names, as services and service groups share the same namespace.13Precedence Rules and SCM Handling: The SCM must ensure that all services named in
DependOnServiceare running. ForDependOnGroup, SCM ensures that at least one service from each listed group is running after attempting to start all members of said group.13 SCM constructs a dependency graph and starts services in an order that honors these dependencies.If a dependency cannot be satisfied (e.g., the depended-on service/driver fails to start, is disabled, or its registry entry is missing/corrupted), the SCM will not start the service. This typically results in Win32 error
ERROR_SERVICE_DEPENDENCY_FAIL(1068), logged as Event ID 7001 by the SCM.33 If a dependency service has been marked for deletion or does not exist,ERROR_SERVICE_DEPENDENCY_DELETED(1075) may occur, also often logged as Event ID 7000 or 7001 by SCM.33 If a circular dependency is detected (e.g., Service A depends on Service B, and Service B depends on Service A), the SCM will reportERROR_CIRCULAR_DEPENDENCY(1059), typically logged as Event ID 7000 by SCM, and will not start the services involved in the loop.43These dependency declarations are primary mechanisms for ensuring system stability and correct functionality by enforcing an orderly service initialization sequence. Failures in dependency resolution are a very common category of service startup issues.
-
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\TriggerInfo: (REG_BINARY)35Structure: This value stores the binary representation of a
SERVICE_TRIGGER_INFOstructure. This C structure contains a count of triggers (cTriggers) and a pointer to an array ofSERVICE_TRIGGERstructures (pTriggers).35 EachSERVICE_TRIGGERstructure defines the specifics of a single trigger, including its type (e.g.,SERVICE_TRIGGER_TYPE_DEVICE_INTERFACE_ARRIVAL,SERVICE_TRIGGER_TYPE_IP_ADDRESS_AVAILABILITY,SERVICE_TRIGGER_TYPE_CUSTOM), the action to perform (SERVICE_TRIGGER_ACTION_SERVICE_STARTorSERVICE_TRIGGER_ACTION_SERVICE_STOP), the trigger subtype (a GUID, e.g., a device interface class GUID or an ETW provider GUID), and optionally, trigger-specific data items (e.g., hardware IDs for device triggers).36 The precise on-disk binary layout within theREG_BINARYvalue is an internal serialization of these C structures and is not publicly documented by Microsoft.Operational Effect: The SCM monitors the system for the conditions defined by these triggers. When a registered trigger condition is met, the SCM initiates the configured action (start or stop) for the associated service. If a service is started as a result of a trigger, its
ServiceMainfunction will receiveSERVICE_TRIGGER_STARTED_ARGUMENTas its second command-line argument (lpszArgv).35Service triggers enable a more dynamic and event-driven service model, allowing services to remain dormant until actually needed, thereby optimizing system resources and boot performance. Troubleshooting trigger-start services involves verifying the
TriggerInforegistry configuration, ensuring the underlying trigger events are occurring correctly, and checking that SCM is processing these events as expected.
Boot Phases and Service Initiation:
The initiation of services is tightly coupled with the distinct phases of the Windows boot process.1
-
OS Loader Phase (e.g.,
winload.exeorwinload.efi):- This is one of the earliest phases. The OS loader is responsible for loading the core Windows kernel (
ntoskrnl.exe) and the Hardware Abstraction Layer (hal.dll) into memory. - It reads the system registry hive (
SYSTEM) and other boot-critical files. - Crucially, it loads all kernel-mode drivers whose
Starttype is set toSERVICE_BOOT_START(0). These drivers are essential for fundamental operations like accessing the boot disk and interacting with basic system hardware.17 Failure of a boot-start driver often results in a system inability to boot.
- This is one of the earliest phases. The OS loader is responsible for loading the core Windows kernel (
-
Kernel Initialization Phase (
ntoskrnl.exeexecution):- Once
ntoskrnl.exereceives control, it initializes core kernel components: memory manager, object manager, security reference monitor, process manager, etc. - I/O Manager Initialization (
IoInitSystem): This sub-phase initializes the I/O subsystem. It is responsible for loading kernel-mode drivers whoseStarttype isSERVICE_SYSTEM_START(1).17 These include drivers for file systems, Plug and Play bus enumerators, and other devices that are detected early but are not strictly necessary for the initial bootstrap performed bywinload.exe. - Plug and Play (PnP) Manager Initialization: The PnP Manager becomes active, enumerates hardware devices based on information from buses (like PCI, USB), builds the system's device tree, and loads the appropriate drivers for these devices. Many of these drivers might be
SERVICE_DEMAND_STARTbut are loaded during this phase if their corresponding hardware is present and enumerated. - After kernel initialization is sufficiently complete, the kernel starts the initial user-mode process, the Session Manager Subsystem (
smss.exe).
- Once
-
SCM Initialization (User Mode):
smss.exeis responsible for creating the user-mode environment. It starts several critical processes, including the Windows Initialization process (wininit.exe).wininit.exe, in turn, is responsible for launching key system processes, includingservices.exe(the Service Control Manager),lsass.exe(Local Security Authority Subsystem Service), andlsm.exe(Local Session Manager).1- Once
services.exe(SCM) starts, it performs its own initialization sequence:- It reads the entire service configuration database from
HKLM\SYSTEM\CurrentControlSet\Servicesinto its memory space. - It builds internal data structures to represent all services, their configurations, and their dependencies.
- It processes the
HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\Listto establish the startup order for service groups.21 - With its database built and group order determined, the SCM begins the process of starting all services configured with
StarttypeSERVICE_AUTO_START(2). This is done iteratively, respecting the group order and all individual service dependencies (DependOnService,DependOnGroup).18
- It reads the entire service configuration database from
The strict sequential nature of these boot phases means that failures or significant delays in earlier stages (e.g., a problematic
SERVICE_BOOT_STARTdriver) will inevitably cascade, impacting the ability of later stages (like SCM initialization or auto-start service loading) to proceed correctly. Diagnosing boot-time service issues often requires examining event logs not just from the "Service Control Manager" source, but also from "System" or specific driver sources, to pinpoint where in this lifecycle the initial fault occurred. The heavy reliance on registry data throughout these phases also means that registry integrity is critical; corruption in keys likeServices,ServiceGroupOrder, or individual service configuration values can severely disrupt or halt the boot process or service startup.
III. Windows Service Architecture Internals
This section provides a granular examination of the key architectural components involved in Windows service management, detailing their responsibilities, interactions, and configurations.
Service Control Manager (services.exe)
The SCM, embodied by the services.exe process, is the central authority for service management in Windows.3
Responsibilities:
- Service Database Management: The SCM maintains a comprehensive, in-memory database of all installed services and drivers. This database is primarily populated by reading configuration information from the
HKLM\SYSTEM\CurrentControlSet\Servicesregistry hive at startup and upon notification of changes. This includes details such as the service'sImagePath,StartType,ServiceType,ErrorControl, dependencies (DependOnService,DependOnGroup), account information (ObjectName), required privileges, and failure actions.3 - Process Lifecycle Management: The SCM is responsible for launching service processes. For services running as a specific user (defined by
ObjectName), it handles the logon to obtain a token and then usesCreateProcessAsUserto start the service process with that token. For shared services like those insvchost.exe, it determines if a compatible host process instance is already running (based on group name and security context) or if a new one needs to be created. It also monitors the lifetime of these processes. - Control Request Brokering: It acts as an intermediary for control requests. Client applications (e.g.,
services.msc,sc.exe, or custom management tools using service control APIs) send requests to the SCM. The SCM validates these requests and then forwards them to the appropriate service process. Within the service process, the Service Control Dispatcher routes the request to the specific service'sHandlerExfunction.3 - Service State Tracking: The SCM actively tracks the current state of all services (e.g.,
SERVICE_RUNNING,SERVICE_STOPPED,SERVICE_START_PENDING). It updates these states based on notifications received from services via theSetServiceStatusAPI and based on its own actions (e.g., after successfully starting or stopping a service).3 This status information is made available to querying applications. - Dependency Management: Before starting any service, the SCM resolves its dependencies as specified in
DependOnServiceandDependOnGroup. It ensures all prerequisite services or at least one member of a prerequisite group is running.13 - Trigger Event Monitoring: For services configured with trigger-start conditions, the SCM monitors the system for these specific events (e.g., device arrival, network changes) and initiates the start or stop of the service accordingly.35
SCM Initialization Sequence:
- The
services.exeprocess is launched bywininit.exeduring the user-mode segment of the Windows boot sequence, after the kernel and essential drivers are initialized.1 - SCM initializes its RPC server interface, making itself available to receive commands from service control programs and to communicate with service processes.3
- It meticulously reads the service configuration data from the
HKLM\SYSTEM\CurrentControlSet\Servicesregistry hive, building its internal, in-memory database of all services and their properties. - It parses the
HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\Listregistry value to determine the prescribed startup order for defined service groups.21 - Subsequently, the SCM commences the process of starting all services marked as
SERVICE_AUTO_START, adhering to the established group order and resolving all inter-service and inter-group dependencies.21 This initialization sequence is critical; any failure, such as inability to read the registry or parse configurations, can lead to significant system malfunction.
Interaction Mechanisms with Service Processes:
- LPC/RPC: The SCM functions as an RPC server.3 Communication between the SCM and client applications (like
sc.exe) and between SCM and service processes primarily utilizes Local Procedure Calls (LPC), an optimized form of RPC for inter-process communication on the same machine. This is the standard high-level mechanism for invoking SCM APIs and for SCM to send directives to service processes. - Named Pipes: The underlying transport for control commands and status updates between the SCM and a connected service process (after
StartServiceCtrlDispatchersucceeds) is typically a named pipe. For instance, pipes like\Pipe\Net\NtControlPipeX(where X is an instance number) are used for this dedicated control channel. Disruptions or failures in these IPC mechanisms can prevent the SCM from managing services or services from correctly reporting their status, often manifesting as timeouts or control request failures.
Service Processes and svchost.exe
Windows services can run in their own dedicated process or share a process with other services, most commonly through svchost.exe.
Contrast SERVICE_WIN32_OWN_PROCESS vs. SERVICE_WIN32_SHARE_PROCESS implementation models:
SERVICE_WIN32_OWN_PROCESS: TheImagePathregistry value for the service directly specifies the service's executable file. The SCM launches this executable as a new process when the service is started.13 This model provides strong isolation, as a crash in one service does not directly affect others. However, it can lead to higher overall system resource consumption if many services are configured this way. Debugging is often simpler as the process maps directly to a single service.SERVICE_WIN32_SHARE_PROCESS: TheImagePathtypically points toC:\Windows\System32\svchost.exe, usually with a-k <GroupName>parameter.13 The actual service logic is implemented in a separate DLL, specified by theServiceDllvalue in the service'sParametersregistry subkey.48 This model is designed for resource efficiency but means that multiple services co-exist within onesvchost.exeinstance. The choice between these models has significant implications for resource management, security isolation, and troubleshooting complexity.
svchost.exe Internals37
The svchost.exe process is a generic host for services implemented as DLLs.
Rationale:
- Resource Pooling: Reduces the total number of running processes, thereby decreasing memory footprint and CPU overhead associated with process creation and context switching.37
- Security Boundary Consolidation: Allows services with identical security requirements (e.g., running under the same service account like LocalService or NetworkService and requiring similar privileges) to be grouped into a single process instance. This simplifies the security model.37
- Reduced System Overhead: Fewer processes translate to less management burden on the kernel for tracking process objects, threads, handles, etc.37 Microsoft's refactoring of
svchostservices in Windows 10 (for systems with >3.5GB RAM) to run more services in separatesvchostinstances indicates a strategic shift towards prioritizing reliability and diagnosability when system resources are ample, mitigating the risk of one faulty shared service impacting others.37
Command-Line Syntax Breakdown: svchost.exe -k <GroupName> [-p]
-k <GroupName>: This is the most critical and common parameter. It instructssvchost.exeto host a specific group of services.<GroupName>corresponds to a named value under theHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchostregistry key.svchost.exereads this registry entry to determine which services (listed asREG_MULTI_SZdata) it is responsible for hosting.37-p: This flag indicates that thesvchost.exeinstance should run as a "provider" process. This is particularly relevant for services that expose COM objects and might be activated out-of-process viaCoCreateInstance. The-pflag ensures that thesvchost.exeinstance performs necessary COM initializations (likeCoInitializeSecurity) making it suitable for hosting such COM services. It can affect the security context and marshalling behavior for COM interactions involving the hosted services.-s <ServiceName>: This parameter directssvchost.exeto load and initialize only the single, specified<ServiceName>within that newsvchost.exeinstance, even if that service is part of a larger group defined by-k. The SCM uses this when launching the very first service for a particular group and security context; thatsvchost.exeinstance then becomes ready to host other services from the same group if they are subsequently started. It can also be (less commonly) used for isolating a specific service for debugging purposes, though this typically involves modifying the service'sImagePathin the registry.
Svchost Registry Key (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost):37
Structure: This key acts as the central configuration point for svchost.exe groupings. Each named value under this key (e.g., netsvcs, LocalService, DcomLaunch) represents a distinct service group name (the <GroupName> used with the -k parameter). The data associated with each named value is of type REG_MULTI_SZ and contains a list of service names that belong to that group.37
Associated values: For each group, further configuration can be specified, often as separate values under the Svchost key that match the group name or within subkeys named after the group. These can include:
CoInitializeSecurityParam(REG_DWORD): Specifies parameters for theCoInitializeSecuritycall made by thesvchost.exeinstance, controlling default COM security settings for services in that group.AuthenticationCapabilities(REG_DWORD): Defines COM authentication capabilities for the group.ImpersonationLevel(REG_DWORD): Sets the default COM impersonation level for services within the group.Type(REG_DWORD): Not the service type, but a type specifier for thesvchostgroup itself, which can influence specific hosting behaviors or security settings. These parameters collectively define the shared operational environment, particularly COM security context, for all services hosted within a givensvchost.exegroup instance. Misconfiguration or corruption of this key can prevent entire groups of essential services from starting or functioning correctly.
Internal svchost.exe Service Management: The svchost.exe process, often with the aid of helper DLLs (such as services.dll to which svchost.exe links, or more specialized hosting DLLs like netsvcs.dll, umpnpmgr.dll), performs several key steps to manage its hosted services38:
SERVICE_TABLE_ENTRYConstruction: Upon starting with a-k <GroupName>parameter,svchost.exe(or its main helper) reads the list of service names associated with<GroupName>from theSvchostregistry key. For each service name in this list, it dynamically constructs aSERVICE_TABLE_ENTRYstructure. ThelpServiceNamemember is set to the actual service name, and thelpServiceProcmember is typically set to point to a genericServiceMainwrapper function withinsvchost.exeor its primary helper DLL. This array ofSERVICE_TABLE_ENTRYstructures is then passed toStartServiceCtrlDispatcher().4- Loading of
ServiceDlls: When the SCM, through thesvchost.exe's dispatcher thread, directs a specific service within the group to start (i.e., when the generic wrapperServiceMainis called for that service), this wrapper logic retrieves the path to the service's actual implementation DLL. This path is stored in theServiceDllvalue (typicallyREG_EXPAND_SZ) under the service's specific registry key:HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Parameters\ServiceDll.48 Thesvchost.exehosting code then callsLoadLibraryEx()on this path to load the service-specific DLL into thesvchost.exeprocess space. - Invocation of
ServiceMain: After successfully loading theServiceDll, thesvchost.exehosting logic usesGetProcAddress()to obtain the address of the trueServiceMainfunction exported by thatServiceDll(the export name is conventionallyServiceMainbut can be different if configured). This service-specificServiceMainfunction is then invoked, usually on a new thread obtained from a thread pool managed bysvchost.exefor its hosted services. - Internal Tracking: The
svchost.exeprocess (or its helper DLLs) maintains internal data structures to map active services (identified by their names) to their corresponding loadedServiceDllmodule handles, the threads executing theirServiceMainandHandlerExfunctions, service status handles, and other state information necessary for managing their lifecycle within the shared process. These internal mechanisms are critical. Failures duringServiceDllloading (e.g., DLL not found, dependency issues,DllMainfailure) or problems during the invocation or execution of the service-specificServiceMainare common points of failure for shared services.
Service Configuration Registry (HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>)
This registry key is the primary persistent store for a service's configuration parameters. The SCM reads this information to manage the service.13
Comprehensive examination of critical values:
Type(REG_DWORD): Defines the service type (e.g.,SERVICE_KERNEL_DRIVER(0x1),SERVICE_FILE_SYSTEM_DRIVER(0x2),SERVICE_WIN32_OWN_PROCESS(0x10),SERVICE_WIN32_SHARE_PROCESS(0x20)). Can be combined withSERVICE_INTERACTIVE_PROCESS(0x100, deprecated).18Start(REG_DWORD): Specifies the start type:SERVICE_BOOT_START(0),SERVICE_SYSTEM_START(1),SERVICE_AUTO_START(2),SERVICE_DEMAND_START(3),SERVICE_DISABLED(4).18ErrorControl(REG_DWORD): Determines system action on service start failure:SERVICE_ERROR_IGNORE(0),SERVICE_ERROR_NORMAL(1),SERVICE_ERROR_SEVERE(2),SERVICE_ERROR_CRITICAL(3).18ImagePath(REG_EXPAND_SZorREG_SZ): Fully qualified path to the service's executable file. Forsvchost.exe-hosted services, this is typically%SystemRoot%\System32\svchost.exe -k <groupname>. Arguments for the service can also be included in this path.13DisplayName(REG_SZ): The user-friendly name of the service displayed in administrative tools like the Services MMC snap-in or Task Manager.18ObjectName(REG_SZ): Specifies the account name under which the service process will run. Common values includeLocalSystem,NT AUTHORITY\LocalService, orNT AUTHORITY\NetworkService. It can also be a specific domain or local user account (e.g.,DomainName\UserNameor.\UserName). If an account other thanLocalSystem(or the other built-in service accounts) is specified, the SCM must be able to log on as this user to obtain a security token for the service process. This value is paramount for defining the service's security context and the privileges its process token will possess.13DependOnService(REG_MULTI_SZ): A list of null-separated service names that this service depends upon. All listed services must be running before this service can start.13DependOnGroup(REG_MULTI_SZ): A list of null-separated service group names (prefixed with +) that this service depends upon. At least one service from each listed group must be running.13ServiceSidType(REG_DWORD): Controls the inclusion and type of the per-service SID in the service's process token:SERVICE_SID_TYPE_NONE(0),SERVICE_SID_TYPE_UNRESTRICTED(1),SERVICE_SID_TYPE_RESTRICTED(3).24RequiredPrivileges(REG_MULTI_SZ): A list of null-separated privilege constant names (e.g.,SeDebugPrivilege,SeAuditPrivilege,SeBackupPrivilege) that the service requires to function correctly. When the SCM starts the service, it attempts to adjust the service process's token to include these privileges and remove others not specified (forOWN_PROCESSor if all services in aSHARE_PROCESSagree). If a required privilege is not available to the service account, the service may fail to start or operate correctly.47FailureActions(REG_BINARY): Contains a binarySERVICE_FAILURE_ACTIONSstructure that specifies the actions the SCM should take if the service terminates unexpectedly (e.g., restart the service, run a specific command, reboot the system) and the reset period for the failure count.13 The binary data directly maps to theSERVICE_FAILURE_ACTIONSand associatedSC_ACTIONstructures.DelayedAutostart(REG_DWORD): If this value is set to 1 and theStarttype isSERVICE_AUTO_START, the SCM will delay the startup of this service until after other non-delayed auto-start services have completed their initialization and a brief period has elapsed. This can improve system boot performance.58Description(REG_SZ): A textual description of the service.Group(REG_SZ): The name of the load order group this service belongs to, used in conjunction withServiceGroupOrder\List. The integrity and correctness of these registry values are essential for proper service operation. Misconfigurations are a primary source of service startup failures and malfunctions.
Parameters subkey (HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Parameters):48
- Role: This subkey is a dedicated location for storing service-specific configuration parameters that the service's own code can read at runtime to customize its behavior.
ServiceDll(REG_EXPAND_SZorREG_SZ): This value is critical for services of typeSERVICE_WIN32_SHARE_PROCESS(typically those hosted bysvchost.exe). It specifies the fully qualified path to the dynamic-link library (DLL) that contains the service's entry point (ServiceMain) and its core logic.48 If this path is incorrect or the DLL is missing/corrupt, the shared service will fail to load.- Service-specific parameters: Developers can define any other registry values within the
Parameterssubkey that their service needs. For example, a service might read values likeLogLevel(REG_DWORD),ConfigurationFilePath(REG_SZ), orMaxConnections(REG_DWORD) from this location to tailor its operation without requiring code changes or recompilation. TheParameterssubkey provides a standardized way for services, especially shared ones, to locate their implementation (ServiceDll) and access custom operational settings.
The intricate web of registry settings, combined with the svchost.exe hosting model, underscores the complexity of the Windows service architecture. While svchost.exe offers resource efficiency, it introduces layers of indirection (group definitions in HKLM\...\Svchost, then individual ServiceDll paths in HKLM\...\Services\<SvcName>\Parameters) that can make tracing a specific service's execution path more challenging. Furthermore, the security context, defined by ObjectName and refined by RequiredPrivileges and ServiceSidType, is paramount. An improperly configured ObjectName can lead to logon failures (Event ID 7038)67, while overly broad privileges create security risks. The SCM's role in creating and potentially trimming the service process token based on these settings is a crucial security function.
IV. Detailed Service Start Lifecycle and Initialization Sequence
This section provides a precise, sequential, and deeply researched explanation of the Windows service start lifecycle, detailing Service Control Manager (SCM) actions and service process responses. Explicit notation of potential SCM-reported error codes (Win32 error codes and corresponding Event Log IDs from source "Service Control Manager"), common failure points, and the SCM's expected behavior/timeout mechanisms are included for each critical step.
Phase 0: Boot and System Start Drivers (Type: SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER; Start: SERVICE_BOOT_START, SERVICE_SYSTEM_START)
These drivers are loaded by the kernel's I/O Manager or the OS Loader, not directly by the SCM in the same manner as user-mode services. The SCM's role is primarily for enumeration, configuration, and control (start/stop for demand-start drivers) once they are registered.
Loading by NTOSKRNL I/O Manager (IoInitSystem, PnP Manager) or OS Loader (winload.exe/.efi) during kernel initialization phases17:
SERVICE_BOOT_STARTdrivers are loaded by the OS Loader (winload.exeorwinload.efi) before the main kernel initialization sequence begins. These are critical for basic system functions like accessing the boot device.17SERVICE_SYSTEM_STARTdrivers are loaded later during kernel initialization, typically by the I/O Manager (IoInitSystem) or the Plug and Play (PnP) Manager as devices are enumerated.17
Potential Failure Points/Errors:
- Driver Image Corruption/Not Found: If the driver file specified in
ImagePathis missing or corrupt. The OS Loader or Kernel I/O subsystem handles this. Errors likeSTATUS_IMAGE_CHECKSUM_MISMATCHor file not found errors. Event Log (System): Non-SCM errors, potentially from sources like BugCheck (if it causes a system crash, e.g.,INACCESSIBLE_BOOT_DEVICE), PnP Manager, or disk drivers. SCM is not directly involved in logging these early failures. - Unsatisfied Dependencies: Driver dependencies are defined in their INF files (
Dependenciesentry) or through PnP device hierarchy. If a prerequisite driver fails to load, the current driver may also fail. Event Log (System): PnP Manager may log events related to device start failures. - Resource Conflicts: For non-PnP drivers or misconfigured PnP drivers, conflicts in hardware resources (IRQ, DMA, I/O ports, memory regions) can prevent loading. Event Log (System): PnP manager logs.
SCM Impact: While SCM doesn't load these, failure of these drivers can prevent the system from booting or cause dependent user-mode services (which rely on the functionality provided by these drivers) to fail later. SCM might log Event ID 7001 for a user-mode service if its underlying driver dependency isn't met, though this is an indirect consequence.
SCM Behavior: SCM is not active at this stage for loading. If the system boots despite these failures, SCM will later be unable to start any user-mode services that depend (even implicitly) on the failed kernel components.
Driver Entry Points (DriverEntry):
Once a driver image is loaded into memory by the I/O Manager, its DriverEntry routine is called. This function is responsible for initializing the driver, creating device objects, and registering dispatch routines.
Potential Failure Points/Errors: DriverEntry routine returns an NTSTATUS error code (e.g., STATUS_INSUFFICIENT_RESOURCES, STATUS_DEVICE_CONFIGURATION_ERROR). Event Log (System): The driver itself might log an event, or the I/O Manager/PnP Manager might log a generic failure for the device associated with the driver.
SCM Behavior: Not directly involved.
Registration with SCM for control:
Although loaded by the kernel, drivers have an entry in the SCM database (created during installation). SCM can be used to query their status, and if they are SERVICE_DEMAND_START, to initiate their start (which translates to an I/O Manager load request) or stop. Control interaction often occurs via NtDeviceIoControlFile to a control device object, potentially \Device\ServiceController, which the SCM might use, or directly to the driver's own device objects if it implements custom IOCTLs for SCM.68
Potential Failure Points/Errors: Issues here are less about initial loading and more about subsequent control if the driver fails to correctly handle SCM IOCTLs or if its service registry entry is corrupted.
SCM Behavior: If a StartService call is made to a demand-start driver and it fails to load/initialize, SCM would report an error, potentially Event ID 7000.
Phase 1: SCM Initialization and Auto-Start User-Mode Services (Start: SERVICE_AUTO_START)
This phase begins after the kernel has initialized and started wininit.exe, which in turn starts services.exe (the SCM).
SCM Core Initialization:
-
services.exeprocess creation and initialization:wininit.exelaunchesservices.exe.1services.exeinitializes itself, setting up its RPC server and internal data structures.Potential Failure Points/Errors:
wininit.exefails to launchservices.exe: Catastrophic system failure, unlikely to reach a usable desktop. Event Log (System): System-level errors fromwininit.exeor kernel process creation failures.services.exeimage corrupt:CreateProcessbywininit.exefails. Win32 errorERROR_BAD_EXE_FORMAT(193). Event Log (System): Error logged bywininit.exeor kernel.
SCM Behavior: SCM itself fails to start; no user-mode services will be started by SCM.
-
SCM reads service configuration database: SCM parses
HKLM\SYSTEM\CurrentControlSet\Servicesto build its in-memory database of all services and drivers.Potential Failure Points/Errors:
- Corrupt
SYSTEMregistry hive: SCM cannot read configurations. Event Log (System): May see errors related to registry access. SCM may log a generic failure event (e.g., Event ID 7026 "The following boot-start or system-start driver(s) did not load" can sometimes be a symptom of broader registry issues, or a specific SCM event indicating database load failure). - Individual service registry key corruption: SCM might skip the malformed entry or log an error for that specific service.
SCM Behavior: If critical parts of the database are unreadable, SCM may fail to initialize fully. If individual entries are bad, those services will be unavailable.
- Corrupt
-
SCM builds internal data structures: Represents services, dependencies, groups, etc., in memory.
Potential Failure Points/Errors: Insufficient memory (highly unlikely in modern systems for this stage). Errors parsing specific malformed service entries.
SCM Behavior: SCM may log errors for services whose configurations it cannot parse.
-
SCM processes
ServiceGroupOrder\List: SCM readsHKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\Listto determine the startup order for service groups.21Potential Failure Points/Errors:
ServiceGroupOrder\Listvalue is corrupt or unparseable. Event Log (SCM): SCM may log an event indicating failure to process group order (e.g., Event ID 7026 if it indirectly affects driver loading logic that SCM might re-evaluate, or a more generic SCM error like 7000 if it prevents auto-start processing).SCM Behavior: May default to an alternative ordering (e.g., alphabetical by group, or no group preference) or fail to correctly process auto-start services that rely on group ordering.
Iterative Auto-Start Service Processing (respecting group order and dependencies):
The SCM iterates through services marked SERVICE_AUTO_START, respecting the ServiceGroupOrder\List and individual service dependencies.
For SERVICE_WIN32_OWN_PROCESS services:
-
SCM: Dependency Resolution & Group Ordering: SCM verifies that all services and groups listed in the current service's
DependOnServiceandDependOnGroupregistry values are already running. It also ensures that services in groups that appear earlier inServiceGroupOrder\List(andGroupOrderListfor intra-group order) are processed first.13Potential Failure Points/Errors:
ERROR_SERVICE_DEPENDENCY_FAIL(1068): A prerequisite service or driver failed to start or is not yet running. SCM Event ID: 7001 ("The<ThisServiceName>service depends on the<DependencyName>service which failed to start due to the following error:<ErrorFromDependency>").33ERROR_CIRCULAR_DEPENDENCY(1059): A loop is detected in the dependency chain (e.g., A depends on B, B depends on A). SCM Event ID: Typically 7000, with the description indicating a circular dependency.43ERROR_SERVICE_DEPENDENCY_DELETED(1075): A service named in a dependency does not exist or has been marked for deletion. SCM Event ID: 7000 or 7001.33
SCM Behavior: The start of the current service is aborted. SCM proceeds to the next service in its queue.
-
SCM: Service Record Access: SCM retrieves the service's configuration details (e.g.,
ImagePath,ObjectName,RequiredPrivileges) from its internal database.Potential Failure Points/Errors:
ERROR_SERVICE_DOES_NOT_EXIST(1060): This can occur if an auto-start service was deleted from the registry but SCM's internal state or a dependency still references it, or if the service key is present but critical values are missing. SCM Event ID: 7000 ("The<ServiceName>service failed to start due to the following error: The specified service does not exist as an installed service.").33SCM Behavior: Service start is aborted.
-
SCM: Process Token Creation (if
ObjectNamespecified): If the service'sObjectNameis not LocalSystem (or other built-in accounts likeNT AUTHORITY\LocalService,NT AUTHORITY\NetworkServicewhich have well-known SIDs and tokens), SCM attempts to log on the specified user account by callingLogonUserEx(or a similar API) to create an access token for the new service process.13Potential Failure Points/Errors:
ERROR_LOGON_FAILURE(1326): Typically due to an incorrect password or an unknown user account. SCM Event ID: 7038 ("The<ServiceName>service was unable to log on as<AccountName>with the currently configured password due to the following error: Logon failure: unknown user name or bad password.").67ERROR_SERVICE_LOGON_FAILED(1069): The account is valid but lacks the "Log on as a service" right (SeServiceLogonRight), or the account is disabled, expired, locked out, or has logon hour restrictions. SCM Event ID: 7000 ("The<ServiceName>service failed to start due to the following error: The service did not start due to a logon failure.") or 7038 (may also provide more specific sub-errors in description).43
SCM Behavior: Service start is aborted.
-
SCM: Process Creation: SCM calls
CreateProcessAsUser(using the token from step 3, or the LocalSystem token ifObjectNamewas LocalSystem) to launch the executable specified inImagePath. The process is typically created with theCREATE_SUSPENDEDflag, so its main thread does not run immediately.Potential Failure Points/Errors:
ERROR_PATH_NOT_FOUND(3): The path inImagePathis invalid, or the executable file is missing. SCM Event ID: 7000 ("The<ServiceName>service failed to start due to the following error: The system cannot find the file specified.").70ERROR_ACCESS_DENIED(5): The SCM process itself (running as LocalSystem) or the service account (if SCM impersonates for creation, though less common forCreateProcessAsUserwhich takes a token) lacks execute permissions on theImagePathfile or traverse permissions on its directory. SCM Event ID: 7000.ERROR_BAD_EXE_FORMAT(193): The file specified inImagePathis not a valid Win32 executable or is corrupted. SCM Event ID: 7000.ERROR_INVALID_IMAGE_HASH(577) /STATUS_INVALID_IMAGE_HASH: Windows cannot verify the digital signature for the file, or integrity checking failed. SCM Event ID: 7000.
SCM Behavior: Service start is aborted.
-
SCM: Privileges & Environment: SCM applies any
RequiredPrivilegesspecified in the service's registry configuration to the primary token of the newly created (and still suspended) process. Privileges not listed inRequiredPrivilegesmay be removed from the token. SCM also sets up a standard service environment block for the process.47Potential Failure Points/Errors: Generally, failures at this stage are rare and would indicate deeper system issues (e.g., SCM failing to adjust token privileges due to a kernel problem). More commonly, if a service needs a privilege that its configured account (
ObjectName) doesn't possess and it's not inRequiredPrivileges(orRequiredPrivilegeslists something the account can't have), the service will likely fail later during itsServiceMaininitialization when it attempts a privileged operation. SCM does not typically log an error at this specific step unless the token manipulation itself fails.SCM Behavior: Usually proceeds, but the service might fail during its own initialization if necessary privileges are absent.
-
SCM: Resume Process: SCM calls
ResumeThreadon the main thread of the service process, allowing it to begin execution.Potential Failure Points/Errors: The process crashes immediately upon being resumed. This can be due to various reasons:
- Missing critical DLLs that the service executable depends on (loader errors).
- Failures in static C/C++ initializers within the executable or its dependent DLLs.
- An unhandled exception occurring very early in the process's
main()orWinMain()function, beforeStartServiceCtrlDispatcheris called. - This typically results in
ERROR_PROCESS_ABORTED(1067). SCM Event ID: 7034 ("The<ServiceName>service terminated unexpectedly. It has done this X time(s).") or 7031 ("The<ServiceName>service terminated unexpectedly... The following corrective action will be taken...").43
SCM Behavior: SCM detects the process termination, marks the service as stopped/failed, and may initiate configured failure actions (e.g., restart).
-
Service Process: Connect to SCM (
StartServiceCtrlDispatcher): The main thread of the now-running service process must callStartServiceCtrlDispatcher()promptly. This API call takes an array ofSERVICE_TABLE_ENTRYstructures, which maps service names to theirServiceMainfunctions.4 This call blocks until all services in the process terminate. The SCM imposes a timeout for this connection to be established (default is 30 seconds, but configurable globally via theServicesPipeTimeoutregistry value:HKLM\SYSTEM\CurrentControlSet\Control\ServicesPipeTimeout).4Potential Failure Points/Errors:
ERROR_SERVICE_REQUEST_TIMEOUT(1053): The service process fails to callStartServiceCtrlDispatcherwithin the SCM's timeout period. SCM Event ID: 7009 ("A timeout was reached (X milliseconds) while waiting for the<ServiceName>service to connect.") or 7000 ("The<ServiceName>service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion.").9ERROR_FAILED_SERVICE_CONTROLLER_CONNECT(1063):StartServiceCtrlDispatcheris called, but the calling process is not one that was started by the SCM as a service (e.g., it's a regular console application being run manually). SCM Event ID: 7000.4- The service process crashes before or during the
StartServiceCtrlDispatchercall (refer to errors in step 6).
SCM Behavior: SCM considers the service to have failed its startup. It will typically terminate the service process if SCM itself created it.
-
SCM/Dispatcher: ServiceMain Invocation: Upon a successful connection from
StartServiceCtrlDispatcher, the SCM communicates to the dispatcher thread in the service process which service to start. The dispatcher thread then looks up the correspondinglpServiceProc(theServiceMainfunction pointer) in theSERVICE_TABLE_ENTRYarray and invokes this function on a new, dedicated thread.4Potential Failure Points/Errors:
- Invalid
ServiceMainfunction pointer in theSERVICE_TABLE_ENTRY(e.g., NULL or points to invalid code). ServiceMainfunction itself causes an immediate unhandled exception upon invocation on its new thread.- These typically lead to the service process crashing or the
ServiceMainthread terminating prematurely. SCM would likely see this asERROR_PROCESS_ABORTED(1067). SCM Event ID: 7031 or 7034.
SCM Behavior: Marks the service as failed.
- Invalid
-
ServiceMain: Handler Registration (RegisterServiceCtrlHandlerEx): TheServiceMainfunction, now running on its own thread, must immediately callRegisterServiceCtrlHandlerEx()(or its predecessorRegisterServiceCtrlHandler()) to register a handler function (HandlerEx) that will process control requests (like STOP, PAUSE, etc.) from the SCM.6 This call returns a service status handle required forSetServiceStatus.Potential Failure Points/Errors:
RegisterServiceCtrlHandlerExitself fails (e.g., due toERROR_NOT_ENOUGH_MEMORY). If this call is not made, or fails and the service continues, the SCM will be unable to send any control signals to the service. This is not an immediate SCM-reported start error but a critical functional deficiency.SCM Behavior: If registration fails and
ServiceMainsubsequently exits reporting an error, SCM logs that error. IfServiceMainproceeds without a registered handler, the service might appear to start, but it will be unresponsive to SCM controls (e.g., stop requests), potentially leading to Event ID 7011 ("A timeout...was reached while waiting for a transaction response...") during later attempts to control the service. -
ServiceMain: ReportSERVICE_START_PENDING: TheServiceMainfunction must callSetServiceStatus()to inform the SCM that it is starting. This status update should setdwCurrentStatetoSERVICE_START_PENDING, provide an initialdwCheckPoint(e.g., 1), and adwWaitHint(an estimate in milliseconds for how long the current phase of initialization will take, or until the nextSetServiceStatuscall).6 The SCM usesdwWaitHintto set its internal timer for this service's startup.Potential Failure Points/Errors:
- Failure to call
SetServiceStatuswithSERVICE_START_PENDING. - Providing an unrealistic or zero
dwWaitHintwhile performing lengthy initialization. - If the service does not update its status (increment
dwCheckPointor change state) within the specifieddwWaitHint(or subsequent hints), or if an overall SCM startup timeout for the service is exceeded (related toServicesPipeTimeout), SCM will consider the service hung. - Win32 Error:
ERROR_SERVICE_REQUEST_TIMEOUT(1053). SCM Event ID: 7022 ("The<ServiceName>service hung on starting.").75
SCM Behavior: SCM waits for the duration of
dwWaitHintfor the next status update. If this timeout expires without an update, SCM marks the service as failed/hung. - Failure to call
-
ServiceMain: Initialization Logic: The service executes its core initialization tasks (e.g., allocating resources, reading configuration files, establishing network connections, starting worker threads). If this initialization is lengthy,ServiceMainmust periodically callSetServiceStatus()withSERVICE_START_PENDING, incrementingdwCheckPoint, and providing an updateddwWaitHintto signal ongoing progress.6Potential Failure Points/Errors:
- Any error during the service's own initialization logic (e.g., database connection failure, configuration parsing error, critical resource unavailable). The service should detect this, perform cleanup, and then call
SetServiceStatuswithdwCurrentState=SERVICE_STOPPED, a relevantdwWin32ExitCode(e.g., a specific Win32 error code, orERROR_SERVICE_SPECIFIC_ERRORifdwServiceSpecificExitCodeis also set), and optionallydwServiceSpecificExitCode. - SCM Event ID for service-reported stop: 7023 ("The
<ServiceName>service terminated with the following error:<ErrorStringOrErrorCode>.")70 ifdwWin32ExitCodeis a standard error, or 7024 ("The<ServiceName>service terminated with the following service-specific error:<ServiceSpecificErrorCode>.") ifdwWin32ExitCodewasERROR_SERVICE_SPECIFIC_ERROR(1066).77 - Service hangs indefinitely (e.g., deadlock, infinite loop) without updating status. SCM timeout based on
dwWaitHint. SCM Event ID: 7022. - Service crashes due to an unhandled exception during initialization. Win32 Error:
ERROR_PROCESS_ABORTED(1067). SCM Event ID: 7031 or 7034.
SCM Behavior: If the service reports
SERVICE_STOPPED, SCM logs the termination and provided error codes. If the service hangs or crashes, SCM marks it as failed and may initiate configured failure actions. - Any error during the service's own initialization logic (e.g., database connection failure, configuration parsing error, critical resource unavailable). The service should detect this, perform cleanup, and then call
-
ServiceMain: ReportSERVICE_RUNNING: Upon successful completion of all initialization,ServiceMainmust callSetServiceStatus()withdwCurrentState=SERVICE_RUNNING. It should also specify the control codes it is prepared to accept in thedwControlsAcceptedmember of theSERVICE_STATUSstructure.6Potential Failure Points/Errors:
ServiceMainexits (e.g., "falls off the end" of the function) after initialization without callingSetServiceStatusto reportSERVICE_RUNNINGorSERVICE_STOPPED.- SCM may eventually timeout waiting for a definitive status, logging
ERROR_SERVICE_REQUEST_TIMEOUT(1053). SCM Event ID: 7000 or 7022. ERROR_SERVICE_NEVER_STARTED(1077) ("No attempts to start the service have been made since the last boot.") is less common for auto-start services that reach this point but can occur ifServiceMainreturns prematurely in certain ways, especially for demand-start services.43
SCM Behavior: Once
SERVICE_RUNNINGis reported, SCM considers the service operational. SCM logs Event ID 7036 ("The<ServiceName>service entered the running state.").79 - SCM may eventually timeout waiting for a definitive status, logging
For SERVICE_WIN32_SHARE_PROCESS services (typically involving svchost.exe):
-
SCM: Dependency Resolution & Group Ordering: Identical to OWN_PROCESS step 1.13
Potential Failure Points/Errors: Same as OWN_PROCESS step 1 (Win32 1068/Event 7001; Win32 1059/Event 7000; Win32 1075/Event 7000 or 7001).
-
SCM: Service Record & Group Identification: SCM accesses the service's configuration. The
ImagePathis typically a command likeC:\Windows\System32\svchost.exe -k <groupname>. SCM parses<groupname>from this command line. It then consults theHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchostregistry key to validate that the service is a member of this<groupname>and to identify other services that may share thissvchost.exeinstance.37Potential Failure Points/Errors: Service name not found under the specified
<groupname>in theSvchostregistry key.ImagePathis malformed or does not correctly specify a group. SCM Event ID: 7000, potentially with an error indicating invalid parameter or configuration. -
SCM: Target
svchost.exeInstance:- Determine Security Context: The security context for the
svchost.exeinstance is determined by theObjectName(service account) of the first service being started for this specific group. If multiple services in the group use differentObjectNames, they cannot share the samesvchost.exeinstance unless thoseObjectNames resolve to the same security context or theSvchostgroup has overriding security parameters defined (e.g.,CoInitializeSecurityParamin theSvchostregistry key).37 - Check for Existing, Compatible
svchost.exeInstance: SCM checks if ansvchost.exeprocess is already running that is hosting the same group name AND is running under the same security context (determined in step 3a). - Launch New
svchost.exeInstance (if needed): If no compatiblesvchost.exeinstance exists, SCM launches a new process using theImagePath(e.g.,svchost.exe -k <groupname>). The creation of thissvchost.exeprocess follows the same logic as OWN_PROCESS steps 3 (Process Token Creation for the determined security context), 4 (Process Creation), 5 (Privileges), and 6 (Resume Process).
Potential Failure Points/Errors: All errors from OWN_PROCESS steps 3-6 are applicable here to the
svchost.exeprocess itself. This includes logon failures for the group's designated account (Win32 1326/Event 7038; Win32 1069/Event 7000/7038),svchost.exepath not found (Win32 3/Event 7000), access denied forsvchost.exe(Win32 5/Event 7000), orsvchost.execrashing on startup (Win32 1067/Event 7031/7034). - Determine Security Context: The security context for the
-
svchost.exe(Host Process): Connect/Notify SCM:- New
svchost.exeInstance: The main thread of the newly launchedsvchost.exeprocess (or its primary helper DLL, likeservices.dll) is responsible for callingStartServiceCtrlDispatcher(). TheSERVICE_TABLE_ENTRYarray passed to this function will typically include entries for all services listed under the<groupname>in theHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchostregistry key, as this instance is now prepared to host any of them.4 - Existing
svchost.exeInstance: If a compatiblesvchost.exeinstance was already running, the SCM sends a special control request (an internal "add service" or "start service within host" command) to that existingsvchost.exeprocess. The Service Control Dispatcher thread within that runningsvchost.exereceives this command and initiates the loading sequence for the newly requested service from within the existing process.
Potential Failure Points/Errors:
- New instance:
ERROR_SERVICE_REQUEST_TIMEOUT(1053) / SCM Event ID 7009 or 7000 if the newsvchost.exefails to callStartServiceCtrlDispatcherin time. - New instance:
svchost.exeprocess crashes before callingStartServiceCtrlDispatcher(see OWN_PROCESS step 6 errors). - Existing instance: The running
svchost.exemight fail to process the SCM's internal command to load the new service (e.g., due to internal errors, resource exhaustion within that process). SCM would then log an error for the specific service that was meant to be started.
- New
-
svchost.exe(Host Process): LoadServiceDll: Thesvchost.exehosting logic (which could be insvchost.exeitself, a generic helper likenetsvcs.dllorservices.dll, or a service-specific hosting DLL likegpsvc.dllfor the Group Policy Client service) looks up theServiceDllparameter in the target service's registry key:HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Parameters\ServiceDll. It then callsLoadLibraryEx()on the DLL path specified in this value.48Potential Failure Points/Errors:
ServiceDllregistry value missing or the path is incorrect/points to a non-existent file: Win32 errorERROR_MOD_NOT_FOUND(126). SCM Event ID: 7000 ("...The specified module could not be found.") or 7023 ("...The specified module could not be found.").71LoadLibraryExfails: This can happen if theServiceDllitself is corrupt, one of its dependent DLLs is missing or corrupt, there's insufficient memory, or theDllMainfunction of theServiceDll(or one of its dependencies) returnsFALSEduringDLL_PROCESS_ATTACH. Win32 errorERROR_DLL_INIT_FAILED(1114) is common ifDllMainfails. SCM Event ID: 7000 or 7023.
SCM Behavior: The
svchost.exehosting logic would typically report a failure to the SCM for this specific service, or the thread designated for this service withinsvchost.exemight terminate. -
svchost.exe(Host Process): InvokeServiceMainfromServiceDll: After successfully loading theServiceDll, thesvchost.exehosting logic retrieves the address of the exportedServiceMainfunction (or a custom-named entry point if specified elsewhere in parameters) from theServiceDllusingGetProcAddress(). ThisServiceMainfunction is then called, typically on a new thread allocated from a thread pool managed bysvchost.exefor the services it hosts.Potential Failure Points/Errors:
- The
ServiceMain(or custom entry point) function is not actually exported by theServiceDll, or it has an incorrect function signature.GetProcAddresswould fail. - A crash occurs within the
ServiceDll'sDllMain(if not caught by theLoadLibraryExfailure itself) or very early in the execution of itsServiceMainfunction before it can register a handler or report status. - SCM Event ID: 7000, 7023. If a crash occurs that destabilizes the
svchost.exeinstance, Event ID 7031 or 7034 for thesvchost.exeprocess itself might be logged, affecting all services in that instance.
- The
-
ServiceMain(inServiceDll): Handler Registration, Status Reporting, Init, Running: This sequence of actions performed by the service code within theServiceDllis identical to OWN_PROCESS steps 9 through 12. TheServiceMainmust register its control handler, reportSERVICE_START_PENDINGwith checkpoints and wait hints during its initialization, and finally reportSERVICE_RUNNINGupon success, orSERVICE_STOPPEDwith appropriate error codes if initialization fails.Potential Failure Points/Errors: Same as OWN_PROCESS steps 9-12. For example, Win32 1053/Event 7022 if stuck in start-pending; Win32 1066/Event 7024 for a service-specific error reported by the
ServiceDll; or a crash leading to Event 7031/7034 for thesvchost.exeinstance if the error is uncontained.
Phase 2: Demand-Start Services (Start: SERVICE_DEMAND_START)
Services configured as SERVICE_DEMAND_START are not started automatically at boot but are initiated under specific conditions.
Initiation via:
- An explicit call to the
StartService()API by an application (e.g.,services.mscconsole,sc.exe start <servicename>command, or custom management software). - Automatic start by the SCM if another service (either auto-start or another demand-start service) that is currently starting lists this demand-start service in its
DependOnServiceorDependOnGroup. - A configured Service Trigger Event, if the service is set up to start based on specific system events.35
SCM actions: Upon receiving a demand-start request (from any of these sources), the SCM performs the same dependency checks and follows the same loading sequence as detailed in Phase 1 for auto-start services, depending on whether the service is SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS.
Potential Failure Points/Errors: All errors listed in Phase 1 (for OWN_PROCESS steps 1-12 or SHARE_PROCESS steps 1-7) are applicable to demand-start services.
Additionally, if StartService() is called programmatically, the calling application may receive specific Win32 error codes directly from the API:
ERROR_SERVICE_ALREADY_RUNNING(1056): The service is already in theSERVICE_RUNNINGorSERVICE_START_PENDINGstate.4ERROR_SERVICE_DISABLED(1058): The service'sStarttype isSERVICE_DISABLED.43ERROR_SERVICE_MARKED_FOR_DELETE(1072): The service has been marked for deletion and cannot be started.13ERROR_ACCESS_DENIED(5): The calling process/user lacks theSERVICE_STARTpermission for the service object.
SCM Event Log IDs generated will be the same as those for auto-start service failures (e.g., 7000, 7001, 7009, 7022, 7023, 7024, 7031, 7034, 7038).
Service Communication Post-Start
Once a service successfully reaches the SERVICE_RUNNING state, its interaction with the SCM continues for control and status purposes.
Service Control Dispatcher Role: In each service process, the thread that successfully called StartServiceCtrlDispatcher() remains dedicated to SCM communication. It waits on the named pipe connection to the SCM for incoming control commands targeted at any of the services hosted within that process. When a command arrives, this dispatcher thread identifies the target service and invokes its registered HandlerEx function (on the dispatcher thread itself or by queuing to a service worker thread, implementation dependent).4
ServiceMain Completion: After ServiceMain reports SERVICE_RUNNING, the thread on which ServiceMain was executed typically either:
- Enters a primary work loop if the service performs continuous tasks (e.g., listening on a socket, processing a message queue).
- Sets up necessary worker threads and event-driven mechanisms (e.g., waits on synchronization objects that are signaled by worker threads or I/O completion ports) and then may return. The service logic continues on these other threads or via callbacks from the
HandlerExfunction. It is critical thatServiceMaindoes not exit prematurely unless the service is intentionally stopping. If theServiceMainthread terminates while the service is expected to be running, and no other threads are designated to maintain the service's active status or respond to SCM, the SCM might eventually consider the service to have failed or stopped unexpectedly, depending on howSetServiceStatuswas last called and whether the process itself exits.
Control Handler (HandlerEx): This function is the service's interface for runtime management by the SCM. It processes various control codes, such as SERVICE_CONTROL_STOP, SERVICE_CONTROL_PAUSE, SERVICE_CONTROL_CONTINUE, SERVICE_CONTROL_INTERROGATE (to request current status), SERVICE_CONTROL_SHUTDOWN (system is shutting down), SERVICE_CONTROL_DEVICEEVENT, SERVICE_CONTROL_TRIGGEREVENT, and user-defined controls.7
The HandlerEx must call SetServiceStatus() to report any changes in the service's state resulting from these control codes (e.g., transitioning to SERVICE_STOP_PENDING, then SERVICE_STOPPED; or SERVICE_PAUSED).
Potential Failure Points/Errors during operation or stop:
- Failure to respond to control codes (especially
SERVICE_CONTROL_STOPorSERVICE_CONTROL_SHUTDOWN) within the SCM's allotted timeout. For shutdown, this is governed byWaitToKillServiceTimeout(default ~20 seconds).7 For other controls, it's typically around 30 seconds. SCM Event ID: 7011 ("A timeout (X milliseconds) was reached while waiting for a transaction response from the<ServiceName>service.").9 - The service process crashes while handling a control request. SCM Event ID: 7031 or 7034.
- When stopping, the service should use
SetServiceStatusto reportSERVICE_STOPPEDand provide appropriatedwWin32ExitCodeanddwServiceSpecificExitCodevalues in theSERVICE_STATUSstructure to indicate success or the reason for any failure during shutdown.6
The multiple timeout mechanisms (ServicesPipeTimeout for initial connection and overall start, dwWaitHint for start-pending updates by ServiceMain, and various control-response timeouts for HandlerEx, including WaitToKillServiceTimeout) are critical control points. A generic "timeout" (Win32 error 1053) can occur at different lifecycle stages, making the specific SCM Event ID (7009 for connect, 7022 for start-pending, 7011 for control response) essential for diagnosis. Error propagation is also a key consideration; an internal application error within ServiceMain might be reported as a service-specific error (1066, Event 7024) if handled gracefully, or result in a crash (1067, Event 7031/7034) if unhandled. SCM logs often point to the symptom, requiring deeper investigation (e.g., application event logs, debugging) for the root cause.
V. Differentiating Service Types: Initiation and Operational Nuances
The Type parameter of a service, defined in its registry configuration (HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Type), fundamentally dictates how it is loaded, managed, and its operational context within the Windows architecture.
User-mode services (SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_SHARE_PROCESS):
- Initiation: These services are managed and initiated by the Service Control Manager (
services.exe).- For
SERVICE_WIN32_OWN_PROCESS, the SCM directly launches the executable specified in the service'sImagePathregistry value.13 - For
SERVICE_WIN32_SHARE_PROCESS, theImagePathtypically points tosvchost.exe -k <GroupName>. The SCM launchessvchost.exe(if a suitable instance isn't already running for that group and security context).svchost.exethen loads the actual service code from a DLL specified in the service'sParameters\ServiceDllregistry value.13
- For
- Lifecycle Management: The entire lifecycle (start, stop, pause, status reporting) is governed by the SCM. Services must adhere to the SCM's communication protocol, including calling
StartServiceCtrlDispatcher,RegisterServiceCtrlHandlerEx, andSetServiceStatusat appropriate times.4 - Communication with SCM: Interaction occurs via Local Procedure Calls (LPC)/Remote Procedure Calls (RPC) for general commands and a dedicated named pipe for control signals and status updates once the service process is connected to the SCM.3
- Operational Nuances: They run in user mode, with security context determined by their
ObjectName(service account) andRequiredPrivileges. Shared services withinsvchost.exeshare the process space, memory, and security token of thatsvchost.exeinstance, leading to resource efficiency but reduced isolation compared to own-process services.
Kernel-mode drivers (SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER):
- Initiation: These are not started by the SCM in the same way as user-mode services. They are loaded into kernel space by the I/O Manager or the OS Loader much earlier in the boot process.17
SERVICE_BOOT_STARTdrivers are loaded bywinload.exe/.efi.17SERVICE_SYSTEM_STARTdrivers are loaded byIoInitSystemor the PnP Manager during kernel initialization.17
- Entry Points: Their primary entry point is the
DriverEntryfunction, notServiceMain.DriverEntryis responsible for initializing the driver and registering it with the I/O Manager.17 - Lifecycle Management: Managed by the I/O Manager and PnP Manager. While they have service entries in the SCM database (allowing
sc.exeto query or, for demand-start drivers, request start/stop), their core loading and operation are kernel-internal. - Communication with SCM: SCM's interaction for control (e.g., stopping a demand-start driver) or status query is typically indirect, often via IOCTLs sent to a control device object like
\Device\ServiceController(which SCM uses) or through specific PnP mechanisms.68 Drivers do not callStartServiceCtrlDispatcherorSetServiceStatusin the user-mode sense. - Operational Nuances: They run in kernel mode (Ring 0) with high privileges, directly interacting with hardware and core OS components. Errors in kernel drivers are far more likely to cause system instability or crashes (Blue Screen of Death) than errors in user-mode services.
Interactive services (SERVICE_INTERACTIVE_PROCESS):
- Constraints and Security Implications: This flag, if set for a
SERVICE_WIN32_OWN_PROCESSorSERVICE_WIN32_SHARE_PROCESSservice running as LocalSystem, was intended to allow the service to display a user interface on the interactive user's desktop.13 - Session 0 Isolation and Effective Deprecation: Since Windows Vista, all services run in Session 0, which is isolated from interactive user logon sessions (Session 1, Session 2, etc.).15 This means any UI created by a service in Session 0 is not visible to any logged-on user. The
NoInteractiveServicesregistry value (HKLM\SYSTEM\CurrentControlSet\Control\Windows) defaults to 1 (enabled), explicitly preventing services from interacting with the desktop, regardless of theSERVICE_INTERACTIVE_PROCESSflag.15 - Operational Nuances: Using
SERVICE_INTERACTIVE_PROCESSis strongly discouraged and generally non-functional for its original purpose on modern Windows versions. It poses significant security risks if it were to bypass Session 0 isolation (e.g., shatter attacks where a lower-privilege application could send messages to a higher-privilege service window). Any service requiring user interaction must do so indirectly, for example, by launching a separate GUI application in the user's session (usingCreateProcessAsUser) and communicating with it via IPC (e.g., named pipes, RPC), or usingWTSSendMessageto display simple message boxes in a user's session.15 - Troubleshooting services that attempt to be "interactive" usually involves educating developers about Session 0 isolation and guiding them towards proper IPC-based solutions for user interaction.
The choice of service type fundamentally alters its relationship with the SCM, the kernel, and the system's security model. User-mode services are fully orchestrated by the SCM, while kernel-mode drivers operate under the I/O Manager's purview with SCM playing a more limited control/query role. Interactive services are a legacy concept incompatible with modern Windows security architecture.
VI. Service Diagnostics and Troubleshooting
Advanced techniques for diagnosing service failures and identifying service resource utilization are critical for Tier 3/4 engineers.
A. Identifying Specific Services within Shared svchost.exe Instances:
Given that multiple services often run within a single svchost.exe process, isolating a problematic service requires mapping the svchost.exe Process ID (PID) to the services it hosts.
-
Task Manager (Details/Services Tab):
- On modern Windows versions (Windows 10/11, Server 2016+), the "Services" tab in Task Manager directly shows the PID for each service. Sorting by PID or grouping by name can help.
- On the "Details" tab, find the
svchost.exeinstance of interest (e.g., by high CPU/memory). Right-click and select "Go to service(s)". This will switch to the "Services" tab and highlight the services running in that specificsvchost.exeinstance.38
-
Command Line (
tasklist /svc):- Executing
tasklist /svcin a command prompt lists all running processes. For eachsvchost.exeinstance, it will list the short names of the services it is currently hosting.38 The output can be piped tofindstrto filter for a specificsvchost.exePID or service name. - Example:
tasklist /svc /fi "imagename eq svchost.exe"
- Executing
-
PowerShell (
Get-ServiceandGet-Process):- To find services hosted by a specific
svchost.exePID (e.g., PID 1234):PowerShell
Get-WmiObject win32_service | Where-Object {$_.ProcessId -eq 1234} | Select-Object Name, DisplayName, State, ProcessId - To find the PID for a specific service (e.g., BITS):
PowerShell
(Get-WmiObject win32_service | Where-Object {$_.Name -eq "BITS"}).ProcessIdThen use this PID with Process Explorer or other tools.
- To find services hosted by a specific
-
Process Explorer (Sysinternals):
- Launch Process Explorer. Hovering the mouse over an
svchost.exeprocess in the tree view will show a tooltip listing the services it hosts.38 - Alternatively, double-click an
svchost.exeprocess to open its properties dialog, then navigate to the "Services" tab. This tab lists all services hosted by that instance, their display names, and allows stopping/restarting individual services (with appropriate permissions).38
- Launch Process Explorer. Hovering the mouse over an
-
Resource Monitor (
resmon.exe):- On the "CPU" or "Memory" tab, select a specific
svchost.exeprocess. The "Services" pane (usually at the bottom or accessible via a dropdown) will then list the services associated with the selectedsvchost.exeinstance. Understanding these mappings is the first step in isolating issues like high resource consumption or crashes within a shared service host.
- On the "CPU" or "Memory" tab, select a specific
B. Common Service Failure Signatures and Error Analysis:
Diagnosing service failures often begins with the Windows Event Logs, primarily the System log.
System Event Log (Source: "Service Control Manager"):
The SCM is the primary source for events related to service start, stop, and operational failures. Key Event IDs include:
- Event ID 7000: "The
<ServiceName>service failed to start due to the following error:<ErrorString/ErrorCode>." This is a generic but critical event indicating a service could not start. The<ErrorString/ErrorCode>(often a Win32 error code) is vital for diagnosis.9 Common embedded errors include logon failures (1069), path not found (3), module not found (126), timeout (1053). - Event ID 7001: "The
<ServiceName>service depends on the<DependencyName>service which failed to start because of the following error:<ErrorString>." Indicates a failure due to an unsatisfied dependency.74 The root cause is the failure of<DependencyName>. - Event ID 7009: "A timeout was reached (X milliseconds) while waiting for the
<ServiceName>service to connect." This occurs if the service process starts but fails to callStartServiceCtrlDispatcher()within the SCM's timeout period (default 30s, viaServicesPipeTimeout).9 - Event ID 7011: "A timeout (X milliseconds) was reached while waiting for a transaction response from the
<ServiceName>service." This typically means the service'sHandlerExfunction failed to respond to a control request (e.g., STOP, PAUSE, SHUTDOWN) in time.9 - Event ID 7022: "The
<ServiceName>service hung on starting." The service calledStartServiceCtrlDispatcher(),ServiceMainwas invoked and reportedSERVICE_START_PENDING, but it failed to reportSERVICE_RUNNING(orSERVICE_STOPPED) within its declareddwWaitHintor an overall SCM timeout.75 - Event ID 7023: "The
<ServiceName>service terminated with the following error:<ErrorString/ErrorCode>." The service, during its operation or startup, explicitly calledSetServiceStatuswithSERVICE_STOPPEDand a Win32 error code (other thanERROR_SERVICE_SPECIFIC_ERROR).70 The embedded error code is key. - Event ID 7024: "The
<ServiceName>service terminated with the following service-specific error:<ServiceSpecificErrorCode>." The service calledSetServiceStatuswithSERVICE_STOPPED,dwWin32ExitCode=ERROR_SERVICE_SPECIFIC_ERROR(1066), anddwServiceSpecificExitCodecontaining the specific code.77 The meaning of the service-specific code is defined by the service vendor. - Event ID 7031: "The
<ServiceName>service terminated unexpectedly. It has done this X time(s). The following corrective action will be taken in Y milliseconds:<Action>." Indicates the service process crashed or was terminated without a graceful shutdown notification to SCM.71 Often associated with unhandled exceptions. - Event ID 7032: "The Service Control Manager tried to take a corrective action (
<Action>) after the unexpected termination of the<ServiceName>service, but this action failed with the following error:<ErrorString>." SCM's configured recovery action (e.g., restart service, run program) itself failed.85 - Event ID 7034: "The
<ServiceName>service terminated unexpectedly. It has done this X time(s)." Similar to 7031, indicating a crash, often logged repeatedly if the service keeps crashing and SCM keeps restarting it.72 - Event ID 7036: "The
<ServiceName>service entered the<running/stopped>state." Informational event indicating a successful start or stop.79 Note: Availability of this event for all start/stop actions has varied across Windows versions, particularly for desktop OSes.79 - Event ID 7038: "The
<ServiceName>service was unable to log on as<AccountName>with the currently configured password due to the following error:<ErrorString>." Specifically indicates a logon failure for the service account.67 Common error strings are "Logon failure: unknown user name or bad password." or "The user has not been granted the requested logon type at this computer." (missing "Log on as a service" right).
The Win32 error code often embedded in these event descriptions is crucial for pinpointing the cause.
Application Event Log:
Services may log their own specific errors, warnings, or informational messages to the Application event log (or custom application-specific logs). These logs often provide more detailed context about internal failures (e.g., configuration file parsing errors, database connectivity issues, unhandled exceptions within service logic) that the SCM is not aware of beyond the fact that the service failed or crashed. Always check the Application log for entries from the failing service's Source name.
Correlating Errors to Specific Service Lifecycle Failures (Section IV):
The detailed lifecycle steps in Section IV provide a framework for mapping SCM Event IDs and Win32 error codes to specific failure points:
- Event 7000 with error 1069 (
ERROR_SERVICE_LOGON_FAILED) or Event 7038: Points to Phase 1, OWN_PROCESS, Step 3 (SCM: Process Token Creation) or Phase 1, SHARE_PROCESS, Step 3c (SCM: Launch Newsvchost.exe). - Event 7000 with error 3 (
ERROR_PATH_NOT_FOUND): Points to Phase 1, OWN_PROCESS, Step 4 (SCM: Process Creation) (missingImagePath) or Phase 1, SHARE_PROCESS, Step 5 (LoadServiceDll) (missingServiceDll). - Event 7009 (timeout connecting) or Event 7000 with error 1053 ("service did not respond..."): Often maps to Phase 1, OWN_PROCESS, Step 7 (Service Process: Connect to SCM
StartServiceCtrlDispatcher) or Phase 1, SHARE_PROCESS, Step 4 (Newsvchost.exe: Connect to SCM). - Event 7022 (service hung on starting): Maps to Phase 1, OWN_PROCESS, Step 10 or 11 (
ServiceMain: ReportSERVICE_START_PENDING/ Initialization Logic) or Phase 1, SHARE_PROCESS, Step 7 (equivalentServiceMainsteps inServiceDll). - Event 7031/7034 (service terminated unexpectedly): Can occur at Phase 1, OWN_PROCESS, Step 6 (Resume Process) if it crashes immediately, or during Step 8, 11 if
ServiceMaincrashes, or equivalent steps for SHARE_PROCESS. - Event 7001 (dependency failed): Maps to Phase 1, OWN_PROCESS/SHARE_PROCESS, Step 1 (Dependency Resolution).
Detailed Error Code Breakdown:
- Configuration & Path Issues:
ERROR_SERVICE_DOES_NOT_EXIST(1060)33: Service registry key missing or SCM cannot find the service. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 2).ERROR_PATH_NOT_FOUND(3)70:ImagePathin registry is invalid or file is missing. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 4).ERROR_INVALID_NAME(123)13: Invalid service name or other name parameter during API calls.ERROR_BAD_EXE_FORMAT(193):ImagePathpoints to a corrupted or non-Win32 executable. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 4).ERROR_MOD_NOT_FOUND(126):ServiceDllfor a shared service is missing or path is incorrect. (Ref. Sec IV, Phase 1, SHARE_PROCESS Step 5).
- Dependency Issues:
ERROR_SERVICE_DEPENDENCY_FAIL(1068)33: A service or group this service depends on failed to start. (Ref. Sec IV, Phase 1, OWN_PROCESS/SHARE_PROCESS Step 1).ERROR_CIRCULAR_DEPENDENCY(1059)43: A circular dependency loop was detected. (Ref. Sec IV, Phase 1, OWN_PROCESS/SHARE_PROCESS Step 1).ERROR_SERVICE_DEPENDENCY_DELETED(1075)33: A depended-upon service does not exist or is marked for deletion. (Ref. Sec IV, Phase 1, OWN_PROCESS/SHARE_PROCESS Step 1).
- Account & Privilege Issues:
ERROR_LOGON_FAILURE(1326)43: Incorrect username or password forObjectName. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 3; SHARE_PROCESS Step 3c).ERROR_SERVICE_LOGON_FAILED(1069)43: Service account lacks "Log on as a service" right, is disabled, etc. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 3; SHARE_PROCESS Step 3c).ERROR_SERVICE_ACCOUNT_LOCKED_OUT(1079)44: Service account is locked out.ERROR_ACCESS_DENIED(5): SCM or service account lacks permissions forImagePathexecution, or other resource access issues. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 4; SHARE_PROCESS Step 3c).
- Service Execution & Initialization Failures within Service Code:
ERROR_SERVICE_SPECIFIC_ERROR(1066)43: Service explicitly reported this viaSetServiceStatus(dwWin32ExitCode= 1066,dwServiceSpecificExitCodehas the specific error). Indicates failure inServiceMaininitialization or runtime. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 11; SHARE_PROCESS Step 7).ERROR_PROCESS_ABORTED(1067)43: Service process terminated unexpectedly (crashed) early after start or duringServiceMain. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 6 or duringServiceMainexecution; SHARE_PROCESS equivalents).ERROR_SERVICE_NEVER_STARTED(1077)43:ServiceMainexited without reportingSERVICE_RUNNINGorSERVICE_STOPPED. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 12; SHARE_PROCESS Step 7).
- SCM Timeouts:
ERROR_SERVICE_REQUEST_TIMEOUT(1053)9: SCM did not receive a timely response. Can occur at multiple stages:- Service process not calling
StartServiceCtrlDispatcher(Ref. Sec IV, Phase 1, OWN_PROCESS Step 7; SHARE_PROCESS Step 4). ServiceMainnot responding or updating status in time (Ref. Sec IV, Phase 1, OWN_PROCESS Steps 10, 11; SHARE_PROCESS Step 7).
- Service process not calling
Works cited
- Problems with wininit.exe - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/problems-with-wininitexe/9887afe1-a8ee-480b-934d-ac3c224b0452
- Process list for fresh Windows 11 install - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/2080030/process-list-for-fresh-windows-11-install
- Service control manager - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-control-manager
- StartServiceCtrlDispatcherA function (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicectrldispatchera
- SERVICE_TABLE_ENTRYA (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_table_entrya
- Service ServiceMain Function - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-servicemain-function
- LPHANDLER_FUNCTION_EX (winsvc.h) - Win32 apps | Microsoft ..., accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nc-winsvc-lphandler_function_ex
- Service Control Handler Function - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-control-handler-function
- Several Service Control Manager Issues (Event ID's 7000, 7009, 7011), accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/several-service-control-manager-issues-event-ids/5eb047bb-e5bf-47b3-a661-299f6f9835ba
- A slow service does not start due to time-out error in Windows - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/troubleshoot/windows-server/system-management-components/service-not-start-events-7000-7011-time-out-error
- Writing a ServiceMain Function - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/writing-a-servicemain-function
- RegisterServiceCtrlHandlerExA function (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerexa
- CreateServiceA function (winsvc.h) - Win32 apps - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-createservicea
- Fonction CreateServiceW (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/fr-fr/windows/win32/api/winsvc/nf-winsvc-createservicew
- Interactive Services - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/interactive-services
- How do I make the service activated on incoming connections? - Microsoft Q&A, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/1162629/how-do-i-make-the-service-activated-on-incoming-co
- File System Filter Load Order - Windows drivers - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/ifs/what-determines-when-a-driver-is-loaded
- HKLM\SYSTEM\CurrentControlSet\Services Registry Tree - Windows drivers, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/install/hklm-system-currentcontrolset-services-registry-tree
- INF AddService Directive - Windows drivers - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/install/inf-addservice-directive
- Change method of the Win32_Service class (Mbnapi.h) (TerminalService) - Win32 apps, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/termserv/win32-terminalservice-change
- Automatically Starting Services - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/automatically-starting-services
- Service State Transitions - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-status-transitions
- SERVICE_STATUS structure (winsvc.h) - Win32 - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status
- SERVICE_SID_INFO (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_sid_info
- ServiceSidType Enum (Microsoft.SqlServer.Management.UI.ConnectionDlg), accessed May 10, 2025, https://learn.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.management.ui.connectiondlg.servicesidtype?view=sqlserver-2016
- Security Descriptor Components - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/ad/security-descriptor-components
- Security Descriptors - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptors
- Modifying the DACL for a Service - Win32 apps - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/modifying-the-dacl-for-a-service
- Service Security and Access Rights - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-security-and-access-rights
- Specifying Driver Load Order - Windows drivers | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/install/specifying-driver-load-order
- Detect, enable, and disable SMBv1, SMBv2, and SMBv3 in Windows | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-server/storage/file-server/troubleshoot/detect-enable-and-disable-smbv1-v2-v3
- about_Registry_Provider - PowerShell | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_registry_provider?view=powershell-7.5
- Issues with BITS - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/de-de/security-updates/windowsupdateservices/21669602
- Agent Service Fails to Start on Standalone Server - SQL Server - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/startup-shutdown/agent-service-fails-start-stand-alone-server
- Service Trigger Events - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-trigger-events
- SERVICE_TRIGGER (winsvc.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_trigger
- Service host grouping in Windows 10 | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/application-management/svchost-service-refactoring
- Abnormally high CPU usage from svchost.exe [SOLVED] - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/abnormally-high-cpu-usage-from-svchostexe-solved/eb38d25d-6bb2-47cd-80f2-5389c62337be
- Windows Hardware Compatibility Program - Download Center, accessed May 10, 2025, https://download.microsoft.com/download/A/C/9/AC95E05C-3B35-43F1-86E5-E948A70454E5/Windows%20Hardware%20Compatibilty%20Program_151106.pdf
- Service Accounts | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-service-accounts
- Registry Service Group Order - Microsoft Community Hub, accessed May 10, 2025, https://techcommunity.microsoft.com/t5/windows-insider-program/registry-service-group-order/m-p/366706
- Set startup types of many services once and for all (by using batch - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/insider/forum/all/set-startup-types-of-many-services-once-and-for/83c14b73-d885-4ca9-a4a3-a0b33eadb7d3
- System Error Codes (1000-1299) (WinError.h) - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-
- Remote Desktop Services isn't starting on an Azure VM - Virtual Machines | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/troubleshoot-remote-desktop-services-issues
- Windows 10 Booting process in details - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-10-booting-process-in-details/1f16021a-c907-4c7a-ba62-2f6356fdf89a
- accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/client-management/windows-boot-process
- windows-services.docx - Microsoft, accessed May 10, 2025, https://download.microsoft.com/download/3/0/2/3027d574-c433-412a-a8b6-5e0a75d5b237/windows-services.docx
- Get manufacturer / company name for a windows service - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/1459089/get-manufacturer-company-name-for-a-windows-servic
- Weird untitled running Windows process that uses network and CPU - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/weird-untitled-running-windows-process-that-uses/e13e6ae4-ddd0-43b9-8604-681d6caf8db8
- SVCHOST-svchost.exe -k netsvcs uses 90% + CPU Usage, slows powerful, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/windows_xp-performance/svchost-svchostexe-k-netsvcs-uses-90-cpu-usage/41ba79ae-5e92-44d2-91ba-0de886061b4f?messageId=ba092fa6-01cf-42cd-96a9-193e0cf486b9&page=4
- accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/svchost-exe-and-the-svchost-registry-key
- accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/service-processes
- Messed up the registry - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/messed-up-the-registry/41e4aceb-3b5b-49bb-b315-fbcb3d918fb5
- Security Service Centre is disabled. - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/security-service-centre-is-disabled/cb5b009d-ef94-4230-9435-14fa82b350b2
- 4663(S) An attempt was made to access an object. - Windows 10 | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4663
- RequiredPrivileges (requiredPrivilegesType) Element - Win32 apps - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-requiredprivileges-requiredprivilegestype-element
- Windows Installer 4.5 and SeBackupPrivilege - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-installer-45-and-sebackupprivilege/23302d76-ddd1-4100-a304-303aa661966c
- ServiceInstaller.DelayedAutoStart Property (System.ServiceProcess) - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/dotnet/api/system.serviceprocess.serviceinstaller.delayedautostart?view=netframework-4.8.1
- registry group policy - Microsoft Q&A, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/191159/registry-group-policy
- Tutorial: Create a Windows service app - .NET Framework - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer
- ServiceInstaller.DisplayName Property (System.ServiceProcess) | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/dotnet/api/system.serviceprocess.serviceinstaller.displayname?view=netframework-4.8.1
- Diagnostic Policy Service not running - Error 13: The data is invalid [Windows 10], accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/diagnostic-policy-service-not-running-error-13-the/4650d362-e4f9-4262-b495-8058ac8fe616
- BSOD on startup every day - Trying to identify specific causation - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/592000/bsod-on-startup-every-day-trying-to-identify-speci?childtoview=601936&page=13
- Service Configuration - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-configuration
- Windows Time service tools and settings | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings
- accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/service-registry-entries
- 100's of Azure AD Connect service messages in event log after reboot - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/33611/100s-of-azure-ad-connect-service-messages-in-event
- DispatchDeviceControl and DispatchInternalDeviceControl Routines - Windows drivers, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/dispatchdevicecontrol-and-dispatchinternaldevicecontrol-routines
- Service Control Manager Event ID 7038 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/service-control-manager-event-id-7038/bb2d1d19-464e-4b1d-b620-826aa2f65d1c
- Event ID 7023 Error - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-id-7023-error/8741d4a5-d7ea-4441-88d5-80420f1966c7
- I have been getting these two errors of Service Control Manager 7023 and 7031, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/i-have-been-getting-these-two-errors-of-service/7fc383c9-098a-4382-bce7-5d9fffd3ec21
- Error - Service Control Manager - Event ID 7031 - The Cron Service - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/error-service-control-manager-event-id-7031-the/900ee514-6285-425b-a0c2-931701c5dd10
- Error Event 7000, what causes this problem? - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/error-event-7000-what-causes-this-problem/3bee4589-663e-41cc-9f33-432ae0b9383d
- Windows 10 Service Control Manager Event Id 7009 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-10-service-control-manager-event-id-7009/23d5bb46-f9e1-47bb-9dad-236f855c8678
- Windows 10, Event 7022, The LSM service hung on starting - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-10-event-7022-the-lsm-service-hung-on/530c7caa-5baa-4395-80f5-240291d5e98b
- windows 7, event 7022, service control manager hung on starting - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-7-event-7022-service-control-manager-hung/7561004b-abd7-47aa-ab20-284a6ce91d9c
- Event ID 7024 at Startup - storage control blocks destroyed - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-id-7024-at-startup-storage-control-blocks/c0c3b4f4-74ec-4239-b7e9-62932e08347f
- Windows event viewer error 7024 7031 every minute - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/windows-event-viewer-error-7024-7031-every-minute/740d965a-a442-4f2c-9e6c-9f0ec92bdb20
- Solution for reviewing Service Start/Stop events in Windows 11 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/solution-for-reviewing-service-startstop-events-in/8454f0ec-34a6-4a6d-939e-3fc2de25376c
- Event id 7036 Service Control Manager had 1727 in the last 7 days - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-id-7036-service-control-manager-had-1727-in/b8343f9a-d271-e011-8dfc-68b599b31bf5
- (Event 7000, Service Control Manager) Does anyone know why my computer - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-7000-service-control-manager-does-anyone/ba2c771d-9801-47c1-9b9c-2abfd8078277
- Event ID 7001 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-id-7001/a48a3ead-4ed1-41e8-bf31-94b59b196163
- Event 7001 Service Control Management - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-7001-service-control-management/c12e55db-90c1-4200-8aea-1d2db7bdf7dd
- Event 7031 System Control Manager - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-7031-system-control-manager/995ff658-fa62-4535-a355-b5d19e0e947e
- Error 7032 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/error-7032/ce0c2910-1d64-4385-ac83-eae524e6ba8b
- Event ID: 7032 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/windows_7-performance/event-id-7032/c7fab4cb-08ab-4400-aa5a-9de6eda92bfa
- event ID 7034 - Local Session Manager service terminated unexpectedly - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/2199191/event-id-7034-local-session-manager-service-termin
- Event ID 7034 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/event-id-7034/8586ffb2-1716-46d1-a31d-bfbf5681da93
- Cannot RDP to Azure Virtual Machines because the DHCP Client service is disabled, accessed May 10, 2025, https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/troubleshoot-rdp-dhcp-disabled
