CreateFile() hangs on VMWare with a disk disconnected.
I am calling CreateFile to open a file for reading and writing on an external Windows volume running over VMWare. However, if the disk is disconnected for any reason (after having been previously connected), CreateFile will hang indefinitely. How can I terminate the CreateFile attempt safely?
I've tried starting a thread to do the CreateFile and then using CancelSynchronousIO, but this call also seems to block indefinitely. As far as I can tell, the only way to abort the CreateFile attempt is with TerminateThread, which I know is a messy option that is never recommended. Is TerminateThread safe to do in this instance?