Disclaimer: ChatGPT generated document.
WinDbg (Windows Debugger) is a powerful debugging tool for Windows that can be used for kernel-mode and user-mode debugging, crash dump analysis, reverse engineering, and performance analysis.
This guide will cover:
β
Installation & Setup
β
Basic Commands
β
User-Mode Debugging
β
Kernel Debugging
β
Crash Dump Analysis
β
Advanced WinDbg Techniques
β
WinDbg Preview (Recommended for newer versions)
π Available via Microsoft Store: WinDbg Preview
β
Classic WinDbg (For older versions)
π Part of Windows SDK: Windows SDK Download
π WinDbg Preview is recommended as it has a better UI and new features.
Once inside WinDbg, you can use commands to examine memory, breakpoints, stack traces, and variables.
| Command | Description |
|---|---|
.help |
Show available commands |
.hh command |
Open help for a command |
!help |
List debugger extensions |
.symfix |
Automatically set symbol path |
.reload |
Reload symbols |
To attach to a running process, use:
- Open WinDbg
- Click File β Attach to a Process
- Select the target process
- Click OK
π Or, use the command line:
windbg -pn my_program.exe| Command | Description |
|---|---|
bp <address> |
Set a breakpoint at an address |
bl |
List all breakpoints |
bc <ID> |
Clear a specific breakpoint |
bd <ID> |
Disable a breakpoint |
be <ID> |
Enable a breakpoint |
Example: Break at main()
bp my_program!main| Command | Description |
|---|---|
k |
Show call stack |
kb |
Show call stack with arguments |
kp |
Show call stack with function parameters |
kv |
Show call stack with variable info |
π Example: Show a function call stack
kb| Command | Description |
|---|---|
dt <Type> |
Display structure type information |
?? <Variable> |
Display variable value |
dv |
List local variables |
dw <Address> |
Display memory at address |
π Example: Inspect a C++ object
dt my_program!MyClass my_objectKernel debugging is useful for analyzing BSODs (Blue Screens of Death), driver issues, and system crashes.
-
Enable Debugging Mode
in Windows:
bcdedit /debug on
-
Connect to a Kernel Debugging Session
:
kd -k com:port=\\.\pipe\com_1
-
Run Kernel Debugging Commands
:
!analyze -v
| Command | Description |
|---|---|
!process 0 0 |
List all running processes |
!thread |
Show current thread info |
~ |
List all threads |
~#s |
Switch to thread # |
WinDbg is widely used to analyze crash dumps (BSODs and application crashes).
- Open WinDbg
- Click File β Open Crash Dump
- Select the
.dmpfile
π Or, via the command line:
windbg -z C:\Windows\Minidump\memory.dmp| Command | Description |
|---|---|
!analyze -v |
Perform crash dump analysis |
!analyze -hang |
Analyze application hang |
lm |
List loaded modules |
lmv |
List module details |
π Example: Analyze a BSOD
!analyze -v| Command | Description |
|---|---|
r |
Display registers |
r eax |
Show register EAX |
r eax=0x1234 |
Set register EAX |
db <Address> |
Dump memory as bytes |
dw <Address> |
Dump memory as words |
π Example: Dump memory at address 0x1000
db 0x1000 L32WinDbg uses symbols (.pdb files) to map function names and variables correctly.
π Set Symbol Path:
.sympath srv*c:\symbols*https://msdl.microsoft.com/download/symbols
.reloadπ Check if symbols are loaded:
lm| Task | Command |
|---|---|
| Attach to a Process | windbg -pn my_program.exe |
| Set a Breakpoint | bp my_program!main |
| View Call Stack | kb |
| Inspect a Variable | ?? myVar |
| Analyze a Crash Dump | !analyze -v |
| Dump Memory | db 0x1000 L32 |
Visual Studioβs "Debug -> Attach to Process" does not use WinDbg directly. Instead, it uses its own debugging engine (DbgEng), which is part of the Visual Studio Debugger (VS Debugger).
-
Uses the Microsoft Visual Studio Debugger
- The VS Debugger is separate from WinDbg but shares some underlying Windows debugging components (DbgHelp.dll, DbgEng.dll).
-
Provides a UI-friendly Debugging Experience
- Unlike WinDbg (which is command-line heavy), Visual Studio offers GUI tools like breakpoints, watch windows, call stack navigation, and variable inspection.
-
Supports Different Debugging Types
- Managed Debugging (for .NET apps)
- Native Debugging (for C/C++ apps)
- Mixed-Mode Debugging (for apps using both .NET & native code)
-
Can Attach to Running Processes
- This allows debugging without restarting an application.
β No, Visual Studio does not call WinDbg when attaching to a process.
β
However, both WinDbg and Visual Studio use the same Windows Debug API (DbgEng.dll), meaning they can both debug user-mode and kernel-mode applications.
| Scenario | Use Visual Studio Debugger | Use WinDbg |
|---|---|---|
| Debugging a .NET or C++ App | β Yes | β Not Ideal |
| Debugging Kernel (BSODs) | β No | β Yes |
| Debugging Large Crash Dumps | β No | β Yes |
| Debugging Malware/Reverse Engineering | β No | β Yes |
| Debugging a Process Without Symbols | β Harder | β Easier |
| Debugging in Production | β No | β Yes |
π WinDbg is preferred for deep system debugging, reverse engineering, and crash dump analysis.
π Visual Studio is preferred for application development and interactive debugging.
Disclaimer: ChatGPT generated document.
Both WinDbg and OllyDbg are powerful debugging tools, but they serve different purposes.
β
WinDbg β Used for Windows system debugging, crash dump analysis, kernel debugging, and large-scale application debugging.
β
OllyDbg β Used for reverse engineering, malware analysis, and analyzing compiled binaries without source code.
| Feature | WinDbg | OllyDbg |
|---|---|---|
| Purpose | System debugging, kernel debugging, crash dump analysis | Reverse engineering, binary analysis, malware analysis |
| Type | Symbolic debugger | Disassembler/debugger |
| User Interface | Command-line + GUI | Graphical with interactive assembly view |
| Supported Platforms | x86, x64 | Primarily x86 (OllyDbg 2.0 supports x64) |
| Kernel Debugging | β Yes | β No |
| User-Mode Debugging | β Yes | β Yes |
| Crash Dump Analysis | β Yes | β No |
| Debugging Without Source Code | β Yes (with symbols) | β Yes (without symbols) |
| Dynamic Analysis (Hooking, API Monitoring, Code Injection) | β Limited | β Yes |
| Breakpoints | β Software & Hardware Breakpoints | β Software & Hardware Breakpoints |
| Graphical Disassembly View | β No | β Yes |
| Plugins & Extensibility | β Yes (via WinDbg Extensions) | β Yes (OllyDbg Plugins) |
π Conclusion:
- Use WinDbg if you are analyzing Windows internals, kernel bugs, system crashes, or large applications.
- Use OllyDbg if you are reverse engineering, analyzing malware, or modifying compiled binaries.
| Scenario | Use WinDbg? | Use OllyDbg? |
|---|---|---|
| Debugging a running Windows process | β Yes | β Yes |
| Debugging Windows kernel or drivers | β Yes | β No |
| Analyzing a crash dump (BSOD, minidump) | β Yes | β No |
| Reverse engineering a compiled program (no source code) | β No | β Yes |
| Debugging malware behavior | β No | β Yes |
| Debugging a large application with symbols | β Yes | β No |
| Stepping through a disassembled binary | β No | β Yes |
| Viewing Assembly Instructions | β Yes (limited) | β Yes (graphical) |
π Summary:
- WinDbg is the tool of choice for system debugging, crash dump analysis, and Windows internals.
- OllyDbg is best for reverse engineering, malware analysis, and low-level binary manipulation.
βοΈ Kernel Debugging β Can debug Windows drivers and kernel crashes.
βοΈ Crash Dump Analysis β Used for analyzing BSODs and application crashes.
βοΈ Symbolic Debugging β Works well with .pdb symbol files to display function names and variables.
βοΈ Multi-threaded Debugging β Can debug complex multi-threaded applications.
βοΈ Microsoft-Supported β Used for official debugging in Windows development.
β Difficult to Use β Command-line heavy; requires deep Windows internals knowledge.
β No Disassembler View β Unlike OllyDbg, it lacks a graphical assembly view.
β Not Great for Reverse Engineering β Harder to analyze binaries without symbols.
βοΈ Graphical Assembly View β Shows disassembled binary code with function calls.
βοΈ Great for Reverse Engineering β Used for cracking, binary patching, and malware analysis.
βοΈ No Source Code Required β Can analyze any compiled executable.
βοΈ Plugins & Extensibility β Supports third-party plugins for additional functionality.
βοΈ Dynamic Analysis β Can hook functions, patch executables, and trace API calls.
β No Kernel Debugging β Cannot debug Windows drivers or analyze BSODs.
β No Symbol Support β Unlike WinDbg, it does not load .pdb files for debugging with symbols.
β Not Ideal for Large Applications β Better suited for small-to-medium binaries rather than system-level debugging.
- Uses Windows Debug API (DbgEng.dll) to interact with processes.
- Loads symbol files (.pdb) to map function names and variables.
- Provides both user-mode and kernel-mode debugging.
- Can analyze memory dumps (Minidumps, Full Dumps, Kernel Dumps).
- Executes commands via WinDbg Extensions (e.g.,
!analyze -v).
π Example: Attach to a process in WinDbg:
windbg -pn my_program.exe- Loads an executable file (EXE, DLL) directly into memory.
- Disassembles the binary into assembly instructions.
- Hooks API calls and modifies memory at runtime.
- Uses breakpoints to analyze execution flow.
- Allows manual patching of instructions in the executable.
π Example: Open an EXE in OllyDbg:
- File β Open β Select
my_program.exe - Press
F9to start debugging.
| Use Case | Best Tool |
|---|---|
| Debugging Windows crashes (BSOD, minidumps) | WinDbg |
| Debugging a running Windows process with symbols | WinDbg |
| Kernel-mode debugging (drivers, system analysis) | WinDbg |
| Debugging malware, reverse engineering, or cracking software | OllyDbg |
| Analyzing an EXE without source code | OllyDbg |
| Debugging user-mode applications without symbols | OllyDbg |
π Final Verdict:
- Use WinDbg for Windows system debugging, BSOD analysis, and debugging large applications with symbols.
- Use OllyDbg for reverse engineering, malware analysis, and debugging compiled binaries without source code.
WinDbg is not the best tool for reverse engineering (compared to tools like OllyDbg, IDA Pro, or x64dbg), but it can still be used to analyze binaries, set breakpoints, inspect memory, and modify execution flow.
This guide will show step-by-step how to reverse engineer a Windows application using WinDbg, including:
β
Attaching to a Running Process
β
Setting Breakpoints
β
Inspecting Memory & Registers
β
Disassembling Code
β
Modifying Execution Flow
β
Use WinDbg Preview (recommended) from the Microsoft Store
π Download WinDbg Preview
β
Alternatively, download the classic WinDbg from the Windows SDK
π Windows SDK Download
- Run WinDbg as Administrator (
Right-click β Run as Admin). - Go to "File" β "Attach to a Process".
- Select the target application (e.g.,
notepad.exeormy_target.exe). - Click OK to start debugging.
π Alternatively, attach via the command line:
windbg -pn my_target.exeUse:
.tlistThis will list all running processes.
Example output:
1234 my_target.exe
5678 explorer.exe
9101 cmd.exe
Use:
.attach 1234π Replace 1234 with the PID of the target process.
Now, we need to find a function of interest and set a breakpoint.
To break at MessageBoxA (commonly used in Windows applications):
bp user32!MessageBoxAπ If unsure of the module name, use:
x user32!*MessageBox*blbc 0π This removes breakpoint ID 0.
Run the program:
gOnce the breakpoint hits, execution will pause, allowing you to inspect registers, memory, and stack.
rExample output:
eax=00000000 ebx=12345678 ecx=87654321 edx=abcdef12
To inspect a specific register:
r eaxdps espπ Shows function arguments in the stack.
db 0x00400000 L16π Dumps 16 bytes at address 0x00400000.
uExample output:
00401000 push ebp
00401001 mov ebp,esp
00401003 sub esp,0x10
00401006 call 0x00402000
u 0x00401000If execution reaches:
call 0x00402000
You can skip it by modifying the EIP register:
r eip=0x00401006
gThis makes execution jump past the function call.
If eax contains a return value that needs to be changed:
r eax=1
gThis forces a function to return 1 instead of 0.
Use:
!strings -aThis lists all ASCII strings in memory.
To dump memory at a specific location:
db 0x12345678 L32π Shows 32 bytes at address 0x12345678.
To modify a specific memory address, use:
eb 0x12345678 90 90 90π This overwrites the first 3 bytes with NOP instructions (0x90).
.dump /f my_debug.dmpπ Saves current session for later analysis.
lmπ Lists all loaded DLLs and EXEs.
To log all commands:
.logopen my_log.txt| Task | Command |
|---|---|
| Attach to process | .attach <PID> |
| Set a breakpoint | bp user32!MessageBoxA |
| List breakpoints | bl |
| Run program | g |
| Disassemble code | u |
| View registers | r |
| Modify register value | r eax=1 |
| Dump memory | db 0x12345678 L32 |
| Modify memory (patch) | eb 0x12345678 90 90 90 |
| List loaded modules | lm |
β
When debugging applications with symbols (.pdb)
β
When analyzing Windows internals (API calls, system behavior)
β
When analyzing crash dumps and minidumps
β Not ideal for malware analysis or packed binaries (use OllyDbg, x64dbg, or IDA Pro instead)

Genuine question, what prompt did you use for this guide?