A library for creating, reading and editing PE files and .NET modules.
This is an incremental maintenance release that adds .NET 8.0 as an official target and fixes issues related to type signatures, CIL optimizations, as well as some rare edge cases in .NET metadata directory parsing.
BinaryStreamWriter::AlignRelative
(af2e49d434a6e6071a3f03f6930858207b992c08)SignatureComparer
(#512, thanks @rstarkov)ldloca
and ldarga
opcodes would not shorten to their shorter variants (9ab4e94d5e18e6c5fe373a22fcb31d9f2add3554)This version brings rudimentary low-level .NET ReadyToRun (R2R) parsing and writing to AsmResolver, allowing you to locate and read native code of precompiled managed method bodies (see documentation). Additionally, basic Span<T>
support was added to primitives like IDataSource
and Utf8String
for newer .NET runtime targets (netstandard 2.1 and above), and some new convenience APIs were added. Finally, some bugfixes were implemented, increasing general stability of the library.
Span<T>
support for IDataSource
s and Utf8String
(#483, thanks @DaZombieKiller).TypeDefinition::GetConstructor
, MethodDefinition::CreateConstructor
and similar (#480).ReferenceTable
primitive segment class, representing structures like VTables that can be directly used as a writable ISegment
.BinaryStreamReader::RemainingLength
.SegmentReference
s.netstandard2.1
target.TypeReference::IsImportedInModule
now correctly takes its resolution scope into account (#497).TypeNameParser
now correctly does not return fully imported types, but they can still be resolved using .Resolve()
(#497).MemberCloner
now correctly fixes cross-references to included System.Type
arguments in Custom Attributes (#482, #493).ZeroesDataSource
would clear out too much data in the buffer provided to ReadBytes
(thanks @DaZombieKiller)BitList
would incorrectly accept negative indices (#478).TlsCallbackCollection
, replaced with ReferenceTable
.TlsDirectory::CallbackFunctions
is now of type ReferenceTable
.IDotNetDirectory::ManagedNativeHeader
is now of the more specific segment type IManagedNativeHeader
.This release includes support for PE certificate tables, PE forwarder exports, as well as various quality of life improvements and bug fixes. Check out the documentation and the full change-log below:
NativeMethodBody
(#444, #449).ModuleReaderParameters::WorkingDirectory
(#438, #441).ExportedSymbol::IsForwarder
(#437, #440).ManagedPEFileBuilder::ErrorListener
(#468).ITypeDescriptor::Scope
to be null
and of type ModuleDefinition
. (#466)MemberCloner
(#461)DotNetRuntimeInfo::GetDefaultCorLib
and KnownCorlibs::FromRuntimeInfo
(#462)PEFile::CreateReaderAtFileOffset
now supports reading from EOF data (582142876aad038721a3f6f6969f0195f99f332a).Culture=
part of AssemblyDescriptor.FullName
was not included in the output (#458).GetImpliedMemoryLayout
would stack-overflow with unresolved generic parameter type signatures (#447, #448).ModuleReaderParameters
were not passed along correctly in ModuleDefinition::FromBytes
(bbf57811bdcfdf22a77365a8aef28795d7d7a517)This version is mostly a maintenance version with performance improvements and bug fixes. Developers of .NET obfsucators and deobfuscators will also be happy to know that ManagedPEImageBuilder
now accepts any IErrorListener
. This should make it easier to ignore any invalid metadata that is introduced to the assembly model (e.g., by passing in an EmptyErrorListener
). Finally, a migration from readthedocs to DocFX was made, giving a new home and look to the documentation. Let us know what you think of it!
IErrorListener
objects as opposed to just DiagnosticBag
s in ManagedPEImageBuilder
(#367, thanks @ds5678 for the help!).LazyVariable<TOwner, TValue>
, reducing the number of allocations made by AsmResolver's internals significantly for larger binaries (#428)Platform::Is32Bit
, Platform::Is64Bit
and Platform::PointerSize
(#430)ZeroesSegment
and ZeroesDataSource
for creating, reading and writing memory-efficient segments containing only zero bytes (#430).SignatureComparer::GetHashCode
for assembly descriptors did not respect the configuration flags passed into the constructor (#427, #429).IntPtr
and UIntPtr
typed fields (#430).OriginalFirstThunk
= 0. This is the case for many packed executables such as UPX packed binaries (#431, #432)PEImageBuildContext::DiagnosticBag
is superseded by PEImageBuildContext::IErrorListener
.PEImageBuildResult
taking a DiagnosticBag
is superseded by the one taking an IErrorListener
.IFieldRvaDataReader::ResolveFieldData
has changed slightly. See the documentation for how to use the new interface (#430).TypeSignature::IsCompatibleWith
and TypeSignature::IsAssignableTo
methods (#421)DotNetDirectory
(#422)Parameter::GetOrCreateDefinition()
(#418, thanks @ElektroKill)PdbImage
(e28df25ba827d4112e3edfebdfca980814c6a2e1)OptionalHeader::SetDataDirectory
helper method (8357a77dd4873facb5af59473e12a279dede12f7)CallingConventionSignature::CallingConvention
convenience property that masks out the used convention from Attributes
(#414)CallingConvention::NativeVarArg
(#414)MethodSignature
's sentinel parameter type preservation (#413, #414).ParameterCollection::ThisParameter
's parameter type for generic instance types (e27b6e8c2d70fb189fb409a81b676925856763bb, thanks @ElektroKill)MethodSignatureBase::GetTotalParameterCount()
for ExplicitThis
signatures (dae99095fd2df0831fae87f95722243d25a436a7, thanks @ElektroKill)BundlerParameters
are superseded by BundlerParameters::FromTemplate
and BundlerParameters::FromExistingFile
.DotNetDirectory::EntryPoint
using an uint
are obsoleted and should be replaced with a construction of a DotNetEntryPoint
structure.CallingConventionSignature::IsSentinel
(#414)DotNetDirectory::EntryPoint
from uint
to DotNetEntryPoint
DU struct.ModuleDefinition::LookupMember<T>
and ModuleDefinition::TryLookupMember<T>
methods (#392, #402)TypeDefinition::IsModuleType
(#391, thanks @sunnamed434)GetModuleType()
behavior for .NET Core / .NET 5+ modules (#395, #396)CodeSegment
is now deprecated. Use the DataSegment
combined with the new patching API for address fixups.This marks the first major version bump since the rewrite of AsmResolver. A huge thanks to all the contributors and testers. Without them this release would not have been possible!
AsmResolver.Symbols.Pdb
for reading and writing Windows PDB files using only managed code (#324, #326, #342, #368 (thanks @ds5678))IMemberClonerListener
s, allowing for automatically post-processing cloned metadata (e.g., automatically injecting it into the target module) as the cloner is cloning metadata (#333, #337, #354, thanks @CursedLand)DotNetRuntimeInfo::IsNetCoreApp
, IsNetFramework
and IsNetStandard
properties for easily identifying whether a module targets .NET Core, .NET Framework or .NET Standard (505da7a9255a96bb649023f7a36b9d628a41ad63).SignatureComparer::Default
(#366, thanks @ds5678)TypeDefinition::IsByRefLike
(#358, #362)AsmResolver.DotNet
trimmable (#304, thanks @ds5678)MetadataTable::IsSorted
property (#348)DynamicMethodDefinition
now has better support for dynamic methods that are initialized via DynamicILInfo
(b0b13c8be4a81ed56d983b57589fc00a3913288e)BinaryStreamReader
that take a byte[]
or a IDataSource
alone (54c65ee64277b42326aec54f499efc7407a4e556).OriginalMetadataTokenProvider
(#361)type.IsTypeOfUtf8
to avoid conversions from Utf8String
to string
(baf25ac0e3881e31698f0367a8ea03ce4fc0e652)SignatureComparer
immutable (#366, thanks @ds5678)class BlobReadContext
to a mutable struct BlobReaderContext
(#356, c0283c721957ddbb149a1edbfa77b16b1555ae2d).ISegment::UpdateOffsets
's method signature (#236, #346)ITlsDirectory::ImageBase
and CodeSegment::ImageBase
(#346)SegmentReference::CanUpdateOffsets
and SegmentReference::UpdateOffsets
(#346)TypeDefOrRefSignature::Type
and GenericInstanceTypeSignature::Type
(#338, thanks @JPaja)AsmResolver.DotNet.Dynamic
into a separate nuget package (#304).Entrypoint
to EntryPoint
(b6fa3edd613a0521c2fc9dbecb554605ac25706e).OptionalHeaderMagic::Pe32
and Pe32Plus
to PE32
and PE32Plus
(d954be07d8dabcbcd2e97e521342d9f6213dca2e).LazyVariable
lock on itself (16367c198a9a50470a9cb780e83038c102ebe0f7)ContinuousMetadataRange
and RedirectedMetadataRange
to a single struct MetadataRange
(3bb6b6ad33cf41b86411142a50332c0423020126)OneToManyRelation
return a ValueSet
with a struct enumerator instead of a generic ICollection
(07b09c33cbc7a98d616e64c7baed834a767e20df)MemberClonerContext::Importer
to CloneContextAwareReferenceImporter
.Utf8String
instead of string
(baf25ac0e3881e31698f0367a8ea03ce4fc0e652, 5d8cb885873d58c9af1a9f62a42e45068e4ce704).FullNameGenerator
to MemberNameGenerator
. This class has a new layout and is not API compatible with the old version (#386).MethodImplementation
now implements IEquatable<MethodImplementation>
, drastically reducing allocations and increasing performance for large binaries with lots of interface implementations (d10cf47c1eef0a7974f162285310b38df4621f3f).OneToManyRelation
now returns a ValueSet
with a struct enumerator instead of an interface (07b09c33cbc7a98d616e64c7baed834a767e20df)Utf8String
instances when resolving types and members (baf25ac0e3881e31698f0367a8ea03ce4fc0e652)Utf8String
objects in StringStreamBuffer
(533a9117b99e53ca521e30289e798ad2d67adff1)member.FullName
and reduced memory consumption by up to 70% (#386)System.Reflection
now correctly imports the declaring type. This was especially a problem when converting DynamicMethod
s to a DynamicMethodDefinition
. (#365)DynamicMethod
s initialized with DynamicILInfo
.COR_ELEMENT_TYPE_INTERNAL
types should be fixed.ldarga.s
and bge.un.s
to their correct expanded forms (#322, thanks @N78750469)MethodBase
s that use generic parameters of its declaring type in its signature should now be fixed.LPArrayMarshalDesriptor
now correctly respects signatures with a null
ArrayElementType (d9ef330187efdb1d645beb7b6193ddcd9983f9a0).endfinally
opcode correctly clears the stack during stack analysis (eb41d58f81a77f94a7cf8a8c2e49863ba64ae9c4)This quick hotfix addresses a few problems in 5.0.0-beta.1 with DynamicILInfo
initialized DynamicMethod
s. In particular:
DynamicMethod
s.COR_ELEMENT_TYPE_INTERNAL
types should be fixedMethodBase
s that use generic parameters of its declaring type in its signature should now be fixed.Note this is still a prerelease. Breaking changes can still happen until the final release. See the remainder of changelog of 5.0.0-beta.1
This marks the first major version bump since the rewrite of AsmResolver. Note that, this is still a pre-release. last-minute breaking API changes may still happen before the full release.
AsmResolver.Symbols.Pdb
for reading and writing Windows PDB files using only managed code (#324, #326, #342)SignatureComparer::Default
(#366, thanks @ds5678)TypeDefinition::IsByRefLike
(#358, #362)IMemberClonerListener
s, allowing for automatically post-processing cloned metadata (e.g., automatically injecting it into the target module) as the cloner is cloning metadata (#333, #337, #354, thanks @CursedLand)DotNetRuntimeInfo::IsNetCoreApp
, IsNetFramework
and IsNetStandard
properties for easily identifying whether a module targets .NET Core, .NET Framework or .NET Standard (505da7a9255a96bb649023f7a36b9d628a41ad63).MetadataTable::IsSorted
property (#348)DynamicMethodDefinition
now supports dynamic methods that are initialized via DynamicILInfo
(b0b13c8be4a81ed56d983b57589fc00a3913288e)BinaryStreamReader
that take a byte[]
or a IDataSource
alone (54c65ee64277b42326aec54f499efc7407a4e556).OriginalMetadataTokenProvider
(#361)SignatureComparer
immutable (#366, thanks @ds5678)BlobReadContext
a struct (#356).ISegment::UpdateOffsets
's method signature (#236, #346)ITlsDirectory::ImageBase
and CodeSegment::ImageBase
(#346)SegmentReference::CanUpdateOffsets
and SegmentReference::UpdateOffsets
(#346)TypeDefOrRefSignature::Type
and GenericInstanceTypeSignature::Type
(#338, thanks @JPaja)AsmResolver.DotNet.Dynamic
into a separate nuget package (#304).Entrypoint
to EntryPoint
(b6fa3edd613a0521c2fc9dbecb554605ac25706e).OptionalHeaderMagic::Pe32
and Pe32Plus
to PE32
and PE32Plus
(d954be07d8dabcbcd2e97e521342d9f6213dca2e).LazyVariable
lock on itself (16367c198a9a50470a9cb780e83038c102ebe0f7)ContinuousMetadataRange
and RedirectedMetadataRange
to a single struct MetadataRange
(3bb6b6ad33cf41b86411142a50332c0423020126)OneToManyRelation
return a ValueSet
with a struct enumerator instead of a generic ICollection
(07b09c33cbc7a98d616e64c7baed834a767e20df)MemberClonerContext::Importer
to CloneContextAwareReferenceImporter
.MethodImplementation
now implements IEquatable<MethodImplementation>
, drastically reducing allocations and increasing performance for large binaries with lots of interface implementations (d10cf47c1eef0a7974f162285310b38df4621f3f).OneToManyRelation
now returns a ValueSet
with a struct enumerator instead of an interface (07b09c33cbc7a98d616e64c7baed834a767e20df)System.Reflection
now correctly imports the declaring type. This was especially a problem when converting DynamicMethod
s to a DynamicMethodDefinition
. (#365)ldarga.s
and bge.un.s
to their correct expanded forms (#322, thanks @N78750469)Note: v4.11.x is very likely the last minor version bump for version 4 of AsmResolver. We are working on version 5.0, which will include some breaking changes. There might be a few more hotfixes before 5.0 will be merged into master, but no more new features will be introduced until the next major version bump.