{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Windows Executable Header and Data Handler" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from byteclasses.handlers.executables.pe import DOSHdr, NTHdr32\n", "from byteclasses.print import byteclass_info, byteclass_inspect" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with open(\"../../../tests/data/hello_world.pe\", \"rb\") as file:\n", " data = file.read()\n", "dos_hdr = DOSHdr()\n", "dos_hdr.attach(memoryview(data))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(dos_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(dos_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nt32_hdr = NTHdr32()\n", "nt32_hdr.attach(data[dos_hdr.e_lfanew.value :])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(nt32_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(nt32_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(nt32_hdr.file_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(nt32_hdr.file_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(nt32_hdr.opt_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(nt32_hdr.opt_hdr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_info(nt32_hdr.opt_hdr.data_directory)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "byteclass_inspect(nt32_hdr.opt_hdr.data_directory)" ] } ], "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 }