Windows OS Architecture

πŸ’‘ Goal: Understand how Windows is built under the hood β€” from User Mode to Kernel Mode, system layers, and what makes it tick. This is foundational for everything from malware development to EDR evasion.


🧠 What is an Operating System?

An OS acts as a middleman between:

  • You (the user / programs) and
  • Hardware (CPU, RAM, Disk, etc.)

It:

  • Manages processes and memory
  • Handles file I/O
  • Provides APIs to run apps
  • Controls devices through drivers

os a

🧩 Key Components Breakdown

πŸ”Ή User Mode

  • Apps like notepad.exe, chrome.exe
  • Can’t directly talk to hardware or manage memory
  • Must ask Kernel Mode via System Calls
  • Hosts subsystems (e.g., Win32, POSIX, WOW64)

πŸ”Έ Subsystems

  • Win32: Main API for GUI apps
  • WOW64: Lets 32-bit apps run on 64-bit Windows
  • POSIX: Legacy support for Unix-style tools

πŸ”Έ Kernel Mode

  • Has full access to memory, devices, drivers
  • Runs privileged code (Ring 0)
  • Includes the Kernel, Executive, Drivers, and HAL

🧱 Executive (NTOS)

Think of it as the “brains” of the kernel

Includes:

  • Object Manager (handles Windows objects like files, processes)
  • Memory Manager (allocates and pages memory)
  • Process Manager (creates, manages threads/processes)
  • Security Reference Monitor (permission enforcement)

βš™οΈ Kernel (Core)

  • Deals with low-level threading, interrupt handling, synchronization

πŸ“¦ Device Drivers

  • .sys files like disk.sys, kbdclass.sys
  • Run in kernel mode and interact directly with hardware

🧬 HAL (Hardware Abstraction Layer)

  • Allows Windows to run on different hardware by abstracting CPU/IO differences
  • File: hal.dll

πŸ”€ User Mode vs Kernel Mode

FeatureUser ModeKernel Mode
Privilege LevelRing 3 (low)Ring 0 (high)
Memory AccessOwn virtual memoryFull system memory
Crash ImpactJust the appWhole system (BSOD)
Direct Hardware Access❌ Noβœ… Yes
Exampleexplorer.exentoskrnl.exe, disk.sys

βš™οΈ System Call Flow (Behind the Scenes)

When you run calc.exe, here’s what happens:

  1. You click a shortcut
  2. Explorer.exe launches calc.exe using CreateProcess
  3. CreateProcess β†’ Win32 API
  4. Win32 API β†’ System Call (like NtCreateProcess)
  5. Kernel validates permissions, allocates memory
  6. Kernel returns handle, app runs

➑️ Every “simple” action is backed by 100+ low-level operations.


πŸ§ͺ Hands-On Practice

Want to see the layers in action? Try these:

# On Windows PowerShell
Get-Process | Select-Object Name, Path, Id

# Peek into ntoskrnl usage
Get-WmiObject -Query "Select * from Win32_OperatingSystem"

# View loaded drivers (kernel-mode)
driverquery /v

Use Process Hacker or WinDbg to see threads, handles, and kernel objects live.


🧠 Summary

  • Windows is a hybrid kernel OS with clear User Mode and Kernel Mode
  • User Mode apps can’t touch hardware directly β€” they rely on System Calls
  • Kernel Mode contains the brain (ntoskrnl.exe), drivers, and HAL
  • Everything you do β€” launching apps, copying files β€” goes through this architecture

5 1 vote
Article Rating
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
James

Great Detailed