Operator On The Wire
← Back to Knowledge Base
OOTW / Chapter I - Foundation / 01. Operating Systems / Windows

Introduction

Windows Layers

Windows OS Ecosystem

Application
    ↓
Win32 API
    ↓
ntdll.dll
    ↓
System Call (syscall)
    ↓
Kernel (ntoskrnl.exe)
    ↓
Drivers
    ↓
Hardware

This path explains most Windows behavior.


User Mode Components

ComponentPurposeExamples
ApplicationsPerform user tasksChrome, Outlook, Word
ProcessesRunning instances of programschrome.exe
ThreadsUnits of executionBrowser tab thread
DLLsShared functionalitykernel32.dll
Win32 APIOperating system interfaceCreateFile(), CreateProcess()
.NET RuntimeManaged execution environmentC# applications
COMComponent communicationOffice automation
Services (User Mode)Background functionalityWindows Update
SubsystemsCompatibility layersWSL

User Mode DLL Hierarchy

Application
    ↓
user32.dll
kernel32.dll
advapi32.dll
ws2_32.dll
    ↓
ntdll.dll
    ↓
Kernel

Common DLLs

DLLPurpose
kernel32.dllProcess, memory, file operations
user32.dllGUI
gdi32.dllGraphics
advapi32.dllSecurity, Registry
ws2_32.dllNetworking
crypt32.dllCryptography
ntdll.dllNative API + Syscalls

Native API Layer

Most Win32 functions eventually reach:

ntdll.dll

Examples:

Win32 APINative API
CreateFile()NtCreateFile()
CreateProcess()NtCreateUserProcess()
VirtualAlloc()NtAllocateVirtualMemory()
OpenProcess()NtOpenProcess()

This is where many EDR hooks live.


Kernel Executive Components

ComponentResponsibility
Process ManagerProcesses and threads
Memory ManagerVirtual memory (RAM)
I/O ManagerDevice communication
Security Reference MonitorAccess control, permissions
Object ManagerNamed kernel objects
Configuration ManagerRegistry
Plug and Play ManagerDevice detection
Power ManagerSleep, hibernate

Core Kernel Responsibilities

ComponentPurpose
SchedulerChooses running thread
DispatcherContext switching
Interrupt HandlingHardware events
Exception HandlingFaults/crashes
APCDeferred execution
DPCHigh-priority deferred work

Memory Management

ConceptDescription
Virtual MemoryProcess sees private address space
PagingMemory swapped to disk
Page TablesVA → PA mapping
Working SetActive memory pages
Pool MemoryKernel allocations
Page CacheCached file data

Windows Object Model

Everything is an object.

ObjectExample
Processnotepad.exe
ThreadWorker thread
FileC:\test.txt
Registry KeyHKLM\Software
EventSynchronization object
MutexSynchronization object
TokenSecurity context

Access is controlled by handles.

Object
    ↓
Handle
    ↓
Access Rights

Security Architecture

Security Identifier (SID)

User
    ↓
SID
    ↓
Access Check

Example:

S-1-5-18

Local SYSTEM


Access Token

Contains:

  • User SID
  • Group SIDs
  • Privileges
  • Integrity Level

Examples:

TokenDescription
UserNormal user
AdministratorElevated user
SYSTEMHighest local privilege

Integrity Levels

LevelTypical Use
LowSandbox
MediumNormal user
HighAdministrator
SystemSYSTEM

Driver Architecture

Driver TypeExample
File System DriverNTFS
Network DriverTCP/IP
USB DriverUSB stack
Storage DriverNVMe
Graphics DriverGPU driver
Filter DriverAV/EDR

Hardware Abstraction Layer (HAL)

Purpose:

Kernel
    ↓
HAL
    ↓
Hardware

HAL hides hardware differences from Windows.

Without HAL every CPU and motherboard would require separate kernel code.


Interrupt Flow

Keyboard Key Press
        ↓
Interrupt
        ↓
HAL
        ↓
Kernel ISR
        ↓
Driver
        ↓
Input Subsystem
        ↓
Application

Process Creation

User Clicks EXE
        ↓
CreateProcess()
        ↓
NtCreateUserProcess()
        ↓
Kernel
        ↓
EPROCESS Created
        ↓
Thread Created
        ↓
Image Loaded
        ↓
Execution Begins

File Access

Application
        ↓
CreateFile()
        ↓
NtCreateFile()
        ↓
I/O Manager
        ↓
File System Driver
        ↓
Storage Driver
        ↓
Disk

Network Access

Application
        ↓
Winsock
        ↓
TCP/IP Stack
        ↓
Network Driver
        ↓
NIC
        ↓
Network

Important DFIR Artifacts

AreaExamples
ExecutionPrefetch
PersistenceRun Keys
AuthenticationSecurity Log
NetworkingSRUM
TimelineMFT
User ActivityJump Lists
Application ActivityAmcache
PowerShellScriptBlock Logs

Important Offensive Targets

TargetWhy
Access TokensPrivilege escalation
LSASSCredentials
ServicesPersistence
Scheduled TasksPersistence
RegistryConfiguration
COMLateral movement
DriversKernel access
WMIExecution
ETWDetection visibility
AMSIScript inspection

Windows Mental Model for Operators

User Mode
    ↓
APIs
    ↓
Native APIs
    ↓
System Calls
    ↓
Kernel
    ↓
Drivers
    ↓
Hardware

Everything in Windows eventually becomes one of four things:

  1. CPU execution
  2. Memory access
  3. File I/O
  4. Network I/O

Every attack, defense, forensic artifact, and operating system feature ultimately manipulates one or more of these four resources.