forked from sneakyevil/IL2CPP_Resolver
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCache.cpp
More file actions
74 lines (61 loc) · 1.38 KB
/
Cache.cpp
File metadata and controls
74 lines (61 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "Includes.hpp"
namespace IL2CPP
{
namespace SystemTypeCache
{
class CCache
{
public:
unsigned int m_uHash = 0U;
Unity::il2cppObject* m_pSystemType = nullptr;
CCache() { }
CCache(unsigned int m_uKey, Unity::il2cppObject* m_pValue)
{
m_uHash = m_uKey;
m_pSystemType = m_pValue;
}
};
std::vector<CCache> m_vCache;
void Add(unsigned int m_uHash, Unity::il2cppObject* m_pSystemType)
{
if (!m_pSystemType)
return;
m_vCache.emplace_back(CCache(m_uHash, m_pSystemType));
}
void Add(const char* m_pName, Unity::il2cppObject* m_pSystemType)
{
if (!m_pName)
return;
Add(Utils::JOAAT(m_pName), m_pSystemType);
}
Unity::il2cppObject* Find(unsigned int m_uHash)
{
size_t m_sSize = m_vCache.size();
if (m_sSize > 0)
{
CCache* m_pData = m_vCache.data();
for (size_t i = 0; m_sSize > i; ++i)
{
if (m_pData[i].m_uHash == m_uHash)
return m_pData[i].m_pSystemType;
}
}
return nullptr;
}
Unity::il2cppObject* Find(const char* m_pName)
{
return Find(Utils::JOAAT(m_pName));
}
namespace Initializer
{
std::vector<const char*> m_vList;
void Add(const char* m_pName) { m_vList.emplace_back(m_pName); }
void PreCache()
{
for (const char* m_pName : m_vList)
SystemTypeCache::Add(m_pName, IL2CPP::Class::GetSystemType(m_pName));
m_vList.clear();
}
}
}
}