-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Support not using Win32 APIs that aren't allowed for Microsoft Store UWP apps & games on NativeAOT #96510
Comments
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsProblemUsing UWP is a requirement for creating & publishing apps for Xbox without being in the XDK/ID@Xbox program, and realistically it's the only way community members can write games and apps for Xbox since they won't be approved to join the ID@Xbox program. Currently apps compiled using NAOT are statically importing these Win32 functions:
While these functions work perfectly under UWP, they aren't whitelisted by Microsoft Store for UWP apps, a list of whitelisted Win32 APIs for apps that target Windows SDK 22621.755 can be found here. Suggested solutionThere's two possible ways this can be fixed:
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsProblemUsing UWP is a requirement for creating & publishing apps for Xbox without being in the XDK/ID@Xbox program, and realistically it's the only way community members can write games and apps for Xbox since they won't be approved to join the ID@Xbox program. Currently apps compiled using NativeAOT are statically importing these Win32 functions:
While these functions work perfectly under UWP, they aren't whitelisted by Microsoft Store for UWP apps, a list of whitelisted Win32 APIs for apps that target Windows SDK 22621.755 can be found here. Suggested solutionThere's two possible ways this can be fixed:
|
Notably https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis is the official list of supported APIs and is likely a better resource than the checked in xml file referenced. |
cc. @tommcdon Of course, another option is also to just have these APIs being added to the set of allowed APIs for UWP apps (which would also make sense, given as there's nothing inherently dangerous about these APIs, not to mention the fact that as mentioned, one could literally just use That said, assuming there was interest in making this scenario viable (which I would certainly love to see, because like, apps and games using NativeAOT on Xbox, what's not to love), it would be nice to at least add some smoke tests or something to easily validate that new updates to NativeAOT don't accidentally bring in any new imports that might break WACK. |
This list is very old and outdated, Microsoft Partner Center itself uses that xml file which comes with Windows App Certification Kit. note that there's a bug in WACK where it replaces the xml file that is bundled with Windows SDK with a really old version, and that's why that repo the file I linked from exists, to preserve the original xml file for each Windows SDK version (which is what Partner Center actually use, not the outdated one). |
How did you compile this list? I expect that many more APIs are going to show up once you start using libraries like crypto or networking.
Yes. The workarounds for disallowed APIs caused a constant pain when we were targeting UWP subset. I do not think we want to go there again. |
By creating a basic small game in UWP, compiled it using NAOT, then ran it against WACK. |
I think we'd basically need to restore the
There was a lot of UAP code in the frameworks that was nuked from orbit in dotnet/corefx#41759, we'd probably need that back. |
I have a couple questions on that:
|
Answering this question would require analysis of the delta between allowed UAP APIs and what's actually used by libraries in the repo now. My guess is that it would not be a few target changes. Also, UAP is its own unique OS from infrastructure point of view. Adding a new unique OS to the official build and test matrix is very non-trivial cost. |
I don't think .NET should add special handling for anything UAP other than these disallowed functions, at least for now, I have tested many parts of the runtime under UWP and none of what I have tested seem to have any problems, both under CoreCLR and NAOT So I think the Is there a list of all Win32 APIs that .NET runtime (or its libraries) would use? |
This list would need to be generated by analyzing the repo source code or by analyzing binaries produced by the repo build. |
I think it's worth noting that such support will likely be needed once Unity decides to migrate from IL2CPP to NativeAOT for their XBOX support so I'd assume the discussion is really whether such support needs to be added now or in a few years when they request it. |
Unity doesn't request platform support. They're not going to request Playstation builds, for example. They have their own fork with separate build and testing. There can be overlaps in supported platforms but all of it is orthogonal. E.g. The fact that Loongson contributes loongarch support still doesn't mean we make official builds or test it. |
If one can workaround the WACK checks with See Chuyu-Team/YY-Thunks#66 where people are trying to make NativeAOT work in Windows XP, it does not seems to need a CoreCLR recompile according to the author. |
Closing this one, as no changes are actually needed. That whitelist of Win32 APIs is only applied to submissions using .NET Native, but native apps are not subject to it. And publishing a UWP app with NativeAOT is exactly identical to publishing a UWP app with C++/WinRT (or any other language). The security is enforced via the sandbox and all the other restrictions that UWP has anyway. You can declare a P/Invoke for whatever you want, and if that API is not safe, it'll just not work at runtime. TLDR: the Store will not block UWP apps using NativeAOT just because they are importing arbitrary Win32 APIs. |
Problem
Using UWP is a requirement for creating & publishing apps for Xbox without being in the XDK/ID@Xbox program, and realistically it's the only way community members can write games and apps for Xbox since they won't be approved to join the ID@Xbox program.
Currently apps compiled using NativeAOT are statically importing these Win32 functions:
While these functions work perfectly under UWP, they aren't whitelisted by Microsoft Store for UWP apps, a list of whitelisted Win32 APIs for apps that target Windows SDK 22621.755 can be found here. (explanation why this list should be used instead of docs)
Suggested solution
There's two possible ways this can be fixed:
Adding an MSBuild property that prevents NAOT from using these APIs
UseOneCoreCompatibleImports
.Adding an MSBuild property to make NAOT use dynamic loading through
LoadLibrary
andGetProcAddress
for specified set of imports instead of statically linking themKernel32.dll!
) optionalThe text was updated successfully, but these errors were encountered: