Files
faumaray bba5c8a39a initial commit
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
2026-05-22 02:40:32 +03:00

61 lines
1.8 KiB
C++

#pragma once
#include "format/reloc_ir.hpp"
#include <cstdint>
#include <string>
#include <vector>
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<std::uint8_t> code; // [.text] + [.rdata] blob
std::vector<WinExportedSymbol> exports;
std::vector<voidlibc::format::RelocEntry> relocs;
std::vector<WinInternalSymbol> internal_symbols;
std::vector<WinImportedSymbol> imports;
std::vector<std::uint8_t> data_blob; // [.data] + [.bss]
std::vector<WinDataSymbol> data_symbols;
std::string dll_name; // suggested file name
};
struct PeSynthOutput {
std::vector<std::uint8_t> 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