pe_assembler/types/nt/
mod.rs1use byteorder::{LittleEndian, ReadBytesExt};
2use gaia_types::GaiaError;
3use serde::{Deserialize, Serialize};
4use std::io::{Read, Seek, SeekFrom};
5
6#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
11pub struct NtHeader {
12 pub signature: u32,
14}
15
16impl NtHeader {
17 pub fn read<R>(mut reader: R) -> Result<Self, GaiaError>
25 where
26 R: Read,
27 {
28 let signature = reader.read_u32::<LittleEndian>()?;
29 Ok(NtHeader { signature })
30 }
31
32 pub fn read_at<R, E>(mut reader: R, offset: u64) -> Result<Self, GaiaError>
33 where
34 R: Read + Seek,
35 {
36 reader.seek(SeekFrom::Start(offset))?;
37 Self::read(reader)
38 }
39}
40
41impl Default for NtHeader {
42 fn default() -> Self {
43 Self {
44 signature: 0x00004550,
46 }
47 }
48}