Module refinery.lib.dotnet

A library to parse .NET headers and metadata.

Expand source code Browse git
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A library to parse .NET headers and metadata.
"""


def integer_from_ldc(ins: bytes):
    """
    This function parses an integer value from the bytes representing an LDC instruction.
    """
    if len(ins) == 1:
        return ins[0] - 0x16
    if ins[0] == 0x1F:
        return ins[1]
    return int.from_bytes(ins[1:], 'little')

Sub-modules

refinery.lib.dotnet.deserialize

Deserialization of .NET data which was serialized using BinaryFormatter …

refinery.lib.dotnet.header

Parsing of the .NET header. The code is based on the description in [1] …

refinery.lib.dotnet.resources

Parsing of managed .NET resources, which are .NET resource directories which begin with the magic sequence 0xBEEFCACE. These resources can contain …

refinery.lib.dotnet.types

These definitions in this module are used across the other modules in the .NET parsing library.

Functions

def integer_from_ldc(ins)

This function parses an integer value from the bytes representing an LDC instruction.

Expand source code Browse git
def integer_from_ldc(ins: bytes):
    """
    This function parses an integer value from the bytes representing an LDC instruction.
    """
    if len(ins) == 1:
        return ins[0] - 0x16
    if ins[0] == 0x1F:
        return ins[1]
    return int.from_bytes(ins[1:], 'little')