Windows2000 startup process detailed [from Insidewindows20003RD]

xiaoxiao2021-03-06  114

[Previous]

[Next]

Boot process

In describing the Windows 2000 boot process, we'll start with the installation of Windows 2000 and proceed through the execution of Ntldr and Ntdetect. Device drivers are a crucial part of the boot process, so we'll explain the way that they control the point in the boot process at which they load and initialize. Then we'll describe how the executive subsystems initialize and how the kernel launches the user-mode portion of Windows 2000 by starting the Session Manager process (Smss.exe), the Win32 subsystem , and the logon process (Winlogon). Along the way, we'll highlight the points at which various text appears on the screen to help you correlate the internal process with what you see when you watch Windows 2000 boot. Table 4-1 presents A Summary of Boot-Process Components with Their Execution Modi and Responsibilities.

Table 4-1 Boot Process Components

Component Processor ExecutionResponsibilitiesMaster boot record (MBR) code16-bit real modeReads and loads partition boot sectorsBoot sector 16-bit real mode Reads the root directory to load NtldrNtldr 16-bit real mode and 32-bit protected mode; turns on paging Reads Boot.ini , presents boot menu, and loads Ntoskrnl.exe, Bootvid.dll, Hal.dll, and boot-start device driversNtoskrnl.exe 32-bit protected mode with pagingInitializes executive subsystems and boot and system-start device drivers, prepares the system for running native applications, and runs Smss.exeSmss 32-bit native applicationLoads Win32 subsystem, including Win32k.sys and Csrss.exe, and starts Winlogon processWinlogon 32-bit native applicationStarts the service control manager (SCM), the Local Security Subsystem (Lsass), And Presents Interactive Logon Dialog BoxService Control Manager (SCM) 32-bit Native ApplicationLoads and Initializes Auto-Start Device Drivers And Win32 ServicesPreboot

The Windows 2000 boot process does not begin when you power on your computer or press the reset button. It begins when you install Windows 2000 on your computer. At some point during the execution of the Windows 2000 Setup program, the system's primary hard disk is prepared with code that takes part in the boot process. Before we get into what this code does, let's look at how and where Windows 2000 places the code on a disk. Since the early days of MSDOS, a standard has existed on x86 systems for the way physical hard disks are divided into volumes. Microsoft operating systems split hard disks into discrete areas known as partitions and use file systems (such as FAT and NTFS) to format each partition into a volume. A hard disk can contain up to four primary partitions. Because this apportioning scheme would limit a disk to four volumes, a special partition type, called an extended partition, further allocates up to four additional partitions within each primary partition. Extended part itions can contain extended partitions, which can contain extended partitions, and so on, making the number of volumes an operating system can place on a disk effectively infinite. Figure 4-1 shows an example of a hard disk layout. (You can learn more About Windows 2000 Partitioning in Chapter 10, Which Covers Storage Management.) Figure 4-1 EXAMPLE HARD DISK LAYOUT

Physical disks are addressed in units known as sectors. A hard disk sector on an IBM-compatible PC is typically 512 bytes. Utilities that prepare hard disks for the definition of logical drives, including the MS-DOS Fdisk utility or the Windows 2000 Setup program , write a sector of data called a master boot record (MBR) to the first sector on a hard disk. The MBR includes a fixed amount of space that contains executable instructions (called boot code) and a table (called a partition table) with four entries that define the locations of the primary partitions on the disk. When an IBM-compatible computer boots, the first code it executes is called the BIOS, which is encoded into the computer's ROM. The BIOS reads the MBR into memory and transfers control to the code in the MBR.The MBRs written by Microsoft partitioning tools, such as the one integrated into Windows 2000 Setup and the Disk Management MMC snap-in, go through a similar process of reading and transferring control. First, an MBR's code scans the primary partition table until it locates a partition containing a flag that signals the partition is bootable. When the MBR finds at least one such flag, it reads the first sector from the flagged partition into memory and transfers control to code within the .................... ..

