Skip to content

Commit

Permalink
macho: is_64_bit -> pointer_size
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Jan 28, 2024
1 parent 9ff38c5 commit c5a1b7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/file_format/macho.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Support for parsing MachO files
use crate::{Process, Address};
use crate::{Address, PointerSize, Process};

use core::mem;

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

/// Determines whether a MachO header at the address is 64-bit or 32-bit
pub fn is_64_bit(process: &Process, address: Address) -> Option<bool> {
pub fn pointer_size(process: &Process, address: Address) -> Option<PointerSize> {
let magic: u32 = process.read(address).ok()?;
match magic {

Check failure on line 66 in src/file_format/macho.rs

View workflow job for this annotation

GitHub Actions / Check formatting

Diff in /home/runner/work/asr/asr/src/file_format/macho.rs
MH_MAGIC_64 | MH_CIGAM_64 => Some(true),
MH_MAGIC_32 | MH_CIGAM_32 => Some(false),
MH_MAGIC_64 | MH_CIGAM_64 => Some(PointerSize::Bit64),
MH_MAGIC_32 | MH_CIGAM_32 => Some(PointerSize::Bit32),
_ => None
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/game_engine/unity/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ impl Module {
}
}
#[cfg(feature = "std")]
BinaryFormat::MachO => {
if macho::is_64_bit(process, macho::scan_macho_page(process, module_range)?)? {
PointerSize::Bit64
} else {
PointerSize::Bit32
}
}
BinaryFormat::MachO => macho::pointer_size(process, macho::scan_macho_page(process, module_range)?)?,
};
let offsets = Offsets::new(version, pointer_size, format)?;

Expand Down
8 changes: 1 addition & 7 deletions src/game_engine/unity/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ impl SceneManager {
_ => PointerSize::Bit32,
}
}
BinaryFormat::MachO => {
if macho::is_64_bit(process, macho::scan_macho_page(process, unity_player)?)? {
PointerSize::Bit64
} else {
PointerSize::Bit32
}
}
BinaryFormat::MachO => macho::pointer_size(process, macho::scan_macho_page(process, unity_player)?)?,
};
let is_il2cpp = process.get_module_address("GameAssembly.dll").is_ok();

Expand Down

0 comments on commit c5a1b7c

Please sign in to comment.