MMNA
Security Academy
📖 MODULE 1 OF 3
🏛️ KERNEL ARCHITECTURE

Windows Architecture & Kernel Fundamentals

Understanding OS Structure and Security Boundaries

Master the foundational concepts of Windows operating system architecture. Learn how user-mode applications interact with the kernel, understand privilege levels and security boundaries, explore executive components, and discover how attackers exploit architectural weaknesses. Essential knowledge for advanced threat detection and malware analysis.

Windows OS Architecture Overview

Privilege Levels and System Organization

Windows Privilege Hierarchy
🖥️ User Applications
Notepad, Chrome, Word, Visual Studio - Execute in restricted user-mode privilege level
⬇️ System Call Interface ⬇️
🔐 System DLLs & APIs
ntdll.dll, kernel32.dll - Provide interface between user-mode and kernel
⬇️ Privilege Transition ⬇️
⚙️ Windows Kernel (ntoskrnl.exe)
Executive components, process/memory/file management - Runs in privileged kernel-mode
⬇️ Hardware Interface ⬇️
🔧 Hardware Abstraction Layer
Abstracts CPU, memory, interrupts - Bridges kernel and physical hardware
⬇️ Direct Hardware ⬇️
💾 CPU, Memory, Devices
Physical processors, RAM, disk, network - Foundation of entire system

🎯 User-Mode vs Kernel-Mode: Critical Security Boundary

User-Mode (Ring 3)

User-mode is restricted execution environment for applications. Each application runs in its own isolated virtual address space—one program crash doesn't affect others. Applications cannot directly access hardware or memory outside their allocated space. Operating system enforces this isolation through CPU privilege levels and memory management units. When user-mode code needs OS service (read file, allocate memory, create network connection), it cannot execute the operation directly. Instead, it must request kernel via system call.

Kernel-Mode (Ring 0)

Kernel-mode is unrestricted execution environment for OS core. Code running in kernel-mode can access all hardware directly, read/write any memory, manage physical resources. Only kernel components (ntoskrnl.exe, drivers) run in kernel-mode. Hardware CPU enforces this: attempting to execute privileged instruction in user-mode causes fault. This separation is fundamental security boundary: user applications cannot directly manipulate kernel memory or hardware.

Why This Matters for Security

Attack Scenario: Malware running as user-mode process wants to disable antivirus. Antivirus driver is in kernel-mode. Malware cannot directly manipulate kernel memory or call kernel functions. It must use legitimate OS APIs. However, if malware finds kernel vulnerability (bug that allows privilege escalation), it can jump from user-mode to kernel-mode. Once in kernel-mode, malware has unrestricted access—it can disable security features, hide from monitoring, persist across reboots.

This is why privilege escalation is critical attack step. Malware without kernel access is limited. Malware in kernel-mode is devastating.

💡 Key Concept: The user-mode/kernel-mode boundary is the fundamental security divide in Windows. Attackers invest significant effort in crossing this boundary through exploitation. Defenders focus on keeping malware trapped in user-mode where it's restricted.

Executive Components & System Organization

Core Kernel Subsystems

Object Manager
Windows represents everything as objects (processes, threads, files, registry keys, events). Object Manager maintains object directory hierarchy. Tracking object creation and access is powerful forensic technique. Malware creating unusual objects or accessing protected objects indicates compromise.
💾
Memory Manager
Manages virtual memory system, page tables, memory allocation. Implements demand paging (loads code only when needed). Memory protection prevents one process from accessing another's memory. Malware uses memory-based attacks: code injection, API hooking, shellcode execution—all exploit memory management.
🔄
Process Manager
Creates and manages processes and threads. Each process has unique process ID (PID). Process Manager allocates resources, manages process termination. Monitoring process creation tree reveals attack chain: legitimate process spawns suspicious child process spawns malware.
📂
I/O Manager
Manages file systems, disk I/O, device drivers. I/O request packets (IRPs) carry I/O requests through driver stack. Malware interception of I/O (filesystem mini-filters) allows hiding files, modifying reads. Understanding I/O architecture reveals rootkit hiding mechanisms.
🔐
Security Reference Monitor
Enforces access control policy. Checks permissions before allowing resource access. Maintains security context (user identity, groups, privileges). Misconfigured security descriptors create vulnerability windows. Malware exploits weak permissions to access protected resources.
🎤
Registry Manager
Manages registry database of system configuration. Registry stores startup programs, service configurations, security settings. Registry modification is persistent malware technique. Monitoring registry changes detects attacker persistence attempts and configuration modifications.
💡 Investigation Approach: Each Executive component is attack surface. Security tool monitoring Process Manager detects suspicious process creation. Tool monitoring Registry Manager catches persistence attempts. Comprehensive OS understanding enables comprehensive threat detection.

Kernel Security Concepts

Drivers, Interrupts, and Protection Mechanisms

🔧 Device Drivers: Power and Vulnerability

Device drivers are specialized programs that manage hardware devices (network adapters, USB controllers, graphics cards). Drivers execute in kernel-mode with unrestricted access. This power is necessary: drivers need direct hardware access to function. However, this creates massive security risk. Malicious or compromised driver becomes rootkit—attacker controls system completely.

Attack Examples:

  • Bootkits: Malicious drivers load during system startup, before antivirus. They hide from detection by intercepting filesystem operations
  • Rootkits: Kernel-mode malware loading as driver. Hides processes, files, network connections from user-mode tools
  • Vulnerable Drivers: Legitimate drivers with security bugs. Attackers exploit bugs to execute arbitrary code in kernel-mode
  • Unsigned Drivers: Unsigned drivers bypass signing verification. Attacker-signed drivers load without verification in some contexts

Defense Strategy: Code integrity checking (Secure Boot, PatchGuard) prevents unsigned kernel-mode code loading. Kernel patch levels affect vulnerability surface. Driver monitoring reveals malicious drivers loading or suspicious driver behavior.

⚡ Interrupt Handling and Context Switching

Hardware interrupts are asynchronous events: timer tick, network packet arrival, disk I/O completion. When interrupt occurs, CPU switches from current code to interrupt handler in kernel. Interrupt Dispatch Table (IDT) maps interrupts to handlers. This is fundamental CPU mechanism, not unique to Windows.

Why This Matters: Malware exploiting IDT can redirect interrupts to malicious code. Hypervisor rootkits intercept interrupts at hardware level. Understanding interrupt mechanism helps identify sophisticated rootkit techniques. Event tracing detects unusual interrupt patterns indicating rootkit activity.

Context Switching: When one thread yields CPU to another thread, kernel saves thread's CPU state (registers, instruction pointer) and restores new thread's state. This happens thousands of times per second. Context switch decisions (which thread runs next) are scheduling decisions made by kernel scheduler. Malware attempting to prioritize its threads or starve security tools attempts scheduling manipulation.

🔐 Memory Protection and Hardware-Enforced Security

Virtual Address Spaces

Each process has 64-bit virtual address space (on 64-bit Windows). Virtual addresses are translated to physical addresses by Memory Management Unit (MMU) using page tables. This translation happens in hardware, very fast. Virtual address spaces provide isolation: Process A cannot access Process B's virtual memory even if they want to. Operating system maintains separate page tables per process.

Page Protection Attributes

Each memory page has protection attributes: readable, writable, executable. Hardware enforces these: attempt to write to read-only page causes access violation fault. This enables powerful defenses: mark code pages execute-only (prevent code from being modified), mark data pages non-executable (prevent code execution from data).

Modern Mitigations

  • DEP (Data Execution Prevention): Mark data memory non-executable. Prevents shellcode in data from executing
  • ASLR (Address Space Layout Randomization): Randomize memory layout. Makes exploitation difficult because attacker doesn't know code addresses
  • Control Flow Guard (CFG): Prevent redirection of function calls. Detects and prevents ROP (return-oriented programming) attacks
  • Kernel ASLR: Randomize kernel memory layout. Requires attacker to leak kernel addresses before attacking
💡 Security Implication: Modern Windows implements multiple hardware-enforced protections. However, kernel vulnerabilities can bypass these. Keeping kernel patched is critical—unpatched kernel = vulnerable to exploitation despite protections.

Enterprise Endpoint Risks

Why Kernel-Level Compromise is Severe

⚠️ Kernel Compromise: The Ultimate Threat

User-mode malware has limited capabilities. Kernel-mode malware has unrestricted access. This is why privilege escalation is attacker's priority. Once in kernel-mode, malware can:

  • Disable Security Tools: Unload antivirus driver, disable Windows Defender, disconnect from security monitoring system
  • Hide Presence: Hide malicious processes from process listing, hide malicious files from file browsing, hide network connections from netstat
  • Modify System Behavior: Intercept system calls, redirect API calls, inject code into other processes
  • Establish Persistence: Load malicious drivers that survive reboots, modify firmware, hijack boot process
  • Monitor Everything: Keylogging at keyboard driver level (captures keystrokes before applications receive them), network sniffing at network adapter level
  • Cover Tracks: Modify event logs, delete audit trails, alter filesystem timestamps

Once malware is in kernel-mode, all user-mode defenses are compromised. Endpoint is effectively under attacker control. This is why prevention (not getting compromised) is so critical.

🏢 Enterprise Endpoint Exposure

Enterprises manage thousands of Windows endpoints. Each endpoint is attack surface. Common exposure factors:

  • Patch Management Gaps: Not all systems patched promptly. Unpatched systems vulnerable to known exploits. Attackers scan networks for unpatched systems
  • Vulnerable Services: Services running with unnecessary privileges. Service running as SYSTEM is more valuable target than service running as unprivileged user
  • Weak Permissions: Directories with overly-permissive ACLs. Unprivileged user can write to system directory enabling privilege escalation
  • Outdated Legacy Systems: Older systems may run unsupported OS versions, drivers with known vulnerabilities
  • Third-Party Vulnerabilities: Popular third-party applications have vulnerabilities. Attackers exploit widely-used software knowing many endpoints affected
  • Misconfigured Security: Security features disabled for compatibility reasons. Security monitor whitelisting malware due to misconfig

📊 Importance of OS-Level Monitoring

Network-level monitoring (firewalls, IDS) sees network traffic. Application-level monitoring sees application logs. But OS-level compromise happens below applications. OS-level monitoring provides visibility into:

  • Process Behavior: What processes are created, by whom, what arguments, what parent process spawned them
  • File System Activity: What files are created/modified/deleted, by which process, at what time
  • Registry Changes: What registry keys are modified, what values changed, what applications triggered changes
  • Network Connections: What network connections are established, source/destination, protocol, data volume
  • Loaded Drivers: What kernel-mode drivers loaded, when, from where, are they signed

OS-level monitoring by endpoint detection and response (EDR) tools provides behavioral visibility. Malware behavior often detectable even if malware itself undetectable due to rootkit hiding.

💡 Strategic Implication: Enterprise security depends on preventing kernel compromise. Multiple layers of defense needed: patch management (fix vulnerabilities before exploitation), privilege management (run services with minimum necessary privileges), OS-level monitoring (detect behavior of compromised systems).

Official Learning Resources

Deepen Your Understanding with Official Documentation

📚 Microsoft Official Documentation

💡 Reading Recommendation: Start with Kernel Overview to understand basic architecture. Then explore specific components relevant to your analysis. Microsoft documentation is authoritative source for Windows internals.
🎓
Verified Certificate Notice
Course Completion Achievement
Complete all 3 modules of this course to unlock your
Verified Cybersecurity Certificate
from
MONEY MITRA NETWORK ACADEMY
with unique verification ID and QR code
✓ PROFESSIONAL CERTIFICATION AVAILABLE

Continue Your Journey

Module 1 Complete - Proceed to Advanced Topics

Module 1 Summary - Windows Architecture Mastered:
✅ User-mode vs Kernel-mode architecture and security boundaries
✅ Executive components and system organization concepts
✅ Privilege levels and protection mechanisms
✅ Driver interaction and kernel-level security
✅ Enterprise endpoint exposure understanding

You now understand the foundational Windows OS architecture. Module 2 builds on this knowledge to explore process management, memory exploitation techniques, and malware persistence mechanisms. Advanced threat detection requires understanding both legitimate OS behavior and how attackers abuse these mechanisms.

Progress: 1 of 3 Modules Complete (33%)
Next: Process, Memory & Persistence Mechanisms