https://github.com/dacap/safedlgs
Proof of concept to avoid random crashes from the Windows file dialog
https://github.com/dacap/safedlgs
crash file-dialog win32 windows
Last synced: 2 months ago
JSON representation
Proof of concept to avoid random crashes from the Windows file dialog
- Host: GitHub
- URL: https://github.com/dacap/safedlgs
- Owner: dacap
- License: mit
- Created: 2024-10-15T21:19:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-25T23:02:12.000Z (over 1 year ago)
- Last Synced: 2026-03-12T06:58:11.936Z (3 months ago)
- Topics: crash, file-dialog, win32, windows
- Language: C
- Homepage:
- Size: 55.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# safedlgs
> This is a proof of concept. Use this code as [you wish](LICENSE.txt).
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.
## Demo
This project includes the following programs:
* `dlgs.exe`: Shows the native Windows file dialog using the
[IFileDialog](https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog)
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-)executes `dlgs.exe`. This process
shouldn't crash, if it detects that `dlgs.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:

## Crashes
You can find some stack traces in the [CRASHES](CRASHES.md) file
about real world Windows and IME bugs out there.
## License
This project is released under the terms of the MIT license. Read
[LICENSE](LICENSE.txt) for more information.