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 into svchost.exe internals (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.exe instances (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\Services registry 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_ENTRY structures. Each entry maps a service name (for shared processes) to its corresponding ServiceMain entry 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 ServiceMain function 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:

  1. Initialize any global variables or service-wide state.
  2. Crucially, and immediately, call RegisterServiceCtrlHandlerEx() to register a HandlerEx function 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
  3. Perform all service-specific initialization. If initialization is lengthy (expected to exceed approximately one second), the service must call SetServiceStatus() to report SERVICE_START_PENDING, providing a dwWaitHint (estimated time in milliseconds for the next update or completion) and an initial dwCheckPoint value. This status must be periodically updated with incrementing dwCheckPoint values and new dwWaitHints if initialization continues.6
  4. Upon successful completion of all initialization tasks, ServiceMain must call SetServiceStatus() to report SERVICE_RUNNING and specify the control codes it is prepared to accept via the dwControlsAccepted member of the SERVICE_STATUS structure.6
  5. 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, ServiceMain must not exit unless the service is transitioning to a stopped state.6
  6. If an error occurs that prevents the service from running, or when the service is stopping, it should call SetServiceStatus() to report SERVICE_STOP_PENDING (if cleanup is lengthy) followed by SERVICE_STOPPED. The dwWin32ExitCode and dwServiceSpecificExitCode members of SERVICE_STATUS must 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.13

  • SERVICE_WIN32_SHARE_PROCESS (0x00000020): The service shares a process, typically an instance of svchost.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.13

  • SERVICE_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.13

  • SERVICE_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.13

  • SERVICE_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_PROCESS or SERVICE_WIN32_SHARE_PROCESS and 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 NoInteractiveServices registry value (HKLM\SYSTEM\CurrentControlSet\Control\Windows), which controls this behavior, defaults to 1 (disallowing interactive services).15 Using SERVICE_INTERACTIVE_PROCESS is 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.

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.exe or winload.efi) very early in the boot sequence, before the kernel is fully operational.17
  • SERVICE_SYSTEM_START (1): Indicates a driver essential for system operation, started by the I/O Manager (specifically IoInitSystem) during kernel initialization, after boot-start drivers have loaded.17
  • SERVICE_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 for DelayedAutostart.
  • SERVICE_DEMAND_START (3): (Also known as Manual start) A service that is started only when explicitly requested via an API call to StartService(), as a result of a dependency from another starting service, or by a configured service trigger event.17
  • SERVICE_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.13
  • SERVICE_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.13
  • SERVICE_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.13
  • SERVICE_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 with SERVICE_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. ServiceMain reports this state during its initialization phase.
  • SERVICE_STOP_PENDING (0x00000003): The service is in the process of stopping. The HandlerEx function 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.24
  • SERVICE_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.13
  • DependOnGroup (REG_MULTI_SZ): Contains a list of one or more service group names. Group names in this list must be prefixed with the SC_GROUP_IDENTIFIER character (+), 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.exe instance, 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)18

    Significance: 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.exe or winload.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, IoInitSystem as 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_START or Manual): Started by the SCM only when explicitly requested via the StartService() 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 Start value is a frequent cause of misconfiguration, leading to services not initiating as expected or, in the case of critical drivers, potential system boot failures.

  • HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Type: (REG_DWORD)13

    Impact on early boot loading for driver types: This value, in conjunction with the Start value, determines the loading mechanism.

    • For services of type SERVICE_KERNEL_DRIVER (0x1) or SERVICE_FILE_SYSTEM_DRIVER (0x2), if their Start type is SERVICE_BOOT_START (0), they are loaded by the OS loader.17
    • If their Start type is SERVICE_SYSTEM_START (1), they are loaded by the kernel's I/O Manager (via IoInitSystem) 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.

  • HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List: (REG_MULTI_SZ)21

    Role: This value contains an ordered list of service group names. During the startup of SERVICE_AUTO_START services, the SCM processes these groups sequentially. Services belonging to groups listed earlier in this List (and their resolved dependencies) are generally prioritized for startup over services in groups listed later.21

    This 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>\DependOnService and DependOnGroup: (REG_MULTI_SZ)13

    Data 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. DependOnService lists explicit service names. DependOnGroup lists group names, which must be prefixed with SC_GROUP_IDENTIFIER (the + character) to distinguish them from service names, as services and service groups share the same namespace.13

    Precedence Rules and SCM Handling: The SCM must ensure that all services named in DependOnService are running. For DependOnGroup, 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 report ERROR_CIRCULAR_DEPENDENCY (1059), typically logged as Event ID 7000 by SCM, and will not start the services involved in the loop.43

    These 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)35

    Structure: This value stores the binary representation of a SERVICE_TRIGGER_INFO structure. This C structure contains a count of triggers (cTriggers) and a pointer to an array of SERVICE_TRIGGER structures (pTriggers).35 Each SERVICE_TRIGGER structure 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_START or SERVICE_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 the REG_BINARY value 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 ServiceMain function will receive SERVICE_TRIGGER_STARTED_ARGUMENT as its second command-line argument (lpszArgv).35

    Service 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 TriggerInfo registry 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.exe or winload.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 Start type is set to SERVICE_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.
  • Kernel Initialization Phase (ntoskrnl.exe execution):

    • Once ntoskrnl.exe receives 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 whose Start type is SERVICE_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 by winload.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_START but 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).
  • SCM Initialization (User Mode):

    • smss.exe is 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, including services.exe (the Service Control Manager), lsass.exe (Local Security Authority Subsystem Service), and lsm.exe (Local Session Manager).1
    • Once services.exe (SCM) starts, it performs its own initialization sequence:
      1. It reads the entire service configuration database from HKLM\SYSTEM\CurrentControlSet\Services into its memory space.
      2. It builds internal data structures to represent all services, their configurations, and their dependencies.
      3. It processes the HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List to establish the startup order for service groups.21
      4. With its database built and group order determined, the SCM begins the process of starting all services configured with Start type SERVICE_AUTO_START (2). This is done iteratively, respecting the group order and all individual service dependencies (DependOnService, DependOnGroup).18

    The strict sequential nature of these boot phases means that failures or significant delays in earlier stages (e.g., a problematic SERVICE_BOOT_START driver) 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 like Services, 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\Services registry hive at startup and upon notification of changes. This includes details such as the service's ImagePath, 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 uses CreateProcessAsUser to start the service process with that token. For shared services like those in svchost.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's HandlerEx function.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 the SetServiceStatus API 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 DependOnService and DependOnGroup. 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:

  1. The services.exe process is launched by wininit.exe during the user-mode segment of the Windows boot sequence, after the kernel and essential drivers are initialized.1
  2. SCM initializes its RPC server interface, making itself available to receive commands from service control programs and to communicate with service processes.3
  3. It meticulously reads the service configuration data from the HKLM\SYSTEM\CurrentControlSet\Services registry hive, building its internal, in-memory database of all services and their properties.
  4. It parses the HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List registry value to determine the prescribed startup order for defined service groups.21
  5. 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 StartServiceCtrlDispatcher succeeds) 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: The ImagePath registry 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: The ImagePath typically points to C:\Windows\System32\svchost.exe, usually with a -k <GroupName> parameter.13 The actual service logic is implemented in a separate DLL, specified by the ServiceDll value in the service's Parameters registry subkey.48 This model is designed for resource efficiency but means that multiple services co-exist within one svchost.exe instance. 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 svchost services in Windows 10 (for systems with >3.5GB RAM) to run more services in separate svchost instances 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 instructs svchost.exe to host a specific group of services. <GroupName> corresponds to a named value under the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost registry key. svchost.exe reads this registry entry to determine which services (listed as REG_MULTI_SZ data) it is responsible for hosting.37
  • -p: This flag indicates that the svchost.exe instance should run as a "provider" process. This is particularly relevant for services that expose COM objects and might be activated out-of-process via CoCreateInstance. The -p flag ensures that the svchost.exe instance performs necessary COM initializations (like CoInitializeSecurity) 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 directs svchost.exe to load and initialize only the single, specified <ServiceName> within that new svchost.exe instance, 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; that svchost.exe instance 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's ImagePath in 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 the CoInitializeSecurity call made by the svchost.exe instance, 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 the svchost group 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 given svchost.exe group 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:

  1. SERVICE_TABLE_ENTRY Construction: Upon starting with a -k <GroupName> parameter, svchost.exe (or its main helper) reads the list of service names associated with <GroupName> from the Svchost registry key. For each service name in this list, it dynamically constructs a SERVICE_TABLE_ENTRY structure. The lpServiceName member is set to the actual service name, and the lpServiceProc member is typically set to point to a generic ServiceMain wrapper function within svchost.exe or its primary helper DLL. This array of SERVICE_TABLE_ENTRY structures is then passed to StartServiceCtrlDispatcher().4
  2. Loading of ServiceDlls: When the SCM, through the svchost.exe's dispatcher thread, directs a specific service within the group to start (i.e., when the generic wrapper ServiceMain is called for that service), this wrapper logic retrieves the path to the service's actual implementation DLL. This path is stored in the ServiceDll value (typically REG_EXPAND_SZ) under the service's specific registry key: HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Parameters\ServiceDll.48 The svchost.exe hosting code then calls LoadLibraryEx() on this path to load the service-specific DLL into the svchost.exe process space.
  3. Invocation of ServiceMain: After successfully loading the ServiceDll, the svchost.exe hosting logic uses GetProcAddress() to obtain the address of the true ServiceMain function exported by that ServiceDll (the export name is conventionally ServiceMain but can be different if configured). This service-specific ServiceMain function is then invoked, usually on a new thread obtained from a thread pool managed by svchost.exe for its hosted services.
  4. Internal Tracking: The svchost.exe process (or its helper DLLs) maintains internal data structures to map active services (identified by their names) to their corresponding loaded ServiceDll module handles, the threads executing their ServiceMain and HandlerEx functions, service status handles, and other state information necessary for managing their lifecycle within the shared process. These internal mechanisms are critical. Failures during ServiceDll loading (e.g., DLL not found, dependency issues, DllMain failure) or problems during the invocation or execution of the service-specific ServiceMain are 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 with SERVICE_INTERACTIVE_PROCESS (0x100, deprecated).18
  • Start (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).18
  • ErrorControl (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).18
  • ImagePath (REG_EXPAND_SZ or REG_SZ): Fully qualified path to the service's executable file. For svchost.exe-hosted services, this is typically %SystemRoot%\System32\svchost.exe -k <groupname>. Arguments for the service can also be included in this path.13
  • DisplayName (REG_SZ): The user-friendly name of the service displayed in administrative tools like the Services MMC snap-in or Task Manager.18
  • ObjectName (REG_SZ): Specifies the account name under which the service process will run. Common values include LocalSystem, NT AUTHORITY\LocalService, or NT AUTHORITY\NetworkService. It can also be a specific domain or local user account (e.g., DomainName\UserName or .\UserName). If an account other than LocalSystem (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.13
  • DependOnService (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.13
  • DependOnGroup (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.13
  • ServiceSidType (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).24
  • RequiredPrivileges (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 (for OWN_PROCESS or if all services in a SHARE_PROCESS agree). If a required privilege is not available to the service account, the service may fail to start or operate correctly.47
  • FailureActions (REG_BINARY): Contains a binary SERVICE_FAILURE_ACTIONS structure 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 the SERVICE_FAILURE_ACTIONS and associated SC_ACTION structures.
  • DelayedAutostart (REG_DWORD): If this value is set to 1 and the Start type is SERVICE_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.58
  • Description (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 with ServiceGroupOrder\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_SZ or REG_SZ): This value is critical for services of type SERVICE_WIN32_SHARE_PROCESS (typically those hosted by svchost.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 Parameters subkey that their service needs. For example, a service might read values like LogLevel (REG_DWORD), ConfigurationFilePath (REG_SZ), or MaxConnections (REG_DWORD) from this location to tailor its operation without requiring code changes or recompilation. The Parameters subkey 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_START drivers are loaded by the OS Loader (winload.exe or winload.efi) before the main kernel initialization sequence begins. These are critical for basic system functions like accessing the boot device.17
  • SERVICE_SYSTEM_START drivers 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 ImagePath is missing or corrupt. The OS Loader or Kernel I/O subsystem handles this. Errors like STATUS_IMAGE_CHECKSUM_MISMATCH or 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 (Dependencies entry) 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:

  1. services.exe process creation and initialization: wininit.exe launches services.exe.1 services.exe initializes itself, setting up its RPC server and internal data structures.

    Potential Failure Points/Errors:

    • wininit.exe fails to launch services.exe: Catastrophic system failure, unlikely to reach a usable desktop. Event Log (System): System-level errors from wininit.exe or kernel process creation failures.
    • services.exe image corrupt: CreateProcess by wininit.exe fails. Win32 error ERROR_BAD_EXE_FORMAT (193). Event Log (System): Error logged by wininit.exe or kernel.

    SCM Behavior: SCM itself fails to start; no user-mode services will be started by SCM.

  2. SCM reads service configuration database: SCM parses HKLM\SYSTEM\CurrentControlSet\Services to build its in-memory database of all services and drivers.

    Potential Failure Points/Errors:

    • Corrupt SYSTEM registry 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.

  3. 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.

  4. SCM processes ServiceGroupOrder\List: SCM reads HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder\List to determine the startup order for service groups.21

    Potential Failure Points/Errors: ServiceGroupOrder\List value 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:
  1. SCM: Dependency Resolution & Group Ordering: SCM verifies that all services and groups listed in the current service's DependOnService and DependOnGroup registry values are already running. It also ensures that services in groups that appear earlier in ServiceGroupOrder\List (and GroupOrderList for intra-group order) are processed first.13

    Potential 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>").33
    • ERROR_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.43
    • ERROR_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.

  2. 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.").33

    SCM Behavior: Service start is aborted.

  3. SCM: Process Token Creation (if ObjectName specified): If the service's ObjectName is not LocalSystem (or other built-in accounts like NT AUTHORITY\LocalService, NT AUTHORITY\NetworkService which have well-known SIDs and tokens), SCM attempts to log on the specified user account by calling LogonUserEx (or a similar API) to create an access token for the new service process.13

    Potential 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.").67
    • ERROR_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.

  4. SCM: Process Creation: SCM calls CreateProcessAsUser (using the token from step 3, or the LocalSystem token if ObjectName was LocalSystem) to launch the executable specified in ImagePath. The process is typically created with the CREATE_SUSPENDED flag, so its main thread does not run immediately.

    Potential Failure Points/Errors:

    • ERROR_PATH_NOT_FOUND (3): The path in ImagePath is 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.").70
    • ERROR_ACCESS_DENIED (5): The SCM process itself (running as LocalSystem) or the service account (if SCM impersonates for creation, though less common for CreateProcessAsUser which takes a token) lacks execute permissions on the ImagePath file or traverse permissions on its directory. SCM Event ID: 7000.
    • ERROR_BAD_EXE_FORMAT (193): The file specified in ImagePath is 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.

  5. SCM: Privileges & Environment: SCM applies any RequiredPrivileges specified in the service's registry configuration to the primary token of the newly created (and still suspended) process. Privileges not listed in RequiredPrivileges may be removed from the token. SCM also sets up a standard service environment block for the process.47

    Potential 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 in RequiredPrivileges (or RequiredPrivileges lists something the account can't have), the service will likely fail later during its ServiceMain initialization 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.

  6. SCM: Resume Process: SCM calls ResumeThread on 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() or WinMain() function, before StartServiceCtrlDispatcher is 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).

  7. Service Process: Connect to SCM (StartServiceCtrlDispatcher): The main thread of the now-running service process must call StartServiceCtrlDispatcher() promptly. This API call takes an array of SERVICE_TABLE_ENTRY structures, which maps service names to their ServiceMain functions.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 the ServicesPipeTimeout registry value: HKLM\SYSTEM\CurrentControlSet\Control\ServicesPipeTimeout).4

    Potential Failure Points/Errors:

    • ERROR_SERVICE_REQUEST_TIMEOUT (1053): The service process fails to call StartServiceCtrlDispatcher within 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.").9
    • ERROR_FAILED_SERVICE_CONTROLLER_CONNECT (1063): StartServiceCtrlDispatcher is 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 StartServiceCtrlDispatcher call (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.

  8. 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 corresponding lpServiceProc (the ServiceMain function pointer) in the SERVICE_TABLE_ENTRY array and invokes this function on a new, dedicated thread.4

    Potential Failure Points/Errors:

    • Invalid ServiceMain function pointer in the SERVICE_TABLE_ENTRY (e.g., NULL or points to invalid code).
    • ServiceMain function itself causes an immediate unhandled exception upon invocation on its new thread.
    • These typically lead to the service process crashing or the ServiceMain thread terminating prematurely. SCM would likely see this as ERROR_PROCESS_ABORTED (1067). SCM Event ID: 7031 or 7034.

    SCM Behavior: Marks the service as failed.

  9. ServiceMain: Handler Registration (RegisterServiceCtrlHandlerEx): The ServiceMain function, now running on its own thread, must immediately call RegisterServiceCtrlHandlerEx() (or its predecessor RegisterServiceCtrlHandler()) 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 for SetServiceStatus.

    Potential Failure Points/Errors: RegisterServiceCtrlHandlerEx itself fails (e.g., due to ERROR_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 ServiceMain subsequently exits reporting an error, SCM logs that error. If ServiceMain proceeds 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.

  10. ServiceMain: Report SERVICE_START_PENDING: The ServiceMain function must call SetServiceStatus() to inform the SCM that it is starting. This status update should set dwCurrentState to SERVICE_START_PENDING, provide an initial dwCheckPoint (e.g., 1), and a dwWaitHint (an estimate in milliseconds for how long the current phase of initialization will take, or until the next SetServiceStatus call).6 The SCM uses dwWaitHint to set its internal timer for this service's startup.

    Potential Failure Points/Errors:

    • Failure to call SetServiceStatus with SERVICE_START_PENDING.
    • Providing an unrealistic or zero dwWaitHint while performing lengthy initialization.
    • If the service does not update its status (increment dwCheckPoint or change state) within the specified dwWaitHint (or subsequent hints), or if an overall SCM startup timeout for the service is exceeded (related to ServicesPipeTimeout), 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 dwWaitHint for the next status update. If this timeout expires without an update, SCM marks the service as failed/hung.

  11. 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, ServiceMain must periodically call SetServiceStatus() with SERVICE_START_PENDING, incrementing dwCheckPoint, and providing an updated dwWaitHint to signal ongoing progress.6

    Potential 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 SetServiceStatus with dwCurrentState = SERVICE_STOPPED, a relevant dwWin32ExitCode (e.g., a specific Win32 error code, or ERROR_SERVICE_SPECIFIC_ERROR if dwServiceSpecificExitCode is also set), and optionally dwServiceSpecificExitCode.
    • SCM Event ID for service-reported stop: 7023 ("The <ServiceName> service terminated with the following error: <ErrorStringOrErrorCode>.")70 if dwWin32ExitCode is a standard error, or 7024 ("The <ServiceName> service terminated with the following service-specific error: <ServiceSpecificErrorCode>.") if dwWin32ExitCode was ERROR_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.

  12. ServiceMain: Report SERVICE_RUNNING: Upon successful completion of all initialization, ServiceMain must call SetServiceStatus() with dwCurrentState = SERVICE_RUNNING. It should also specify the control codes it is prepared to accept in the dwControlsAccepted member of the SERVICE_STATUS structure.6

    Potential Failure Points/Errors: ServiceMain exits (e.g., "falls off the end" of the function) after initialization without calling SetServiceStatus to report SERVICE_RUNNING or SERVICE_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 if ServiceMain returns prematurely in certain ways, especially for demand-start services.43

    SCM Behavior: Once SERVICE_RUNNING is reported, SCM considers the service operational. SCM logs Event ID 7036 ("The <ServiceName> service entered the running state.").79

For SERVICE_WIN32_SHARE_PROCESS services (typically involving svchost.exe):
  1. 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).

  2. SCM: Service Record & Group Identification: SCM accesses the service's configuration. The ImagePath is typically a command like C:\Windows\System32\svchost.exe -k <groupname>. SCM parses <groupname> from this command line. It then consults the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost registry key to validate that the service is a member of this <groupname> and to identify other services that may share this svchost.exe instance.37

    Potential Failure Points/Errors: Service name not found under the specified <groupname> in the Svchost registry key. ImagePath is malformed or does not correctly specify a group. SCM Event ID: 7000, potentially with an error indicating invalid parameter or configuration.

  3. SCM: Target svchost.exe Instance:

    1. Determine Security Context: The security context for the svchost.exe instance is determined by the ObjectName (service account) of the first service being started for this specific group. If multiple services in the group use different ObjectNames, they cannot share the same svchost.exe instance unless those ObjectNames resolve to the same security context or the Svchost group has overriding security parameters defined (e.g., CoInitializeSecurityParam in the Svchost registry key).37
    2. Check for Existing, Compatible svchost.exe Instance: SCM checks if an svchost.exe process is already running that is hosting the same group name AND is running under the same security context (determined in step 3a).
    3. Launch New svchost.exe Instance (if needed): If no compatible svchost.exe instance exists, SCM launches a new process using the ImagePath (e.g., svchost.exe -k <groupname>). The creation of this svchost.exe process 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.exe process itself. This includes logon failures for the group's designated account (Win32 1326/Event 7038; Win32 1069/Event 7000/7038), svchost.exe path not found (Win32 3/Event 7000), access denied for svchost.exe (Win32 5/Event 7000), or svchost.exe crashing on startup (Win32 1067/Event 7031/7034).

  4. svchost.exe (Host Process): Connect/Notify SCM:

    • New svchost.exe Instance: The main thread of the newly launched svchost.exe process (or its primary helper DLL, like services.dll) is responsible for calling StartServiceCtrlDispatcher(). The SERVICE_TABLE_ENTRY array passed to this function will typically include entries for all services listed under the <groupname> in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost registry key, as this instance is now prepared to host any of them.4
    • Existing svchost.exe Instance: If a compatible svchost.exe instance was already running, the SCM sends a special control request (an internal "add service" or "start service within host" command) to that existing svchost.exe process. The Service Control Dispatcher thread within that running svchost.exe receives 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 new svchost.exe fails to call StartServiceCtrlDispatcher in time.
    • New instance: svchost.exe process crashes before calling StartServiceCtrlDispatcher (see OWN_PROCESS step 6 errors).
    • Existing instance: The running svchost.exe might 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.
  5. svchost.exe (Host Process): Load ServiceDll: The svchost.exe hosting logic (which could be in svchost.exe itself, a generic helper like netsvcs.dll or services.dll, or a service-specific hosting DLL like gpsvc.dll for the Group Policy Client service) looks up the ServiceDll parameter in the target service's registry key: HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Parameters\ServiceDll. It then calls LoadLibraryEx() on the DLL path specified in this value.48

    Potential Failure Points/Errors:

    • ServiceDll registry value missing or the path is incorrect/points to a non-existent file: Win32 error ERROR_MOD_NOT_FOUND (126). SCM Event ID: 7000 ("...The specified module could not be found.") or 7023 ("...The specified module could not be found.").71
    • LoadLibraryEx fails: This can happen if the ServiceDll itself is corrupt, one of its dependent DLLs is missing or corrupt, there's insufficient memory, or the DllMain function of the ServiceDll (or one of its dependencies) returns FALSE during DLL_PROCESS_ATTACH. Win32 error ERROR_DLL_INIT_FAILED (1114) is common if DllMain fails. SCM Event ID: 7000 or 7023.

    SCM Behavior: The svchost.exe hosting logic would typically report a failure to the SCM for this specific service, or the thread designated for this service within svchost.exe might terminate.

  6. svchost.exe (Host Process): Invoke ServiceMain from ServiceDll: After successfully loading the ServiceDll, the svchost.exe hosting logic retrieves the address of the exported ServiceMain function (or a custom-named entry point if specified elsewhere in parameters) from the ServiceDll using GetProcAddress(). This ServiceMain function is then called, typically on a new thread allocated from a thread pool managed by svchost.exe for the services it hosts.

    Potential Failure Points/Errors:

    • The ServiceMain (or custom entry point) function is not actually exported by the ServiceDll, or it has an incorrect function signature. GetProcAddress would fail.
    • A crash occurs within the ServiceDll's DllMain (if not caught by the LoadLibraryEx failure itself) or very early in the execution of its ServiceMain function before it can register a handler or report status.
    • SCM Event ID: 7000, 7023. If a crash occurs that destabilizes the svchost.exe instance, Event ID 7031 or 7034 for the svchost.exe process itself might be logged, affecting all services in that instance.
  7. ServiceMain (in ServiceDll): Handler Registration, Status Reporting, Init, Running: This sequence of actions performed by the service code within the ServiceDll is identical to OWN_PROCESS steps 9 through 12. The ServiceMain must register its control handler, report SERVICE_START_PENDING with checkpoints and wait hints during its initialization, and finally report SERVICE_RUNNING upon success, or SERVICE_STOPPED with 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 the svchost.exe instance 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.msc console, 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 DependOnService or DependOnGroup.
  • 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 the SERVICE_RUNNING or SERVICE_START_PENDING state.4
  • ERROR_SERVICE_DISABLED (1058): The service's Start type is SERVICE_DISABLED.43
  • ERROR_SERVICE_MARKED_FOR_DELETE (1072): The service has been marked for deletion and cannot be started.13
  • ERROR_ACCESS_DENIED (5): The calling process/user lacks the SERVICE_START permission 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:

  1. Enters a primary work loop if the service performs continuous tasks (e.g., listening on a socket, processing a message queue).
  2. 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 HandlerEx function. It is critical that ServiceMain does not exit prematurely unless the service is intentionally stopping. If the ServiceMain thread 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 how SetServiceStatus was 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_STOP or SERVICE_CONTROL_SHUTDOWN) within the SCM's allotted timeout. For shutdown, this is governed by WaitToKillServiceTimeout (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 SetServiceStatus to report SERVICE_STOPPED and provide appropriate dwWin32ExitCode and dwServiceSpecificExitCode values in the SERVICE_STATUS structure 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's ImagePath registry value.13
    • For SERVICE_WIN32_SHARE_PROCESS, the ImagePath typically points to svchost.exe -k <GroupName>. The SCM launches svchost.exe (if a suitable instance isn't already running for that group and security context). svchost.exe then loads the actual service code from a DLL specified in the service's Parameters\ServiceDll registry value.13
  • 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, and SetServiceStatus at 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) and RequiredPrivileges. Shared services within svchost.exe share the process space, memory, and security token of that svchost.exe instance, 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_START drivers are loaded by winload.exe/.efi.17
    • SERVICE_SYSTEM_START drivers are loaded by IoInitSystem or the PnP Manager during kernel initialization.17
  • Entry Points: Their primary entry point is the DriverEntry function, not ServiceMain. DriverEntry is 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.exe to 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 call StartServiceCtrlDispatcher or SetServiceStatus in 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_PROCESS or SERVICE_WIN32_SHARE_PROCESS service 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 NoInteractiveServices registry value (HKLM\SYSTEM\CurrentControlSet\Control\Windows) defaults to 1 (enabled), explicitly preventing services from interacting with the desktop, regardless of the SERVICE_INTERACTIVE_PROCESS flag.15
  • Operational Nuances: Using SERVICE_INTERACTIVE_PROCESS is 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 (using CreateProcessAsUser) and communicating with it via IPC (e.g., named pipes, RPC), or using WTSSendMessage to 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.

  1. 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.exe instance 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 specific svchost.exe instance.38
  2. Command Line (tasklist /svc):

    • Executing tasklist /svc in a command prompt lists all running processes. For each svchost.exe instance, it will list the short names of the services it is currently hosting.38 The output can be piped to findstr to filter for a specific svchost.exe PID or service name.
    • Example: tasklist /svc /fi "imagename eq svchost.exe"
  3. PowerShell (Get-Service and Get-Process):

    • To find services hosted by a specific svchost.exe PID (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"}).ProcessId

      Then use this PID with Process Explorer or other tools.

  4. Process Explorer (Sysinternals):

    • Launch Process Explorer. Hovering the mouse over an svchost.exe process in the tree view will show a tooltip listing the services it hosts.38
    • Alternatively, double-click an svchost.exe process 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
  5. Resource Monitor (resmon.exe):

    • On the "CPU" or "Memory" tab, select a specific svchost.exe process. The "Services" pane (usually at the bottom or accessible via a dropdown) will then list the services associated with the selected svchost.exe instance. Understanding these mappings is the first step in isolating issues like high resource consumption or crashes within a shared service host.

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 call StartServiceCtrlDispatcher() within the SCM's timeout period (default 30s, via ServicesPipeTimeout).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's HandlerEx function 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 called StartServiceCtrlDispatcher(), ServiceMain was invoked and reported SERVICE_START_PENDING, but it failed to report SERVICE_RUNNING (or SERVICE_STOPPED) within its declared dwWaitHint or 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 called SetServiceStatus with SERVICE_STOPPED and a Win32 error code (other than ERROR_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 called SetServiceStatus with SERVICE_STOPPED, dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR (1066), and dwServiceSpecificExitCode containing 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 New svchost.exe).
  • Event 7000 with error 3 (ERROR_PATH_NOT_FOUND): Points to Phase 1, OWN_PROCESS, Step 4 (SCM: Process Creation) (missing ImagePath) or Phase 1, SHARE_PROCESS, Step 5 (Load ServiceDll) (missing ServiceDll).
  • 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 (New svchost.exe: Connect to SCM).
  • Event 7022 (service hung on starting): Maps to Phase 1, OWN_PROCESS, Step 10 or 11 (ServiceMain: Report SERVICE_START_PENDING / Initialization Logic) or Phase 1, SHARE_PROCESS, Step 7 (equivalent ServiceMain steps in ServiceDll).
  • 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 ServiceMain crashes, 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: ImagePath in 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): ImagePath points to a corrupted or non-Win32 executable. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 4).
    • ERROR_MOD_NOT_FOUND (126): ServiceDll for 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 for ObjectName. (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 for ImagePath execution, 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 via SetServiceStatus (dwWin32ExitCode = 1066, dwServiceSpecificExitCode has the specific error). Indicates failure in ServiceMain initialization 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 during ServiceMain. (Ref. Sec IV, Phase 1, OWN_PROCESS Step 6 or during ServiceMain execution; SHARE_PROCESS equivalents).
    • ERROR_SERVICE_NEVER_STARTED (1077)43: ServiceMain exited without reporting SERVICE_RUNNING or SERVICE_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).
      • ServiceMain not responding or updating status in time (Ref. Sec IV, Phase 1, OWN_PROCESS Steps 10, 11; SHARE_PROCESS Step 7).

Works cited

  1. 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
  2. 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
  3. Service control manager - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-control-manager
  4. 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
  5. 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
  6. Service ServiceMain Function - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-servicemain-function
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. Interactive Services - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/interactive-services
  16. 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
  17. 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
  18. 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
  19. INF AddService Directive - Windows drivers - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/install/inf-addservice-directive
  20. 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
  21. Automatically Starting Services - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/automatically-starting-services
  22. Service State Transitions - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-status-transitions
  23. 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
  24. 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
  25. 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
  26. Security Descriptor Components - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/ad/security-descriptor-components
  27. Security Descriptors - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/secauthz/security-descriptors
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. Issues with BITS - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/de-de/security-updates/windowsupdateservices/21669602
  34. 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
  35. Service Trigger Events - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-trigger-events
  36. 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
  37. Service host grouping in Windows 10 | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/application-management/svchost-service-refactoring
  38. 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
  39. 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
  40. Service Accounts | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-service-accounts
  41. 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
  42. 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
  43. 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-
  44. 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
  45. 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
  46. accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/client-management/windows-boot-process
  47. windows-services.docx - Microsoft, accessed May 10, 2025, https://download.microsoft.com/download/3/0/2/3027d574-c433-412a-a8b6-5e0a75d5b237/windows-services.docx
  48. 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
  49. 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
  50. 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
  51. accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/svchost-exe-and-the-svchost-registry-key
  52. accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/service-processes
  53. 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
  54. 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
  55. 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
  56. RequiredPrivileges (requiredPrivilegesType) Element - Win32 apps - Learn Microsoft, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-requiredprivileges-requiredprivilegestype-element
  57. 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
  58. 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
  59. registry group policy - Microsoft Q&A, accessed May 10, 2025, https://learn.microsoft.com/en-us/answers/questions/191159/registry-group-policy
  60. 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
  61. 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
  62. 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
  63. 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
  64. Service Configuration - Win32 apps | Microsoft Learn, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows/win32/services/service-configuration
  65. 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
  66. accessed January 1, 1970, https://learn.microsoft.com/en-us/windows/win32/services/service-registry-entries
  67. 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
  68. DispatchDeviceControl and DispatchInternalDeviceControl Routines - Windows drivers, accessed May 10, 2025, https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/dispatchdevicecontrol-and-dispatchinternaldevicecontrol-routines
  69. 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
  70. 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
  71. 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
  72. 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
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. 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
  79. 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
  80. 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
  81. (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
  82. 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
  83. 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
  84. 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
  85. Error 7032 - Microsoft Community, accessed May 10, 2025, https://answers.microsoft.com/en-us/windows/forum/all/error-7032/ce0c2910-1d64-4385-ac83-eae524e6ba8b
  86. 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
  87. 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
  88. 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
  89. 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