Anatoly Lyutin wrote:
len = MultiByteToWideChar( CP_ACP, 0, message, -1, NULL, 0 );
bufW = HeapAlloc( GetProcessHeap(), 0, len );
len is in WCHARs, not bytes so this will cause heap corruption.
It really would be a lot easier to make "output" take a Unicode string instead.