9
9
use core:: { array, iter, mem:: MaybeUninit } ;
10
10
11
11
use crate :: {
12
- file_format:: { macho, pe} ,
12
+ file_format:: { elf , macho, pe} ,
13
13
future:: retry,
14
14
signature:: Signature ,
15
15
string:: ArrayCString ,
@@ -34,6 +34,7 @@ impl SceneManager {
34
34
/// Attaches to the scene manager in the given process.
35
35
pub fn attach ( process : & Process ) -> Option < Self > {
36
36
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" ) ;
37
38
const SIG_64_BIT_MACHO : Signature < 13 > =
38
39
Signature :: new ( "41 54 53 50 4C 8B ?5 ???????? 41 83" ) ;
39
40
const SIG_32_1 : Signature < 12 > = Signature :: new ( "55 8B EC 51 A1 ???????? 53 33 DB" ) ;
@@ -42,13 +43,15 @@ impl SceneManager {
42
43
43
44
let ( unity_player, format) = [
44
45
( "UnityPlayer.dll" , BinaryFormat :: PE ) ,
46
+ ( "UnityPlayer.so" , BinaryFormat :: ELF ) ,
45
47
( "UnityPlayer.dylib" , BinaryFormat :: MachO ) ,
46
48
]
47
49
. into_iter ( )
48
50
. find_map ( |( name, format) | Some ( ( process. get_module_range ( name) . ok ( ) ?, format) ) ) ?;
49
51
50
52
let pointer_size = match format {
51
53
BinaryFormat :: PE => pe:: MachineType :: read ( process, unity_player. 0 ) ?. pointer_size ( ) ?,
54
+ BinaryFormat :: ELF => elf:: pointer_size ( process, unity_player. 0 ) ?,
52
55
BinaryFormat :: MachO => macho:: pointer_size ( process, unity_player) ?,
53
56
} ;
54
57
@@ -61,6 +64,10 @@ impl SceneManager {
61
64
let addr = SIG_64_BIT_PE . scan_process_range ( process, unity_player) ? + 7 ;
62
65
addr + 0x4 + process. read :: < i32 > ( addr) . ok ( ) ?
63
66
}
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
+ }
64
71
( PointerSize :: Bit64 , BinaryFormat :: MachO ) => {
65
72
let addr = SIG_64_BIT_MACHO . scan_process_range ( process, unity_player) ? + 7 ;
66
73
addr + 0x4 + process. read :: < i32 > ( addr) . ok ( ) ?
@@ -454,6 +461,7 @@ impl Transform {
454
461
#[ derive( Copy , Clone , PartialEq , Hash , Debug ) ]
455
462
enum BinaryFormat {
456
463
PE ,
464
+ ELF ,
457
465
MachO ,
458
466
}
459
467
0 commit comments