-
Notifications
You must be signed in to change notification settings - Fork 127
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
Mixed Mode / Unmanaged PE File Builders #554
Conversation
The current implementation works, except for one limitation. As it stands now, the new PE builder injects small chunks of native code to trampoline slots in the original IAT and VTable fixup tables to their newly added counterparts (based on the idea in this blog post). This works really well for functions and has been tested thoroughly. However, functions are not the only type of symbol that can be imported using the IAT: Global variables (such as One way to still support binaries that import global variables is to let the newly constructed PE file manually initialize these original IAT entries based on our new IAT. This requires injecting some additional native code (executed after the new IAT has been initialized by the Windows PE loader but before the PE's entry point is actually called) that copies the populated entries of our new IAT to the old IAT. Some open problems with this:
|
Includes:
PEFileBuilderBase
into a commonPEFileBuilder
facilitating the general rebuilding of all data directories in a PE. New PE file builders now only have to decide on final section layout as a bare minimum.ManagedPEFileBuilder
toAsmResolver.PE.Builder
.UnmanagedPEFileBuilder
for rebuilding mixed-mode assemblies or fully native PE files based on a base image.TrampolineTableBuffer
for building code trampolines for IATs and VTable fixups.Platform::CreateAddressTableInitializer
to create platform-specific dynamic IAT initializers.IPEImage::PEFile
andIPEImage::ToPEFile
.SegmentPatch
, allowing for entire segments to be written as a patch.IPatch::UpdateOffsets
.DataDirectory.CreateForSegment(ISegment)
.AsmResolver.PE.DotNet.Builder
namespace.Bugfixes:
FieldRvaDataReader
now correctly skips types with custom modifiers in field size determination.OptionalHeader::SetDataDirectory
now ensures that all data directories are present.