Git Product home page Git Product logo

Comments (3)

sneakyevil avatar sneakyevil commented on May 25, 2024

You can already see that when you hover over the FindObjectsOfType function it shows you the return value.
So there are 2 pointers.
I changed some stuff since the wiki so the actual FindObjectsOfType just need type without pointer.

ex.

Unity::il2cppArray<Unity::CGameObject*>* m_pObjects = Unity::Object::FindObjectsOfType<Unity::CGameObject>(UNITY_GAMEOBJECT_CLASS);

Also the Unity::il2cppArray type has no m_pArray, I'm thinking this has been replaced with m_pValues?

Use defined function to get array value:

Unity::CGameObject* m_pObject = m_pObjects->operator[](/* index */);

Other than that, the lib seems to be working fine, I've successfully printed methods of my PlayerManager class, but I have no idea how to call them. CClass has the CallMethod function, I got the method pointer through IL2CPP::Class::Utils::GetMethodPointer, but how do I get a CClass in the first place? I couldn't find a constructor and got stuck.

There is no way to get easily initialized class in memory besides hooking some function and stealing the pointer, finding gameobject that has the class connected to it via component or calling constructor function.

Also this depends if the function even needs class pointer. If the function is defined "statically" you can just call the function directly with pointer as:

reinterpret_cast<void(__fastcall*)(/* args */)>(/* pointer to function */)(/* args values */);

You gonna need to debug some stuff to figure out multiple stuff for desired game or whatever you're doing to see how the method is handled.
I also still recommend dumping the game with il2cppDumper and checking dump.cs & script.json for easier work.

from il2cpp_resolver.

ReijiAzuma avatar ReijiAzuma commented on May 25, 2024

Thanks for clarifying the first part, I can now get the player GameObject just fine and it works like a charm!

I also still recommend dumping the game with il2cppDumper and checking dump.cs & script.json for easier work.

I did that and I'm trying to apply what I've learned modding with BepInEx to C++.

As for the second part, in my game's case, the PlayerManager exposes a static Instance() method as well as a static _instance field so I guess that's easy for getting the initialized class in memory. If I call it then I should be able to get the pointer and afterwards the aforementioned fields, like the characterList. But how do I adapt it to the lib, like getting a CClass or something else from the instance pointer.

from il2cpp_resolver.

sneakyevil avatar sneakyevil commented on May 25, 2024

You might need to understand that when you're getting the class via Instance it can diff from the actual class you want to get which holds desired fields.
Thats when I mentioned the requirement of hooking or finding gameobject that holds the component (with the class)

The IL2CPP::CClass is literally just class handler for any custom class the game offers so you can easily use some function such as, get/set fields & properties or call/get methods.

You gonna need to reinterpret_cast the class pointer to the IL2CPP::CClass if you wanna use it.

from il2cpp_resolver.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.