Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GetTempPath2 on Windows if available #104642

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

tommcdon
Copy link
Member

@tommcdon tommcdon commented Jul 9, 2024

Since Windows 10 Build 20348, there is a new API to get the temporary files path called GetTempPath2. This API returns a directory inaccessible to non-SYSTEM processes if the calling process runs as SYSTEM, and it is recommended to call this function instead of GetTempPath.

This PR tries to find GetTempPath2A / GetTempPath2W and uses that, otherwise it falls back to GetTempPathA / GetTempPathW.

Note: this PR removes an unused function GetTempPathWrapper that which referenced GetTempPathW

Since Windows 10 Build 20348, there is a new API to get the temporary files path called [`GetTempPath2`](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppath2w). This API returns a directory inaccessible to non-SYSTEM processes if the calling process runs as SYSTEM, and [it is recommended to call this function instead of `GetTempPath`](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppathw#remarks).

This PR tries to find `GetTempPath2A` / `GetTempPath2W` and uses that, otherwise it falls back to `GetTempPathA` / `GetTempPathW`.

*Note:* this PR removes an unused function `GetTempPathWrapper` that which referenced `GetTempPathW`
Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@tommcdon
Copy link
Member Author

All failures are known, merging

@tommcdon tommcdon merged commit e3d2dd1 into dotnet:main Jul 10, 2024
140 of 148 checks passed
matouskozak added a commit to matouskozak/runtime that referenced this pull request Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants