A library for reading .NET modules
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dnpy-1.0.0.tar.gz.
File metadata
- Download URL: dnpy-1.0.0.tar.gz
- Upload date:
- Size: 65.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
953d919ed0fb0745a07852f3150674c3cb727f61a4b719741b511729f2e80801
|
|
| MD5 |
065cc535bf18605aea8a9795251fe3cc
|
|
| BLAKE2b-256 |
9574893a23837dc54ef759d1fbfd50dc47a3852c7c25ccad6382b356596aa860
|
File details
Details for the file dnpy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dnpy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 67.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdd1996359fa7f7e97ea425c783b98adf4fa27692d866821bab5d5429eca58e0
|
|
| MD5 |
1ec80b7822a3e1afb7d900b22f2926e0
|
|
| BLAKE2b-256 |
d9faf6cef6aa0c17e53b27f60ae854d3ca3f1917e7abee54f8eaa6e5d359aa06
|