{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MacOS Executable Header and Data Handler" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from rich.console import Console\n", "from rich.table import Table\n", "\n", "from byteclasses.handlers.executables.mach import Mach64, MachHdr64\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.mach-o\", \"rb\") as file:\n", " data = file.read()\n", "mach64_hdr = MachHdr64()\n", "mach64_hdr.attach(memoryview(data))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(mach64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(mach64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "collection_table(mach64_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mach64 = Mach64(data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "table = Table(title=\"Mach64 Handler\")\n", "\n", "table.add_column(\"Name\")\n", "table.add_column(\"Value\")\n", "\n", "table.add_row(\"len(mach64)\", str(len(mach64)))\n", "table.add_row(\"str(mach64)\", str(mach64))\n", "table.add_row(\"repr(mach64)\", repr(mach64))\n", "table.add_row(\"mach64.data\", str(mach64.data))\n", "table.add_row(\"mach64.hdr\", str(mach64.hdr))\n", "table.add_row(\"mach64.magic\", str(mach64.magic))\n", "table.add_row(\"mach64.cpu_type\", str(mach64.cpu_type))\n", "table.add_row(\"mach64.cpu_subtype\", str(mach64.cpu_subtype))\n", "table.add_row(\"mach64.filetype\", str(mach64.filetype))\n", "table.add_row(\"mach64.num_cmds\", str(mach64.num_cmds))\n", "table.add_row(\"mach64.cmd_size\", str(mach64.cmd_size))\n", "table.add_row(\"mach64.flags\", str(mach64.flags))\n", "\n", "console = Console()\n", "console.print(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 }