Skip to content

Commit 4d12aaf

Browse files
committed
Support Linux SceneManager
1 parent c5bd38a commit 4d12aaf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/game_engine/unity/scene.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use core::{array, iter, mem::MaybeUninit};
1010

1111
use crate::{
12-
file_format::{macho, pe},
12+
file_format::{elf, macho, pe},
1313
future::retry,
1414
signature::Signature,
1515
string::ArrayCString,
@@ -34,6 +34,7 @@ impl SceneManager {
3434
/// Attaches to the scene manager in the given process.
3535
pub fn attach(process: &Process) -> Option<Self> {
3636
const SIG_64_BIT_PE: Signature<13> = Signature::new("48 83 EC 20 4C 8B ?5 ???????? 33 F6");
37+
const SIG_64_BIT_ELF: Signature<13> = Signature::new("41 54 53 50 4C 8B ?5 ???????? 41 83");
3738
const SIG_64_BIT_MACHO: Signature<13> =
3839
Signature::new("41 54 53 50 4C 8B ?5 ???????? 41 83");
3940
const SIG_32_1: Signature<12> = Signature::new("55 8B EC 51 A1 ???????? 53 33 DB");
@@ -42,13 +43,15 @@ impl SceneManager {
4243

4344
let (unity_player, format) = [
4445
("UnityPlayer.dll", BinaryFormat::PE),
46+
("UnityPlayer.so", BinaryFormat::ELF),
4547
("UnityPlayer.dylib", BinaryFormat::MachO),
4648
]
4749
.into_iter()
4850
.find_map(|(name, format)| Some((process.get_module_range(name).ok()?, format)))?;
4951

5052
let pointer_size = match format {
5153
BinaryFormat::PE => pe::MachineType::read(process, unity_player.0)?.pointer_size()?,
54+
BinaryFormat::ELF => elf::pointer_size(process, unity_player.0)?,
5255
BinaryFormat::MachO => macho::pointer_size(process, unity_player)?,
5356
};
5457

@@ -61,6 +64,10 @@ impl SceneManager {
6164
let addr = SIG_64_BIT_PE.scan_process_range(process, unity_player)? + 7;
6265
addr + 0x4 + process.read::<i32>(addr).ok()?
6366
}
67+
(PointerSize::Bit64, BinaryFormat::ELF) => {
68+
let addr = SIG_64_BIT_ELF.scan_process_range(process, unity_player)? + 7;
69+
addr + 0x4 + process.read::<i32>(addr).ok()?
70+
}
6471
(PointerSize::Bit64, BinaryFormat::MachO) => {
6572
let addr = SIG_64_BIT_MACHO.scan_process_range(process, unity_player)? + 7;
6673
addr + 0x4 + process.read::<i32>(addr).ok()?
@@ -454,6 +461,7 @@ impl Transform {
454461
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
455462
enum BinaryFormat {
456463
PE,
464+
ELF,
457465
MachO,
458466
}
459467

0 commit comments

Comments
 (0)