forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassLibraryPAL.cpp
More file actions
72 lines (63 loc) · 1.8 KB
/
ClassLibraryPAL.cpp
File metadata and controls
72 lines (63 loc) · 1.8 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
#include "vm/Class.h"
#include "vm/ClassLibraryPAL.h"
#include "os/ClassLibraryPAL/pal_mirror_structs.h"
#if IL2CPP_DEBUG && !RUNTIME_NONE
#define IL2CPP_ENABLE_PAL_MIRROR_CHECK 1
#else
#define IL2CPP_ENABLE_PAL_MIRROR_CHECK 0
#endif
namespace il2cpp
{
namespace vm
{
#if IL2CPP_ENABLE_PAL_MIRROR_CHECK
static Il2CppClass* GetSysKlass()
{
static Il2CppClass* sysKlass = NULL;
if (!sysKlass)
{
Il2CppClass *interop = Class::FromName(il2cpp_defaults.corlib, "", "Interop");
if (interop == NULL)
return NULL;
void* iter = NULL;
while (auto nestedType = Class::GetNestedTypes(interop, &iter))
{
if (strcmp(nestedType->name, "Sys") == 0)
{
sysKlass = nestedType;
break;
}
}
}
return sysKlass;
}
template<typename MirrorStructType>
static void CheckStructSizeForInteropSys(const char* nameInClassLibrary)
{
do
{
Il2CppClass* sysClass = GetSysKlass();
if (sysClass == NULL)
return;
void* iter = NULL;
while (Il2CppClass* nestedType = Class::GetNestedTypes(sysClass, &iter))
{
if (!strcmp(nestedType->name, nameInClassLibrary))
{
IL2CPP_ASSERT(nestedType->native_size == sizeof(MirrorStructType));
return;
}
}
IL2CPP_ASSERT(0 && "Item not found");
}
while (0);
}
#endif
void ClassLibraryPAL::Initialize()
{
#if IL2CPP_ENABLE_PAL_MIRROR_CHECK
CheckStructSizeForInteropSys<struct FileStatus>("FileStatus");
#endif
}
} // namespace vm
} // namepsace il2cpp