lewisclark / glua-steal

Retrieves client-sided Lua files from Garry's Mod game servers
GNU General Public License v3.0
151 stars 15 forks source link

OSX 12.6 build failing #37

Closed PhoenixShay closed 1 year ago

PhoenixShay commented 1 year ago

Describe the bug Building the repo on OSX 12.6 fails - unable to find link.h.

Expected behavior Building the repo succeeds and the 0.001% of people probably using GLua-Steal on OSX can live a happy life.

Screenshots

image
shayne@Shaynes-MacBook-Pro build % make
[  4%] Building CXX object src/library/CMakeFiles/library.dir/library.cpp.o
In file included from /Users/shayne/Desktop/glua-steal/src/library/library.cpp:17:
/Users/shayne/Desktop/glua-steal/src/library/library.hpp:30:10: fatal error: link.h: No such file or directory
   30 | #include <link.h>
      |          ^~~~~~~~
compilation terminated.
make[2]: *** [src/library/CMakeFiles/library.dir/library.cpp.o] Error 1
make[1]: *** [src/library/CMakeFiles/library.dir/all] Error 2
make: *** [all] Error 2

Additional details (please complete the following information):

Additional context I don't really care that much, so I'm not offended if this doesn't get fixed. I know Mac isn't officially supported.

lewisclark commented 1 year ago

I'd love to get glua-steal working on OSX - I never had the chance previously due to not having a device to test on. I've started a new branch for OSX so hopefully we can make some progress towards this. Thanks for the issue; it gives a good starting point.

lewisclark commented 1 year ago

It's building in CI now - so feel free to test it by building the osx branch. I have no idea if it will inject nicely, so enabling debug logging using the config would give some really helpful info.

PhoenixShay commented 1 year ago

I appreciate you jumping right into this!

Definitely some issues injecting; not sure if it's the lib or user error though. Tried LD_PRELOAD by modifying hl2_osx; game immediately crashes upon launch. Tried LLDB injecting directly - can't even attach to the process (error 1 from LLDB). Tried jerryrigging the hl2_osx to launch it with GAMEDEBUGGER set to lldb; immediate crash. I saw the game tries to load some .dylibs that don't actually exist in a few different places (i.e html_awesomium.dylib, client.dylib, engine.dylib, etc). Tried putting gluasteal dylib in one of those spots but it looks like it's expecting x86_64 instead of arm64 (understandably).

My Discord is Shayne#2226, might be less cluttered and easier to go back and forth there. Happy to be a guinea pig!

lewisclark commented 1 year ago

Awesome - thanks!

Injecting with a debugger is definitely the way to go in terms of reliability. I've adapted a GDB injection script for LLDB below - just the pid and full path to libgluasteal.dylib need to be filled in.

sudo lldb --attach-pid 0 --batch -o "p (void*)dlopen(\"/full/path/to/libgluasteal.dylib\", 1)" -o detach -o quit

Some googling tells me that error 1 from LLDB is caused by insufficient permissions to attach? Perhaps Garry's Mod enables the hardened runtime?

StupidRepo commented 1 year ago

sudo lldb --attach-pid 0 --batch -o "p (void*)dlopen(\"/full/path/to/libgluasteal.dylib\", 1)" -o detach -o quit

If anyone is still getting Error 1, reboot to RecoveryOS. Then put in csrutil disable into the Terminal and restart your machine.