AsmResolver Versions Save

A library for creating, reading and editing PE files and .NET modules.

v4.11.1

2 years ago

Note: v4.11.x is very likely the last minor version bump for version 4 of AsmResolver. We will be working on version 5.0, which will include some breaking changes. There might be a few hotfixes before 5.0 will be merged into master, but no more new features will be introduced until the next major version bump.

Bug Fixes

  • Fixed an issue where the full name of methods include generic parameter brackets even if the method didn't have generic parameters
  • Fixed a signature comparison issue where nested types with the same name but different declaring types were considered equal (#318, #319)

See full change log of 4.11.0

v4.11.0

2 years ago

Note: this is very likely the last minor version bump for version 4 of AsmResolver. We will be working on version 5.0, which will include some breaking changes. There might be a few hotfixes before 5.0 will be merged into master, but no more new features will be introduced until the next major version bump.

New Features

  • Add ModuleDefinition.DefaultImporter reference importer (#302)
  • Add convenience factory methods for building up and importing new type and member references directly from IResolutionScope and ITypeDefOrRef instances (#303, #312)
  • The possibility to define symbols that are local to a single native method body (#305, #310).
  • Add support for 64-bit address relocations in native method bodies (d7e11c89b6808ddd618ee7db29155467bf88b6d6)
  • Reduced boxing of row structures in metadata tables (46f4d09c76a9cf45d2a1a32e6c7becbd1437a333)
  • Updated System.Text.Json to 6.0.4 (#313)

Bug Fixes

  • Fixed a race condition that would result in collections such as type.Methods and type.Fields being initialized incorrectly when accessed from multiple threads at the same time (#299, #300)
  • Fixed an issue where importing an instance field via System.Reflection produced a member reference with an invalid signature (#307, #308)
  • Fixed an issue where MethodSignature.CreateStatic and MethodSignature.CreateInstance would not set the Generic flag in its header when a non-zero generic parameter count was provided (b12957d4cdecdb0626c97598cdfcca26c57281a4)
  • Names of MethodDefinition are now properly stored as Utf8Strings instead of string (e888e433220d7f1fedf8053d1d3b8cd897244cbe)
  • MethodDefinition::FullName() and MemberReference::FullName() now include any generic parameters defined in their signatures (bffed664253f3eb1a1247aa913f4b6d2bf5e17df).

v4.10.0

2 years ago

New Features

  • Read/write support for End-of-File (EOF) data in PEFile (#284).
  • Read/write support for bundled and fully self-contained .NET applications (#246, #279).
  • MemberCloner now allows for customizing the behavior of the underlying reference importer, and now redirects System.Object from other .NET framework versions by default. This can be useful e.g. for cloning members into modules targeting a different .NET framework version (#93, #280, #283, thanks @ds5678).
  • Various metadata models now implement IImportable, which defines an IsImportedInModule convenience method.
  • PropertyDefinition and EventDefinition now define a SetSemanticMethods method for attaching new get/set/add/remove/fire methods easily (#168, #286, thanks @ds5678)
  • AsmResolver, AsmResolver.PE.File, AsmResolver.PE and AsmResolver.Win32Resources are now trimmable packages (#287, thanks @ds5678).
  • Various small performance improvements (#278)

Bug Fixes

  • Fixed an issue where importing a nested type definition would not properly import the parent type (#273, #275)
  • Fixed an issue where importing complex type signatures would not be fully imported in some scenarios (#268, #274)
  • Fixed a concurrency issue in DefaultMetadataResolver (#270, thanks @SamboyCoding)
  • Fixed an issue in .NET Core installation folder detection on UNIX systems (fb3516a097021a559c3c6127cba3342e6fd1ec37)

Community

  • We opened a Discord server. See #291.

v4.9.0

2 years ago

New Features

  • Add .NET 7.0 file support (#256, thanks @ds5678)
  • Add .NET Core 3.1 and .NET 6.0 build targets for additional performance (#266).
  • Add DataBlobSignature.FromValue and Constant.FromValue factory methods (#244, thanks @ds5678)
  • Add MakeGenericInstanceMethod helper method (5b49ddc65a51aa2fdd877af831fc1a718f1dc421)
  • Method bodies that could not be parsed (e.g. native entry points) are now represented using UnresolvedMethodBody (#255).
  • Add CilInstruction.ReplaceWith and CilInstruction.ReplaceWithNop helper methods (#259).
  • Various performance improvements in CilAssembler, looking up serialized metadata members, and other places (#260, #261, 826157feb131a461f317f6990240328272f1f7be, #265).
  • Bumped package version of System.Text.Json to 6.0.2 (#258, thanks @ds5678)

API Deprecations

  • FieldSignature.CreateInstance and FieldSignature.CreateStatic are deprecated. Use the constructor of FieldSignature or FieldDefinition instead.

Bug Fixes

  • Fixed an issue where duplicated metadata members would not be preserved by the metadata builder, even with PreserveAll enabled (#252 , #253)
  • Fixed an issue where custom attributes using arguments such as typeof(object) caused the resolution scope of CorLibTypeSignatures to be removed from the list of imported assemblies (#263, #264).
  • TypeNameParser now correctly reuses the AssemblyReference instances that were imported into the parent module if available.
  • Creating new modules no longer adds the corlib assembly reference twice to ModuleDefinition.AssemblyReferences.

v4.8.0

2 years ago

New Features

  • .NET 6.0 CorLib support (#228, thanks @ds5678)
  • Read/Write support for resource sets stored in .resources manifest resource files (#169, #216)
  • Read/Write support TLS data directories (#207, #218)
  • The concept of target platforms, represented by Platform classes. These are architecture specific services such as creating unmanaged thunk stubs. This simplifies the builder API a lot and removes the need for all BootstrapperSegment classes. Built-in support for i386 and AMD64 architectures.
  • Read/Write support for method definitions that are exported by a PE header export entry (#178, #179, #230).
  • Undocumented OS masks to MachineType (0149d5fb536256777b3f33573f3254d4c7584f2f).
  • ModuleDefinition.FromModule convenience method to load a module from a System.Reflection.Module instance (#233, #234).
  • Various convenience Win32 resource directory traversal methods (#220)
  • GenericContext now supports partial resolution of generic parameters within signatures + GenericContext.FromXXX convenience methods (#225, thanks @JPaja).
  • BlobStream, StringsStream, UserStringsStream and GuidStream now come with a TryFindXXXIndex method for finding an index of an existing blob (#227, #229).
  • XML documentation for all CIL opcodes (#231, thanks @ds5678).
  • Reduced the use of seeking in the output file when writing large .NET modules (#232).

Bug Fixes

  • Fixed an issue where FieldDefinition.IsAccessibleFromType returned the wrong result when the declaring type was accessible (#217, thanks @ElektroKill)
  • Fixed an issue where TypeNameBuilder did not parse generic type arguments properly (#222, #223, thanks @JPaja).
  • Fixed an issue where a CustomAttribute with a null argument on a System.Type parameter would parse incorrectly (#224).
  • Fixed an issue where DotNetDirectoryFlags.ILLibrary was incorrectly used to identify whether the output file needs an entrypoint or not (2b32f3089a38687a2521f37e5e27b6f6af6ddbc5)
  • Fixed an issue where AssemblyDefinition.Write would not work properly when providing a relative path as output file path (#238, thanks @ds5678)
  • Fixed an issue regarding the selection of GAC directories during assembly resolution (#240, #242)
  • Fixed an issue regarding method resolution that do not use the HideBySig flag (e.g. in modules written in VB.NET) (#241, #243)

v4.7.1

2 years ago

For the remainder of the change log of 4.7.x, refer to 4.7.0

Bug fixes

  • Fixes an issue with invalid string offsets being calculated as a result of using multibyte UTF-8 code-points.
  • Assume explicitly typed CA arguments are enum types if they cannot be resolved.
  • Fixes an issue where EndLabel was not considered during the label verification of a CIL body.
  • Fixes an issue where mscoree.dll was not included as module import in the build process when the binary targeted the i386 machine type.
  • Adds missing NRT annotations in GenericContext.

v4.7.0

2 years ago

New Features

  • C#9.0 Nullable Reference Type (NRT) Annotations for all main packages of AsmResolver (#132, #185, #186, #188, #189).
  • Add implementations for ImpHash and TypeRefHash, which are used by many AV companies and other vendors to identify malware families based on imported symbols and type references (#195, #199, thanks @evandrix).
  • Preservation of names with invalid UTF-8 byte sequences in .NET metadata (#200, #201).
  • String folding in #Strings stream, resulting in smaller output files (#192, #204).
  • Metadata tables and rows are now fully mutable. Rows in a table can now be accessed and updated by reference using the new MetadataTable<TRow>.GetRowRef method.
  • Memory consumption reduced for some of the core reader methods.
  • DefaultMethodBodyReader.ReadMethodBody is now marked virtual (#190, thanks @CursedLand).
  • Add MethodSignature.ReturnsValue convenience property (#183, thanks @CursedLand).
  • Add AssemblyDefinition.HasManifestModule convenience property (b925d5b934aa01d24e9d727f5963d5f8b149a3af).

Bug fixes

  • Fixed an issue where an invalid FieldRVA value would crash AsmResolver's metadata parser, regardless of whether EmptyErrorListener was provided in the module reader parameters (#184).
  • Fixed an issue where the TokenAllocator would incorrectly assign tokens to members, resulting in conflicting RIDs being used in the final assembly (#187).
  • Fixed an issue where stack behavior would be computed incorrectly for method calls with a modreq or modopt modifier added to their return type (#193, thanks @zsr2531).
  • Fixed an issue where both the file offset and RVA were incorrectly set to zero for the metadata directory and structures within this data directory (#194).
  • Fixed various custom attribute type name parsing issues regarding whitespaces (af36ad8952859b6a1c99edd16f17a7e2b1a43906).
  • Fixed an issue where RVAs in base relocation blocks were not calculated properly (5f0770752026d3e31622deb02fefcdac0b00d21b)
  • Fixed an issue where incorrect GetHashCode implementations were used in SignatureComparer, resulting in random hash codes for some types of metadata members (706f5b0ae5c8c9e2b32cb279b1d95fcb43825270).
  • Fixed an issue where an empty exports directory with zero exported symbols would let AsmResolver believe it is an invalid export directory (b2dde79b8b0f4b2e430fa2010f911367b8d2b795)
  • Various null checks added and overall stability improvements.

v4.6.0

3 years ago

New Features:

  • Replace IBinaryStreamReader classes with stack allocated BinaryStreamReader structs, reducing memory consumption by up to 40% (#136, #166).
  • Added concept of IFileServices and IInputFiles. This allows for memory mapped I/O on input binaries as well as caching of previously read PE files. This vastly reduces the memory consumption on reading large PE files and resolving dependent dll files (#115, #174).
  • Revisited representation of raw CIL method bodies, which reduces the memory consumption of the reader significantly when dealing with large method bodies that have megabytes worth of code in them (#171, #180)
  • Add rich read/write support for VTable entries in the .NET data directory (#63, #173, thanks @Anonym0ose)
  • Add support for reading PEs and modules from a HINSTANCE / module base address (#177).
  • Add read/write support for function pointer (FnPtr) type signatures (#167, #172)
  • Add shortcut method MethodSignature.MakeFunctionPointerType (655adc89f1019fd03ca4ffe78cbf49eb3529b047)
  • Add shortcut method BlobSignature.MakeStandAloneSignature (08e510e4ff04cfa876299cc512e124b93b86828c)
  • Add ManifestResource.GetReader method (#161, thanks @JPaja).
  • Add PropertyAttributes.None (#170, thanks @oSumAtrIX)
  • Add support for unmanaged calling convention method signatures (a58b4c95f2ede51488f6e1f64e5c2b3afe1b67e9)
  • Add support for managed entrypoints defined in a separate child module (975bda9fc741f2e1eed9731de38252c35338006a)
  • Various improvements in reader and writer diagnostics.

Bug Fixes:

  • Importing corlib TypeDefinitions as signature now properly converts to CorLibTypeSignature instances instead of TypeDefOrRefSignature (#160)
  • Fixed a bug where a NullReferenceException would be thrown when trying to resolve .NET Core dependencies, while running AsmResolver using a .NET Framework host (695235e98c3de684ca496424d178a9555ac3516b).
  • Set default hash algorithm for assemblies to SHA1, preventing all kinds of problems with invalid / incomplete metadata (a9f5eda3c8983ec5dcc20834e0d3332c04eec6d5)
  • Fixed incorrect column type in MethodSpec's Method column (afcb7a169c2a86977e4e435e72164abd8de8347b).
  • Fixed an error where the scope of a parsed type from string was not set properly if the type refers to a type in the same module (d18fa6719d5836cea2b59561f63c85b9bde8adc8).
  • Fixed a bug where OptimizeMacros would crash if the unaligned prefix opcode was present in the method body (7b8e2691934cf7ca951c27c578834437e68709dd).
  • Fixed a bug where ldc.i4.s and similar instructions would have the wrong operand set after calling Add(CilOpCode, int) (ad77103180856febc3eab87c2c1fe2fe4a12d441)
  • Fixed a bug where certain new metadata members (e.g. type references) that were manually assigned a metadata token using the TokenAllocator would not appear in the final binary (#175, #176).
  • Fixed a bug where assembly linked resources would be parsed incorrectly and throw exceptions on writing (7fe14d5cdf363c2b1b915d1948a12f7aa1302438)

v4.5.1

3 years ago

Removes the redundent xunit dependency from AsmResolver.DotNet (Thanks @HoLLy-HaCKeR)

For full change log of 4.5.x, check the change log of 4.5.0.

v4.5.0

3 years ago

New Features

  • Automatic detection of .NET Core / .NET 5+ installation folders (#105)
  • Add support for .NET Core / .NET 5+ runtimeconfig.json file parsing and interpretation (#137).
  • Significant improvements in assembly and member resolution (#104)
  • Add RSDS CodeView Debug Data read/write support (#140, thanks @dr4k0nia)
  • Add final token mapping as an artifact of the module serialization. This allows for easy lookup of members in the constructed PEImage for post processing (#121 #148).
  • Add TypeMemoryLayout.IsPlatformDependent flag to easily determine whether a memory layout is dependent on the bitness of the environment (#143 #153)
  • Add better CIL assembler/disassembler diagnostics, allowing for better support of invalid instruction streams without crashing the main readers/writers of AsmResolver (fb31c424af7267aec05d4a55e02a1c68f252ec66)
  • Add ICilOperandResolver to CilDisassembler.
  • Significant performance improvements in CIL disassembling, making it possible to easily parse 100k+ instructions per method body with less memory usage (7662a412eb6d6f649cdb41853e8ab46ec6610051).
  • Add CIL label verification, providing writer diagnostics when invalid labels exist in the method body (#146)
  • Improved CIL instruction formatting with escaped strings literals (55c81cd96bd018cea5ddd365ba8a309805855b91)
  • Add ITypeSignatureVisitor<in TSTate, out TResult> variant (#147, thanks @JPaja)
  • Add read support for x64 SEH PE data directory (#139)

Bug Fixes

  • Fixed a thread safety issue regarding reading metadata tables (#135)
  • Fixed a bug where System.Type CustomAttribute arguments with = in their full name would result in an incorrect parsing of the CA signature (460bcf22ba67e5dd9a1d2730a0cd7177a67f2548)
  • Fixed a bug where System.Type and enum typed CustomAttribute arguments that don't have a resolution scope explicitly defined, would not be looked up correctly (31fc864fc14976097d55a893ff3ca550f8d941a1)
  • Fixed a bug where TryLookupString returned false even if the string was found successfully (5fcc4d2d32330c43627ef5b249c3335376f7e20c)
  • Fixed a bug where GenericParameter.Index would not be updated before serialization to PEImage (#145, thanks @Charterino)
  • Fixed a bug where cloning instance methods with ldarg would result in the wrong operand being selected (#155, thanks @oSumAtrIX)
  • Fixed a bug with token preservation where methods and parameter list tokens were incorrectly assigned, resulting in methods (re)defining parameter definitions incorrectly (#150)