Skip to content

IL2CPP::Callback::Initialize crashes on UnityEngine.GameObject::GetComponentsInternal call (Unity 6000.0.41f1) #67

@tikkamasala

Description

@tikkamasala

What is the game you are using with IL2CPP Resolver?

Dofus 3 https://www.dofus.com/en/mmorpg/discover

Details:

I am making a bot for this game and I managed to call the functions by putting all my bot logic into the Update hook because calling game functions after IL2CPP::Thread::Attach() made the game crash.

Now that the game has updated from Unity 2022.3.29f1 to Unity 6000.0.41f1, IL2CPP::Callback::Initialize fails. A lot of unity function names have changed and I managed to find the name changes by logging calls to il2cpp_resolve_icall on the game/my own Unity project with the same version. This is what I get :

GameAssembly address: 00007FF937190000
Resolving UnityEngine.GameObject::Internal_AddComponentWithType = 0000000000000000
Resolving UnityEngine.GameObject::CreatePrimitive = 0000000000000000
Resolving UnityEngine.GameObject::Find = 0000000000000000
Resolving UnityEngine.GameObject::GetComponentByName = 0000000000000000
Resolving UnityEngine.GameObject::GetComponentsInternal = 0000000000000000
Resolving UnityEngine.GameObject::GetComponentInChildren = 0000000000000000
Resolving UnityEngine.GameObject::get_active = 0000000000000000
Resolving UnityEngine.GameObject::get_layer = 0000000000000000
Resolving UnityEngine.GameObject::get_transform = 0000000000000000
Resolving UnityEngine.GameObject::set_active = 0000000000000000
Resolving UnityEngine.GameObject::set_layer = 0000000000000000
Resolving UnityEngine.GameObject::FindGameObjectsWithTag = 0000000000000000


Resolving UnityEngine.GameObject::Internal_AddComponentWithType_Injected = 00007FF9513E96B0
Resolving UnityEngine.GameObject::CreatePrimitive_Injected = 00007FF9513E8010
Resolving UnityEngine.GameObject::Find_Injected = 00007FF9513EBA00
Resolving UnityEngine.GameObject::GetComponentByName_Injected = 00007FF9513E8200
Resolving UnityEngine.GameObject::GetComponentsInternal_Injected = 00007FF9513E8B50
Resolving UnityEngine.GameObject::GetComponentInChildren_Injected = 00007FF9513E8960
Resolving UnityEngine.GameObject::get_active_Injected = 00007FF9513E9870
Resolving UnityEngine.GameObject::get_layer_Injected = 00007FF9513A8210
Resolving UnityEngine.GameObject::get_transform_Injected = 00007FF9513E97E0
Resolving UnityEngine.GameObject::set_active_Injected = 00007FF9513E9880
Resolving UnityEngine.GameObject::set_layer_Injected = 00007FF9513E9860
Resolving UnityEngine.GameObject::FindGameObjectsWithTag_Injected = 00007FF9513EA670

This is the value that got passed to il2cpp_resolve_icall : UnityEngine.GameObject::GetComponentsInternal_Injected(System.IntPtr,System.Type,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Object)

The arguments don't seem to have changed

/* 
0 - Object
1 - Type
2 - Use search type as array return type
3 - Recursive
4 - Include inactive
5 - Reverse
6 - Result list
*/
return reinterpret_cast<Unity::il2cppArray<CComponent*>*(UNITY_CALLING_CONVENTION)(void*, void*, bool, bool, bool, bool, void*)>(m_GameObjectFunctions.m_GetComponents)(this, m_pSystemType, false, false, true, false, nullptr);

In Visual Studio Debugger this is the call stack :

 	UnityPlayer.dll!00007ff9513e8c28()	Unknown
 	my.dll!Unity::CGameObject::GetComponents(Unity::il2cppObject * m_pSystemType) Line 61	C++
 	my.dll!Unity::CGameObject::GetComponentByIndex(Unity::il2cppObject * m_pSystemType, unsigned int m_uIndex) Line 73	C++
 	my.dll!Unity::CGameObject::GetComponentByIndex(const char * m_pSystemTypeName, unsigned int m_uIndex) Line 85	C++
 	my.dll!IL2CPP::Helper::GetMonoBehaviour() Line 15	C++
 	my.dll!DebugUnity6000() Line 335	C++

I get an exception for an access violation at 0x000001C6C0000000 on the m_GetComponents call.
m_pSystemType is a class object of System.RuntimeType but I doubt it matters that much.

I am trying to figure out how to fix this but I am looking forward to any idea.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

#define UNITY_GAMEOBJECT_CLASS "UnityEngine.GameObject"
#define UNITY_GAMEOBJECT_ADDCOMPONENT IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::Internal_AddComponentWithType_Injected")
#define UNITY_GAMEOBJECT_CREATEPRIMITIVE IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::CreatePrimitive_Injected")
#define UNITY_GAMEOBJECT_FIND IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::Find_Injected")
#define UNITY_GAMEOBJECT_GETCOMPONENT IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::GetComponentByName_Injected")
#define UNITY_GAMEOBJECT_GETCOMPONENTS IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::GetComponentsInternal_Injected")
#define UNITY_GAMEOBJECT_GETCOMPONENTINCHILDREN IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::GetComponentInChildren_Injected")
#define UNITY_GAMEOBJECT_GETACTIVE IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::get_active_Injected")
#define UNITY_GAMEOBJECT_GETLAYER IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::get_layer_Injected")
#define UNITY_GAMEOBJECT_GETTRANSFORM IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::get_transform_Injected")
#define UNITY_GAMEOBJECT_SETACTIVE IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::set_active_Injected")
#define UNITY_GAMEOBJECT_SETLAYER IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::set_layer_Injected")
#define UNITY_GAMEOBJECT_FINDGAMEOBJECTWITHTAG IL2CPP_RStr(UNITY_GAMEOBJECT_CLASS "::FindGameObjectsWithTag_Injected")

IL2CPP::Initialize(true);
IL2CPP::Callback::Initialize();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions