-
Notifications
You must be signed in to change notification settings - Fork 130
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
Adding a single exports section causes 2 sections to be added. #588
Comments
Thanks for the catch. #589 has a potential fix. If you could verify this is indeed solving the issue of duplicated export directories then that would be great. (Build artifacts: https://github.com/Washi1337/AsmResolver/actions/runs/11217464280/artifacts/2024294167) As a note: The constructor string parameter of |
Note that data directories are not necessarily bound to a specific section with a specific name. Sections can be named anything, it has zero effect on the runtime behavior of the PE from the Windows PE loader's perspective. The constructor argument of If you really need it to be in // Open file.
var file = PEFile.FromFile("file.dll");
// Create new exports dir.
var newDirectory = new ExportDirectory("file.dll");
newDirectory.Entries.Add(new ExportedSymbol(new VirtualAddress(0x3000), "MyExport"));
// Create new exports buffer (this ensures the directory is reconstructed into a new segment buffer).
var newExportsBuffer = new ExportDirectoryBuffer();
newExportsBuffer.AddDirectory(newDirectory);
// Add the buffer to a new section.
var newSection = new PESection(
".edata",
SectionFlags.MemoryRead | SectionFlags.ContentInitializedData,
newExportsBuffer
);
// Add the section.
file.Sections.Add(newSection);
// Recalculate all offsets.
file.AlignSections();
// Update the export data dir in the optional header.
file.OptionalHeader.SetDataDirectory(DataDirectoryIndex.ExportDirectory, newExportsBuffer);
// Save file.
file.Write("file.output.dll"); |
Closing this as solved, will be present on nightly nuget shortly and in 6.0.0. |
AsmResolver Version
6.0.0-beta.1
.NET Version
Net Framework 4.8
Operating System
Windows
Describe the Bug
I am trying to append a export section to an existing dll.
When I run the code because I was expecting a ".edata" exports section in the final dll.
How To Reproduce
Run the code above on an existing dll.
Expected Behavior
single .edata section should be present in the final output.
Actual Behavior
Instead I see sections named like ".auxtext" and ".auxdata" which seem to be duplicates.
Additional Context
No response
The text was updated successfully, but these errors were encountered: