Skip to content

Commit 05d5342

Browse files
committed
dir/gen2: make Entry packed, HuffmanModule not repr(C)
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent 107d6a3 commit 05d5342

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/dir/gen2.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const CHUNK_OFFSET_MASK: u32 = 0x00ff_ffff;
2828

2929
// https://github.com/skochinsky/me-tools me_unpack.py MeModuleHeader2
3030
#[derive(Immutable, IntoBytes, FromBytes, Serialize, Deserialize, Clone, Copy, Debug)]
31-
#[repr(C)]
31+
#[repr(C, packed)]
3232
pub struct Entry {
3333
pub magic: [u8; 4],
3434
pub name: [u8; 0x10],
@@ -103,8 +103,9 @@ pub struct BinaryMap {
103103
impl Entry {
104104
pub fn bin_map(&self) -> BinaryMap {
105105
let b = self.mod_base;
106-
let rapi = self.flags.rapi();
107-
let kapi = self.flags.kapi();
106+
let f = self.flags;
107+
let rapi = f.rapi();
108+
let kapi = f.kapi();
108109
let code_start = b as usize + (rapi + kapi) * 0x1000;
109110
let code_end = (b + self.code_size) as usize;
110111
let data_end = (b + self.memory_size) as usize;
@@ -148,7 +149,8 @@ impl Display for Entry {
148149
let o = self.offset;
149150
let s = self.size;
150151
let e = self.entry_point;
151-
let c = self.flags.compression();
152+
let fl = self.flags;
153+
let c = fl.compression();
152154
write!(f, "{n:16} {s:08x} @ {o:08x}, entry point {e:08x}, {c:10?}")
153155
}
154156
}
@@ -173,7 +175,6 @@ pub struct LutHeader {
173175
pub const LUT_HEADER_SIZE: usize = size_of::<LutHeader>();
174176

175177
#[derive(Serialize, Deserialize, Clone, Debug)]
176-
#[repr(C)]
177178
pub struct HuffmanModule {
178179
pub header: LutHeader,
179180
pub chunks: Vec<u32>,
@@ -249,7 +250,8 @@ impl Directory {
249250
let modules = entries
250251
.iter()
251252
.map(|e| {
252-
let c = e.flags.compression();
253+
let f = e.flags;
254+
let c = f.compression();
253255
let o = e.offset as usize;
254256
if o + 4 > data.len() {
255257
return Module::Unknown(*e);

0 commit comments

Comments
 (0)