Skip to main content

pe_assembler/formats/exe/writer/
mod.rs

1//! EXE file writer module
2//!
3//! This module provides the functionality to write PE structures to EXE binary files,
4//! corresponding to the reader module.
5
6use std::io::{Seek, Write};
7
8use crate::helpers::PeWriter;
9
10/// EXE file writer
11#[derive(Debug)]
12pub struct ExeWriter<W> {
13    writer: W,
14}
15
16impl<W> ExeWriter<W> {
17    /// Create a new EXE writer
18    pub fn new(writer: W) -> Self {
19        Self { writer }
20    }
21
22    /// Finish writing and return the underlying writer
23    pub fn finish(self) -> W {
24        self.writer
25    }
26}
27
28impl<W: Write + Seek> PeWriter<W> for ExeWriter<W> {
29    fn get_writer(&mut self) -> &mut W {
30        &mut self.writer
31    }
32}