NeighTools / UnityDoorstop

Doorstop -- run C# before Unity does!
GNU Lesser General Public License v2.1
454 stars 69 forks source link

Cannot run on M1 Mac (ARM games) #25

Closed mo10 closed 2 years ago

mo10 commented 2 years ago

Game: The Stanley Parable: Ultra Deluxe Hardware: MacBook Air M1

I use libdoorstop.dylib compiled by github action. It seems can be loaded, but it cannot hook any methods.

Basedir: /Users/test/Library/Application Support/Steam/steamapps/common/The Stanley Parable Ultra Deluxe
Executeable path: /Users/test/Library/Application Support/Steam/steamapps/common/The Stanley Parable Ultra Deluxe/TSPUD.app/Contents/MacOS/The Stanley Parable_ Ultra Deluxe
slide=bd3000
Image name: /Users/test/Library/Application Support/Steam/steamapps/common/The Stanley Parable Ultra Deluxe/TSPUD.app/Contents/MacOS/The Stanley Parable_ Ultra Deluxe
LC_SEGMENT_64
segname __PAGEZERO
vmaddr 0 vmsize 100000000
fileoff 0 filesize 0
maxprot 0 initprot 0
nsects 0 flags 0
LC_SEGMENT_64
segname __TEXT
vmaddr 100000000 vmsize 1000
fileoff 0 filesize 1000
maxprot 7 initprot 5
nsects 4 flags 0
LC_SEGMENT_64
segname __DATA
vmaddr 100001000 vmsize 1000
fileoff 1000 filesize 1000
maxprot 7 initprot 3
nsects 2 flags 0
LC_SEGMENT_64
segname __LINKEDIT
vmaddr 100002000 vmsize 8000
fileoff 2000 filesize 4ee0
maxprot 7 initprot 1
nsects 0 flags 0
LC_DYLD_INFO_ONLY
offset size
rebase 2000 8
bind 2008 18
weak_bind 0 0
lazy_bind 2020 20
export_bind 2040 20
LC_SYMTAB
symbol count: c
symbol offset: 2068
stf offset: 2138
str size: 110
LC_DYSYMTAB
itable offset: 2128
itable count: 4
LC_LOAD_DYLINKER
LC_UUID
LC_VERSION_MIN_MACOSX
LC_SOURCE_VERSION
LC_MAIN
LC_LOAD_DYLIB
LC_LOAD_DYLIB
LC_LOAD_DYLIB
LC_FUNCTION_STARTS
LC_DATA_IN_CODE
LC_? (0x1d)
__DATA section __nl_symbol_ptr
__DATA section __la_symbol_ptr
Found lazy symbol pointers
Got base offset: 0
Symbol (0x10b94f2d0) 10 -> __Z10PlayerMainiPPKc
Failed to hook dlsym, ignoring it. Error: no such function: dlsym
Failed to hook fclose, ignoring it. Error: no such function: fclose
Failed to hook dup2, ignoring it. Error: no such function: dup2
Failed to hook jit_init_version, ignoring it. Error: no such function: mono_jit_init_version
mo10 commented 2 years ago

I'm working on x86_64 mac now. It has the same problem as m1 mac.

At present, plthook_handle_by_name can obtain the address of UnityPlayer.dylib, but plthook_open_by_address not working.

I tried to print its error, i got: Cannot find address: 0x207b47100 It seems that dladdr cannot get info from this address, https://github.com/NeighTools/UnityDoorstop/blob/2441a60f6b7d946d9e6c1493378796d196edac29/src/nix/entrypoint.c#L75-L86 https://github.com/NeighTools/UnityDoorstop/blob/2441a60f6b7d946d9e6c1493378796d196edac29/src/nix/plthook/plthook_osx.c#L192-L201

Update:

I replaced plthook_open_by_address with plthook_open, it will working.

ghorsington commented 2 years ago

https://github.com/NeighTools/UnityDoorstop/pull/27 should fix it now. Feel free to reopen if the issue still persists.

Aem1024 commented 1 year ago

Still seems to be an Issue for me. Same hardware as mo10, But i'm trying to run on Subnautica.

mo10 commented 1 year ago

Still seems to be an Issue for me. Same hardware as mo10, But i'm trying to run on Subnautica.

Please use this: https://github.com/NeighTools/UnityDoorstop/pull/41