-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for MEdnafen (SMS) and removed an unused leftover function
- Loading branch information
Showing
2 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::{file_format::pe, signature::Signature, Address, Address32, Process}; | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
pub struct State; | ||
|
||
impl State { | ||
pub fn find_ram(&self, game: &Process) -> Option<Address> { | ||
const SIG_32: Signature<8> = Signature::new("25 FF 1F 00 00 0F B6 80"); | ||
const SIG_64: Signature<7> = Signature::new("25 FF 1F 00 00 88 90"); | ||
|
||
let main_module_range = super::PROCESS_NAMES | ||
.iter() | ||
.filter(|(_, state)| matches!(state, super::State::Mednafen(_))) | ||
.find_map(|(name, _)| game.get_module_range(name).ok())?; | ||
|
||
let is_64_bit = | ||
pe::MachineType::read(game, main_module_range.0) == Some(pe::MachineType::X86_64); | ||
|
||
let ptr = match is_64_bit { | ||
true => SIG_64.scan_process_range(game, main_module_range)? + 8, | ||
false => SIG_32.scan_process_range(game, main_module_range)? + 7, | ||
}; | ||
|
||
Some(game.read::<Address32>(ptr).ok()?.into()) | ||
} | ||
|
||
pub const fn keep_alive(&self) -> bool { | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters