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

Unmanaged exports in AsmResolver.DotNet #178

Closed
Washi1337 opened this issue May 21, 2021 · 0 comments
Closed

Unmanaged exports in AsmResolver.DotNet #178

Washi1337 opened this issue May 21, 2021 · 0 comments
Labels
dotnet Issues related to AsmResolver.DotNet enhancement pe Issues related to AsmResolver.PE
Milestone

Comments

@Washi1337
Copy link
Owner

Washi1337 commented May 21, 2021

Problem Description

The CLR supports exporting managed methods as unmanaged functions that can be referenced by other native binaries or being P/Invoked. Currently, there is no way in AsmResolver.DotNet to specify that a MethodDefinition should be exported.

Proposal

Add a property to MethodDefinition that indicates the method should be exported or not. The ManagedPEImageBuilder would then add the appropriate VTable fixup and export directory entries to the image.

This could look something like the following:

MethodDefinition method = ...

// Indicate method should be exported by name.
method.ExportInfo = new UnmanagedExportInfo
{
   Name = "MyExportedFunctionName",
};

// Indicate method should be exported by ordinal.
method.ExportInfo = new UnmanagedExportInfo
{
   Ordinal = 1234,
};

Alternatives

Users of AsmResolver could first transform the ModuleDefinition they are working with to a PEImage first, to then manually create and add the appropriate VTable fixup and export directory entries before writing it to the disk. This adds a lot of noise to the code, which is something we want to solve with this proposal.

Additional context

Requires #63, #179

@Washi1337 Washi1337 added enhancement pe Issues related to AsmResolver.PE dotnet Issues related to AsmResolver.DotNet labels May 21, 2021
@Washi1337 Washi1337 added this to the 4.7.0 milestone May 26, 2021
@Washi1337 Washi1337 modified the milestones: 4.7.0, 4.8.0 Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Issues related to AsmResolver.DotNet enhancement pe Issues related to AsmResolver.PE
Projects
None yet
Development

No branches or pull requests

1 participant