diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Callback.cpp b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Callback.cpp index 2bbc1cf..d94996b 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Callback.cpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Callback.cpp @@ -61,10 +61,15 @@ namespace IL2CPP // Fetch { void** m_pMonoBehaviourVTable = *reinterpret_cast(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); } } } \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.cpp b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.cpp index dc13d6f..64dad2e 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.cpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.cpp @@ -2,11 +2,11 @@ namespace IL2CPP { - namespace Class - { + namespace Class + { Unity::il2cppFieldInfo* GetFields(Unity::il2cppClass* m_pClass, void** m_pIterator) { - return reinterpret_cast(Data.Functions.m_pClassGetFields)(m_pClass, m_pIterator); + return reinterpret_cast(Data.Functions.m_pClassGetFields)(m_pClass, m_pIterator); } void FetchFields(Unity::il2cppClass* m_pClass, std::vector* m_pVector, void* m_pFieldIterator) @@ -25,7 +25,7 @@ namespace IL2CPP Unity::il2cppMethodInfo* GetMethods(Unity::il2cppClass* m_pClass, void** m_pIterator) { - return reinterpret_cast(Data.Functions.m_pClassGetMethods)(m_pClass, m_pIterator); + return reinterpret_cast(Data.Functions.m_pClassGetMethods)(m_pClass, m_pIterator); } void FetchMethods(Unity::il2cppClass* m_pClass, std::vector* m_pVector, void* m_pMethodIterator) @@ -44,12 +44,12 @@ namespace IL2CPP Unity::il2cppType* GetType(Unity::il2cppClass* m_pClass) { - return reinterpret_cast(Data.Functions.m_pClassGetType)(m_pClass); + return reinterpret_cast(Data.Functions.m_pClassGetType)(m_pClass); } Unity::il2cppObject* GetSystemType(Unity::il2cppClass* m_pClass) { - return reinterpret_cast(Data.Functions.m_pTypeGetObject)(GetType(m_pClass)); + return reinterpret_cast(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(Data.Functions.m_pClassFromName)(m_pImage, m_pNamespace, m_pName); + return reinterpret_cast(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* m_pVector, const char* m_pModuleName, const char* m_pNamespace) { @@ -127,7 +127,7 @@ namespace IL2CPP size_t m_sClassesCount = reinterpret_cast(Data.Functions.m_pImageGetClassCount)(m_pImage); for (size_t i = 0U; m_sClassesCount > i; ++i) { - Unity::il2cppClass* m_pClass = reinterpret_cast(Data.Functions.m_pImageGetClass)(m_pImage, i); + Unity::il2cppClass* m_pClass = reinterpret_cast(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(Data.Functions.m_pClassGetMethodFromName)(m_pClass, m_pMethodName, m_iArgs); + Unity::il2cppMethodInfo* pMethod = reinterpret_cast(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 m_vNames) + void* GetMethodPointer(const char* m_pClassName, const char* m_pMethodName, std::initializer_list m_vNames) { Unity::il2cppClass* m_pClass = Find(m_pClassName); if (!m_pClass) return nullptr; - int m_iNamesCount = static_cast(m_vNames.size()); - const char** m_pNames = const_cast(m_vNames.begin()); + int m_iNamesCount = static_cast(m_vNames.size()); + const char** m_pNames = const_cast(m_vNames.begin()); void* m_pMethodIterator = nullptr; while (1) @@ -220,7 +220,7 @@ namespace IL2CPP } return nullptr; } - + Unity::il2cppClass* FilterClass(std::vector* m_pClasses, std::initializer_list m_vNames, int m_iFoundCount) { int m_iNamesCount = static_cast(m_vNames.size()); @@ -285,5 +285,5 @@ namespace IL2CPP return m_pMethodPointer; } } - } -} + } +} \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.hpp index 783b0dc..5dd6d0a 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Functions/Class.hpp @@ -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 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(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pPropType); - if (pField) + Unity::il2cppFieldInfo* pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pPropType); + if (pField) return m_eClassPropType::Field; - Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropType); - if (pProperty) + Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropType); + if (pProperty) return m_eClassPropType::Property; - Unity::il2cppMethodInfo* pMethod = reinterpret_cast(Data.Functions.m_pClassGetMethodFromName)(m_Object.m_pClass, m_pPropType, -1); - if (pMethod) + Unity::il2cppMethodInfo* pMethod = reinterpret_cast(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 T GetPropertyValue(const char* m_pPropertyName) { - Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName); - if (pProperty && pProperty->m_pGet) + Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName); + if (pProperty && pProperty->m_pGet) return reinterpret_cast(pProperty->m_pGet->m_pMethodPointer)(this); T tDefault = {}; @@ -155,8 +155,8 @@ namespace IL2CPP template void SetPropertyValue(const char* m_pPropertyName, T m_tValue) { - Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName); - if (pProperty && pProperty->m_pSet) + Unity::il2cppPropertyInfo* pProperty = reinterpret_cast(Data.Functions.m_pClassGetPropertyFromName)(m_Object.m_pClass, m_pPropertyName); + if (pProperty && pProperty->m_pSet) return reinterpret_cast(pProperty->m_pSet->m_pMethodPointer)(this, m_tValue); } @@ -196,7 +196,7 @@ namespace IL2CPP template T GetMemberValue(const char* m_pMemberName) { - Unity::il2cppFieldInfo* pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); + Unity::il2cppFieldInfo* pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); if (pField) { if (pField->m_iOffset >= 0) return *reinterpret_cast(reinterpret_cast(this) + pField->m_iOffset); @@ -211,7 +211,7 @@ namespace IL2CPP template void SetMemberValue(const char* m_pMemberName, T m_tValue) { - Unity::il2cppFieldInfo* pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); + Unity::il2cppFieldInfo* pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); if (pField) { if (pField->m_iOffset >= 0) *reinterpret_cast(reinterpret_cast(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(reinterpret_cast(this) + m_iOffset); long long m_lValue = *reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_lKey)); @@ -237,7 +237,7 @@ namespace IL2CPP return *reinterpret_cast(&m_lValue); } break; - case sizeof(int): + case sizeof(int) : { int m_iKey = *reinterpret_cast(reinterpret_cast(this) + m_iOffset); int m_iValue = *reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_iKey)); @@ -246,7 +246,7 @@ namespace IL2CPP return *reinterpret_cast(&m_iValue); } break; - case sizeof(bool): + case sizeof(bool) : { unsigned char m_uKey = *reinterpret_cast(reinterpret_cast(this) + m_iOffset); int m_iValue = *reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_uKey)); @@ -265,7 +265,7 @@ namespace IL2CPP template T GetObscuredValue(const char* m_pMemberName) { - Unity::il2cppFieldInfo* m_pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); + Unity::il2cppFieldInfo* m_pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); return GetObscuredViaOffset(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(reinterpret_cast(this) + m_iOffset); long long* m_pValue = reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_lKey)); @@ -285,7 +285,7 @@ namespace IL2CPP *m_pValue = *reinterpret_cast(&m_tValue) ^ m_lKey; } break; - case sizeof(int): + case sizeof(int) : { int m_iKey = *reinterpret_cast(reinterpret_cast(this) + m_iOffset); int* m_pValue = reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_iKey)); @@ -293,7 +293,7 @@ namespace IL2CPP *m_pValue = *reinterpret_cast(&m_tValue) ^ m_iKey; } break; - case sizeof(bool): + case sizeof(bool) : { unsigned char m_uKey = *reinterpret_cast(reinterpret_cast(this) + m_iOffset); int* m_pValue = reinterpret_cast(reinterpret_cast(this) + m_iOffset + sizeof(m_uKey)); @@ -307,11 +307,11 @@ namespace IL2CPP template void SetObscuredValue(const char* m_pMemberName, T m_tValue) { - Unity::il2cppFieldInfo* m_pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); + Unity::il2cppFieldInfo* m_pField = reinterpret_cast(Data.Functions.m_pClassGetFieldFromName)(m_Object.m_pClass, m_pMemberName); if (!m_pField) return; - + SetObscuredViaOffset(m_pField->m_iOffset, m_tValue); } }; -} +} \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/GameObject.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/GameObject.hpp index c52c463..22ec579 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/GameObject.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/GameObject.hpp @@ -28,12 +28,12 @@ namespace Unity CComponent* GetComponent(const char* m_pName) { - return reinterpret_cast(GameObjectFunctions.m_pGetComponent)(this, IL2CPP::String::New(m_pName)); + return reinterpret_cast(GameObjectFunctions.m_pGetComponent)(this, IL2CPP::String::New(m_pName)); } il2cppArray* 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(GameObjectFunctions.m_pGetTransform)(this); + return reinterpret_cast(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* FindWithTag(const char* m_pTag); } -} +} \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/Object.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/Object.hpp index bd2a30c..f82ad25 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/Object.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/API/Object.hpp @@ -20,7 +20,7 @@ namespace Unity System_String* GetName() { - return reinterpret_cast(ObjectFunctions.m_pGetName)(this); + return reinterpret_cast(ObjectFunctions.m_pGetName)(this); } }; @@ -61,4 +61,4 @@ namespace Unity return FindObjectOfType(IL2CPP::Class::GetSystemType(m_pClass)); } } -} +} \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Defines.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Defines.hpp index b65e8bd..d6e081a 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Defines.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Defines.hpp @@ -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, }; -} +} \ No newline at end of file diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/System_String.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/System_String.hpp index 653e33a..6cc5e8c 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/System_String.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/System_String.hpp @@ -19,8 +19,8 @@ namespace Unity { if (!this) return ""; - std::string sRet(static_cast(m_iLength) + 1, '\0'); - WideCharToMultiByte(CP_UTF8, 0, m_wString, m_iLength, &sRet[0], m_iLength, 0, 0); + std::string sRet(static_cast(m_iLength) * 3 + 1, '\0'); + WideCharToMultiByte(CP_UTF8, 0, m_wString, m_iLength, &sRet[0], static_cast(sRet.size()), 0, 0); return sRet; } }; diff --git a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/il2cppDictionary.hpp b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/il2cppDictionary.hpp index b16cac2..2344b2b 100644 --- a/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/il2cppDictionary.hpp +++ b/DevourClient/Dependencies/IL2CPP_Resolver/Unity/Structures/il2cppDictionary.hpp @@ -2,12 +2,18 @@ namespace Unity { - // Don't use! Untested - template + template struct il2cppDictionary : il2cppObject { + struct Entry + { + int m_iHashCode; + int m_iNext; + TKey m_tKey; + TValue m_tValue; + }; il2cppArray* m_pBuckets; - il2cppArray* m_pEntries; + il2cppArray* 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; + } }; } \ No newline at end of file