NeighTools / UnityDoorstop

Doorstop -- run C# before Unity does!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run on M1 Mac (ARM games)

mo10 opened this issue · comments

commented

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
commented

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,

void *unity_player = plthook_handle_by_name("UnityPlayer");
// TODO: Chekc if this still works on macOS
if (unity_player && plthook_open_by_address(&hook, unity_player) == 0) {
LOG("Found UnityPlayer, hooking into it instead");
} else if (plthook_open(&hook, NULL) != 0) {
LOG("Failed to open current process PLT! Cannot run Doorstop! "
"Error: "
"%s\n",
plthook_error());
return;
}

int plthook_open_by_address(plthook_t **plthook_out, void *address) {
Dl_info dlinfo;
uint32_t idx = 0;
uint32_t cnt = _dyld_image_count();
if (!dladdr(address, &dlinfo)) {
*plthook_out = NULL;
set_errmsg("Cannot find address: %p", address);
return PLTHOOK_FILE_NOT_FOUND;
}

Update:

I replaced plthook_open_by_address with plthook_open, it will working.

#27 should fix it now. Feel free to reopen if the issue still persists.

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

commented

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

Please use this: #41