#pragma once #include "format/reloc_ir.hpp" #include #include #include namespace voidlibc::loader::windows { struct WinExportedSymbol { std::string name; std::uint64_t code_offset; std::uint64_t size; bool is_function = true; }; struct WinImportedSymbol { std::uint32_t sym_id = 0; std::string name; std::string library; // DLL name (e.g. "KERNEL32.DLL"); "" → default ucrtbase.dll }; struct WinInternalSymbol { std::uint32_t sym_id = 0; std::uint64_t code_offset = 0; std::string name; }; struct WinDataSymbol { std::uint32_t sym_id = 0; std::uint64_t data_offset = 0; std::string name; }; struct PeSynthInput { std::vector code; // [.text] + [.rdata] blob std::vector exports; std::vector relocs; std::vector internal_symbols; std::vector imports; std::vector data_blob; // [.data] + [.bss] std::vector data_symbols; std::string dll_name; // suggested file name }; struct PeSynthOutput { std::vector bytes; // complete PE image bytes std::string error; bool ok = true; }; // Produce a minimal PE64 DLL image (IMAGE_FILE_DLL, Machine=0x8664) that // LoadLibraryEx will accept on Windows x64. Exports all symbols in // input.exports; resolves imported symbols via an IAT pointing into a // synthetic ".voidlib" import descriptor (the voidlib shim resolves these // at load time against the calling process's symbol space). PeSynthOutput synthesize_pe(const PeSynthInput& input); } // namespace voidlibc::loader::windows