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

Does Native AOT support exporting apis by serial number? #110979

Open
Gaoyifei1011 opened this issue Dec 28, 2024 · 4 comments
Open

Does Native AOT support exporting apis by serial number? #110979

Gaoyifei1011 opened this issue Dec 28, 2024 · 4 comments
Labels
area-NativeAOT-coreclr question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner

Comments

@Gaoyifei1011
Copy link

Does Native AOT support exporting apis by serial number?

--------------------------

Native AOT 支持以序号导出 API 吗?


c++ generated Native DLLS can support ordinal export, such as Uxtheme.dll 135 API, 136 API used as the default right-click menu dark theme.

--------------------------

c++ 生成的 Native dll 可以支持以序号导出,比如 Uxtheme.dll 的 135 API,136 API 用作为默认右键菜单的深色主题。


[LibraryImport(Uxtheme, EntryPoint = "#135", SetLastError = false), PreserveSig]
public static partial void SetPreferredAppMode(PreferredAppMode preferredAppMode);

[LibraryImport(Uxtheme, EntryPoint = "#136", SetLastError = false), PreserveSig]
public static partial void FlushMenuThemes();
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 28, 2024
@teo-tsirpanis teo-tsirpanis added question Answer questions and provide assistance, not an issue with source code or documentation. area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 28, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

@hez2010
Copy link
Contributor

hez2010 commented Dec 28, 2024

You can manipulate the exports file by yourself with MSBuild, and update it before the NativeAOT compiler calls the linker.
For example:

  <Target Name="ReadExportsFile" BeforeTargets="LinkNative" DependsOnTargets="IlcCompile">
    <ReadLinesFromFile File="$(ExportsFile)">
      <Output TaskParameter="Lines" ItemName="_ExportsFileContent" />
    </ReadLinesFromFile>
  </Target>

  <Target Name="WriteExportsFile" BeforeTargets="LinkNative" DependsOnTargets="ReadExportsFile">
    <ItemGroup>
      <_ExportsFileContent Remove="Foo" />
      <_ExportsFileContent Include="Foo @42" />
    </ItemGroup>
    <WriteLinesToFile File="$(ExportsFile)" Lines="@(_ExportsFileContent)" Overwrite="True" />
  </Target>

Verify with dumpbin:

    ordinal hint RVA      name

         43    0 000DE380 DotNetRuntimeDebugHeader = DotNetRuntimeDebugHeader
         42    1 00001430 Foo = Foo

@KalleOlaviNiemitalo
Copy link

That WriteExportsFile target looks like the duplicate file write BuildCheck dotnet/msbuild#9881 dotnet/msbuild#10184 should warn about it.

@hez2010
Copy link
Contributor

hez2010 commented Dec 29, 2024

That WriteExportsFile target looks like the duplicate file write BuildCheck dotnet/msbuild#9881 dotnet/msbuild#10184 should warn about it.

Nope. The exports file was originally not written by an MSBuild target. Instead, it was written by ilc directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

4 participants