Computer Technos

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 10 August 2010

Smss, Csrss, and Wininit

Posted on 10:39 by Unknown
Smss is like any other user-mode process except for two differences: First, Windows considers Smss a trusted part of the operating system. Second, Smss is a native application. Because it’s a trusted operating system component, Smss can perform actions few other processes can perform, such as creating security tokens. Because it’s a native application, Smss doesn’t use Windows APIs—it uses only core executive APIs known collectively as the Windows native API. Smss doesn’t use the Win32 APIs because the Windows subsystem isn’t executing when Smss launches. In fact, one of Smss’s first tasks is to start the Windows subsystem.

Smss then calls the configuration manager executive subsystem to finish initializing the registry, fleshing the registry out to include all its keys. The configuration manager is programmed to know where the core registry hives are stored on disk (excluding hives corresponding to user profiles), and it records the paths to the hives it loads in the HKLM\SYSTEM\CurrentControlSet\Control\hivelist key.

The main thread of Smss performs the following initialization steps:
1. Marks itself as a critical process and its main thread as a critical thread. As discussed earlier, this will cause the kernel to crash the system if Smss quits unexpectedly. Smss also enables the automatic affinity update mode to support dynamic processor addition.

2. Creates protected prefixes for the mailslot and named pipe file system drivers, creating privileged paths for administrators and service accounts to communicate through those paths.

3. Calls SmpInit, which tunes the maximum concurrency level for Smss, meaning the maximum number of parallel sessions that will be created by spawning copies of Smss into other sessions. This is at minimum four and at most the number of active CPUs.

4. SmpInit then creates an ALPC port object (\SmApiPort) to receive client requests (such as to load a new subsystem or create a session).

5. SmpInit calls SmpLoadDataFromRegistry, which starts by setting up the default environment variables for the system, and sets the SAFEBOOT variable if the system was booted in safe mode.

6. SmpLoadDataFromRegistry calls SmpInitializeDosDevices to define the symbolic links for MS-DOS device names (such as COM1 and LPT1).

7. SmpLoadDataFromRegistry creates the \Sessions directory in the object manager’s namespace (for multiple sessions).

8. SmpLoadDataFromRegistry runs any programs defined in HKLM\SYSTEM\Current Control Set\Control\Session Manager\BootExecute with SmpExecuteCommand. Typically, this value contains one command to run Autochk (the boot-time version of Chkdsk).

9. SmpLoadDataFromRegistry calls SmpProcessFileRenames to perform delayed file rename and delete operations as directed by HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\PendingFileRenameOperations and HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations2.

10. SmpLoadDataFromRegistry calls SmpCreatePagingFiles to create additional paging files. Paging file configuration is stored under HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles.

11. SmpLoadDataFromRegistry initializes the registry by calling the native function NtInitializeRegistry. The configuration manager builds the rest of the registry by loading the registry hives for the HKLM\SAM, HKLM\SECURITY, and HKLM\SOFTWARE keys. Although HKLM\SYSTEM\CurrentControlSet\Control\hivelist locates the hive files on disk, the configuration manager is coded to look for them in \Windows\System32\Config.

12. SmpLoadDataFromRegistry calls SmpCreateDynamicEnvironmentVariables to add system environment variables that are defined in HKLM\SYSTEM\CurrentControlSet\
Session Manager\Environment, as well as processor-specific environment variables such
as NUMBER_PROCESSORS, PROCESSOR_ARCHITECTURE, and PROCESSOR_LEVEL.

13. SmpLoadDataFromRegistry runs any programs defined in HKLM\SYSTEM\Current-
ControlSet\Control\Session Manager\SetupExecute with SmpExecuteCommand. Typically, this value is set only if Windows is being booted as part of the second stage of installation and Setupcl.exe is the default value.

14. SmpLoadDataFromRegistry calls SmpConfigureSharedSessionData to initialize the list of subsystems that will be started in each session (both immediately and deferred) as well as the Session 0 initialization command (which, by default, is to launch the Wininit.exe process). The initialization command can be overridden by creating a string value called S0InitialCommand in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager and setting it as the path to another program.

15. SmpLoadDataFromRegistry calls SmpInitializeKnownDlls to open known DLLs, and creates section objects for them in the \Knowndlls directory of the object manager namespace. The list of DLLs considered known is located in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs, and the path to the directory in which the DLLs are located is stored in the Dlldirectory value of the key.

16. Finally, SmpLoadDataFromRegistry calls SmpTranslateSystemPartitionInformation to convert the SystemPartition key stored in HKLM\SYSTEM\Setup, which is stored in native NT object manager path format, to a volume drive letter stored in the BootDir value. Among other components, Windows Update uses this registry key to figure out what the system volume is.

17. At this point, SmpLoadDataFromRegistry returns to SmpInit, which returns to the main thread entry point. Smss then creates the number of initial sessions that were defined (typically, only one, session 0, but you can change this number through the NumberOfInitialSessions registry value in the Smss registry key mentioned earlier) by calling SmpCreateInitialSession, which creates an Smss process for each user session. This function’s main job is to call SmpStartCsr to start Csrss in each session.

18. As part of Csrss’s initialization, it loads the kernel-mode part of the Windows subsystem (Win32k.sys). The initialization code in Win32k.sys uses the video driver to switch the screen to the resolution defined by the default profile, so this is the point at which the screen changes from the VGA mode the boot video driver uses to the default resolution chosen for the system.

19. Meanwhile, each spawned Smss in a different user session starts the other subsystem processes, such as Psxss if the Subsystem for Unix-based Applications feature was installed.

20. The first Smss from session 0 executes the Session 0 initialization command (described in step 14), by default launching the Windows initialization process (Wininit). Other Smss instances start the interactive logon manager process (Winlogon), which, unlike Wininit, is hardcoded. The startup steps of Wininit and Winlogon are described shortly.

After performing these initialization steps, the main thread in Smss waits forever on the process handle of Winlogon, while the other ALPC threads wait for messages to create new sessions or subsystems. If either Wininit or Csrss terminate unexpectedly, the kernel crashes the system because these processes are marked as critical. If Winlogon terminates unexpectedly, the session associated with it is logged off.

