Windows Messages

On Windows, you can use dbW while debugging to set a breakpoint for the message handler of a specific window.

Get a list of the current process windows with dW :

  1. [0x7ffe885c1164]> dW
  2. .----------------------------------------------------.
  3. | Handle | PID | TID | Class Name |
  4. )----------------------------------------------------(
  5. | 0x0023038e | 9432 | 22432 | MSCTFIME UI |
  6. | 0x0029049e | 9432 | 22432 | IME |
  7. | 0x002c048a | 9432 | 22432 | Edit |
  8. | 0x000d0474 | 9432 | 22432 | msctls_statusbar32 |
  9. | 0x00070bd6 | 9432 | 22432 | Notepad |
  10. `----------------------------------------------------'

Set the breakpoint with a message type, together with either the window class name or its handle:

  1. [0x7ffe885c1164]> dbW WM_KEYDOWN Edit
  2. Breakpoint set.

Or

  1. [0x7ffe885c1164]> dbW WM_KEYDOWN 0x002c048a
  2. Breakpoint set.

If you aren’t sure which window you should put a breakpoint on, use dWi to identify it with your mouse:

  1. [0x7ffe885c1164]> dWi
  2. Move cursor to the window to be identified. Ready? y
  3. Try to get the child? y
  4. .--------------------------------------------.
  5. | Handle | PID | TID | Class Name |
  6. )--------------------------------------------(
  7. | 0x002c048a | 9432 | 22432 | Edit |
  8. `--------------------------------------------'