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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use GetTempPath2W if it is available (only on Windows 11+)...
IFDYNAMICGETCACHEDFUNCTION(GetTempPath2W) {
returnpfGetTempPath2W(BufferLength, Buffer);
}
#endif// ^^^ !defined(_ONECORE) ^^^
// ...otherwise use GetTempPathW.
returnGetTempPathW(BufferLength, Buffer);
}
winapisupp.cpp is built into the STL's DLL, and the non-dllexported __crtGetTempPath2W is used by filesys.cpp in the DLL, implementing the non-Standard/highly-deprecated <experimental/filesystem>.
For Standard <filesystem>, we inject filesystem.cpp into the STL's import LIB, but we weren't similarly guarding GetModuleHandleW. (This is the only other call in the STL.) Somehow, nobody has hissed about <filesystem> being incompatible with UWP apps, but I suspect maybe nobody happened to be calling temp_directory_path() in their UWP apps, and so the linker discarded this unused machinery from the import lib. In any event, we should fix the code to be consistent and avoid potential problems for UWP.
I suspect UWP apps prefer using WinRT over STL to obtain this information because the STL lacks support for access permissions and lacks APIs related to application data folders.
I'm going to recharacterize this as a consistency enhancement instead of a bugfix. @amyw-msft informed me that the banned API restrictions were lifted back in 2020, and while certain APIs still can't be physically called (e.g. user32 UI), there are no deployment time blocks for common Win32 APIs. In the future I'll try to eradicate all of the OneCore checks, but for now I'll merge this.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetModuleHandleW
is a "desktop apps only" API. We avoid calling it for OneCore:STL/stl/src/winapisupp.cpp
Lines 179 to 194 in 7841cf8
and so we can't load
GetTempPath2W
for OneCore and must always use theGetTempPathW
fallback instead:STL/stl/src/winapisupp.cpp
Lines 164 to 175 in 7841cf8
winapisupp.cpp
is built into the STL's DLL, and the non-dllexported__crtGetTempPath2W
is used byfilesys.cpp
in the DLL, implementing the non-Standard/highly-deprecated<experimental/filesystem>
.For Standard
<filesystem>
, we injectfilesystem.cpp
into the STL's import LIB, but we weren't similarly guardingGetModuleHandleW
. (This is the only other call in the STL.) Somehow, nobody has hissed about<filesystem>
being incompatible with UWP apps, but I suspect maybe nobody happened to be callingtemp_directory_path()
in their UWP apps, and so the linker discarded this unused machinery from the import lib. In any event, we should fix the code to be consistent and avoid potential problems for UWP.