Expand description
A “compatibility layer” for supporting older versions of Windows
The standard library uses some Windows API functions that are not present
on older versions of Windows. (Note that the oldest version of Windows
that Rust supports is Windows 7 (client) and Windows Server 2008 (server).)
This module implements a form of delayed DLL import binding, using
GetModuleHandle
and GetProcAddress
to look up DLL entry points at
runtime.
This is implemented simply by storing a function pointer in an atomic. Loading and calling this function will have little or no overhead compared with calling any other dynamically imported function.
The stored function pointer starts out as an importer function which will swap itself with the real function when it’s called for the first time. If the real function can’t be imported then a fallback function is used in its place. While this is low cost for the happy path (where the function is already loaded) it does mean there’s some overhead the first time the function is called. In the worst case, multiple threads may all end up importing the same function unnecessarily.
Macros
- ansi_str 🔒Helper macro for creating CStrs from literals and symbol names.
- Optionally loaded functions.
- Load a function or use a fallback implementation if that fails.
Structs
- Module 🔒Represents a loaded module.
Statics
Functions
- Creates a C string wrapper from a byte slice, in a constant context.
- init 🔒 ⚠Preload some imported functions.
- Load all needed functions from “api-ms-win-core-synch-l1-2-0”.