Windows NT Architecture
Every version of Windows you are likely to touch today, from Windows 11 on a laptop to Windows Server in a data centre, is built on the Windows NT design that Microsoft started in 1988. NT was planned from day one as a portable, secure, multi-user operating system, and its layered structure is still clearly visible in a modern Windows 11 machine.
In this lesson you will meet the layers one by one, follow a single API call from an application down to a driver, and look at the system processes that are always running in Task Manager.
The big picture
Windows is a hybrid kernel: the core services run in kernel mode inside one big binary (like a monolithic kernel), but the design is split into well-separated components that talk through defined interfaces (an idea borrowed from microkernels).
USER MODE
+------------------+ +-----------------+ +-------------------------------+
| Applications | | Services | | System processes |
| (notepad, Chrome)| | (svchost, sql) | | smss csrss wininit winlogon |
+--------+---------+ +--------+--------+ | services lsass |
| | +---------------+---------------+
+--------v---------------------v---------------------------v---------------+
| Subsystem DLLs: kernel32.dll / kernelbase.dll, user32.dll, gdi32.dll ... |
+-------------------------------------+------------------------------------+
| ntdll.dll (Nt*/Zw* system call stubs, loader, heap, Rtl* helpers) |
+====================================|=====================================+ <- syscall
KERNEL MODE v
| Executive (ntoskrnl.exe): I/O mgr, Object mgr, Process mgr, Memory mgr, |
| Security Reference Monitor, Configuration mgr (registry), PnP, Power, |
| Cache mgr, ALPC | win32k.sys |
| Kernel (ntoskrnl.exe): thread scheduling, interrupts, dispatching, sync |
| Device drivers (*.sys): file systems, network, storage, graphics, USB |
| HAL (hal.dll): hides interrupt controllers, timers, multiprocessor quirks|
+--------------------------------------------------------------------------+
HardwareThe layers, bottom up
| Layer | File | What it does |
|---|---|---|
| HAL (Hardware Abstraction Layer) | hal.dll |
Hides differences in interrupt controllers, timers and platform firmware so the rest of the kernel is portable. |
| Kernel | ntoskrnl.exe (lower part) |
Thread scheduling, interrupt and exception dispatch, low-level synchronisation (spinlocks, dispatcher objects). |
| Executive | ntoskrnl.exe (upper part) |
The "managers": objects and handles, processes and threads, virtual memory, I/O, security checks, the registry, Plug and Play, power. |
| Drivers | *.sys |
Loadable kernel modules: file systems (ntfs.sys), TCP/IP (tcpip.sys), storage, USB, GPU. |
| win32k.sys | win32k*.sys |
The kernel half of windowing and graphics (window manager, input). |
| ntdll.dll | ntdll.dll |
The lowest user-mode layer: tiny stubs that enter the kernel, plus the image loader and heap. |
| Subsystem DLLs | kernel32.dll, kernelbase.dll, user32.dll, advapi32.dll |
The documented Win32 API that programs call. |
Two names cause confusion. The kernel in Windows terminology is only the small scheduling/interrupt core; the executive sits above it in the same binary. People often say "the Windows kernel" for the whole of ntoskrnl.exe.
The Win32 API versus the native API
Applications call the documented Win32 functions such as CreateFileW or ReadFile. Those functions validate and convert parameters and then call the native API in ntdll.dll (NtCreateFile, NtReadFile). Each native stub loads a system service number into a register and executes the CPU's syscall instruction. The kernel uses that number as an index into its system service table.
The service numbers change between Windows builds, which is exactly why Microsoft documents Win32 and not the raw system calls. On Linux the situation is reversed: syscall numbers are a stable ABI (see System Calls).
This little model follows one CreateFileW call down the layers. Each layer adds its piece of work:
LAYERS = [
("user", "kernel32/kernelbase", "CreateFileW: check flags, convert DOS path to NT path"),
("user", "ntdll.dll", "NtCreateFile: load service number, execute syscall"),
("kernel", "System service table","dispatch to the executive routine"),
("kernel", "Object manager", "parse \\??\\C:\\ -> \\Device\\HarddiskVolume3"),
("kernel", "Security monitor", "compare the caller's token with the file's DACL"),
("kernel", "I/O manager", "build an IRP_MJ_CREATE request packet"),
("kernel", "ntfs.sys", "find the MFT record, open the file"),
("kernel", "Object manager", "create a File object, return a handle"),
]
def dos_to_nt(path):
return "\\??\\" + path
path = r"C:\Users\ada\notes.txt"
print("CreateFileW(" + path + ")")
print("NT path:", dos_to_nt(path))
print()
mode = None
for depth, (ring, who, what) in enumerate(LAYERS):
if ring != mode:
print(f"--- {ring} mode ---")
mode = ring
print(f"{depth + 1}. {who:<21} {what}")
print()
print("Result: HANDLE 0x1a4 returned to the application")CreateFileW(C:\Users\ada\notes.txt)
NT path: \??\C:\Users\ada\notes.txt
--- user mode ---
1. kernel32/kernelbase CreateFileW: check flags, convert DOS path to NT path
2. ntdll.dll NtCreateFile: load service number, execute syscall
--- kernel mode ---
3. System service table dispatch to the executive routine
4. Object manager parse \??\C:\ -> \Device\HarddiskVolume3
5. Security monitor compare the caller's token with the file's DACL
6. I/O manager build an IRP_MJ_CREATE request packet
7. ntfs.sys find the MFT record, open the file
8. Object manager create a File object, return a handle
Result: HANDLE 0x1a4 returned to the application
Objects and handles
In NT almost everything the kernel manages is an object: processes, threads, files, registry keys, events, mutexes, sections (shared memory), tokens. The Object Manager names them in a single namespace (\Device\HarddiskVolume3, \BaseNamedObjects\MyEvent, \REGISTRY\MACHINE) and hands user code handles, small integers that index the process's handle table. A handle carries the access rights granted when it was opened, so the security check happens once, at open time.
Linux takes the "everything is a file" route instead: most kernel resources show up as file descriptors. The idea is similar (an index into a per-process table), but the namespaces differ. We compare them in Linux vs Windows.
The system processes
Open Task Manager's Details tab and you'll always see the same core processes. They start in a fixed chain during boot:
System (PID 4) kernel threads; owner of drivers' work
+- smss.exe Session Manager: the first user-mode process
+- (session 0) csrss.exe Client/Server Runtime: console hosting, process bookkeeping
+- (session 0) wininit.exe starts the two below, then waits
| +- services.exe Service Control Manager -> svchost.exe, other services
| +- lsass.exe Local Security Authority: logon, tokens, password checks
+- (session 1) csrss.exe
+- (session 1) winlogon.exe secure attention sequence (Ctrl+Alt+Del), logon UI
+- userinit.exe -> explorer.exe (userinit exits once the shell starts)Session 0 holds services and system processes only. Interactive users get session 1, 2 and so on, so a service can never draw a window on a user's desktop (this "session 0 isolation" closed a whole class of attacks).
On a real machine you can list them with PowerShell (sample output — yours will differ):
PS C:\Users\ada> Get-Process smss, csrss, wininit, winlogon, services, lsass |
>> Sort-Object SessionId, Id | Format-Table Id, ProcessName, SessionId
Id ProcessName SessionId
-- ----------- ---------
532 smss 0
748 csrss 0
856 wininit 0
932 services 0
948 lsass 0
868 csrss 1
996 winlogon 1The model below builds the same tree from parent/child records, the way a tool like Process Explorer does from each process's parent PID:
procs = [
(4, 0, "System", 0),
(532, 4, "smss.exe", 0),
(748, 532, "csrss.exe", 0),
(856, 532, "wininit.exe", 0),
(932, 856, "services.exe", 0),
(948, 856, "lsass.exe", 0),
(868, 532, "csrss.exe", 1),
(996, 532, "winlogon.exe", 1),
(1204, 932, "svchost.exe", 0),
(1288, 932, "svchost.exe", 0),
(4410, 996, "explorer.exe", 1),
]
children = {}
for pid, ppid, name, sess in procs:
children.setdefault(ppid, []).append((pid, name, sess))
def show(pid, name, sess, indent=0):
print(f"{' ' * indent}{name} (pid {pid}, session {sess})")
for child in children.get(pid, []):
show(*child, indent + 1)
show(4, "System", 0)
by_session = {}
for pid, ppid, name, sess in procs:
by_session[sess] = by_session.get(sess, 0) + 1
print(by_session)System (pid 4, session 0)
smss.exe (pid 532, session 0)
csrss.exe (pid 748, session 0)
wininit.exe (pid 856, session 0)
services.exe (pid 932, session 0)
svchost.exe (pid 1204, session 0)
svchost.exe (pid 1288, session 0)
lsass.exe (pid 948, session 0)
csrss.exe (pid 868, session 1)
winlogon.exe (pid 996, session 1)
explorer.exe (pid 4410, session 1)
{0: 8, 1: 3}
(In reality smss.exe starts a short-lived copy of itself for each session, which exits after launching that session's csrss.exe; this is why on a live machine csrss.exe and wininit.exe show a parent PID that no longer exists. Here the copies are folded into one node.)
Environment subsystems
NT was designed to host several "personalities" on top of one kernel: Win32, OS/2 and POSIX. Only Win32 survived, and csrss.exe is its user-mode server. The idea came back in a new form with the Windows Subsystem for Linux: WSL 1 translated Linux system calls inside the NT kernel, and WSL 2 runs a real Linux kernel in a lightweight VM (WSL & Hyper-V).
Virtualization-based security
On Windows 11 with default settings, the Hyper-V hypervisor runs underneath Windows even if you never create a VM. It splits the machine into two virtual trust levels: the normal kernel (VTL 0) and a tiny secure kernel (VTL 1) that guards secrets such as credential hashes (Credential Guard, LsaIso.exe) and checks driver code integrity (HVCI, "Memory integrity"). Even code running in the normal kernel cannot read VTL 1 memory.
Note:
lsass.exe,csrss.exe,wininit.exeandsmss.exeare critical processes: if one of them dies, Windows bugchecks (blue screen) immediately, because the system cannot continue safely without them.
Learn more: Kernel Designs · The Windows Boot Process · Windows Services
Test yourself
Which user-mode DLL contains the stubs that execute the syscall instruction on Windows?
- kernel32.dll
- user32.dll
- ntdll.dll
- hal.dll
Why do Windows programs call Win32 functions instead of raw system calls?
- Raw system calls are slower
- System service numbers change between Windows builds; only Win32 is a stable, documented API
- The kernel rejects syscalls from applications
- Win32 runs in kernel mode
Which process is the Service Control Manager?
- lsass.exe
- services.exe
- csrss.exe
- smss.exe