README.md

July 22, 2019 · View on GitHub

If you're more familiar with Linux and GDB than with Windows, but find yourself needing/wanting to learn Windows debugging, this is the cheat sheet for you.

Breakpoints

GDB CommandWinDBG CommandDescriptionUsage/Examples
b/breakbpSet breakpoint
disablebd #Disable breakpoint
enablebe #Enable breakpoint
info breakpoints/ibblList breakpoints
watchbaBreak on access(read/write)ba [r|w|e] [Size] Addr

Running/Stepping

GDB CommandWinDBG CommandDescription
r/rung
.restart
Run program
s/sipStep over
n/nitStep into
finishptStep to next return
NonepcStep to next call
upaStep to address

Variables, Symbols, and Memory

GDB CommandWinDBG CommandDescriptionUsage/Example
x*d*Dump memory at addressa = ascii chars
u = Unicode chars
b = byte + ascii
w = word (2b)
W = word (2b) + ascii
d = dword (4b)
c = dword (4b) + ascii
q = qword (8b)

dd 0x1000000
set {int}addr = e*Edit memoryed 0x1000000 deadbeef

a = ascii string
za = ascii string (NULL-terminated)
u = Unicode string
zu = Unicode string (NULL-terminated)
e[a|u|za|zu] addr "String"
print/pdt/dvPrint variabledt ntdll!_PEB
dt ntdll!_PEB @$peb
disasmuDisassemble at address/symbolu kernel32!CreateProcessAStub
* (deref)poiDereference pointeru poi(ebp+4)
NonexExamine symbolsx *!
x /t /v MyDll!* list symbols in MyDll with data type, symbol type, and size

C++ Expression Syntax

GDB CommandWinDBG CommandDescriptionUsage/Example
p (Datatype *) &variabledx (Datatype *) &variabledisplays a C++ expressiondx (nt!_EPROCESS *) &nt!PsIdleProcess
p [expression]??Evaluate C++ expressions. Used with the C++ expression parser - @@c++(), that supports operators, registers, macros. etc. See docs for a full list?? @@c++(1+2)

Registers

Access registers with @, like @eip.

GDB CommandWinDBG CommandDescriptionUsage/Example
info registersrShow registersr Reg1 Reg2
r Reg:Type
Type = data format in which to display the register (i.e.: r eax:uw)
ib = Signed byte
ub = Unsigned byte
iw = Signed word (2b)
uw = Unsigned word (2b)
id = Signed dword (4b)
ud = Unsigned dword (4b)
iq = Signed qword (8b)
uq = Unsigned qword (8b)
f = 32-bit floating-point
d = 64-bit floating-point
set reg =r Reg=ValueSet register

Getting information

GDB CommandWinDBG CommandDescriptionUsage/Example
info proc mappings!addressShow virtual memory map and permissions!address addr
print/pxExamine symbolsx kernel32!*CreateProcess*
NonelnList nearest symbol to address
backtrace/btkStack backtrace
None!exchainView SEH Chain

Other useful commands

!peb – dumps Process Environment Block dt ntdll!_PEB @$peb — dumps more PEB info of our process

Tips

The WinDBG executable is installed in C:\Program Files (x86)\Windows Kits\10\Debuggers\x86[64]/. If it's not in your path, add it by going to the Edit system environment variables menu, and append to the Path variable.

$peb is a "pseudo-register", and there are others that hold useful values. Some are $teb, $csp, $curprocess.

References

http://windbg.info/doc/1-common-cmds.html