Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Manually invoke IL2CPP function?!

Discussion in 'iOS and tvOS' started by UnknownRE, Apr 23, 2017.

  1. UnknownRE

    UnknownRE

    Joined:
    Apr 18, 2017
    Posts:
    6
    Long story short, I'm working on reverse-engineering an iOS game written with Unity (you can read more about it here).

    I've successfully been able to inject a custom library into the game process, having it load my second Unity instance, and hook to a couple of functions I'm interested to give a look at.

    Now, considering I'm interested into replacing a method implementation with my custom version, I used these hooks in order to pass the control to my dynamic library (rather than the actual game logic): everything works flawlessly, except when the custom method is supposed to call a function on an interface via the "InterfaceFuncInvoker" approach.

    In this case, in fact, the application crashes with the following stack trace:

    For anyone wondering, the game uses Google Protobuf to share data with a server, so I need to call the "MessageExtensions_ToByteArray_m2556561086" (which is throwing the error) in order to get a byte-array-representation of the message sent.

    When I try to call this routine from the "Update" method on one of my scripts, it works without problems; but if I try to invoke it manually from inside one of my hooks, it crashes... I guess it's something related to the fact that Unity is not really thread-safe etc, but honestly I have no idea.

    Has anyone ever experienced something similar? Or maybe can help me figure this out?
     
    Last edited: Apr 23, 2017
  2. UnknownRE

    UnknownRE

    Joined:
    Apr 18, 2017
    Posts:
    6
  3. NeverTrustShadows

    NeverTrustShadows

    Joined:
    Mar 15, 2020
    Posts:
    13
    What is this? Is this solved? How?