You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the Toolhelp32 API to enumerate loaded Win32 modules. (swiftlang#892)
This PR replaces our call to `EnumProcessModules()` with one to
`CreateToolhelp32Snapshot(TH32CS_SNAPMODULE)`. Three reasons:
1. `EnumProcessModules()` requires us to specify a large, fixed-size
buffer to contain all the `HMODULE` handles;
2. `EnumProcessModules()` does not own any references to the handles it
returns, meaning that a module can be unloaded while we are iterating
over them (while `CreateToolhelp32Snapshot()` temporarily bumps the
refcounts of the handles it produces); and
3. `CreateToolhelp32Snapshot()` lets us produce a lazy sequence of
`HMODULE` values rather than an array, letting us write somewhat
Swiftier code that uses it.
The overhead of using `CreateToolhelp32Snapshot()` was negligible (below
the noise level when measuring).
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
0 commit comments