{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 64-bit Elf Header and Data Handler" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from rich import print\n", "from rich.console import Console\n", "from rich.table import Table\n", "\n", "from byteclasses.handlers.executables.elf import Elf64, ElfHdr64\n", "from byteclasses.print import byteclass_info, byteclass_inspect, collection_table" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with open(\"../../../tests/data/hello_world.elf\", \"rb\") as file:\n", " data = file.read()\n", "elf64_hdr = ElfHdr64()\n", "elf64_hdr.attach(memoryview(data))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(elf64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(elf64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "collection_table(elf64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "elf64 = Elf64(data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "table = Table(title=\"Elf64 Handler\")\n", "\n", "table.add_column(\"Name\")\n", "table.add_column(\"Value\")\n", "\n", "table.add_row(\"len(elf64)\", str(len(elf64)))\n", "table.add_row(\"str(elf64)\", str(elf64))\n", "table.add_row(\"repr(elf64)\", repr(elf64))\n", "table.add_row(\"elf64.data\", str(elf64.data))\n", "table.add_row(\"elf64.hdr\", str(elf64.hdr))\n", "table.add_row(\"elf64.type\", str(elf64.type))\n", "table.add_row(\"elf64.machine\", str(elf64.machine))\n", "table.add_row(\"elf64.version\", str(elf64.version))\n", "table.add_row(\"elf64.entry\", str(elf64.entry))\n", "table.add_row(\"elf64.prog_hdr_offset\", str(elf64.prog_hdr_offset))\n", "table.add_row(\"elf64.section_hdr_offset\", str(elf64.section_hdr_offset))\n", "table.add_row(\"elf64.flags\", str(elf64.flags))\n", "\n", "console = Console()\n", "console.print(table)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(elf64.program_table)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(elf64.section_table)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }