IL2CPP_Resolver updated. #36

Merged
jadis0x merged 1 commits from V2 into V2 2024-04-11 11:30:09 +00:00
8 changed files with 122 additions and 68 deletions
Showing only changes of commit 33e0147a4f - Show all commits

View File

@@ -61,10 +61,15 @@ namespace IL2CPP
// Fetch
{
void** m_pMonoBehaviourVTable = *reinterpret_cast<void***>(IL2CPP::Helper::GetMonoBehaviour()->m_CachedPtr);
if (m_pMonoBehaviourVTable) // x86: darkness my old friend
if (m_pMonoBehaviourVTable) // x86: Hello my old friend :)
{
OnUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0x33, 0xD2, 0xE9 }); // xor edx, edx | jmp
OnLateUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0xBA, 0x01, 0x00, 0x00, 0x00, 0xE9 }); // mov edx, 1 | jmp
#ifdef _WIN64
OnUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0x33, 0xD2, 0xE9 }); // xor edx, edx | jmp
OnLateUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0xBA, 0x01, 0x00, 0x00, 0x00, 0xE9 }); // mov edx, 1 | jmp
#elif _WIN32
OnUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0x6A, 0x00, 0xE8 }); // push 00 | call
OnLateUpdate::Data.m_pVTable = VFunc::Find_ASM(m_pMonoBehaviourVTable, 99, { 0x6A, 0x01, 0xE8 }); // push 01 | call
#endif
}
}
@@ -72,15 +77,15 @@ namespace IL2CPP
// Replace
{
Replace_VFunc(OnUpdate::Data.m_pVTable, OnUpdate::Caller, &OnUpdate::Data.m_pOriginal);
Replace_VFunc(OnLateUpdate::Data.m_pVTable, OnLateUpdate::Caller, &OnLateUpdate::Data.m_pOriginal);
Replace_VFunc(OnUpdate::Data.m_pVTable, OnUpdate::Caller, &OnUpdate::Data.m_pOriginal);
Replace_VFunc(OnLateUpdate::Data.m_pVTable, OnLateUpdate::Caller, &OnLateUpdate::Data.m_pOriginal);
}
}
void Uninitialize()
{
Replace_VFunc(OnUpdate::Data.m_pVTable, OnUpdate::Data.m_pOriginal, nullptr);
Replace_VFunc(OnLateUpdate::Data.m_pVTable, OnLateUpdate::Data.m_pOriginal, nullptr);
Replace_VFunc(OnUpdate::Data.m_pVTable, OnUpdate::Data.m_pOriginal, nullptr);
Replace_VFunc(OnLateUpdate::Data.m_pVTable, OnLateUpdate::Data.m_pOriginal, nullptr);
}
}
}

View File

@@ -2,11 +2,11 @@
namespace IL2CPP
{
namespace Class
{
namespace Class
{
Unity::il2cppFieldInfo* GetFields(Unity::il2cppClass* m_pClass, void** m_pIterator)
{
return reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, void**)>(Data.Functions.m_pClassGetFields)(m_pClass, m_pIterator);
return reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, void**)>(Data.Functions.m_pClassGetFields)(m_pClass, m_pIterator);
}
void FetchFields(Unity::il2cppClass* m_pClass, std::vector<Unity::il2cppFieldInfo*>* m_pVector, void* m_pFieldIterator)
@@ -25,7 +25,7 @@ namespace IL2CPP
Unity::il2cppMethodInfo* GetMethods(Unity::il2cppClass* m_pClass, void** m_pIterator)
{
return reinterpret_cast<Unity::il2cppMethodInfo*(IL2CPP_CALLING_CONVENTION)(void*, void**)>(Data.Functions.m_pClassGetMethods)(m_pClass, m_pIterator);
return reinterpret_cast<Unity::il2cppMethodInfo * (IL2CPP_CALLING_CONVENTION)(void*, void**)>(Data.Functions.m_pClassGetMethods)(m_pClass, m_pIterator);
}
void FetchMethods(Unity::il2cppClass* m_pClass, std::vector<Unity::il2cppMethodInfo*>* m_pVector, void* m_pMethodIterator)
@@ -44,12 +44,12 @@ namespace IL2CPP
Unity::il2cppType* GetType(Unity::il2cppClass* m_pClass)
{
return reinterpret_cast<Unity::il2cppType*(IL2CPP_CALLING_CONVENTION)(void*)>(Data.Functions.m_pClassGetType)(m_pClass);
return reinterpret_cast<Unity::il2cppType * (IL2CPP_CALLING_CONVENTION)(void*)>(Data.Functions.m_pClassGetType)(m_pClass);
}
Unity::il2cppObject* GetSystemType(Unity::il2cppClass* m_pClass)
{
return reinterpret_cast<Unity::il2cppObject*(IL2CPP_CALLING_CONVENTION)(void*)>(Data.Functions.m_pTypeGetObject)(GetType(m_pClass));
return reinterpret_cast<Unity::il2cppObject * (IL2CPP_CALLING_CONVENTION)(void*)>(Data.Functions.m_pTypeGetObject)(GetType(m_pClass));
}
Unity::il2cppObject* GetSystemType(const char* m_pClassName)
@@ -63,11 +63,11 @@ namespace IL2CPP
Unity::il2cppClass* GetFromName(Unity::il2cppImage* m_pImage, const char* m_pNamespace, const char* m_pName)
{
return reinterpret_cast<Unity::il2cppClass*(IL2CPP_CALLING_CONVENTION)(void*, const char*, const char*)>(Data.Functions.m_pClassFromName)(m_pImage, m_pNamespace, m_pName);
return reinterpret_cast<Unity::il2cppClass * (IL2CPP_CALLING_CONVENTION)(void*, const char*, const char*)>(Data.Functions.m_pClassFromName)(m_pImage, m_pNamespace, m_pName);
}
Unity::il2cppClass* Find(const char* m_pName)
{
Unity::il2cppClass* Find(const char* m_pName)
{
size_t m_sAssembliesCount = 0U;
Unity::il2cppAssembly** m_pAssemblies = Domain::GetAssemblies(&m_sAssembliesCount);
if (!m_pAssemblies || 0U >= m_sAssembliesCount) return nullptr;
@@ -101,7 +101,7 @@ namespace IL2CPP
delete[] m_pNameSpace;
return m_pClassReturn;
}
}
void FetchClasses(std::vector<Unity::il2cppClass*>* m_pVector, const char* m_pModuleName, const char* m_pNamespace)
{
@@ -127,7 +127,7 @@ namespace IL2CPP
size_t m_sClassesCount = reinterpret_cast<size_t(IL2CPP_CALLING_CONVENTION)(void*)>(Data.Functions.m_pImageGetClassCount)(m_pImage);
for (size_t i = 0U; m_sClassesCount > i; ++i)
{
Unity::il2cppClass* m_pClass = reinterpret_cast<Unity::il2cppClass*(IL2CPP_CALLING_CONVENTION)(void*, size_t)>(Data.Functions.m_pImageGetClass)(m_pImage, i);
Unity::il2cppClass* m_pClass = reinterpret_cast<Unity::il2cppClass * (IL2CPP_CALLING_CONVENTION)(void*, size_t)>(Data.Functions.m_pImageGetClass)(m_pImage, i);
if (m_pNamespace)
{
if (m_pNamespace[0] == '\0')
@@ -173,7 +173,7 @@ namespace IL2CPP
void* GetMethodPointer(Unity::il2cppClass* m_pClass, const char* m_pMethodName, int m_iArgs)
{
Unity::il2cppMethodInfo* pMethod = reinterpret_cast<Unity::il2cppMethodInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*, int)>(Data.Functions.m_pClassGetMethodFromName)(m_pClass, m_pMethodName, m_iArgs);
Unity::il2cppMethodInfo* pMethod = reinterpret_cast<Unity::il2cppMethodInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*, int)>(Data.Functions.m_pClassGetMethodFromName)(m_pClass, m_pMethodName, m_iArgs);
if (!pMethod) return nullptr;
return pMethod->m_pMethodPointer;
@@ -188,14 +188,14 @@ namespace IL2CPP
return nullptr;
}
void* GetMethodPointer(const char* m_pClassName, const char* m_pMethodName, std::initializer_list<const char*> m_vNames)
void* GetMethodPointer(const char* m_pClassName, const char* m_pMethodName, std::initializer_list<const char*> m_vNames)
{
Unity::il2cppClass* m_pClass = Find(m_pClassName);
if (!m_pClass)
return nullptr;
int m_iNamesCount = static_cast<int>(m_vNames.size());
const char** m_pNames = const_cast<const char**>(m_vNames.begin());
int m_iNamesCount = static_cast<int>(m_vNames.size());
const char** m_pNames = const_cast<const char**>(m_vNames.begin());
void* m_pMethodIterator = nullptr;
while (1)
@@ -220,7 +220,7 @@ namespace IL2CPP
}
return nullptr;
}
Unity::il2cppClass* FilterClass(std::vector<Unity::il2cppClass*>* m_pClasses, std::initializer_list<const char*> m_vNames, int m_iFoundCount)
{
int m_iNamesCount = static_cast<int>(m_vNames.size());
@@ -285,5 +285,5 @@ namespace IL2CPP
return m_pMethodPointer;
}
}
}
}
}
}

