Windows Operating System Internals

Windows architecture

Legacy NTLDR boot

In this historical Windows boot sequence, the boot partition’s first sector and the following sectors load NTLDR. Its real-mode stage switches the CPU to protected mode, where its OS loader runs.

NTLDR builds memory descriptors, sets up page mappings and the page-directory register, enables paging, reads boot.ini, and runs ntdetect.com. It loads ntoskrnl.exe, hal.dll, the SYSTEM hive, boot drivers, and required file-system drivers. It constructs the LOADER_PARAMETER_BLOCK, then transfers control to the kernel entry point.

Kernel initialization

  • Phase 0 initializes the CPU and some kernel data structures in a process context.
  • Phase 1 runs in a thread and initializes most remaining modules, with concurrency where applicable.

Kernel and driver development

How drivers fit into the kernel

Drivers sit between hardware and the kernel’s services to applications. In implementation, kernel and driver development are closely coupled. Driver design must account for synchronous and asynchronous I/O, shared and exclusive access, buffer management, and device state. Drivers are part of the I/O system and can interact with the hardware abstraction layer or hardware.

Types of drivers

A driver is a software component that participates in communication between an OS and a device. An application requesting data calls an operating-system API, which can invoke functions supplied by a driver.

A function driver handles the device’s principal functions. Filter drivers perform additional processing elsewhere in the stack. A software driver can operate without an associated hardware device and may use core OS data structures.

Windows driver model

The OS hosts the driver, and invokes the callbacks registered by the driver on relevant events. Kernel-mode drivers use the Windows kernel APIs, the WDK runtime, and services exposed by other drivers. User-mode APIs and the full standard C or C++ libraries are unavailable in that environment.

Driver objects, device objects, and I/O

A driver object can own multiple device objects. Each device object is associated with one driver object. The I/O manager uses I/O request packets (IRPs) to communicate requests down a device stack.