Operating systems generally write boot sectors to disk without a user's involvement. For example, when Windows 2000 Setup writes the MBR to a hard disk, it also writes a boot sector to the first bootable partition of the disk. You might have used the MS- DOS sys command to manually write MS-DOS boot sectors to disks. Windows 2000 Setup checks to see whether the boot sector it will overwrite with a Windows 2000 boot sector is a valid MS-DOS boot sector. If it is, Windows 2000 Setup copies the boot sector's contents to a file named Bootsect.dos in the root directory of the partition.Before writing to a partition's boot sector, Windows 2000 Setup ensures that the partition is formatted with a file system that Windows 2000 supports (FAT, FAT32, or NTFS) by formatting the boot partition (and any other partition) with a file system type you specify. If partitions are already formatted, you can instruct Setup to skip this step. After Setup formats the boot partition, Setup copies the files Win .

Another of Setup's roles is to create a boot menu file, Boot.ini, in the root directory of the boot partition. This file contains options for starting the version of Windows 2000 that Setup installs and any preexisting Windows 2000 installations. If Bootsect.dos contains a valid MS-DOS boot sector, one of the entries Boot.ini creates is to boot into MS-DOS. The following output shows an example Boot.ini file from a dual-boot computer on which MS-DOS is installed before Windows 2000:

[boot 爈 OADER] Timeout = 30 default = MULTI (0) Disk (0) RDisk (0) Partition (1) / Winnt [Operating 爏 Ystems] Multi (0) DISK (0) RDisk (0) Partition (1) / Winnt = "Microsoft 燱 indeows? 000 燩 rofessional"? FastDetect C: / = "Microsoft 燱 Indows" the boot sector and ntldr

Setup must know the partition format before it writes a boot sector because the contents of the boot sector vary depending on the format. For example, if the boot partition is a FAT partition, Windows 2000 writes code to the boot sector that understands the FAT file system. But if the partition is in NTFS format, Windows 2000 writes NTFS-capable code. The role of the boot-sector code is to give Windows 2000 information about the structure and format of a logical disk drive and to read in the Ntldr file from the root directory of the logical disk drive. Thus, the boot-sector code contains just enough read-only file system code to accomplish this task. After the boot-sector code loads Ntldr into memory, it transfers control to Ntldr's entry point. If the boot-sector code can not find Ntldr in the logical disk drive's root directory, it displays the error message "BOOT: Could not find NTLDR" if the boot file system is FAT or "NTLDR is missing" if the file system IS NTFS.

Ntldr begins its existence while a system is executing in an x86 operating mode called real mode. In real mode, no virtual-to-physical translation of memory addresses occurs, which means that programs that use the memory addresses interpret them as physical addresses and that only the first 1 MB of the computer's physical memory is accessible. Simple MS-DOS programs execute in a real mode environment. However, the first action Ntldr takes is to switch the system to protected mode. Still no virtual-to-physical translation occurs at this point in the boot process, but a full 32 bits of memory becomes accessible. After the system is in protected mode, Ntldr can access all of physical memory. After creating enough page tables to make memory below 16 MB accessible with paging turned on NTLDR Enables Paging. Protected Mode with Paging Enabled Is The Mode in Which Windows 2000 Executes in Normal Operation.After NTLDR Enables Paging, It Is Fully Operational. However, Its STILL RELIES ON FUNCTI ons supplied by the boot code to access IDE-based system and boot disks as well as the display. The boot-code functions briefly switch off paging and switch the processor back to a mode in which services provided by the BIOS can be executed. If either the boot or system drives are SCSI-based, Ntldr loads a file named Ntbootdd.sys and uses it instead of the boot-code functions for disk access. Ntldr next reads the Boot.ini file from the root directory using built-in file System Code. Like the boot sector's code, NTLDR Contains Read-Only NTFS AND FAT CODE; Unlike The Boot Sector's Code, HoWever, NTLDR's File System Code Can Read Subdirectories.

