I realized one thing: this is holding a lock implicitly while calling MonitorFromWindow or GetWindowLongW (with GWL_STYLE) via the WND pointer. Is that a problem?
I'm not very familiar with this so I don't know if it's a good idea or not (I know sending messages isn't). Perhaps due to Windows API hooks?
Fixing it would obviously complicate the code so I'd rather only do it if necessary.