wraith/structures/pe/
relocations.rs1#[repr(C)]
4#[derive(Debug, Clone, Copy)]
5pub struct BaseRelocation {
6 pub virtual_address: u32,
7 pub size_of_block: u32,
8 }
10
11impl BaseRelocation {
12 pub fn entry_count(&self) -> usize {
14 if self.size_of_block <= 8 {
15 0
16 } else {
17 ((self.size_of_block - 8) / 2) as usize
18 }
19 }
20}
21
22#[repr(transparent)]
24#[derive(Debug, Clone, Copy)]
25pub struct RelocationEntry(pub u16);
26
27impl RelocationEntry {
28 pub fn reloc_type(&self) -> u8 {
29 (self.0 >> 12) as u8
30 }
31
32 pub fn offset(&self) -> u16 {
33 self.0 & 0x0FFF
34 }
35}
36
37#[repr(u8)]
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub enum RelocationType {
41 Absolute = 0, High = 1, Low = 2, HighLow = 3, HighAdj = 4, Dir64 = 10, }
48
49impl From<u8> for RelocationType {
50 fn from(val: u8) -> Self {
51 match val {
52 0 => Self::Absolute,
53 1 => Self::High,
54 2 => Self::Low,
55 3 => Self::HighLow,
56 4 => Self::HighAdj,
57 10 => Self::Dir64,
58 _ => Self::Absolute, }
60 }
61}