1 use alloc::vec::Vec;
2 use core::fmt::Debug;
3 use core::{mem, str};
4 
5 use crate::read::coff::{parse_symbol, CoffSymbolIterator, SymbolTable};
6 use crate::read::{
7     self, Architecture, Error, FileFlags, Object, ReadError, Result, SectionIndex, Symbol,
8     SymbolIndex, SymbolMap,
9 };
10 use crate::{pe, Bytes, LittleEndian as LE, Pod};
11 
12 use super::{PeSection, PeSectionIterator, PeSegment, PeSegmentIterator, SectionTable};
13 
14 /// A PE32 (32-bit) image file.
15 pub type PeFile32<'data> = PeFile<'data, pe::ImageNtHeaders32>;
16 /// A PE32+ (64-bit) image file.
17 pub type PeFile64<'data> = PeFile<'data, pe::ImageNtHeaders64>;
18 
19 /// A PE object file.
20 #[derive(Debug)]
21 pub struct PeFile<'data, Pe: ImageNtHeaders> {
22     pub(super) dos_header: &'data pe::ImageDosHeader,
23     pub(super) nt_headers: &'data Pe,
24     pub(super) data_directories: &'data [pe::ImageDataDirectory],
25     pub(super) sections: SectionTable<'data>,
26     pub(super) symbols: SymbolTable<'data>,
27     pub(super) data: Bytes<'data>,
28 }
29 
30 impl<'data, Pe: ImageNtHeaders> PeFile<'data, Pe> {
31     /// Find the optional header and read the `optional_header.magic`.
optional_header_magic(data: &'data [u8]) -> Result<u16>32     pub fn optional_header_magic(data: &'data [u8]) -> Result<u16> {
33         let data = Bytes(data);
34         let dos_header = pe::ImageDosHeader::parse(data)?;
35         // NT headers are at an offset specified in the DOS header.
36         let nt_headers = data
37             .read_at::<Pe>(dos_header.e_lfanew.get(LE) as usize)
38             .read_error("Invalid NT headers offset, size, or alignment")?;
39         if nt_headers.signature() != pe::IMAGE_NT_SIGNATURE {
40             return Err(Error("Invalid PE magic"));
41         }
42         Ok(nt_headers.optional_header().magic())
43     }
44 
45     /// Parse the raw PE file data.
parse(data: &'data [u8]) -> Result<Self>46     pub fn parse(data: &'data [u8]) -> Result<Self> {
47         let data = Bytes(data);
48         let dos_header = pe::ImageDosHeader::parse(data)?;
49         let (nt_headers, data_directories, nt_tail) = dos_header.nt_headers::<Pe>(data)?;
50         let sections = nt_headers.sections(nt_tail)?;
51         let symbols = nt_headers.symbols(data)?;
52 
53         Ok(PeFile {
54             dos_header,
55             nt_headers,
56             data_directories,
57             sections,
58             symbols,
59             data,
60         })
61     }
62 
section_alignment(&self) -> u6463     pub(super) fn section_alignment(&self) -> u64 {
64         u64::from(self.nt_headers.optional_header().section_alignment())
65     }
66 }
67 
68 impl<'data, Pe: ImageNtHeaders> read::private::Sealed for PeFile<'data, Pe> {}
69 
70 impl<'data, 'file, Pe> Object<'data, 'file> for PeFile<'data, Pe>
71 where
72     'data: 'file,
73     Pe: ImageNtHeaders,
74 {
75     type Segment = PeSegment<'data, 'file, Pe>;
76     type SegmentIterator = PeSegmentIterator<'data, 'file, Pe>;
77     type Section = PeSection<'data, 'file, Pe>;
78     type SectionIterator = PeSectionIterator<'data, 'file, Pe>;
79     type SymbolIterator = CoffSymbolIterator<'data, 'file>;
80 
architecture(&self) -> Architecture81     fn architecture(&self) -> Architecture {
82         match self.nt_headers.file_header().machine.get(LE) {
83             // TODO: Arm/Arm64
84             pe::IMAGE_FILE_MACHINE_I386 => Architecture::I386,
85             pe::IMAGE_FILE_MACHINE_AMD64 => Architecture::X86_64,
86             _ => Architecture::Unknown,
87         }
88     }
89 
90     #[inline]
is_little_endian(&self) -> bool91     fn is_little_endian(&self) -> bool {
92         // Only little endian is supported.
93         true
94     }
95 
96     #[inline]
is_64(&self) -> bool97     fn is_64(&self) -> bool {
98         self.nt_headers.is_type_64()
99     }
100 
segments(&'file self) -> PeSegmentIterator<'data, 'file, Pe>101     fn segments(&'file self) -> PeSegmentIterator<'data, 'file, Pe> {
102         PeSegmentIterator {
103             file: self,
104             iter: self.sections.iter(),
105         }
106     }
107 
section_by_name(&'file self, section_name: &str) -> Option<PeSection<'data, 'file, Pe>>108     fn section_by_name(&'file self, section_name: &str) -> Option<PeSection<'data, 'file, Pe>> {
109         self.sections
110             .section_by_name(self.symbols.strings(), section_name.as_bytes())
111             .map(|(index, section)| PeSection {
112                 file: self,
113                 index: SectionIndex(index),
114                 section,
115             })
116     }
117 
section_by_index(&'file self, index: SectionIndex) -> Result<PeSection<'data, 'file, Pe>>118     fn section_by_index(&'file self, index: SectionIndex) -> Result<PeSection<'data, 'file, Pe>> {
119         let section = self.sections.section(index.0)?;
120         Ok(PeSection {
121             file: self,
122             index,
123             section,
124         })
125     }
126 
sections(&'file self) -> PeSectionIterator<'data, 'file, Pe>127     fn sections(&'file self) -> PeSectionIterator<'data, 'file, Pe> {
128         PeSectionIterator {
129             file: self,
130             iter: self.sections.iter().enumerate(),
131         }
132     }
133 
symbol_by_index(&self, index: SymbolIndex) -> Result<Symbol<'data>>134     fn symbol_by_index(&self, index: SymbolIndex) -> Result<Symbol<'data>> {
135         let symbol = self
136             .symbols
137             .get(index.0)
138             .read_error("Invalid PE symbol index")?;
139         Ok(parse_symbol(&self.symbols, index.0, symbol))
140     }
141 
symbols(&'file self) -> CoffSymbolIterator<'data, 'file>142     fn symbols(&'file self) -> CoffSymbolIterator<'data, 'file> {
143         CoffSymbolIterator {
144             symbols: &self.symbols,
145             index: 0,
146         }
147     }
148 
dynamic_symbols(&'file self) -> CoffSymbolIterator<'data, 'file>149     fn dynamic_symbols(&'file self) -> CoffSymbolIterator<'data, 'file> {
150         // TODO: return exports/imports
151         CoffSymbolIterator {
152             symbols: &self.symbols,
153             // Hack: don't return any.
154             index: self.symbols.len(),
155         }
156     }
157 
symbol_map(&self) -> SymbolMap<'data>158     fn symbol_map(&self) -> SymbolMap<'data> {
159         // TODO: untested
160         let mut symbols: Vec<_> = self
161             .symbols()
162             .map(|(_, s)| s)
163             .filter(SymbolMap::filter)
164             .collect();
165         symbols.sort_by_key(|x| x.address);
166         SymbolMap { symbols }
167     }
168 
has_debug_symbols(&self) -> bool169     fn has_debug_symbols(&self) -> bool {
170         self.section_by_name(".debug_info").is_some()
171     }
172 
entry(&self) -> u64173     fn entry(&self) -> u64 {
174         u64::from(self.nt_headers.optional_header().address_of_entry_point())
175     }
176 
flags(&self) -> FileFlags177     fn flags(&self) -> FileFlags {
178         FileFlags::Coff {
179             characteristics: self.nt_headers.file_header().characteristics.get(LE),
180         }
181     }
182 }
183 
184 impl pe::ImageDosHeader {
185     /// Read the DOS header.
186     ///
187     /// Also checks that the `e_magic` field in the header is valid.
parse<'data>(data: Bytes<'data>) -> read::Result<&'data Self>188     pub fn parse<'data>(data: Bytes<'data>) -> read::Result<&'data Self> {
189         // DOS header comes first.
190         let dos_header = data
191             .read_at::<pe::ImageDosHeader>(0)
192             .read_error("Invalid DOS header size or alignment")?;
193         if dos_header.e_magic.get(LE) != pe::IMAGE_DOS_SIGNATURE {
194             return Err(Error("Invalid DOS magic"));
195         }
196         Ok(dos_header)
197     }
198 
199     /// Read the NT headers, including the data directories.
200     ///
201     /// The given data must be for the entire file.  Returns the data following the NT headers,
202     /// which will contain the section headers.
203     ///
204     /// Also checks that the `signature` and `magic` fields in the headers are valid.
205     #[inline]
nt_headers<'data, Pe: ImageNtHeaders>( &self, data: Bytes<'data>, ) -> read::Result<(&'data Pe, &'data [pe::ImageDataDirectory], Bytes<'data>)>206     pub fn nt_headers<'data, Pe: ImageNtHeaders>(
207         &self,
208         data: Bytes<'data>,
209     ) -> read::Result<(&'data Pe, &'data [pe::ImageDataDirectory], Bytes<'data>)> {
210         Pe::parse(self, data)
211     }
212 }
213 
214 /// A trait for generic access to `ImageNtHeaders32` and `ImageNtHeaders64`.
215 #[allow(missing_docs)]
216 pub trait ImageNtHeaders: Debug + Pod {
217     type ImageOptionalHeader: ImageOptionalHeader;
218 
219     /// Return true if this type is a 64-bit header.
220     ///
221     /// This is a property of the type, not a value in the header data.
is_type_64(&self) -> bool222     fn is_type_64(&self) -> bool;
223 
224     /// Return true if the magic field in the optional header is valid.
is_valid_optional_magic(&self) -> bool225     fn is_valid_optional_magic(&self) -> bool;
226 
227     /// Return the signature
signature(&self) -> u32228     fn signature(&self) -> u32;
229 
230     /// Return the file header.
file_header(&self) -> &pe::ImageFileHeader231     fn file_header(&self) -> &pe::ImageFileHeader;
232 
233     /// Return the optional header.
optional_header(&self) -> &Self::ImageOptionalHeader234     fn optional_header(&self) -> &Self::ImageOptionalHeader;
235 
236     // Provided methods.
237 
238     /// Read the NT headers, including the data directories.
239     ///
240     /// The DOS header is required to determine the NT headers offset.
241     ///
242     /// The given data must be for the entire file.  Returns the data following the NT headers,
243     /// which will contain the section headers.
244     ///
245     /// Also checks that the `signature` and `magic` fields in the headers are valid.
parse<'data>( dos_header: &pe::ImageDosHeader, mut data: Bytes<'data>, ) -> read::Result<(&'data Self, &'data [pe::ImageDataDirectory], Bytes<'data>)>246     fn parse<'data>(
247         dos_header: &pe::ImageDosHeader,
248         mut data: Bytes<'data>,
249     ) -> read::Result<(&'data Self, &'data [pe::ImageDataDirectory], Bytes<'data>)> {
250         data.skip(dos_header.e_lfanew.get(LE) as usize)
251             .read_error("Invalid PE headers offset")?;
252         // Note that this does not include the data directories in the optional header.
253         let nt_headers = data
254             .read::<Self>()
255             .read_error("Invalid PE headers size or alignment")?;
256         if nt_headers.signature() != pe::IMAGE_NT_SIGNATURE {
257             return Err(Error("Invalid PE magic"));
258         }
259         if !nt_headers.is_valid_optional_magic() {
260             return Err(Error("Invalid PE optional header magic"));
261         }
262 
263         // Read the rest of the optional header, and then read the data directories from that.
264         let optional_data_size = (nt_headers.file_header().size_of_optional_header.get(LE)
265             as usize)
266             .checked_sub(mem::size_of::<Self::ImageOptionalHeader>())
267             .read_error("PE optional header size is too small")?;
268         let mut optional_data = data
269             .read_bytes(optional_data_size)
270             .read_error("Invalid PE optional header size")?;
271         let data_directories = optional_data
272             .read_slice(nt_headers.optional_header().number_of_rva_and_sizes() as usize)
273             .read_error("Invalid PE number of RVA and sizes")?;
274 
275         Ok((nt_headers, data_directories, data))
276     }
277 
278     /// Read the section table.
279     ///
280     /// `nt_tail` must be the data following the NT headers.
281     #[inline]
sections<'data>(&self, nt_tail: Bytes<'data>) -> read::Result<SectionTable<'data>>282     fn sections<'data>(&self, nt_tail: Bytes<'data>) -> read::Result<SectionTable<'data>> {
283         SectionTable::parse(self.file_header(), nt_tail)
284     }
285 
286     /// Read the symbol table and string table.
287     ///
288     /// `data` must be the entire file data.
289     #[inline]
symbols<'data>(&self, data: Bytes<'data>) -> read::Result<SymbolTable<'data>>290     fn symbols<'data>(&self, data: Bytes<'data>) -> read::Result<SymbolTable<'data>> {
291         SymbolTable::parse(self.file_header(), data)
292     }
293 }
294 
295 /// A trait for generic access to `ImageOptionalHeader32` and `ImageOptionalHeader64`.
296 #[allow(missing_docs)]
297 pub trait ImageOptionalHeader: Debug + Pod {
298     // Standard fields.
magic(&self) -> u16299     fn magic(&self) -> u16;
major_linker_version(&self) -> u8300     fn major_linker_version(&self) -> u8;
minor_linker_version(&self) -> u8301     fn minor_linker_version(&self) -> u8;
size_of_code(&self) -> u32302     fn size_of_code(&self) -> u32;
size_of_initialized_data(&self) -> u32303     fn size_of_initialized_data(&self) -> u32;
size_of_uninitialized_data(&self) -> u32304     fn size_of_uninitialized_data(&self) -> u32;
address_of_entry_point(&self) -> u32305     fn address_of_entry_point(&self) -> u32;
base_of_code(&self) -> u32306     fn base_of_code(&self) -> u32;
307 
308     // NT additional fields.
image_base(&self) -> u64309     fn image_base(&self) -> u64;
section_alignment(&self) -> u32310     fn section_alignment(&self) -> u32;
file_alignment(&self) -> u32311     fn file_alignment(&self) -> u32;
major_operating_system_version(&self) -> u16312     fn major_operating_system_version(&self) -> u16;
minor_operating_system_version(&self) -> u16313     fn minor_operating_system_version(&self) -> u16;
major_image_version(&self) -> u16314     fn major_image_version(&self) -> u16;
minor_image_version(&self) -> u16315     fn minor_image_version(&self) -> u16;
major_subsystem_version(&self) -> u16316     fn major_subsystem_version(&self) -> u16;
minor_subsystem_version(&self) -> u16317     fn minor_subsystem_version(&self) -> u16;
win32_version_value(&self) -> u32318     fn win32_version_value(&self) -> u32;
size_of_image(&self) -> u32319     fn size_of_image(&self) -> u32;
size_of_headers(&self) -> u32320     fn size_of_headers(&self) -> u32;
check_sum(&self) -> u32321     fn check_sum(&self) -> u32;
subsystem(&self) -> u16322     fn subsystem(&self) -> u16;
dll_characteristics(&self) -> u16323     fn dll_characteristics(&self) -> u16;
size_of_stack_reserve(&self) -> u64324     fn size_of_stack_reserve(&self) -> u64;
size_of_stack_commit(&self) -> u64325     fn size_of_stack_commit(&self) -> u64;
size_of_heap_reserve(&self) -> u64326     fn size_of_heap_reserve(&self) -> u64;
size_of_heap_commit(&self) -> u64327     fn size_of_heap_commit(&self) -> u64;
loader_flags(&self) -> u32328     fn loader_flags(&self) -> u32;
number_of_rva_and_sizes(&self) -> u32329     fn number_of_rva_and_sizes(&self) -> u32;
330 }
331 
332 impl ImageNtHeaders for pe::ImageNtHeaders32 {
333     type ImageOptionalHeader = pe::ImageOptionalHeader32;
334 
335     #[inline]
is_type_64(&self) -> bool336     fn is_type_64(&self) -> bool {
337         false
338     }
339 
340     #[inline]
is_valid_optional_magic(&self) -> bool341     fn is_valid_optional_magic(&self) -> bool {
342         self.optional_header.magic.get(LE) == pe::IMAGE_NT_OPTIONAL_HDR32_MAGIC
343     }
344 
345     #[inline]
signature(&self) -> u32346     fn signature(&self) -> u32 {
347         self.signature.get(LE)
348     }
349 
350     #[inline]
file_header(&self) -> &pe::ImageFileHeader351     fn file_header(&self) -> &pe::ImageFileHeader {
352         &self.file_header
353     }
354 
355     #[inline]
optional_header(&self) -> &Self::ImageOptionalHeader356     fn optional_header(&self) -> &Self::ImageOptionalHeader {
357         &self.optional_header
358     }
359 }
360 
361 impl ImageOptionalHeader for pe::ImageOptionalHeader32 {
362     #[inline]
magic(&self) -> u16363     fn magic(&self) -> u16 {
364         self.magic.get(LE)
365     }
366 
367     #[inline]
major_linker_version(&self) -> u8368     fn major_linker_version(&self) -> u8 {
369         self.major_linker_version
370     }
371 
372     #[inline]
minor_linker_version(&self) -> u8373     fn minor_linker_version(&self) -> u8 {
374         self.minor_linker_version
375     }
376 
377     #[inline]
size_of_code(&self) -> u32378     fn size_of_code(&self) -> u32 {
379         self.size_of_code.get(LE)
380     }
381 
382     #[inline]
size_of_initialized_data(&self) -> u32383     fn size_of_initialized_data(&self) -> u32 {
384         self.size_of_initialized_data.get(LE)
385     }
386 
387     #[inline]
size_of_uninitialized_data(&self) -> u32388     fn size_of_uninitialized_data(&self) -> u32 {
389         self.size_of_uninitialized_data.get(LE)
390     }
391 
392     #[inline]
address_of_entry_point(&self) -> u32393     fn address_of_entry_point(&self) -> u32 {
394         self.address_of_entry_point.get(LE)
395     }
396 
397     #[inline]
base_of_code(&self) -> u32398     fn base_of_code(&self) -> u32 {
399         self.base_of_code.get(LE)
400     }
401 
402     #[inline]
image_base(&self) -> u64403     fn image_base(&self) -> u64 {
404         self.image_base.get(LE).into()
405     }
406 
407     #[inline]
section_alignment(&self) -> u32408     fn section_alignment(&self) -> u32 {
409         self.section_alignment.get(LE)
410     }
411 
412     #[inline]
file_alignment(&self) -> u32413     fn file_alignment(&self) -> u32 {
414         self.file_alignment.get(LE)
415     }
416 
417     #[inline]
major_operating_system_version(&self) -> u16418     fn major_operating_system_version(&self) -> u16 {
419         self.major_operating_system_version.get(LE)
420     }
421 
422     #[inline]
minor_operating_system_version(&self) -> u16423     fn minor_operating_system_version(&self) -> u16 {
424         self.minor_operating_system_version.get(LE)
425     }
426 
427     #[inline]
major_image_version(&self) -> u16428     fn major_image_version(&self) -> u16 {
429         self.major_image_version.get(LE)
430     }
431 
432     #[inline]
minor_image_version(&self) -> u16433     fn minor_image_version(&self) -> u16 {
434         self.minor_image_version.get(LE)
435     }
436 
437     #[inline]
major_subsystem_version(&self) -> u16438     fn major_subsystem_version(&self) -> u16 {
439         self.major_subsystem_version.get(LE)
440     }
441 
442     #[inline]
minor_subsystem_version(&self) -> u16443     fn minor_subsystem_version(&self) -> u16 {
444         self.minor_subsystem_version.get(LE)
445     }
446 
447     #[inline]
win32_version_value(&self) -> u32448     fn win32_version_value(&self) -> u32 {
449         self.win32_version_value.get(LE)
450     }
451 
452     #[inline]
size_of_image(&self) -> u32453     fn size_of_image(&self) -> u32 {
454         self.size_of_image.get(LE)
455     }
456 
457     #[inline]
size_of_headers(&self) -> u32458     fn size_of_headers(&self) -> u32 {
459         self.size_of_headers.get(LE)
460     }
461 
462     #[inline]
check_sum(&self) -> u32463     fn check_sum(&self) -> u32 {
464         self.check_sum.get(LE)
465     }
466 
467     #[inline]
subsystem(&self) -> u16468     fn subsystem(&self) -> u16 {
469         self.subsystem.get(LE)
470     }
471 
472     #[inline]
dll_characteristics(&self) -> u16473     fn dll_characteristics(&self) -> u16 {
474         self.dll_characteristics.get(LE)
475     }
476 
477     #[inline]
size_of_stack_reserve(&self) -> u64478     fn size_of_stack_reserve(&self) -> u64 {
479         self.size_of_stack_reserve.get(LE).into()
480     }
481 
482     #[inline]
size_of_stack_commit(&self) -> u64483     fn size_of_stack_commit(&self) -> u64 {
484         self.size_of_stack_commit.get(LE).into()
485     }
486 
487     #[inline]
size_of_heap_reserve(&self) -> u64488     fn size_of_heap_reserve(&self) -> u64 {
489         self.size_of_heap_reserve.get(LE).into()
490     }
491 
492     #[inline]
size_of_heap_commit(&self) -> u64493     fn size_of_heap_commit(&self) -> u64 {
494         self.size_of_heap_commit.get(LE).into()
495     }
496 
497     #[inline]
loader_flags(&self) -> u32498     fn loader_flags(&self) -> u32 {
499         self.loader_flags.get(LE)
500     }
501 
502     #[inline]
number_of_rva_and_sizes(&self) -> u32503     fn number_of_rva_and_sizes(&self) -> u32 {
504         self.number_of_rva_and_sizes.get(LE)
505     }
506 }
507 
508 impl ImageNtHeaders for pe::ImageNtHeaders64 {
509     type ImageOptionalHeader = pe::ImageOptionalHeader64;
510 
511     #[inline]
is_type_64(&self) -> bool512     fn is_type_64(&self) -> bool {
513         true
514     }
515 
516     #[inline]
is_valid_optional_magic(&self) -> bool517     fn is_valid_optional_magic(&self) -> bool {
518         self.optional_header.magic.get(LE) == pe::IMAGE_NT_OPTIONAL_HDR64_MAGIC
519     }
520 
521     #[inline]
signature(&self) -> u32522     fn signature(&self) -> u32 {
523         self.signature.get(LE)
524     }
525 
526     #[inline]
file_header(&self) -> &pe::ImageFileHeader527     fn file_header(&self) -> &pe::ImageFileHeader {
528         &self.file_header
529     }
530 
531     #[inline]
optional_header(&self) -> &Self::ImageOptionalHeader532     fn optional_header(&self) -> &Self::ImageOptionalHeader {
533         &self.optional_header
534     }
535 }
536 
537 impl ImageOptionalHeader for pe::ImageOptionalHeader64 {
538     #[inline]
magic(&self) -> u16539     fn magic(&self) -> u16 {
540         self.magic.get(LE)
541     }
542 
543     #[inline]
major_linker_version(&self) -> u8544     fn major_linker_version(&self) -> u8 {
545         self.major_linker_version
546     }
547 
548     #[inline]
minor_linker_version(&self) -> u8549     fn minor_linker_version(&self) -> u8 {
550         self.minor_linker_version
551     }
552 
553     #[inline]
size_of_code(&self) -> u32554     fn size_of_code(&self) -> u32 {
555         self.size_of_code.get(LE)
556     }
557 
558     #[inline]
size_of_initialized_data(&self) -> u32559     fn size_of_initialized_data(&self) -> u32 {
560         self.size_of_initialized_data.get(LE)
561     }
562 
563     #[inline]
size_of_uninitialized_data(&self) -> u32564     fn size_of_uninitialized_data(&self) -> u32 {
565         self.size_of_uninitialized_data.get(LE)
566     }
567 
568     #[inline]
address_of_entry_point(&self) -> u32569     fn address_of_entry_point(&self) -> u32 {
570         self.address_of_entry_point.get(LE)
571     }
572 
573     #[inline]
base_of_code(&self) -> u32574     fn base_of_code(&self) -> u32 {
575         self.base_of_code.get(LE)
576     }
577 
578     #[inline]
image_base(&self) -> u64579     fn image_base(&self) -> u64 {
580         self.image_base.get(LE)
581     }
582 
583     #[inline]
section_alignment(&self) -> u32584     fn section_alignment(&self) -> u32 {
585         self.section_alignment.get(LE)
586     }
587 
588     #[inline]
file_alignment(&self) -> u32589     fn file_alignment(&self) -> u32 {
590         self.file_alignment.get(LE)
591     }
592 
593     #[inline]
major_operating_system_version(&self) -> u16594     fn major_operating_system_version(&self) -> u16 {
595         self.major_operating_system_version.get(LE)
596     }
597 
598     #[inline]
minor_operating_system_version(&self) -> u16599     fn minor_operating_system_version(&self) -> u16 {
600         self.minor_operating_system_version.get(LE)
601     }
602 
603     #[inline]
major_image_version(&self) -> u16604     fn major_image_version(&self) -> u16 {
605         self.major_image_version.get(LE)
606     }
607 
608     #[inline]
minor_image_version(&self) -> u16609     fn minor_image_version(&self) -> u16 {
610         self.minor_image_version.get(LE)
611     }
612 
613     #[inline]
major_subsystem_version(&self) -> u16614     fn major_subsystem_version(&self) -> u16 {
615         self.major_subsystem_version.get(LE)
616     }
617 
618     #[inline]
minor_subsystem_version(&self) -> u16619     fn minor_subsystem_version(&self) -> u16 {
620         self.minor_subsystem_version.get(LE)
621     }
622 
623     #[inline]
win32_version_value(&self) -> u32624     fn win32_version_value(&self) -> u32 {
625         self.win32_version_value.get(LE)
626     }
627 
628     #[inline]
size_of_image(&self) -> u32629     fn size_of_image(&self) -> u32 {
630         self.size_of_image.get(LE)
631     }
632 
633     #[inline]
size_of_headers(&self) -> u32634     fn size_of_headers(&self) -> u32 {
635         self.size_of_headers.get(LE)
636     }
637 
638     #[inline]
check_sum(&self) -> u32639     fn check_sum(&self) -> u32 {
640         self.check_sum.get(LE)
641     }
642 
643     #[inline]
subsystem(&self) -> u16644     fn subsystem(&self) -> u16 {
645         self.subsystem.get(LE)
646     }
647 
648     #[inline]
dll_characteristics(&self) -> u16649     fn dll_characteristics(&self) -> u16 {
650         self.dll_characteristics.get(LE)
651     }
652 
653     #[inline]
size_of_stack_reserve(&self) -> u64654     fn size_of_stack_reserve(&self) -> u64 {
655         self.size_of_stack_reserve.get(LE)
656     }
657 
658     #[inline]
size_of_stack_commit(&self) -> u64659     fn size_of_stack_commit(&self) -> u64 {
660         self.size_of_stack_commit.get(LE)
661     }
662 
663     #[inline]
size_of_heap_reserve(&self) -> u64664     fn size_of_heap_reserve(&self) -> u64 {
665         self.size_of_heap_reserve.get(LE)
666     }
667 
668     #[inline]
size_of_heap_commit(&self) -> u64669     fn size_of_heap_commit(&self) -> u64 {
670         self.size_of_heap_commit.get(LE)
671     }
672 
673     #[inline]
loader_flags(&self) -> u32674     fn loader_flags(&self) -> u32 {
675         self.loader_flags.get(LE)
676     }
677 
678     #[inline]
number_of_rva_and_sizes(&self) -> u32679     fn number_of_rva_and_sizes(&self) -> u32 {
680         self.number_of_rva_and_sizes.get(LE)
681     }
682 }
683