0

I am trying to mod a macOS game using a dylib injected with DYLD_INSERT_LIBRARIES, but I am having some trouble calling a the game's function from the dylib. I can currently redirect one function to another one that belongs to the game, but I can't just call the same function.

I have tried using: [GamePlayer performSelector:@selector(setPositionOfBall:)]; but the game log says: +[GamePlayer setPositionOfBall]: unrecognized selector sent to class . I am really unsure how to overcome this, because I know the selector and class are correct. I did however notice the error starts with + and the function in the decompiler starts with -, if that helps

Any help is appreciated, Connor

  • The `+` and `-` are important. The former means you can invoke the method, without an initialized object. The latter means you need to create / find an instance of the `GamePlayer` class before you can invoke it. – rustyMagnet Apr 10 '19 at 05:50
  • Have a look here: https://stackoverflow.com/questions/1053592/what-is-the-difference-between-class-and-instance-methods – rustyMagnet Apr 10 '19 at 05:51
  • I changed my code to be: [GamePlayer ClassMethod]; GamePlayer *object = [[GamePlayer alloc] init]; [object setPositionOfBall]; and now I get the error: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_GamePlayer", referenced from: objc-class-ref in FHDylib-344dad.o – Connor Young Apr 10 '19 at 05:58
  • Most likely you will need to find the actual instance of `GamePlayer` the game is using to be able to change its behavior. Use lldb to debug the original game (its executable will suffice ) and try to understand when `setPositionOfBall:` is called (this would also grant you the instance). You can set a symbolic bp like this `b setPositionOfBall:`. To eventually mod the game, obj-c method swizzling is probably your best shot. – Kamil.S Jan 15 '21 at 09:49

0 Answers0