diff --git a/CHANGELOG.md b/CHANGELOG.md index c05654c..70c1329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## v0.1.0-beta.5 (2023/07/26) +- Fixed get version function + ## v0.1.0-beta.4 (2023/07/26) - Added validity check on MEM1 of DolphinProcessMemory - Fixed write memory API diff --git a/Cargo.toml b/Cargo.toml index 1398142..396031d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sup-smsac" -version = "0.1.0-beta.4" +version = "0.1.0-beta.5" edition = "2021" license = "MIT OR Apache-2.0" authors = ["sup39 "] diff --git a/src/big_endian.rs b/src/big_endian.rs index 7d63963..9f50b84 100644 --- a/src/big_endian.rs +++ b/src/big_endian.rs @@ -45,9 +45,9 @@ impl_decode_be_for_int!(i128, 16); impl_decode_be_for_float!(f32, u32, 4); impl_decode_be_for_float!(f64, u64, 8); -impl DecodeBE for &[u8; N] { +impl DecodeBE for [u8; N] { const PACKED_SIZE: usize = N; unsafe fn decode_be(ptr: *const u8) -> Self { - &*(ptr as *const [u8; N]) + *(ptr as *const [u8; N]) } } diff --git a/src/sms/mod.rs b/src/sms/mod.rs index 0a46465..31041e8 100644 --- a/src/sms/mod.rs +++ b/src/sms/mod.rs @@ -38,16 +38,18 @@ impl SMSDolphin { } pub fn from_dolphin_memory(d: DolphinMemory, pid: PidType) -> Result> { - match d.read::<&[u8; 8]>(Addr(0x80000000)) { - None => Err(None), - Some(rver) => match rver { - b"GMSJ01\x00\x00" => Ok(SMSVersion::GMSJ01), - b"GMSE01\x00\x30" => Ok(SMSVersion::GMSE01), - b"GMSP01\x00\x00" => Ok(SMSVersion::GMSP01), - b"GMSJ01\x00\x01" => Ok(SMSVersion::GMSJ0A), - _ => Err(Some(rver.to_owned())), - }.map(|ver| SMSDolphin {d, ver, pid}), - } + unsafe { + d.read_memory_unchecked(DolphinMemAddr::MEM1(0), 8, |ptr| { + match &*(ptr as *const [u8; 8]) { + b"GMSJ01\x00\x00" => Ok(SMSVersion::GMSJ01), + b"GMSE01\x00\x30" => Ok(SMSVersion::GMSE01), + b"GMSP01\x00\x00" => Ok(SMSVersion::GMSP01), + b"GMSJ01\x00\x01" => Ok(SMSVersion::GMSJ0A), + rver => Err(Some(rver.to_owned())), + } + }) + } .unwrap_or(Err(None)) + .map(|ver| SMSDolphin {d, ver, pid}) } pub fn get_class(&self, addr: Addr) -> Option<&'static str> { vt::get_class(self.ver, addr) diff --git a/www/index.html b/www/index.html index 96825a6..a778576 100644 --- a/www/index.html +++ b/www/index.html @@ -8,7 +8,7 @@ -

SMS Web Object Viewer (v0.1.0-beta.4) (2023/07/26)

+

SMS Web Object Viewer (v0.1.0-beta.5) (2023/07/26)