Page 1 of 1

WinDbg Commands

PostPosted: Fri Jun 07, 2013 9:30 pm
by admin
!thread/!process [address] e - on x64 will not show you the meaningless Args to Child information.

.frame /c [FrameNumber] - sets context to specificied stack frame. On x64 provides more reliable register information than .trap.

kn - Dumps call stack with frame numbers, easier than counting stacks for .frame.

.frame /r [FrameNumber] - same as .frame /c, but shows registers without changing context.

Note: With .frame /c or /r you can only trust the nonvolatile registers.

k=rbp rip FrameCount - Dumps call stack starting at rbp/rip on x64. Useful when the stack is corrupt.

.process/.thread /p /r [address] - sets new process context, sets .cache forcedecodeuser, and reloads user symbols.

!process [address] 17 - Sets the context for this command, avoids the need for .process to see user stacks. Try !process 0 17

~~[ThreadID]s - Changes threads in user mode. Use Thread ID number from output such as !locks. Ex: ~~[1bd4]s

runas /netonly /u:<account> windbg.exe - Launch windbg with domain account. Use when dbg computer isn't in domain and symbol server is.

!heap -p -a <address> - Shows information about the heap block containing <address>, even if you aren't using pageheap.

ub - Unassembles starting at a location prior to your address. Accepts l<number> to specify how many instructions to go back. ub . l20

!stacks 2 [FilterString] - Finds kernel mode call stacks that contain the FilterString in a symbol.

!thread [address] 17 (or 1e on x64) - Sets context for this command, avoids the need for .thread/.process for user stacks.

.hh [Text] - Opens the debugger help. [Text] is the topic to lookup in the index. Example: .hh !pte

?? can dump structs using C++ style expressions. Ex: ??((nt!_KTHREAD*)(0xfffffa800ea43bb0))->ApcState

bp /t EThread - Sets a kernel mode breakpoint that only triggers when hit in the context of this thread.

bp /p EProcess - Sets a kernel mode breakpoint that only triggers when hit in the context of this process.

gc - If you run 'p' and hit a breakpoint, gc takes you where p would have gone if you had not hit the bp.

gu - Go until the current function returns. Effectively this unwinds one stack frame. #windbg

pc - Steps through until the next 'call' instruction. Combine with other commands to find who returned your error> pc;p;r eax

pt - Steps through until the next 'ret' instruction. Similar to gu, but pt stops on the ret and gu stops after the ret.

.ignore_missing_pages 1 - supresses the error: "Page 2a49 not present in the dump file. Type ".hh dbgerr004" for details"

.exr -1 shows the most recent exception. Useful in user dumps of crashes, especially for no execute crashes (NX/DEP).

wt - Trace calls until they return to the current address. More useful with -or to get return values. Use -l for depth.

.thread /w - Changes to the WOW64 32-bit context from 64-bit kernel mode. Wow64exts doesn't work in kernel mode.

??sizeof(structure) - Gets the size of a structure, it's easier than counting.

sxe ld:module.dll - Enables an exception which will break into the debugger when module.dll is loaded.

vertarget - Shows OS version of the debug target. Also shows machine name, uptime, and session time (when the dump was taken).

!vm 1 - In a kernel debugger, shows basic information about memory usage. Available, committed, pagefile, pool, sysptes, etc.

.time - Shows session time (when dump was taken) and system uptime. In user mode shows process uptime, kernel/user time.

ba w size [address] - Break on write access only. Replace size with the num bytes you want to watch. Ex: ba w 4 005d5f10

.process -i <address> - Make the process active and break into the debugger. Use in live kernel debugs to get into process context.

.reload /f /o - Overwrites cached files in your downstream symbol store. Useful when your store has corrupt pdbs.

->* - Use with dt to dump pointers. Example: dt _EPROCESS [Address] ObjectTable->*

!for_each_module s -a @#Base @#End "PTag" - Find the drivers using pool tag "PTag".

.unload [DllName] - Unloads the debug extension you didn't intend to load. Omit DllName to unload the last dll loaded.

!exqueue dumps the executive worker queues. Use flags 7f to dump the worker threads and the queues.

lmvm <module> - Dumps information about the module. Remember to use <module> and not <module.dll>.

!thread -t TID - Dump a thread using thread ID rather than thread address. Useful when working with a critical section.

!list - Walks a linked list and displays informatino for each element in a list.

.time -h # - Shows the debug session time using the timezone offset of #. Ex: .time -h 0 shows when a dump was taken in UTC.

!session - Lists all of the user session IDs. A quick way to list the active sessions from a dump of a terminal server.

!session -s SessionID - Changes the current session context to SessionID. Useful when looking at GDI, or other per session data.

| ProcNum s - Switches to process number ProcNum. Use when debugging multiple dumps, or processes, in one windbg.

!! - Launches a shell process and redirects its output to the debugger. The same as .shell, but "bang bang" sounds cooler.

uf Function - Dumps the assembly for Function (name or address). Useful for optimized code that is not contiguous in memory.

uf /c Function - Shows all of the calls made by Function (can be function name or address).

!wow64exts.sw - switches between x64 and x86 contexts. Often used to reverse .thread /w context switch.