View File

@@ -37,14 +37,14 @@ namespace IL2CPP
void* GetMethodPointer(Unity::il2cppClass* m_pClass, const char* m_pMethodName, int m_iArgs = -1);
void* GetMethodPointer(const char* m_pClassName, const char* m_pMethodName, int m_iArgs = -1);
/*
* Usage:
* m_vNames = { "arg1" , "arg2" , ... }
*/
void* GetMethodPointer(const char* m_pClassName, const char* m_pMethodName, std::initializer_list<const char*> m_vNames);
/*
* Name Prefixes
* (Field) ~
@@ -69,7 +69,7 @@ namespace IL2CPP
public:
Unity::il2cppObject m_Object = { 0 };
void* m_CachedPtr = nullptr;
// Wrappers for namespace, ah...
Unity::il2cppFieldInfo* GetFields(void** m_pIterator)
{
@@ -98,16 +98,16 @@ namespace IL2CPP
m_eClassPropType GetPropType(const char* m_pPropType)
{
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pPropType);
if (pField)
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pPropType);
if (pField)
return m_eClassPropType::Field;
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropType);
if (pProperty)
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropType);
if (pProperty)
return m_eClassPropType::Property;
Unity::il2cppMethodInfo* pMethod = reinterpret_cast<Unity::il2cppMethodInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*, int)>(Data.Functions.m_pClassGetMethodFromName)(m_Object.m_pClass, m_pPropType, -1);
if (pMethod)
Unity::il2cppMethodInfo* pMethod = reinterpret_cast<Unity::il2cppMethodInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*, int)>(Data.Functions.m_pClassGetMethodFromName)(m_Object.m_pClass, m_pPropType, -1);
if (pMethod)
return m_eClassPropType::Method;
return m_eClassPropType::Unknown;
@@ -125,9 +125,9 @@ namespace IL2CPP
{
if (!m_pMethod)
{
#ifdef _DEBUG
__debugbreak(); // remove it when you wanna step through your code and be like why the fuck it doesn't do anything.
#endif
#ifdef _DEBUG
__debugbreak(); // remove it when you wanna step through your code and be like why the fuck it doesn't do anything.
#endif
TReturn m_tDefault = {}; // void goes like illegal use of type. (use void* and fuck them)
return m_tDefault;
@@ -144,8 +144,8 @@ namespace IL2CPP
template<typename T>
T GetPropertyValue(const char* m_pPropertyName)
{
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName);
if (pProperty && pProperty->m_pGet)
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName);
if (pProperty && pProperty->m_pGet)
return reinterpret_cast<T(UNITY_CALLING_CONVENTION)(void*)>(pProperty->m_pGet->m_pMethodPointer)(this);
T tDefault = {};
@@ -155,8 +155,8 @@ namespace IL2CPP
template<typename T>
void SetPropertyValue(const char* m_pPropertyName, T m_tValue)
{
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName);
if (pProperty && pProperty->m_pSet)
Unity::il2cppPropertyInfo* pProperty = reinterpret_cast<Unity::il2cppPropertyInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName);
if (pProperty && pProperty->m_pSet)
return reinterpret_cast<void(UNITY_CALLING_CONVENTION)(void*, T)>(pProperty->m_pSet->m_pMethodPointer)(this, m_tValue);
}
@@ -196,7 +196,7 @@ namespace IL2CPP
template<typename T>
T GetMemberValue(const char* m_pMemberName)
{
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
if (pField)
{
if (pField->m_iOffset >= 0) return *reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(this) + pField->m_iOffset);
@@ -211,7 +211,7 @@ namespace IL2CPP
template<typename T>
void SetMemberValue(const char* m_pMemberName, T m_tValue)
{
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
Unity::il2cppFieldInfo* pField = reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
if (pField)
{
if (pField->m_iOffset >= 0) *reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(this) + pField->m_iOffset) = m_tValue;
@@ -228,7 +228,7 @@ namespace IL2CPP
{
switch (sizeof(T))
{
case sizeof(double):
case sizeof(double) :
{
long long m_lKey = *reinterpret_cast<long long*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
long long m_lValue = *reinterpret_cast<long long*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_lKey));
@@ -237,7 +237,7 @@ namespace IL2CPP
return *reinterpret_cast<T*>(&m_lValue);
}
break;
case sizeof(int):
case sizeof(int) :
{
int m_iKey = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
int m_iValue = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_iKey));
@@ -246,7 +246,7 @@ namespace IL2CPP
return *reinterpret_cast<T*>(&m_iValue);
}
break;
case sizeof(bool):
case sizeof(bool) :
{
unsigned char m_uKey = *reinterpret_cast<unsigned char*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
int m_iValue = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_uKey));
@@ -265,7 +265,7 @@ namespace IL2CPP
template<typename T>
T GetObscuredValue(const char* m_pMemberName)
{
Unity::il2cppFieldInfo* m_pField = reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
Unity::il2cppFieldInfo* m_pField = reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
return GetObscuredViaOffset<T>(m_pField ? m_pField->m_iOffset : -1);
}
@@ -277,7 +277,7 @@ namespace IL2CPP
switch (sizeof(T))
{
case sizeof(double):
case sizeof(double) :
{
long long m_lKey = *reinterpret_cast<long long*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
long long* m_pValue = reinterpret_cast<long long*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_lKey));
@@ -285,7 +285,7 @@ namespace IL2CPP
*m_pValue = *reinterpret_cast<long long*>(&m_tValue) ^ m_lKey;
}
break;
case sizeof(int):
case sizeof(int) :
{
int m_iKey = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
int* m_pValue = reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_iKey));
@@ -293,7 +293,7 @@ namespace IL2CPP
*m_pValue = *reinterpret_cast<int*>(&m_tValue) ^ m_iKey;
}
break;
case sizeof(bool):
case sizeof(bool) :
{
unsigned char m_uKey = *reinterpret_cast<unsigned char*>(reinterpret_cast<uintptr_t>(this) + m_iOffset);
int* m_pValue = reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(this) + m_iOffset + sizeof(m_uKey));
@@ -307,11 +307,11 @@ namespace IL2CPP
template<typename T>
void SetObscuredValue(const char* m_pMemberName, T m_tValue)
{
Unity::il2cppFieldInfo* m_pField = reinterpret_cast<Unity::il2cppFieldInfo*(IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
Unity::il2cppFieldInfo* m_pField = reinterpret_cast<Unity::il2cppFieldInfo * (IL2CPP_CALLING_CONVENTION)(void*, const char*)>(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName);
if (!m_pField)
return;
SetObscuredViaOffset<T>(m_pField->m_iOffset, m_tValue);
}
};
}
}

View File

@@ -28,12 +28,12 @@ namespace Unity
CComponent* GetComponent(const char* m_pName)
{
return reinterpret_cast<CComponent*(UNITY_CALLING_CONVENTION)(void*, System_String*)>(GameObjectFunctions.m_pGetComponent)(this, IL2CPP::String::New(m_pName));
return reinterpret_cast<CComponent * (UNITY_CALLING_CONVENTION)(void*, System_String*)>(GameObjectFunctions.m_pGetComponent)(this, IL2CPP::String::New(m_pName));
}
il2cppArray<CComponent*>* GetComponents(il2cppObject* m_pSystemType)
{
/*
/*
0 - Object
1 - Type
2 - Use search type as array return type
@@ -71,7 +71,7 @@ namespace Unity
CTransform* GetTransform()
{
return reinterpret_cast<CTransform*(UNITY_CALLING_CONVENTION)(void*)>(GameObjectFunctions.m_pGetTransform)(this);
return reinterpret_cast<CTransform * (UNITY_CALLING_CONVENTION)(void*)>(GameObjectFunctions.m_pGetTransform)(this);
}
bool GetActive()
@@ -112,11 +112,11 @@ namespace Unity
};
void Initialize();
CGameObject* CreatePrimitive(m_ePrimitiveType m_eType);
CGameObject* Find(const char* m_pName);
il2cppArray<CGameObject*>* FindWithTag(const char* m_pTag);
}
}
}

View File

@@ -20,7 +20,7 @@ namespace Unity
System_String* GetName()
{
return reinterpret_cast<System_String*(UNITY_CALLING_CONVENTION)(void*)>(ObjectFunctions.m_pGetName)(this);
return reinterpret_cast<System_String * (UNITY_CALLING_CONVENTION)(void*)>(ObjectFunctions.m_pGetName)(this);
}
};
@@ -61,4 +61,4 @@ namespace Unity
return FindObjectOfType<T>(IL2CPP::Class::GetSystemType(m_pClass));
}
}
}
}

View File

@@ -1,6 +1,12 @@
#pragma once
// Calling Convention
#ifdef _WIN64
#define UNITY_CALLING_CONVENTION __fastcall*
#elif _WIN32
#define UNITY_CALLING_CONVENTION __cdecl*
#endif
// Camera
#define UNITY_CAMERA_CLASS "UnityEngine.Camera"
@@ -83,7 +89,7 @@ namespace Unity
Type_Variable = 19,
Type_Array = 20,
Type_Enum = 85,
};
};
enum m_eFieldAttribute
{
@@ -107,4 +113,4 @@ namespace Unity
FieldAttribute_Default = 32768,
FieldAttribute_Reserved = 38144,
};
}
}

View File

@@ -19,8 +19,8 @@ namespace Unity
{
if (!this) return "";
std::string sRet(static_cast<size_t>(m_iLength) + 1, '\0');
WideCharToMultiByte(CP_UTF8, 0, m_wString, m_iLength, &sRet[0], m_iLength, 0, 0);
std::string sRet(static_cast<size_t>(m_iLength) * 3 + 1, '\0');
WideCharToMultiByte(CP_UTF8, 0, m_wString, m_iLength, &sRet[0], static_cast<int>(sRet.size()), 0, 0);
return sRet;
}
};

View File

@@ -2,12 +2,18 @@
namespace Unity
{
// Don't use! Untested
template<typename T>
template<typename TKey, typename TValue>
struct il2cppDictionary : il2cppObject
{
struct Entry
{
int m_iHashCode;
int m_iNext;
TKey m_tKey;
TValue m_tValue;
};
il2cppArray<int>* m_pBuckets;
il2cppArray<T>* m_pEntries;
il2cppArray<Entry*>* m_pEntries;
int m_iCount;
int m_iVersion;
int m_iFreeList;
@@ -15,5 +21,42 @@ namespace Unity
void* m_pComparer;
void* m_pKeys;
void* m_pValues;
Entry* GetEntry()
{
return (Entry*)m_pEntries->GetData();
}
TKey GetKeyByIndex(int iIndex)
{
TKey tKey = { 0 };
Entry* pEntry = GetEntry();
if (pEntry)
tKey = pEntry[iIndex].m_tKey;
return tKey;
}
TValue GetValueByIndex(int iIndex)
{
TValue tValue = { 0 };
Entry* pEntry = GetEntry();
if (pEntry)
tValue = pEntry[iIndex].m_tValue;
return tValue;
}
TValue GetValueByKey(TKey tKey)
{
TValue tValue = { 0 };
for (int i = 0; i < m_iCount; i++) {
if (GetEntry()[i].m_tKey == tKey)
tValue = GetEntry()[i].m_tValue;
}
return tValue;
}
};
}