Ntldr clears the screen and if there is more than one boot-selection entry in Boot.ini, it presents the user with the boot-selection menu. (If there is only one entry, Ntldr bypasses the menu and proceeds to displaying the startup progress bar.) Selection entries in Boot.ini direct Ntldr to the partition on which the Windows 2000 system directory (typically / Winnt) of the selected installation resides. This partition might be the same as the boot partition, or it might be another primary partition .If the boot.ini entry refers to an ms-dos instance (That IS, by referring to c: / as the system partition), NTLDR Reads the contents of the bootsect.dos File Into Memory, Switches Back to 16-Bit Real mode, and calls the MBR code in Bootsect.dos. This action causes the Bootsect.dos code to execute as if the MBR had read the code from disk. code in Bootsect.dos continues an MSDOSspecific boot, such as is used to boot Microsoft Windows 98 or Microsoft Windows 95 On A Computer on Which There O Perating Systems Are Installed with Windows 2000.

ENTRIES IN BOOT.INI CAN INCLUDE OPTIONAL ARGUMENTS That NTLDR AND Other Components Involved in The Boot Process Interpret. Table 4-2 Contains a Complete List of these options and their effects.

Table 4-2 Boot.ini Switches

Boot.ini QualifierMeaning / 3GB Increases the size of the user process address space from 2 GB to 3 GB (and therefore reduces the size of system space from 2 GB to 1 GB). Giving virtual-memory-intensive applications such as database servers a . larger address space can improve their performance For an application to take advantage of this feature, however, two additional conditions must be met: the system must be running Windows 2000 Advanced Server or Datacenter Server and the application .exe must be flagged as a 3 -GB-aware application. (See the section "Address Space Layout" in Chapter 7 for more information.) / BASEVIDEO Causes Windows 2000 to use the standard VGA display driver for GUI-mode operations./BAUDRATE=Enables kernel-mode debugging and specifies anoverride for the default baud rate (19200) at which aremote kernel debugger host will connect Example:. /BAUDRATE=115200./BOOTLOG Causes Windows 2000 to write a log of the boot to the file% SystemRoot% / Ntbtlog.txt /. Breakcauses the har han dware abstraction layer (HAL) to stop at a breakpoint at HAL initialization. The first thing the Windows 2000 kernel does when it initializes is to initialize the HAL, so this breakpoint is the earliest one possible. The HAL will wait indefinitely at the breakpoint until a kernel-debugger connection is made. If the switch is used without the / DEBUG switch, the system will Blue Screen with STOP code of 0x00000078 (PHASE0_EXCEPTION) ./ bURNMEMORY = Specifies an amount of memory Windows 2000 can not use (similar to THE / MAXMEM SWITCH. The value is specified in megabytes. EXAMPLE: / BurnMemory = 128 100 Can '

t use 128 MB of the total physical memory on the machine./CLKLVL Causes the standard x86 multiprocessor HAL (Halmps.dll) to configure itself for a level-sensitivesystem clock rather then an edge-triggered clock. Level-sensitive and edge-triggered are terms used to describe hardware interrupt types./CRASHDEBUGCauses the kernel debugger to be loaded when the system boots, but to remain inactive unless a crash occurs. This allows the serial port that the kernel debugger would use to be available for use by the system until the system crashes (vs. / DEBUG, which causes the kernel debugger to use the serial port for the life of the system session) ./ DEBUGEnables kernel-mode debugging./DEBUGPORT=Enables kernel-mode debugging and specifies an override for the DEFAULT Serial Port (com1) to which a transote kernel-debugger host is connected. example: / debugport =

COM2./FASTDETECT Default boot option for Windows 2000. Replaces the Windows NT 4 switch / NOSERIALMICE. The reason the qualifier exists (vs. just having NTDETECT perform this operation by default) is so that NTDETECT can support booting Windows NT 4. Windows 2000 Plug and Play device drivers perform detection of parallel and serial devices, but Windows NT 4 expects NTDETECT to perform the detection. Thus, specifying / FASTDETECT causes NTDETECT to skip parallel and serial deviceenumeration (actions that are not required when booting Windows 2000), whereas omitting the switch causes NTDETECT to perform this enumeration (which isrequired for booting Windows NT 4) ./ INTAFFINITY Directs the standard x86 multiprocessor HAL (Halmps.dll) to set interrupt affinities such that onlythe highest numbered processor will receive interrupts. Without the switch, The Hal Defaults To Its Normalbehavior of Letting All Processors Receive Interrupts./kernel= / Hal = Enable You To Override NTLDR'S Default FileName for the kernel image (Ntoskrnl.exe) and / or the HAL (Hal.dll). These options are useful for alternating between a checked kernel environment and a free (retail) kernel environment or even to manually select a different HAL. If you Want to boot a checked environment That Consists Solely of the checked kernel and hal, Which is type TYPICLES, FOLLOW THESE STEPS ON A System Installed with the Free Build:

Copy the checked versions of the kernel images from the checked build CD to your / Winnt / System32directory, giving the images different names than the default. For example, if you're on a uniprocessor, copy Ntoskrnl.exe to Ntoschk.exe and Ntkrnlpa .exe to Ntoschkpa.exe. If you're on a multiprocessor, copy Ntkrnlmp.exe to Ntoschk.exe and Ntkrpamp.exe to Ntoschkpa.exe. The kernel filename must be an 8.3-style short name. Copy the checked version of the appropriate HALneeded for your system from /I386/Driver.cab on the checked build CD to your / Winnt / System32 directory, naming it Halchk.dll. to determine which HAL to copy, open /Winnt/Repair/Setup.log and search for Hal.dll; you'll Find a line like /winnt/system32/hal.dll="hacpi.dll ,""1d8a1. "The name immediately to the right of the equmediate is the name of the half.. The Hal FileName Must Be An 8.3-Style Short name. Make a copy of the default line in the system'sboot.ini file. In the string description of the boot selecti on, add something that indicates that the new selection will be for a checked build environment (for example, "Windows 2000 Professional Checked") Add the following to the end of the new selection's line:. /KERNEL=NTOSCHK.EXE / HAL = HALCHK.DLL Now when the selection menu appears during the boot process you can select the new entry to boot a checked environment or select the entry you were using to boot the free build./MAXMEM=Limits Windows 2000 to ignore (not use) physicalmemory . beyond the amount indicated The number is interpreted in megabytes Example:. / MAXMEM = 32 would limit the system to using the first 32 MB ofphysical memory even if more were present./MAXPROCSPERCLUSTER=

For the standard x86 multiprocessor HAL (Halmps.dll), forces cluster-mode Advanced Programmable Interrupt Controller (APIC) addressing (not supported on systems with an 82489DX external APIC interrupt controller) ./ NODEBUG Prevents kernel-mode debugging from being initialized. Overrides the specification of any of the three debug-related switches, / DEBUG, / DEBUGPORT, and / BAUDRATE. / NOGUIBOOTInstructs Windows 2000 not to initialize the VGA video driver responsible for presenting bitmapped graphics during the boot process. The driver is used to display boot progress information, so disabling it will disable the ability of Windows 2000 to show this information./NOLOWMEMRequires that the / PAE switch be present and that the system have more than 4 GB of physical memory. If these conditions are met, the PAE-enabled Version of thewindows 2000 kernel, NTKRNLPA.EXE, WON 'THE THE FIRST 4 GB of Physical Memory. INSTEAD, IT WILL LOAD ALL Applications and Device Drivers, And Allocate All Memory Pool s, from above that boundary. This switch is useful only to test device driver compatibility with large memory systems./NOPAEForces Ntldr to load the non-Physical Address Extension (PAE) version of the Windows 2000 kernel, even if the system is detected as Supporting x86 paes and has more Than 4 GB of Physical Memory./noserialmice=

.. [COMx | COMx, y, z ...] Obsolete Windows NT 4 qualifier-replaced by the absence of the / FASTDETECT switch Disables serial mouse detection of the specified COM ports Thisswitch was used if you had a device other than a mouse attached to a serial port during the startup sequence. Using / nOSERIALMICE without specifying a COM port disables serial mouse detection on all COM ports. See Microsoft Knowledge Base article Q131976 for more information./NUMPROC=Specifies the number of CPUs that can be used on A Multiprocessor System. EXAMPLE: / NUMPROC =

2 on a four-way system will prevent Windows 2000 from using two of the four processors./ONECPUCauses Windows 2000 to use only one CPU on a multiprocessor system./PAECauses Ntldr to load Ntkrnlpa.exe, which is the version of the x86 kernel that is able to take advantage of x86 PAEs. The PAE version of the kernel presents 64-bit physical addresses to device drivers, so this switch is helpful for testing device driver support for large memory systems / PCILOCKStops Windows 2000 from dynamically assigning IO / IRQ resources to PCI devices and leaves the devices configured by the BIOS See Microsoft Knowledge Base article Q148501 for more information / SAFEBOOT:. specifies options for a safe boot you should never have to specify this option manually, since Ntldr specifies it for you when you. Use the f8 menu to Perform A Safe Boot. (A Safe Boot IS A Boot in Which Windows 2000 Only Loads Drivers And Services That Are Specified by Name or Group Under The Minimal or Network Registry Keys Underhklm / Sy . STEM / CurrentControlSet / Control / SafeBoot) Following the colon in the option you must specify one of three additional switches: MINIMAL, NETWORK, or DSREPAIR The MINIMAL and NETWORK flags correspond to safe boot with no network and safe boot with network support,. respectively. The DSREPAIR (Directory Services Repair) switch causes Windows 2000 to boot into a mode in which it restores the Active Directory directory service from a backup medium you present. An additional option you can append is (ALTERNATESHELL), which tells Windows 2000 to Use the program specified by the hklm / system / currentcontrolset / safeboot / alternateshell value as the graphhical shell rather Than to use the default, Which is Windows Explorer./scsiordinal:

Directs Windows 2000 to the SCSI ID of the controller. (Adding a new SCSI device to a system with an on-board SCSI controller can cause the controller's SCSI ID to change.) See Microsoft Knowledge Base article Q103625 for more information./SOSCauses Windows 2000 to list the device drivers marked to load at boot time and then to display the system version number (including the build number), amount of physical memory, and number of processors./TIMERES=Sets the resolution of the system timer on the standard . x86 multiprocessor HAL (Halmps.dll) The argument is a number interpreted in hundreds of nanoseconds, but the rate is set to the closest resolution the HAL supports that is not larger than the one requested The HAL supports the following resolutions.:

Hundreds of nanosecondsMilliseconds (ms) 9766 0.9819532 2.00390633.90781257.80 The default resolution is 7.8 ms The system timer resolution affects the resolution of waitable timers Example:.. / TIMERES = 21000 would set the timer to a resolution of 2.0 ms./USE8254Instructs the HAL to use the 8254 timer chip as its base timer (for systems with older BIOS's). See MicrosoftKnowledge Base article Q169901 for more information./WIN95Directs Ntldr to boot the Consumer Windows boot sector stored in Bootsect.w40. This switch is pertinent only on a triple-boot system that has MS-DOS, Consumer Windows, and Windows 2000 installed. See Microsoft Knowledge Base article Q157992 for more information./WIN95DOSDirects Ntldr to boot the MS-DOS boot sector stored in Bootsect.dos. This switch is pertinent only ON A Triple-Boot System That Has MS-DOS, Consumer Windows, And Windows 2000 Installed. See Microsoft Knowledge Base Article Q157992 for more information./year=instructs the Windows 2000 Core Time Functi on to ignore the year that the computer's real-time clock reports and instead use the one indicated Thus, the year used in the switch affects every piece of software on the system, including the Windows 2000 kernel Example:.. / YEAR = 2001. (This switch was created to assist in Y2K testing.) If the user does not select an entry from the selection menu within the timeout period the Boot.ini file specifies, Ntldr chooses the default selection. Once the boot selection has been made, NTLDR LOADS AND EXECUTES NTDETECT.COM, A 16-BIT REAL-MODE Program That Uses a system's bios to query the computer for Basic Device and configuration information. This Information Information Information:

The time and date information stored in the system's CMOS (nonvolatile memory) The types of buses (for example, ISA, PCI, EISA, Micro Channel Architecture [MCA]) on the system and identifiers for devices attached to the buses The number, size , and type of disk drives on the system The types of mouse input devices connected to the system The number and type of parallel ports configured on the systemThis information is gathered into internal data structures that will be stored under the HKLM / HARDWARE / DESCRIPTION registry key Later in the boot.

Ntldr then clears the screen and displays the "Starting Windows" progress bar. This progress bar remains empty until Ntldr begins loading boot drivers. (See step 5 in the following list.) Below the progress bar is the message "For troubleshooting and advanced startup Options for Windows 2000, Press F8. "IF The User Presses F8, The Advanced Boot Menu IS Presented, Which Allows the User To Select Such Options as booting from Last Known Good, Safe Mode, Debug Mode, And So ON.

Next, NTLDR Begins Loading the file from the boot partition needed to start the kernel initialization:

Loads the appropriate kernel and HAL images (Ntoskrnl.exe and Hal.dll by default). If Ntldr fails to load either of these files, it prints the message "Windows 2000 could not start because the following file was missing or corrupt," followed by the name of the file. Reads in the SYSTEM registry hive, / Winnt / System32 / Config / System, so that it can determine which device drivers need to be loaded to accomplish the boot. (A hive is a file that contains a registry subtree. You'll find more details about the registry in Chapter 5.) Scans the in-memory SYSTEM registry hive and locates all the boot device drivers. Boot device drivers are drivers necessary to boot the system. These drivers are indicated in the registry by a start value of SERVICE_BOOT_START. Every device driver has a registry subkey under HKLM / SYSTEM / CurrentControlSet / Services. for example, Services has a subkey named Dmio for the Logical Disk Manager driver, which you can see in Figure 4-2. ( For A Detailed Description of T He Services Registry Entries, See The Section "Services" in Chapter 5.) Figure 4-2 Logical Disk Manager Driver Service Settings

Adds the file system driver that's responsible for implementing the code for the type of partition (FAT, FAT32, or NTFS) on which the installation directory resides to the list of boot drivers to load Ntldr must load this driver at this time;. If it did not, the kernel would require the drivers to load themselves, a requirement that would introduce a circular dependency. Loads the boot drivers. to indicate the progress of the loading, Ntldr updates a progress bar displayed below the text "Starting Windows." The progress bar moves for each driver loaded. (It assumes there are 80 boot device drivers-each successful load moves the progress bar by 1.25 percent.) If the / SOS switch is specified in the Boot.ini selection, Ntldr does not display the progress bar but instead displays the filenames of each boot driver. Keep in mind that the drivers are loaded but not initialized at this time-they initialize later in the boot sequence. Prepares CPU registers for the execution of Ntoskrnl.exe.T His Action Is The End of NTLDR'S Role in The Boot Process. at this Point, NTLDR Calls The Main Function In Ntoskrnl.exe To Perform The Rest of The System Initialization.

Initializing the kenergy and Executive Subsystems

When Ntldr calls Ntoskrnl, it passes a data structure that contains a copy of the line in Boot.ini that represents the selected menu option for this boot, a pointer to the memory tables Ntldr generated to describe the physical memory on the system, a pointer To the in-memory copy of the hardware and system registry hives, and a pointer to the list of boot drivers ntldr loading.

Ntoskrnl then begins the first of its two-phase initialization process, called phase 0 and phase 1. Most executive subsystems have an initialization function that takes a parameter that identifies which phase is executing.During phase 0, interrupts are disabled. The purpose of this phase is to build the rudimentary structures required to allow the services needed in phase 1 to be invoked. Ntoskrnl's main function calls KiSystemStartup, which in turn calls HalInitializeProcessor and KiInitializeKernel for each CPU. KiInitializeKernel, if running on the boot CPU, performs systemwide kernel initialization , such as initializing internal listheads and other data structures that all CPUs share. Each instance of KiInitializeKernel then calls the function responsible for orchestrating phase 0, ExpInitializeExecutive.

ExpInitializeExecutive starts by calling the HAL function HalInitSystem, which gives the HAL a chance to gain system control before Windows 2000 performs significant further initialization. One responsibility of HalInitSystem is to prepare the system interrupt controller of each CPU for interrupts and to configure the interval clock timer Interrupt, WHICH IS Used for CPU Time Accounting. (Section "in Chapter 6 for more on cpu time accounting.)

Only on the boot processor does ExpInitializeExecutive perform initialization other than calling HalInitSystem. When HalInitSystem returns control, ExpInitializeExecutive on the boot CPU proceeds by processing the / BURNMEMORY Boot.ini switch (if the switch is present in the line from the Boot.ini file that corresponds to the menu selection the user made when choosing which installation to boot) and discarding the amount of memory the switch specifies.Next, ExpInitializeExecutive calls the phase 0 initialization routines for the memory manager, object manager, security reference monitor, process manager, and Plug and Play Manager. These Components Perform The Following Initialization Steps:

The memory manager constructs page tables and internal data structures that are necessary to provide basic memory services. The memory manager also builds and reserves an area for the system file cache and creates memory areas for the paged and nonpaged pools. The other executive subsystems, the kernel, and the device drivers use these two memory pools for allocating their data structures. During the object manager initialization, the objects that are necessary to construct the object manager namespace are defined so that other subsystems can insert objects into it. A handle table is created so that resource tracking can begin. The security reference monitor initializes the token type object and then uses the object to create and prepare the first token for assignment to the initial process. The process manager performs most of its initialization in phase 0, defining the Process and thread Object Types and setting up lists to track Active Processes and threads. The process manage r also creates a process object for the initial process and names it Idle. As its last step, the process manager creates the System process and creates a system thread to execute the routine Phase1Initialization. This thread does not start running right away because interrupts are STILL DISABED. The Plug and Play Manager's Phase 0 Initialization The Takes Place, Which Involves Simply Initializing An Executive Resource Used to Synchronize Bus Resources.

When control returns to the KiInitializeKernel function on each processor, control proceeds to the Idle loop, which then causes the system thread created in step 4 of the previous process description to begin executing phase 1. (Secondary processors wait to begin their initialization until step 5 of phase 1, described in the following list.) Phase 1 consists of the following steps. (The steps at which the progress bar on the screen is updated are included in this list.) HalInitSystem is called to prepare the system to accept interrupts from devices and to enable interrupts. The boot video driver (/Winnt/System32/Bootvid.dll) is called, which in turn displays the Windows 2000 startup screen. The power manager's initialization is called. The system time is initialized (by calling HalQueryRealTimeClock) And the remaining processors are initialized and execution starts. The progress bar is set to 5 percent. t he object manager creates the namespace root directory, / ObjectTypes directory, / ?? directory, and the / DosDevices link to the / ?? directory. The executive is called to create the executive object types, including semaphore, mutex, event, and timer . The kernel initializes scheduler (dispatcher) data structures and the system service dispatch table. The security reference monitor creates the / Security directory in the object manager namespace and initializes auditing data structures if auditing is enabled. The progress bar is set to 10 percent. The Memory Manager Is Called To Create The Section Object and The Memory Manager '

s system worker threads (explained in Chapter 7). National language support (NLS) tables are mapped into system space. Ntdll.dll is mapped into the system address space. The cache manager initializes the file system cache data structures and creates its worker threads . The configuration manager creates the / Registry key object in the object manager namespace and copies the initial registry data passed by Ntldr into the HARDWARE and SYSTEM hives. Global file system driver data structures are initialized. The Plug and Play manager calls the Plug and Play BIOS. The progress bar is set to 20 percent. The local procedure call (LPC) subsystem initializes the LPC port type object. If the system was booted with boot logging (/ BOOTLOG), the boot log file is initialized. The progress bar is Set to 25 Percent. The I / O Manager Initialization Now Takes Place. This Stage Is A Complex Phase of System Startup That Accounts for 50 Percent of The "Progress" Reported in The Progress bar. The I / O manager considers each successful driver load to be another 2 percent of progress for the boot. (If there are more than 25 drivers to load, the progress bar stops at 75 percent.) The I / O manager first initializes various internal structures and creates the driver and device object types. It then calls the Plug and Play manager, power manager, and the HAL to begin the various stages of dynamic device enumeration and initialization. (Because this process is complex and specific to the I / O system, we '

ll save the details for Chapter 9.) Then the Windows Management Instrumentation (WMI) subsystem is initialized, which provides WMI support for device drivers that adhere to the Windows Driver Model (WDM). (See the section "Windows Management Instrumentation" in Chapter ? for more information.) Next, all the boot-start drivers are called to perform their driver-specific initialization, and the system-start device drivers are loaded and initialized. (Details on the processing of the driver load control information on the registry are also covered in Chapter 9.) Finally, the MS-DOS device names are created as symbolic links in the object manager's namespace. The progress bar is set to 75 percent. If booting in safe mode, this fact is recorded in the registry. Unless explicitly disabled in the registry, paging of kernel-mode code (in Ntoskrnl and drivers) is enabled. The progress bar is set to 80 percent. The power manager is called to initialize various power management structures. The progress bar is set to 85 percent. The security reference monitor is called to create the Command Server Thread that communicates with Lsass. (See the section "Security System Components" in Chapter 8 for more on how security is enforced in Windows 2000.) The progress bar is set to 90 percent. The last step is to create the Session Manager subsystem (Smss) process (introduced in Chapter 2). Smss is responsible for creating the user-mode environment that provides the visible interface to Windows 2000-its Initialization Steps Are Covered in The next section. The program is (firmly) set to 100%.

As a final step before considering the executive and kernel initialization complete, the phase 1 initialization thread waits on the handle to the Session Manager process with a timeout value of 5 seconds. If the Session Manager process exits before the 5 seconds elapses, the system crashes itself with a SESSION5_INITIALIZATION_FAILED bug check code.If the 5-second wait times out (that is, if 5 seconds elapse), the Session Manager is assumed to have started successfully, and the phase 1 initialization function calls the memory manager's zero page thread function (Explained in Chapter 7). Thus, this System Thread Becomes The RemainDer of The Life of The System.

SMSS, CSRSS, AND WINLOGON

Smss is like any other user-mode process except for two differences:. First, Windows 2000 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 does not use Win32 APIs-it uses only core executive APIs known collectively as the Windows 2000 native API. Smss does not use the Win32 APIs because the Win32 .

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 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:

Creates an LPC port object (/ SmApiPort) and two threads to wait for client requests (such as to load a new subsystem or create a session). Defines the symbolic links for MS-DOS device names (such as COM1 and LPT1). If Terminal Services Is Installed, Creates The / Sessions Directory In the Object Manager '

s namespace (for multiple sessions). Runs any programs defined in HKLM / SYSTEM / CurrentControlSet / Control / Session Manager / BootExecute. Typically, this value contains one command to run Autochk (the boot-time version of Chkdsk). Performs delayed file rename operations as directed by HKLM / SYSTEM / CurrentControlSet / Control / Session Manager / PendingFileRenameOperations. Pending file deletes are in PendingFileRenameOperations2. Opens known DLLs. Creates additional paging files. Initializes the registry. The configuration manager fleshes out 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 / Winnt / System32 / Config. Creates System Environment Variables. Loads the Kernel-Mode Part of The Win32 Subsystem (Win23k.sys). SMSS DETERMINES The Location of Win32k.sys and Other Components It Loads by LO oking for their paths in HKLM / SYSTEM / CurrentControlSet / Control / Session Manager. 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. Starts the subsystem processes, including Csrss. (As noted in Chapter ?, the POSIX and OS / 2 subsystems are defined to start on demand.) Starts the Logon Process (Winlogon). The Startup Steps of Winlogon Are Described Shortly. Creates LPC Ports for Debug Event Messages (DBGSSAPIPORT AND DBGUIPIPIPORT) AND THREADS to LISTEN On Those Ports.

After performing these initialization steps, the main thread in Smss waits forever on the process handles to Csrss and Winlogon. If either of these processes terminates unexpectedly, Smss crashes the system, since Windows 2000 relies on their existence.Winlogon then performs its startup steps, such as creating the initial window station and desktop objects, loading GINA DLLs, and so on. It then creates the service control manager (SCM) process (/Winnt/System32/Services.exe), which loads all services and device drivers marked for auto-start, and the local security authentication subsystem (Lsass) process (/Winnt/System32/Lsass.exe). (for more details on the startup sequence for Winlogon and Lsass, see the section "Winlogon Initialization" in Chapter 8.)

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 last known good control set (as indicated by HKLM / SYSTEM / Select / LastKnownGood) is updated to match / CurrentControlSet. If a user chooses to boot to the last known good menu during the first steps of a boot, or if a driver returns a severe or critical error, the system uses the LastKnownGood value as the current control set. Doing so .

That action brings us to the end of the boot process.

转载请注明原文地址:https://www.9cbs.com/read-125099.html

New Post(0)