Wininit then performs its startup steps, such as creating the initial window station and desktop objects. It also configures the Session 0 window hook, which is used by the Interactive Services Detection service (UI0Detect.exe) to provide backward compatibility with interactive services. Wininit then creates the service control manager (SCM) process (\Windows\System32\Services.exe), which loads all services and device drivers marked for auto-start, and the Local Security Authority subsystem (Lsass) process (\Windows\System32\Lsass.exe). Finally, it loads the local session manager (\Windows\System32\Lsm.exe). On session 1 and beyond, Winlogon runs instead and loads the registered credential providers for the system (by default, the Microsoft credential provider supports password-based and smartcard-based logons) into a child process called LogonUI (\Windows\System32\Logonui.exe, which is responsible for displaying the logon interface.

After the SCM initializes the auto-start services and drivers and a user has successfully logged on at the console, the SCM deems the boot successful. The registry’s last known good control set (as indicated by HKLM\SYSTEM\Select\LastKnownGood) is updated to match \CurrentControlSet.

After launching the SCM, Winlogon waits for an interactive logon notification from the credential provider. When it receives a logon and validates the logon, Winlogon loads the registry hive from the profile of the user logging in and maps it to HKCU. It then sets the user’s environment variables that are stored in HKCU\Environment and notifies the Winlogon notification packages registered in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify that a logon has occurred.

Winlogon next starts the shell by launching the executable or executables specified in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Userinit (with multiple executables separated by commas) that by default points at \Windows\System32\Userinit.exe. Userinit.exe performs the following steps:

1. Processes the user scripts specified in HKCU\Software\Policies\Microsoft\Windows\
System\Scripts and the machine logon scripts in HKLM\SOFTWARE\Policies\Microsoft\Windows\System\Scripts. (Because machine scripts run after user scripts, they can override user settings.)

2. If Group Policy specifies a user profile quota, starts \Windows\System32\Proquota.exe to enforce the quota for the current user.

3. Launches the comma-separated shell or shells specified in HKCU\Software\Microsoft\ Windows NT\CurrentVersion\Winlogon\Shell. If that value doesn’t exist, Userinit.exe launches the shell or shells specified in HKLM\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\Winlogon\Shell, which is by default Explorer.exe.

Winlogon then notifies registered network providers that a user has logged in. The Microsoft network provider, Multiple Provider Router (\Windows\System32\Mpr.dll), restores the user’s persistent drive letter and printer mappings stored in HKCU\Network and HKCU\Printers, respectively. Note the Smss processes that are dimmed (meaning that they have since exited). These refer to the spawned copies that initialized each session.

Source of Information : Microsoft Press Windows Internals 5th Edition
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in Windows | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Windows 7 Shortcut Keys
    Longtime users of Windows have probably grown accustomed to navigating around the Windows user interface using the keyboard. This especially...
  • Windows on Mac: Virtualization Solutions
    If you’d prefer to join the ever-increasing ranks of Mac switchers—you traitor, you—you can still run Windows and, more important, Windows a...
  • Customizing Library Folders in Windows 7
    In your library folders, you can customize view options based on the contents. In the toolbar of the Pictures and Music library folders, Win...
  • Windows 7 BitLocker Drive Encryption
    In Windows Vista, you had the BitLocker Drive Encryption feature that allowed you to encrypt the content of entire volumes. In Windows 7, Mi...
  • Using Windows 7’s Performance Options
    While all the performance tools are available individually throughout the system, Windows 7 introduces a nice list of available tools, if yo...
  • Windows 7 - Installing and Configuring a Printer
    If your printer is already installed and operational at this point, you can skip this section and skim ahead for others that may be of inter...
  • Considering Centralized versus Group Sharing
    One of the most important preparation steps for your server is determining how to store the data you create. The two common methods are cent...
  • Berkeley Motes
    The Berkeley motes are a family of embedded sensor nodes sharing roughly the same architecture. Let us take the MICA mote as an example. The...
  • Using Windows 7 Ease of Access Tools
    If you have difficulty using a mouse or typing, have slightly impaired vision, or are deaf or hard of hearing, you can adjust the appearance...
  • Troubleshooting Boot and Startup Problems - Driver Loading in Safe Mode
    How does Windows know which device drivers and services are part of standard and networking-enabled safe mode? The answer lies in the HKLM\S...

Categories

  • Access 2010
  • BlackBerr
  • BlackBerry
  • Computer Science
  • Cyber Security
  • Exchange Server 2010
  • File Utilities
  • Foursquare
  • Google
  • Hardware
  • Internet
  • iPad
  • Linux
  • Lync Server
  • Microsoft Virtualization
  • Mobile Web
  • Networking
  • News
  • Security
  • Server Architectures
  • Smartphone
  • Ubuntu Linux
  • Windows
  • Windows 7
  • Windows Home Server
  • Windows Security
  • Windows Server 2008
  • Windows Server 2008 Hyper-V
  • Windows XP
  • Wireless

Blog Archive

  • ►  2012 (66)
    • ►  August (5)
    • ►  July (9)
    • ►  June (9)
    • ►  May (8)
    • ►  April (9)
    • ►  March (9)
    • ►  February (8)
    • ►  January (9)
  • ►  2011 (85)
    • ►  December (5)
    • ►  November (6)
    • ►  October (7)
    • ►  September (8)
    • ►  August (9)
    • ►  July (9)
    • ►  June (7)
    • ►  May (7)
    • ►  April (4)
    • ►  March (6)
    • ►  February (8)
    • ►  January (9)
  • ▼  2010 (230)
    • ►  December (13)
    • ►  November (3)
    • ►  October (2)
    • ►  September (10)
    • ▼  August (31)
      • Configuring Small Memory Dump Files
      • Memory Dump Files
      • Types of Stop Errors
      • Stop Messages
      • Stop Message - Identifying the Stop Error
      • Stop Message - Identifying the Stop Error
      • Single, Centralized System Cache and The Memory Ma...
      • Cache Manager
      • Shutdown
      • Windows Resource Protection
      • Solving Common Boot Problems “Part II”
      • Solving Common Boot Problems “Part I”
      • Boot Status File
      • Troubleshooting Boot and Startup Problems – Window...
      • Troubleshooting Boot and Startup Problems – Boot L...
      • Troubleshooting Boot and Startup Problems - Safe-M...
      • Troubleshooting Boot and Startup Problems - Driver...
      • Troubleshooting Boot and Startup Problems - Safe Mode
      • Troubleshooting Boot and Startup Problems - Last K...
      • Images That Start Automatically
      • ReadyBoot
      • Smss, Csrss, and Wininit
      • Initializing the Kernel and Executive Subsystems
      • The EFI Boot Process
      • The BIOS Boot Sector and Bootmgr
      • BIOS Preboot
      • Understanding how WSRM works and what you gain fro...
      • Working with the Windows System Resource Manager (...
      • Understanding Domains
      • Working with Peer Name Resolution Protocol
      • Considering Centralized versus Group Sharing
    • ►  July (32)
    • ►  June (23)
    • ►  May (2)
    • ►  April (21)
    • ►  March (32)
    • ►  February (28)
    • ►  January (33)
  • ►  2009 (119)
    • ►  December (33)
    • ►  November (31)
    • ►  October (35)
    • ►  September (20)
Powered by Blogger.

About Me

Unknown
View my complete profile