Structured Exception Handling
First, I'm very pleased to see this effort being open sourced. Big kudos to you all at Microsoft for formalizing a repository on this subject ❤️.
This is not an issue against the repository, rather, I hope to open a discussion on the topic of structured exception handling. For the Windows Kernel (and the OS in general) structured exception handling is an integral part of developing for Windows and a real blockers to making Rust a reality for Windows Kernel development.
Structured exception handling is a requirement in a number of workflows in the Windows Kernel. There are cases where structured exception handling is unavoidable, e.g. cases where an exported Kernel API expects the caller to handle a structured exception. Here are some examples where structured exceptions are used:
- Reading memory from user mode must be done inside a
__try/__exceptblock. - Paging I/O might raise an exception if the related file data could not be accessed, and must be handled handled appropriately.
- Some APIs for the kernel that are documented to raise exceptions, for example FsRtlIsNameInExpression states, "In low resource conditions, FsRtlIsNameInExpression can raise a structured exception with a code of STATUS_NO_MEMORY, which callers should be prepared to handle."