https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #7 from Alex Henrie alexhenrie24@gmail.com --- Created attachment 53320 --> https://bugs.winehq.org/attachment.cgi?id=53320 Test program that demonstrates the problem
The attached program replicates what Starcraft is doing. Because WriteError fails with ERROR_NOT_READY, the event in the OVERLAPPED structure never fires and the program stalls.
If COM1 is a real serial port, this program will print:
Waiting for the write operation to successfully complete... The write operation finished successfully.
If COM1 is not a real serial port, this program will print:
The device is not ready. Waiting for the write operation to successfully complete...
The tests in the function read_file_test in dlls/ntdll/tests/file.c indicate that ReadFile does not fire events if there is an error, which strongly suggests that Wine's identical behavior for WriteFile is also correct. Still, it would be nice to have more tests specifically for WriteFile.
During boot, Windows checks (by executing NTDETECT) which COM ports are physically present. If COM1 was not detected at boot, CreateFile("COM1", ...) fails, avoiding the problem with Starcraft. By mimicking this behavior, Wine can avoid the problem with Starcraft too.