ddn.elf.io
Low-level binary I/O utilities for ELF structures.
This module provides endianness-aware reading and writing functions for ELF structures. It supports both little-endian and big-endian formats.
enum ElfEndian
struct StructRange
Types 2
enumElfEndian : ubyte
Endianness enumeration for ELF files.
ELF files can be either little-endian or big-endian, independent of host system's native endianness. These values match the ELF specification.
LITTLE = 1Little-endian byte order (least significant byte first)
BIG = 2Big-endian byte order (most significant byte first)
structStructRange(T)
Input range for iterating over packed structs in a byte array.
This range provides lazy iteration over packed structs stored in a byte array.
Functions 16
fn
ElfEndian getElfEndian(ubyte dataEncoding) pure nothrow @nogc @safeGet the ELF endianness from the ELF data encoding field.fn
ubyte getElfDataEncoding(ElfEndian endian) pure nothrow @nogc @safeGet the ELF data encoding value from an ELF endianness.fn
bool isNativeEndian(ElfEndian fileEndian) pure nothrow @nogc @safeCheck if a file endianness matches the native system endianness.fn
T swapBytes(T)(T value) if (isIntegral!T) pure nothrow @nogc @safeSwap bytes of an integral value.fn
T toNative(T)(T value, ElfEndian fileEndian) if (isIntegral!T) pure nothrow @nogc @safeConvert a value from file endianness to native endianness.fn
T fromNative(T)(T value, ElfEndian fileEndian) if (isIntegral!T) pure nothrow @nogc @safeConvert a value from native endianness to file endianness.fn
T readValue(T)(const(ubyte)[] data, size_t offset, ElfEndian fileEndian) if (isIntegral!T)Read a value from a byte array at a specified offset.fn
ubyte[] writeValue(T)(T value, ElfEndian fileEndian) if (isIntegral!T)Write a value to a byte array.fn
T readStruct(T)(const(ubyte)[] data, size_t offset, ElfEndian fileEndian)Read a packed struct from a byte array.fn
T[] readArray(T)(const(ubyte)[] data, size_t offset, size_t count,
ElfEndian fileEndian)Read an array of structs from a byte array.fn
bool isElfMagic(const(ubyte)[] data) pure nothrow @nogc @safeCheck if a byte array starts with the ELF magic number.fn
string readString(const(ubyte)[] data, size_t offset)Read a null-terminated string from a byte array.fn
StructRange!T iterateStructs(T)(const(ubyte)[] data, ElfEndian endian) pure nothrow @nogc @safeCreate a range for iterating over packed structs in a byte array.