WinDbg Cheat Sheet
WinDbg Cheat Sheet
Contents:
!process (Lists _EPROCESS) – This extension displays similar information to the _EPROCESS data
structure, and can be used for displaying all the active processes running on the system.
To list all active processes, then simply use !process 0 0. Otherwise, to display information about a
specific process, then use !process [ImageName]/[Address].
Flags:
!processfields (Omitted _EPROCESS) – This extension will display the offsets and field names within
the _EPROCESS data structure.
Data Structures:
Global Variables:
PsActiveProcessHead – head of a doubly linked list of all active processes on a given processor.
PsInitialSystemProcess – the starting process (System) and the first process within the linked list.
!thread (Lists _ETHREAD) – This extension will display information similar to the _ETHREAD data
structure. It is useful for gathering thread information, and setting the debugger context to the
context of that thread. The .thread command is also used for setting to a local thread context.
Parameters:
The -p parameter can be added which will display information about the process which owns the
thread.
The -t parameter can be used to specific to use the Thread ID (TID) when viewing a specific thread,
instead of the thread's hexadecimal address.
Flags:
2 – This flag must be used with flag bit 1, otherwise it will not work; displays stack trace along with
thread wait states.
3 – The return addresses and stack pointers will added to the stack trace.
4 – Sets the process context to the process which owns the threads being examined (Better stack
traces)
!threadfields (Omitted _ETHREAD) – The concept is the same as the !processfields extension.
!tp – Displays Thread Pool Information; thread pools are used to manage worker threads on behalf
of a process.
Syntax: !tp pool Address [Flags], !tp tqueue Address [Flags] (Check WinDbg for more options).
Flags:
1 – Display as a single-line
3 – This flag will only work with the pool option. It will display pool work queues and/or pool work
queues at normal priority and NUMA nodes.
Data Structures:
k – Smallest amount of information (ChildEBP (Stack Frame Address), Return Address, Function
Name)
knL – Stack Frame Number, Stack Frame Address, Return Address, Function Name
kb – Stack Frame Address, Return Address, Arguments to the Function, Function Name
kv – Stack Frame Address, Return Address, Arguments to the Function, Function Name , FPO
(Frame Pointer Omission) Optimization, Trap Frames
.frame [/r] [Frame Number] – Displays the current stack frame and registers [/r]
!uniqstack [ -b | -v | -p ] [ -n ] – Displays all stacks for all threads within the current process
Parameters:
!findstack [Symbol] [Display Level] – Displays stacks with a specified module or symbol
!poolfind Tag String [Pool Type] – Searches paged and non-paged pool for pool allocations
associated with the specified pool tag.
Pool Types: 0 = Non-Paged Pool, 1 = Paged Pool, 2 = Special Pool 4 = Session Pool
!poolused [Flags[Tag String]] – Displays pool allocations for a specified pool tag string
Flags:
!pool [Address [Flags]] – Displays information about a specific pool allocation or pool page.
Flags:
1 – Suppresses pool header information for all the pool pages, apart from the pool page which
contains the pool address given
!poolval Address [Display Level] – Checks pool headers for consistency and any possible pool
corruption
Troubleshooting Memory:
Flags:
0 – Omits process specific information
!vprot [Address] – Displays the virtual memory protection bits for a address.
!vadump [-v] – Displays the virtual memory protection bits for all address ranges. -v will display the
original allocation information, since this can be changed by certain functions.
!pte [Virtual Address/PTE] – Displays the PTE and PDE for a given virtual address with PTE status
bits.
Flags:
!ptov [PFN] – Shows the physical to virtual mapping between pages for a given process.
PFN is the first four bits of the Directory Base for the process.
Handle = Index of the handle; -1 can be used to display all handles for a process.
Type Name = The name of the type of handle you wish to examine.
4 – Display handle from the kernel handle table instead of the process
5 – Interprets Handle as a TID/PID and then gives information about that object
!sd [Address] – Displays the security descriptor information for a given object.
Address: Use the address found in Security Descriptor field of the _OBJECT_HEADER
!idt [IDT] [-a] – Displays the IDT for a given processor(s). -a will displays the ISRs for each IDT entry
too.
!locks [-v | -p | -d] [Address] – Displays information about ERESOURCE locks. -v will display
detailed information, -p will include performance information and -d displays all locks including
who which do not have any contention. Address is the address of the ERESOURCE structure,
otherwise all locks are displayed.
!irp [Address] [Detail] – Displays information about a I/O packet (IRP). Address is the address of the
IRP. The Detail (any number) will display additional information such as owning thread, status of
the IRP, address of the corresponding MDL and stack locations of the IRP.
!irpfind [-v] [PoolType [Restart Address [Criteria] Data]]] – Searches for a specific IRP matching the
criteria.
PoolType specifies which pool to search through; Restart Address specifies which address to start
at; Criteria specifies which type of data to search for and Data specifies the data to look for e.g.
specific driver name
!devnode – Displays information about a device node within the device tree. !devnode 1 will
display all pending removals of device objects, !devnode 2 will show all pending ejects of a device
object and !devnode 0 1 will display the entire device tree.
!devstack [Device Object] – Displays the device stack for a device object. Device Object is the
address of the device object data structure.
Driver Verifier:
!deadlock – Displays information about a deadlock detected by Driver Verifier. Using !deadlock 1
will display the stacks of the deadlocked threads.
!verifier – Shows the status of Driver Verifier. For the flags consult the WinDbg index.
!cpuinfo – Displays information about the processor such as family, model and stepping.
!cpuid – Displays similar information to !cpuinfo, but will include processor clock speed.
Thread Scheduling:
!running -ti – Displays a list of all the running threads on all processors.
!runaway [Flags] – Displays how long a thread has been running for. This can only be used for live
debugging and crash dumps created by .dump /mt.
Flags:
2 – Displays the amount of time consumed since the creation of the thread.
.trap – Displays a formatted view of the _KTRAP_FRAME data structure with registers.
u – Produces assembly code translation for program code. Use ub for a specific memory range.
Memory Manipulation:
Driver Information:
lmvm [Module Name] – Displays detailed information about a driver module. This includes a
timestamp.
Power Policy:
!popolicy – Displays power related information about the current user. This is the settings
configured within the SYSTEM_POWER_POLICY data structure.
!pocaps - Displays information in relation to the power capabilities of the system, this is ideal for
checking if drivers are attempting to use a unsupported sleep state.
!poaction – Displays a list of outstanding Power IRPs called using the PoRequestPowerIrp function.
The function will create a Power IRP and send it to the top of device stack for a given device object.
The list of power IRPs will be shown under the FieldOffset field. The extension will provide the
device object, driver object and the nature of the power IRP.
!poaction - The !poaction extension will provide the current power action, and a list of devices
which are currently being powered off or down. It also provides a list of completed IRPs.
!ms_timers – It has a similar nature to the !timer extension, however, it is able to provide
information about hooking in the _KTIMER_TABLE.
!ms_idt – Provides the same information as !idt with the additional of hooking detection.
!ms_ssdt – This will dump the SSDT and provide any information on if functions have been hooked
or patched.
!ms_gdt – This will dump the GDT and LDT (LDT is stored within the GDT).
!ms_drivers - The !ms_drivers extension is basically the same as the lm or lmnst command. There
are some additional parameters you can add to the !ms_drivers extension to spice up the
command. The !ms_drivers /scan extension can be used to find drivers using IRP Hooking.
IRP Hooking involves a hook within the array stored within the DRIVER_OBJECT structure, this array
or table of IRP_MJ_ functions is hooked and the code responsible for the IRP is redirected to
malicious code. Please note hooking is used for legitimate processes such as debugging and patch
releases.
Note: If you wish to use the ProcDumpExt DLL for WinDbg, and also view the help information for
the extensions provided in SwishDbgExt, then you'll need to unload ProcDumpExt first since
ProcDumpExt will overload the !help extension with it's own version. You can simply load
ProcDumpExt again afterwards. Alternatively, if you do not wish to unload the ProcDumpExt DLL,
then simply use the longhand method of !SwishDbgExt.help <SwishDbgExt Extension>.
!dpx – Displays the entire stack for the thread, with combination of dps, dpu, dpp and dpa
commands.
!dtr – A slightly more detailed version of r, with the addition of idtr and gdtr.
Please note that !lpc applies to Windows XP and earlier operating systems, whereas, !alpc only
works with later versions.
!alpc /lpp [Address of Process] – Displays all connections for that process. This includes ports
created by the process, and ports which the process is currently connected to.
!alpc /p [Port Address] – Displays information regarding the specified port. This includes port,
server communication port, client communication port, connection port and message queue
information.
Windows Registry:
!reg kcb – Displays the Key Control Block for a registry key, this will require the use of !reg findkcb.
!reg findkcb – This will give the address of the KCB for the specified file path of the registry key.
!reg cellindex – Gives information corresponding to a cell index.
Parameters:
s – Shows memory consumption statistics for all heaps within the process address space.
!address – summary: Displays the process address space and statistics about memory consumption
related to that process address space. This includes heap statistics.
Miscellaneous:
!exchain – Lists all the exception handlers within the stack with the stack frame number.
dl – Transverses through a doubly linked list. The !dblink and !dflink provide similar functionality;
flink transverses forward, whereas, blink will transverse backwards. This command/extension will
require the address of a _LINKED_LIST structure.
!chkimg – Verifies the symbol of an binary image file (.EXE) within the dump file against the symbol
stored within the Microsoft Symbols store or local symbol store. This is used to detect if a binary
file is corrupt.
Parameters:
f – This will fix any corruption found within the image, by transferring the symbols from the symbol
store to the dump file.
.reload – Reloads the symbols from the symbol store, this is useful if there are symbol errors or you
have added additional symbol files (.pdb)
!sym noisy/quiet – By specifying the noisy or quiet parameter, you can control if symbol prompts
are shown when loading symbols.