# microsoft/wil

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/microsoft-wil).**

2,884 stars · 280 forks · C++ · mit

## Links

- GitHub: https://github.com/microsoft/wil
- awesome-repositories: https://awesome-repositories.com/repository/microsoft-wil.md

## Description

wil is a C++ wrapper library for the Windows API designed to simplify system development through RAII and exception handling. It provides a set of resource management tools, a framework for Windows error handling, and type-safe interfaces for registry access and networking.

The library distinguishes itself by automating the conversion between system error codes and C++ exceptions, while providing utilities for contextual error message attachment and early return patterns. It also features specialized networking wrappers for socket initialization and hostname resolution, and a registry interface that supports type-safe reading, writing, and change monitoring.

Broadly, the project covers system integration tasks such as process and module path resolution, COM interface management, and low-level memory allocation patterns. It includes diagnostic tools for debugger synchronization and invariant violation monitoring.

## Tags

### Operating Systems & Systems Programming

- [Windows API Wrappers](https://awesome-repositories.com/f/operating-systems-systems-programming/windows-api-wrappers.md) — Provides a comprehensive set of modern C++ wrappers that simplify interaction with the Windows API.
- [RAII Registry Key Management](https://awesome-repositories.com/f/operating-systems-systems-programming/raii-registry-key-management.md) — Opens or creates registry keys using pointers that automatically close the resource when leaving scope. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))
- [System Error Translation](https://awesome-repositories.com/f/operating-systems-systems-programming/system-error-translation.md) — Automates the conversion between system error codes and C++ exceptions for streamlined error propagation.
- [Windows Registry Interfaces](https://awesome-repositories.com/f/operating-systems-systems-programming/windows-registry-interfaces.md) — Offers a type-safe abstraction for reading, writing, and monitoring the Windows system registry.
- [Windows Resource Management](https://awesome-repositories.com/f/operating-systems-systems-programming/windows-resource-management.md) — Provides smart pointers and wrappers for managing Windows handles, registry keys, and opaque system resources.
- [Dynamic Buffer Allocation Patterns](https://awesome-repositories.com/f/operating-systems-systems-programming/dynamic-buffer-allocation-patterns.md) — Automates the retry logic for buffer allocations when retrieving variable-length strings from system functions. ([source](https://github.com/microsoft/wil/wiki/Win32-helpers))
- [Dynamic Buffer Resizing](https://awesome-repositories.com/f/operating-systems-systems-programming/dynamic-buffer-resizing.md) — Implements automatic buffer expansion logic when system calls indicate the provided memory size was insufficient.
- [Execution Failure Diagnostics](https://awesome-repositories.com/f/operating-systems-systems-programming/execution-failure-diagnostics.md) — Provides a structured exception handling guard that terminates the process at the exact point of failure for easier debugging. ([source](https://github.com/Microsoft/wil/wiki/Error-handling-helpers))
- [Canonical Path Resolution](https://awesome-repositories.com/f/operating-systems-systems-programming/filesystem-path-resolution/path-resolution-caches/canonical-path-resolution.md) — Retrieves full absolute file system paths for the current process, loaded modules, or external processes. ([source](https://github.com/microsoft/wil/wiki/Win32-helpers))
- [Secure Memory Allocators](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/allocation-strategies/dynamic-memory-allocation/custom-memory-allocators/managed-memory-allocators/secure-memory-allocators.md) — Provides various memory allocation patterns, including secure variants that zero memory before release. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [System Function Type Bridges](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/system-programming-primitives/system-abstractions/native-interoperability-bindings/native-system-integrations/native-api-bridges/native-type-bridges/system-function-type-bridges.md) — Casts return values from dynamic library lookups to specific function prototypes to ensure type-safe execution. ([source](https://github.com/microsoft/wil/wiki/Win32-helpers))
- [Nested Resource Cleanup](https://awesome-repositories.com/f/operating-systems-systems-programming/nested-resource-cleanup.md) — Automatically cleans up internal members when a parent structure is destroyed using RAII wrappers. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [Opaque Handle Management](https://awesome-repositories.com/f/operating-systems-systems-programming/opaque-handle-management.md) — Wraps raw handles and opaque resource types in smart pointers for automatic resource cleanup. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [Registry Change Monitoring](https://awesome-repositories.com/f/operating-systems-systems-programming/registry-change-monitoring.md) — Allows applications to monitor specific Windows registry keys and execute callback functions upon modification. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))
- [Registry Content Enumeration](https://awesome-repositories.com/f/operating-systems-systems-programming/registry-content-enumeration.md) — Provides capabilities to iterate through sub-keys or values within a registry key to inspect names and types. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))
- [Registry Metadata Inspection](https://awesome-repositories.com/f/operating-systems-systems-programming/registry-metadata-inspection.md) — Retrieves the last modified timestamp and child counts for specific Windows registry keys. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))
- [COM Interface Management](https://awesome-repositories.com/f/operating-systems-systems-programming/system-call-wrappers/com-interface-management.md) — Ensures specific methods are called on system COM interfaces when wrapper objects leave scope. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [Registry Querying](https://awesome-repositories.com/f/operating-systems-systems-programming/windows-registry-interfaces/registry-querying.md) — Provides a type-safe interface for querying and retrieving strings and integers from the Windows registry. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))
- [Windows Socket Wrappers](https://awesome-repositories.com/f/operating-systems-systems-programming/windows-socket-wrappers.md) — Simplifies Windows socket programming with managed wrappers for initialization and hostname resolution.

### Programming Languages & Runtimes

- [RAII Patterns](https://awesome-repositories.com/f/programming-languages-runtimes/raii-patterns.md) — Provides extensive RAII-based resource management wrappers for Windows handles and pointers.
- [System Error Translation](https://awesome-repositories.com/f/programming-languages-runtimes/async-runtime-bridges/cross-language-async-bridges/error-to-exception-mappings/system-error-translation.md) — Automates the conversion between Windows system error codes and C++ exceptions for streamlined error handling.
- [Reference Counting](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/ownership-borrowing/reference-counting.md) — Creates reference-counted versions of unique resource wrappers to facilitate shared ownership. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [C Output Parameters](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/c-output-parameters.md) — Provides helpers that allow C++ smart pointers to be passed to Windows APIs requiring raw output pointers. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [Opaque Resource Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/opaque-resource-wrappers.md) — Uses generic templates to provide type-safe wrappers around opaque Windows system resources and C structures.
- [Interface Lifetime Binding](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/language-specific-resources/language-tutorials/c-c-tutorials/object-management/object-lifetime-management/raii-patterns/interface-lifetime-binding.md) — Binds resource token lifetimes to specific interfaces to ensure correct sequential resource release.
- [Scope-Exit Tasks](https://awesome-repositories.com/f/programming-languages-runtimes/scope-exit-tasks.md) — Runs custom functions automatically when an object leaves its current scope regardless of the exit reason. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))

### Software Engineering & Architecture

- [Error Code to Exception Mapping](https://awesome-repositories.com/f/software-engineering-architecture/error-code-to-exception-mapping.md) — Transforms system error codes into thrown exceptions to streamline error propagation. ([source](https://github.com/Microsoft/wil/wiki/Error-handling-helpers))
- [Exception to Error Code Translation](https://awesome-repositories.com/f/software-engineering-architecture/exception-to-error-code-translation.md) — Intercepts exceptions at boundaries and translates them into error codes for compatibility with non-exception APIs. ([source](https://github.com/Microsoft/wil/wiki/Error-handling-helpers))
- [Resource Management Patterns](https://awesome-repositories.com/f/software-engineering-architecture/resource-management-patterns.md) — Implements RAII patterns to ensure system resources and handles are automatically released.
- [Windows Error Handling Frameworks](https://awesome-repositories.com/f/software-engineering-architecture/windows-error-handling-frameworks.md) — Provides a toolkit for converting between system error codes and C++ exceptions with integrated diagnostics.
- [Allocation Validation](https://awesome-repositories.com/f/software-engineering-architecture/allocation-validation.md) — Verifies that pointers are not null after allocation and automatically triggers out-of-memory exceptions. ([source](https://github.com/Microsoft/wil/wiki/Error-handling-helpers))
- [Reference-Counted Resource Coordination](https://awesome-repositories.com/f/software-engineering-architecture/reference-counted-resource-coordination.md) — Implements shared ownership of unique resource wrappers via reference counting to allow multi-component handle sharing.
- [Resource Ownership Transfer](https://awesome-repositories.com/f/software-engineering-architecture/resource-ownership-transfer.md) — Provides a method to transfer ownership of a managed resource from a smart pointer to an optional output parameter. ([source](https://github.com/Microsoft/wil/wiki/RAII-resource-wrappers))
- [Runtime Invariant Verifications](https://awesome-repositories.com/f/software-engineering-architecture/runtime-invariant-verifications.md) — Implements mechanisms to trigger immediate process termination when critical program state invariants are violated. ([source](https://github.com/Microsoft/wil/wiki/Error-handling-helpers))
- [Structured Exception Guards](https://awesome-repositories.com/f/software-engineering-architecture/structured-exception-guards.md) — Wraps execution blocks to translate system or hardware exceptions into diagnosable failure reports.

### Data & Databases

- [Registry Value Writing](https://awesome-repositories.com/f/data-databases/persistent-storage-management/application-persistence/process-reboot-persistence/alternate-data-stream-persistence/registry-value-writing.md) — Implements type-safe writing and updating of various data types within the Windows registry. ([source](https://github.com/microsoft/wil/wiki/Registry-Helpers))

### Networking & Communication

- [Network Hostname Resolvers](https://awesome-repositories.com/f/networking-communication/client-ip-identification/network-hostname-resolvers.md) — Translates hostnames into network addresses and manages the lifecycle of the resulting address lists. ([source](https://github.com/microsoft/wil/wiki/Network-Helpers))
- [Address Encapsulation](https://awesome-repositories.com/f/networking-communication/socket-networking/address-encapsulation.md) — Provides wrappers for network address structures that automate byte-order conversions and support equality comparisons. ([source](https://github.com/microsoft/wil/wiki/Network-Helpers))
- [Windows Networking Utilities](https://awesome-repositories.com/f/networking-communication/windows-networking-utilities.md) — Automates socket initialization and memory management for network address structures on Windows.

### System Administration & Monitoring

- [API Initialization Management](https://awesome-repositories.com/f/system-administration-monitoring/administrative-operations/linux-system-administration/networking/socket-protocol-layering/socket-management/api-initialization-management.md) — Manages the initialization and automatic cleanup of the Windows Sockets API using scoped session objects. ([source](https://github.com/microsoft/wil/wiki/Network-Helpers))

### Part of an Awesome List

- [Standard Library Extensions](https://awesome-repositories.com/f/awesome-lists/devtools/standard-library-extensions.md) — Windows implementation library for type-safe interfaces.
