The DotNetPELib library is written in C++ and may be used to generate and/or read the contents of .NET assemblies. It has support for most aspects of the ECMA-335 standard for CIL assemblies, which specifies the formats used in .NET 2.0, but may also be used for later versions of .NET. The reference
MSIL C compiler exercises most aspects of the library
Some of the features of the library include:
- Memory management
- Ability to create an arbitrary container heirarchy consisting of multiple nested namespaces and classes
- Support for loading and referencing members of external assemblies
- Support for finding things in external assemblies
- Support for iterating through assemblies, e.g. to be able to import symbol tables
- Support for C# enumerations
- Support for C#-style 'varargs'
- Support for C# arrays. Multidimensional arrays aren't 100% supported by the library but can be added after the fact.
- Support for C# Properties
- Support for SEH
- Support for all MSIL instructions and data types, including strings
- Support for 'boxed' data types
- Support for PInvokes
- Various optimizations of the MSIL code, and sanity checks for use diagnosing generated code
- Support for either binary output, ILASM source files, or simple object files
- Support for EXE and DLL files output
- Support for reading Strong Name key files and signing assemblies
- Support for analyzing Custom Attributes found in an external assembly
- Support for creating and importing properties
- Support for setting packing and size of classes, and explicit offsets of fields (can support union-like constructs)
- Support for object files
- A simple linker to link object files
- Written using features of C++11
- Documentation in HTML format
This library is hosted on Github.
A CodeProject article written by Alexandre Bencz discusses the library in some depth. There is also an example program called 'test.exe' distributed with the library, which shows how to make several small executables using the library.
This library is released on December 20, 2020 at version 3.0.3
Product | SHA256 Checksum | Size |
Zip file (sources) |
ff3457139d4f7135242fcfe1973726d750e835bb60305e11eafdab6f8b9570bf
| 250KB |