sneakyevil / IL2CPP_Resolver

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

IL2CPP::ResolveCall return zero #5

Closed fork1488 closed 2 years ago

fork1488 commented 2 years ago
IL2CPP::SystemTypeCache::Initializer::Add("CharacterManager");
IL2CPP::ResolveCall("CharacterManager::GetCharacterByFid") -> return zero

IL2CPP::Class::GetSystemType("CharacterManager") -> return address, class have in game
auto ooooo = IL2CPP::Class::Find("CharacterManager"); -> return address same as IL2CPP::Class::GetSystemType("CharacterManager") 

std::vector<Unity::il2cppMethodInfo*> methods;
IL2CPP::Class::FetchMethods(ooooo, &methods);

 for (auto method : methods)
{
 print(method->name); // return string GetCharacterByFid
}
public sealed class CharacterManager : Il2CppSystem.Object
{
public unsafe ActorModel GetCharacterByFid(int fid)
}

when my error?

IL2CPP::Data.Functions.m_pResolveFunction not zero

sneakyevil commented 2 years ago

IL2CPP::ResolveCall is used only for predefined Unity Engine class functions and not custom C# Classes.

You gonna need to find class and fetch method as:

Unity::il2cppClass* m_pCharacterManager = IL2CPP::Class::Find("CharacterManager");
void* m_pGetCharacterByFid = IL2CPP::Class::Utils::GetMethodPointer(m_pCharacterManager , "GetCharacterByFid");
fork1488 commented 2 years ago

IL2CPP::ResolveCall is used only for predefined Unity Engine class functions and not custom C# Classes.

You gonna need to find class and fetch method as:

thx

fork1488 commented 2 years ago

IL2CPP::ResolveCall is used only for predefined Unity Engine class functions and not custom C# Classes.

You gonna need to find class and fetch method as:

Unity::il2cppClass* m_pCharacterManager = IL2CPP::Class::Find("CharacterManager");
void* m_pGetCharacterByFid = IL2CPP::Class::Utils::GetMethodPointer(m_pCharacterManager , "GetCharacterByFid");

sorry for stupid question, how find instance/s of class?

sneakyevil commented 2 years ago

sorry for stupid question, how find instance/s of class?

You can either hook constructor of class or any class function that gets called and just save the pointer. Simplest way to get class instance is find some component of gameobject that is currently using the class.