Finding a WND From an HWND

##dw hwnddesktop l2
fd9f:0000053a  013c 0020

##dw vphheapwnd l2
fd9f:00001610  00ae ec6f

##dw ec6f:ae
ec6f:000000ae  0000 ec6f 0000 0000 0000 0000 0000 0000
ec6f:000000be  0000 0000 0000 0000 0000 0000 0000 0000
ec6f:000000ce  0000 0000 0000 0000 0000 0000 0000 0000
ec6f:000000de  0000 0000 0000 0000 0000 0000 0000 0000
ec6f:000000ee  0000 0000 0044 0000 0000 0000 0000 7098
ec6f:000000fe  ec6f 0000 0000 0000 0000 0000 0000 0000
ec6f:0000010e  0000 0000 0000 1ffc 0000 ebe7 0010 165e
ec6f:0000011e  fd2f 0065 1fad 0000 0000 0000 0000 0000


##dw ec6f:13c
ec6f:0000013c  0000 0000 0000 0000 1250 ec6f 0000 0000
ec6f:0000014c  0000 0000 0400 0300 0004 0000 a000 0000
ec6f:0000015c  1fd8 0000 ebe7 0020 3a24 fd4f 0065 1fad
ec6f:0000016c  0000 0000 0000 0000 0000 0000 0000 0000
ec6f:0000017c  0000 0000 0000 0000 0000 0000 0000 0048
ec6f:0000018c  0354 ec6f 00f4 ec6f 0000 0000 0000 0000
ec6f:0000019c  0000 0000 0000 0000 0000 0000 8000 0000
ec6f:000001ac  1e4c 0000 ebe7 0030 1d42 fd2f 0065 1fad

In this example we find the WND for the desktop from the HWND which is stored at hwnddesktop.

The HWND comprises an offset concatenated with an identifier, the low order nibble of which is a heap index. Thus, for the desktop:

##dw hwnddesktop l2
fd9f:0000053a  013c 0020
                     .    .  .
                     .    .  .
                     .    .  .
             offset...    .  .
             id............  .
             index............

vphheapwnd points to a table of heaps. Each entry is a far pointer and there are at most 16. The index nibble of the HWND is used to select the heap pointer. In this example there is just one entry: ec6f:0000

We use the offset from the HWND with the heap selector to get the PWND. In this case ec6f:13c.

The key fields of interest in the WND are: