Skip to content

Commit c5a1b7c

Browse files
committed
macho: is_64_bit -> pointer_size
1 parent 9ff38c5 commit c5a1b7c

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

src/file_format/macho.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Support for parsing MachO files
22
3-
use crate::{Process, Address};
3+
use crate::{Address, PointerSize, Process};
44

55
use core::mem;
66

@@ -61,11 +61,11 @@ pub fn scan_macho_page(process: &Process, range: (Address, u64)) -> Option<Addre
6161
}
6262

6363
/// Determines whether a MachO header at the address is 64-bit or 32-bit
64-
pub fn is_64_bit(process: &Process, address: Address) -> Option<bool> {
64+
pub fn pointer_size(process: &Process, address: Address) -> Option<PointerSize> {
6565
let magic: u32 = process.read(address).ok()?;
6666
match magic {
67-
MH_MAGIC_64 | MH_CIGAM_64 => Some(true),
68-
MH_MAGIC_32 | MH_CIGAM_32 => Some(false),
67+
MH_MAGIC_64 | MH_CIGAM_64 => Some(PointerSize::Bit64),
68+
MH_MAGIC_32 | MH_CIGAM_32 => Some(PointerSize::Bit32),
6969
_ => None
7070
}
7171
}

src/game_engine/unity/mono.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,7 @@ impl Module {
6565
}
6666
}
6767
#[cfg(feature = "std")]
68-
BinaryFormat::MachO => {
69-
if macho::is_64_bit(process, macho::scan_macho_page(process, module_range)?)? {
70-
PointerSize::Bit64
71-
} else {
72-
PointerSize::Bit32
73-
}
74-
}
68+
BinaryFormat::MachO => macho::pointer_size(process, macho::scan_macho_page(process, module_range)?)?,
7569
};
7670
let offsets = Offsets::new(version, pointer_size, format)?;
7771

src/game_engine/unity/scene.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ impl SceneManager {
4848
_ => PointerSize::Bit32,
4949
}
5050
}
51-
BinaryFormat::MachO => {
52-
if macho::is_64_bit(process, macho::scan_macho_page(process, unity_player)?)? {
53-
PointerSize::Bit64
54-
} else {
55-
PointerSize::Bit32
56-
}
57-
}
51+
BinaryFormat::MachO => macho::pointer_size(process, macho::scan_macho_page(process, unity_player)?)?,
5852
};
5953
let is_il2cpp = process.get_module_address("GameAssembly.dll").is_ok();
6054

0 commit comments

Comments
 (0)