Win32: fix segfault in WriteConsoleW when debugging in gdb

Quite an old patch that somehow got dropped, rebased to 1.8.3