Windbg can be downloaded from the Microsoft store : Widbg download link
Commands and Shortcut Keys:
Note
The debugger injects a software breakpoint by overwriting the current instruction in memory with an INT 3 assembly instruction.
Caution
Terminating the debugger will also kill the attached process. This will require restarting the application either through the executable or, if it is a running service, through the services application.
Note
One of the advantages of WinDbg is the ability to use Microsoft symbols for core modules (DLLs).
| Task | SK | Command | example |
|---|---|---|---|
| Attach a process | F6 | - | - |
| continue execution | - | g | - |
| break execution | alt + del | - | - |
| disassemble function | - | u | u <ADDR> |
| display bytes | - | db | db eip |
| display words | - | dw | dw eip |
| words with ascii | - | dW | dW eip |
| display double words | - | dd | dd eip |
| Double word with ascii | - | dc | dc eip |
| display quadruple words | - | dq | dq eip |
| display ascii | - | da | da esp |
| display unicode | - | du | du esp |
| Length of data | - | L | db eip L1 |
| dereference a pointer’s data | - | poi | db poi(eip) |
| display a structure | - | dt | dt ntdll!_PEB |
| display structure using pseudo registers | - | - | dt -r ntdll!_TEB @$teb |
| display a particular part of structure | - | - | dt ntdll!_TEB @$teb ThreadLocalStoragePointer |
| size of a structure | - | sizeof | ?? sizeof(ntdll!_TEB) |
| edit ascii | - | ea | ea esp "pokemon" |
| edit value | - | ed | ed esp 9878987 |
| searching for a value | - | s | s -d 0 L?8000000 4144141 |
| searching for ascii | - | s | s -a 0 L?8000000 "pokemon" |
| inspect registers value | - | r | - |
| modify value of a register | - | r | r rcx 7473875893 |
| add a software breakpoint | - | bp | bp kernel32!writefile |
| list breakpoints | - | bl | - |
| disbale breakpoint | - | bd | bd 0 |
| enable breakpoint | - | be | be 0 |
| clear breakpoint | - | bc | bc * // clear all breakpoints |
| set unresolved breakpoint | - | bu | bu ole32!WriteStringStream |
| search for a particular match in loaded modules | - | lm | lm m *module* |
| ignore exception | - | sxi | sxi eh |
| breakpoint actions | - | - | bp ... ".printf \" pokemon \" " |
| breakpoint conditional action | - | - | bp ... ".if (poi(esp + 0x0c) != 4 ) {gc} .else {.printf \" lol \" ;r;} " |
Note
To perform a search we need
sand four additional parameters:
- the memory type to search for
- the starting point of memory to search
- the length of memory to search
- the pattern to search for
Breakpoints two types :
- Hardware [
ba] - software [
bp]
Breakpoints controlled directly by the debugger are known as software breakpoints. Breakpoints controlled by the processor and set through the debugger are known as hardware breakpoints.