dnpy
A pure-Python library for parsing .NET assemblies. It reads PE files containing ECMA-335 metadata and CIL bytecode, and exposes them through a typed object model.
The current focus is reading. Writing assemblies back to disk is deliberately out of scope until the read path is fully hardened
Installation
pip install dnpy
Quick start
from dnpy import Module
module = Module.from_path("MyAssembly.exe")
if module.assembly:
a = module.assembly
print(f"{a.name} v{a.major_version}.{a.minor_version}.{a.build_number}.{a.revision_number}")
for type_def in module.types:
print(type_def.full_name)
for method in type_def.methods:
print(f" {method.name}")
for instruction in method.instructions:
print(f" {instruction}")
Module.from_bytes(data) is also available for in-memory binaries.
Documentation
The docs/ directory has longer-form material:
- Getting started – installation, the first script, and recipes for the most common tasks.
- Architecture – how a
Moduleis layered on top of the PE file, metadata streams, tables, and heaps. - Walking IL – the instruction stream, branch targets, exception handlers, and operand resolution.
- API reference – the public surface of the
dnpy.Module,TypeDef,MethodDef, and friends.
Out of scope
The following are not implemented:
- Writing or modifying assemblies
- Reading PDB /
.pdbsymbol files - Strong-name signing or verification
- Decompilation back to C#
License
MIT. See LICENSE.
Metadata
Release files for dnpy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dnpy-1.0.0.tar.gz | 65.3 kB | Without provenance | Details for dnpy-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dnpy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for dnpy-1.0.0-py3-none-any.whl |
Total release size: 132.7 kB
Release files / dnpy-1.0.0.tar.gz
| Download URL | dnpy-1.0.0.tar.gz |
|---|---|
| Size | 65.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
953d919ed0fb0745a07852f3150674c3cb727f61a4b719741b511729f2e80801
|
|
BLAKE2b-256 checksum How to use checksums |
9574893a23837dc54ef759d1fbfd50dc47a3852c7c25ccad6382b356596aa860
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.8
|
Release files / dnpy-1.0.0-py3-none-any.whl
| Download URL | dnpy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 67.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdd1996359fa7f7e97ea425c783b98adf4fa27692d866821bab5d5429eca58e0
|
|
BLAKE2b-256 checksum How to use checksums |
d9faf6cef6aa0c17e53b27f60ae854d3ca3f1917e7abee54f8eaa6e5d359aa06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.8
|
Security for dnpy 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.