This is a proof of concept. Use this code as you wish.
There is no safe way to use the standard file dialog to open/save
files on Windows. What does this mean? It looks like there are several
comctl32.dll
implementations, and some third-party Windows IME
(Input Method Editors) that can crash your application just by using
the standard file dialog from Windows.
As the file dialog contains a EDIT
control, it opens a full range of
possible bugs/crashes when a third-party IME is configured. Which
means that just opening the file selector is a potential source of
crashes for your application.
One possible way to fix this is using a background process just to open the file dialog. If the process crashes, we can reopen it, even using the last location where the crash was produced.
This project includes the following programs:
dlgs.exe
: Shows the native Windows file dialog using the IFileDialog interface. This process can crash. Each time the user changes to other folder, it prints that folder to STDOUT, so we can re-open the file dialog in the last location.test.exe
: Wrapper that (re-)executesdlgs.exe
. This process shouldn't crash, if it detects thatdlgs.exe
crashed, it just re-open it in the last visited location.
The dlgs.exe
will show the native file dialog with an extra "Crash
Process" button just to test how it works in case of crash:
You can find some stack traces in the CRASHES file about real world Windows and IME bugs out there.
This project is released under the terms of the MIT license. Read LICENSE for more information.