sneakyevil / IL2CPP_Resolver

A run-time API resolver for IL2CPP Unity.
https://sneakyevil.gitbook.io/il2cpp-resolver/
The Unlicense
360 stars 66 forks source link

FetchFields results in an empty vector #54

Closed svorogaze closed 3 months ago

svorogaze commented 3 months ago

What is the game you are using with IL2CPP Resolver?

SCP:SL

Details:

I tried fetching fields of object with the name "Default Camera", but using FetchFields results in empty vector. I also tried the same for all objects in the game and they all had zero fetched fields, also tried it in other game(Phasmophobia) and it didn't work there either, so I assume the problem is my code

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

auto ptr = Unity::GameObject::Find("Default Camera");
if (ptr) {
     std::vector<Unity::il2cppFieldInfo*> vect;
     ptr->FetchFields(&vect);
     std::cout << vect.size() << '\n';
     for (auto i : vect) {
           std::cout << i->m_pName << ' ' << i->m_iOffset << '\n';
     }
}
sneakyevil commented 3 months ago

Maybe try attach debugger and step through the code and check what could be wrong?

svorogaze commented 3 months ago

SCP:SL prevents debugger from being attached, so I tried doing it in Phasmophobia, IL2CPP::Class::GetFields never returns value that is not nullptr, but I still don't understand what is wrong with my code

sneakyevil commented 3 months ago

Different unity version might change class to il2cppObject member or that function has been changed, either go debug and figure out what it is calling with pdb to unityplayer.dll or manually check it in static analyze via ghidra/ida and try fix it. There shouldn't be anything wrong with your code.