少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#pragma once
 
#include "il2cpp-config.h"
#include "codegen/il2cpp-codegen-metadata.h"
#include "il2cpp-class-internals.h"
 
#include "vm/Array.h"
#include "vm/Type.h"
#include "vm/Runtime.h"
#include "vm/GlobalMetadataFileInternals.h"
#include "icalls/mscorlib/System/Type.h"
#include "gc/GarbageCollector.h"
 
#if HYBRIDCLR_UNITY_2020
#include "icalls/mscorlib/System/MonoType.h"
#elif HYBRIDCLR_UNITY_2021 || HYBRIDCLR_UNITY_2022
#include "icalls/mscorlib/System/RuntimeType.h"
#include "icalls/mscorlib/System/RuntimeTypeHandle.h"
#elif HYBRIDCLR_UNITY_2019
#include "icalls/mscorlib/System/MonoType.h"
#if IL2CPP_SIZEOF_VOID_P == 8
#define PLATFORM_ARCH_64 1
#else
#define PLATFORM_ARCH_64 0
#endif
#elif !defined(HYBRIDCLR_UNITY_VERSION)
#error "please run 'HybridCLR/Generate/All' before building"
#else
#error "unsupported unity version"
#endif
 
#if IL2CPP_BYTE_ORDER != IL2CPP_LITTLE_ENDIAN
#error "only support litten endian"
#endif
 
#if    PLATFORM_ARCH_64
#define HYBRIDCLR_ARCH_64 1
#else
#define HYBRIDCLR_ARCH_64 0
#endif
 
#define PTR_SIZE IL2CPP_SIZEOF_VOID_P
 
#if HYBRIDCLR_ARCH_64 || HYBRIDCLR_TARGET_X86
#define SUPPORT_MEMORY_NOT_ALIGMENT_ACCESS  1
#else
#define SUPPORT_MEMORY_NOT_ALIGMENT_ACCESS  0
#endif
 
#ifndef ENABLE_PLACEHOLDER_DLL
#define ENABLE_PLACEHOLDER_DLL 1
#endif
 
#if IL2CPP_ENABLE_WRITE_BARRIERS
#define HYBRIDCLR_ENABLE_WRITE_BARRIERS 1
#else
#define HYBRIDCLR_ENABLE_WRITE_BARRIERS 0
#endif
 
 
#if UNITY_ENGINE_TUANJIE
#define HYBRIDCLR_MALLOC(size) IL2CPP_MALLOC(size, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_MALLOC_ALIGNED(size, alignment) IL2CPP_MALLOC_ALIGNED(size, alignment, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_MALLOC_ZERO(size) IL2CPP_MALLOC_ZERO(size, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_CALLOC(count, size) IL2CPP_CALLOC(count, size, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_FREE(ptr) IL2CPP_FREE(ptr, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_FREE_ALIGNED(ptr) IL2CPP_FREE_ALIGNED(ptr, IL2CPP_MEM_META_POOL)
#define HYBRIDCLR_METADATA_MALLOC(size) il2cpp::vm::MetadataMalloc(size, IL2CPP_MSTAT_TYPE)
#define HYBRIDCLR_METADATA_CALLOC(count, size) il2cpp::vm::MetadataCalloc(count, size, IL2CPP_MSTAT_TYPE)
#else
#define HYBRIDCLR_MALLOC(size) IL2CPP_MALLOC(size)
#define HYBRIDCLR_MALLOC_ALIGNED(size, alignment) IL2CPP_MALLOC_ALIGNED(size, alignment)
#define HYBRIDCLR_MALLOC_ZERO(size) IL2CPP_MALLOC_ZERO(size)
#define HYBRIDCLR_CALLOC(count, size) IL2CPP_CALLOC(count, size)
#define HYBRIDCLR_FREE(ptr) IL2CPP_FREE(ptr)
#define HYBRIDCLR_FREE_ALIGNED(ptr) IL2CPP_FREE_ALIGNED(ptr)
#define HYBRIDCLR_METADATA_MALLOC(size) il2cpp::vm::MetadataMalloc(size)
#define HYBRIDCLR_METADATA_CALLOC(count, size) il2cpp::vm::MetadataCalloc(count, size)
#endif
 
 
namespace hybridclr
{
 
    extern const char* g_placeHolderAssemblies[];
 
    Il2CppMethodPointer InitAndGetInterpreterDirectlyCallMethodPointerSlow(MethodInfo* method);
 
    inline Il2CppMethodPointer InitAndGetInterpreterDirectlyCallMethodPointer(const MethodInfo* method)
    {
        Il2CppMethodPointer methodPointer = method->methodPointerCallByInterp;
        if (methodPointer)
        {
            return methodPointer;
        }
        if (method->initInterpCallMethodPointer)
        {
            return methodPointer;
        }
        return InitAndGetInterpreterDirectlyCallMethodPointerSlow(const_cast<MethodInfo*>(method));
    }
 
    inline Il2CppMethodPointer InitAndGetInterpreterDirectlyCallVirtualMethodPointer(const MethodInfo* method)
    {
        Il2CppMethodPointer methodPointer = method->virtualMethodPointerCallByInterp;
        if (methodPointer)
        {
            return methodPointer;
        }
        if (method->initInterpCallMethodPointer)
        {
            return methodPointer;
        }
        InitAndGetInterpreterDirectlyCallMethodPointerSlow(const_cast<MethodInfo*>(method));
        return method->virtualMethodPointerCallByInterp;
    }
 
    inline void HYBRIDCLR_SET_WRITE_BARRIER(void** ptr)
    {
#if HYBRIDCLR_ENABLE_WRITE_BARRIERS
        il2cpp::gc::GarbageCollector::SetWriteBarrier(ptr);
#endif
    }
 
    inline void HYBRIDCLR_SET_WRITE_BARRIER(void** ptr, size_t size)
    {
#if HYBRIDCLR_ENABLE_WRITE_BARRIERS
        il2cpp::gc::GarbageCollector::SetWriteBarrier(ptr, size);
#endif
    }
}
 
#if HYBRIDCLR_UNITY_2019 || HYBRIDCLR_UNITY_2020
 
inline bool IS_CLASS_VALUE_TYPE(const Il2CppClass* klass)
{
    return klass->valuetype;
}
 
inline bool IS_CCTOR_FINISH_OR_NO_CCTOR(const Il2CppClass* klass)
{
    return (klass->cctor_finished) || !(klass->has_cctor);
}
 
inline const Il2CppType* GET_METHOD_PARAMETER_TYPE(const ParameterInfo& param)
{
    return param.parameter_type;
}
 
inline uint32_t GET_CUSTOM_ATTRIBUTE_TYPE_RANGE_START(const Il2CppCustomAttributeTypeRange& tr)
{
    return tr.start;
}
 
inline void SET_IL2CPPTYPE_VALUE_TYPE(Il2CppType& type, bool v)
{
 
}
 
inline void COPY_IL2CPPTYPE_VALUE_TYPE_FLAG(Il2CppType& dst, const Il2CppType& src)
{
 
}
 
#define GET_ARRAY_ELEMENT_ADDRESS load_array_elema
#define VALUE_TYPE_METHOD_POINTER_IS_ADJUST_METHOD 1
 
namespace hybridclr
{
    inline Il2CppReflectionType* GetReflectionTypeFromName(Il2CppString* name)
    {
        return il2cpp::icalls::mscorlib::System::Type::internal_from_name(name, true, false);
    }
 
    inline void ConstructDelegate(Il2CppDelegate* delegate, Il2CppObject* target, const MethodInfo* method)
    {
        delegate->method_ptr = InitAndGetInterpreterDirectlyCallVirtualMethodPointer(method);
        delegate->method = method;
        delegate->target = target;
        //il2cpp::vm::Type::ConstructDelegate(delegate, target, InitAndGetInterpreterDirectlyCallMethodPointer(method), method);
    }
 
    inline const MethodInfo* GetGenericVirtualMethod(const MethodInfo* result, const MethodInfo* inflateMethod)
    {
        return il2cpp::vm::Runtime::GetGenericVirtualMethod(result, inflateMethod);
    }
 
    inline void* GetNulllableDataOffset(void* nullableObj, Il2CppClass* nullableClass)
    {
        uint32_t field_offset = nullableClass->fields[0].offset - sizeof(Il2CppObject); // offset of value field
        return (uint8_t*)nullableObj + field_offset;
    }
 
    inline uint8_t* GetNulllableHasValueOffset(void* nullableObj, Il2CppClass* nullableClass)
    {
        uint32_t field_offset = nullableClass->fields[1].offset - sizeof(Il2CppObject); // offset of has_value field
        return (uint8_t*)nullableObj + field_offset;
    }
 
    inline Il2CppString* GetKlassFullName(const Il2CppType* type)
    {
        Il2CppReflectionType* refType = il2cpp::icalls::mscorlib::System::Type::internal_from_handle((intptr_t)type);
        return il2cpp::icalls::mscorlib::System::MonoType::getFullName(refType, false, false);
    }
}
#elif HYBRIDCLR_UNITY_2021 || HYBRIDCLR_UNITY_2022
 
inline bool IS_CLASS_VALUE_TYPE(const Il2CppClass* klass)
{
    return klass->byval_arg.valuetype;
}
 
inline bool IS_CCTOR_FINISH_OR_NO_CCTOR(const Il2CppClass* klass)
{
    return klass->cctor_finished_or_no_cctor;
}
 
inline const Il2CppType* GET_METHOD_PARAMETER_TYPE(const Il2CppType* param)
{
    return param;
}
 
inline uint32_t GET_CUSTOM_ATTRIBUTE_TYPE_RANGE_START(const Il2CppCustomAttributeTypeRange& tr)
{
    return tr.startOffset;
}
 
inline void SET_IL2CPPTYPE_VALUE_TYPE(Il2CppType& type, bool v)
{
    type.valuetype = v;
}
 
inline void COPY_IL2CPPTYPE_VALUE_TYPE_FLAG(Il2CppType& dst, const Il2CppType& src)
{
    dst.valuetype = src.valuetype;
}
 
#define GET_ARRAY_ELEMENT_ADDRESS il2cpp_array_addr_with_size
#define VALUE_TYPE_METHOD_POINTER_IS_ADJUST_METHOD 0
 
namespace hybridclr
{
 
    inline Il2CppReflectionType* GetReflectionTypeFromName(Il2CppString* name)
    {
        return il2cpp::icalls::mscorlib::System::RuntimeTypeHandle::internal_from_name(name, nullptr, nullptr, true, false, false);
    }
 
    inline void ConstructDelegate(Il2CppDelegate* delegate, Il2CppObject* target, const MethodInfo* method)
    {
        delegate->target = target;
        delegate->method = method;
        delegate->invoke_impl = InitAndGetInterpreterDirectlyCallVirtualMethodPointer(method);
        delegate->invoke_impl_this = target;
    }
 
    inline const MethodInfo* GetGenericVirtualMethod(const MethodInfo* result, const MethodInfo* inflateMethod)
    {
#if HYBRIDCLR_UNITY_2021
        VirtualInvokeData vid;
        il2cpp::vm::Runtime::GetGenericVirtualMethod(result, inflateMethod, &vid);
        return vid.method;
#else
        return il2cpp::metadata::GenericMethod::GetGenericVirtualMethod(result, inflateMethod);
#endif
    }
 
    inline void* GetNulllableDataOffset(void* nullableObj, Il2CppClass* nullableClass)
    {
        uint32_t field_offset = nullableClass->fields[1].offset - sizeof(Il2CppObject); // offset of value field
        return (uint8_t*)nullableObj + field_offset;
    }
 
    inline uint8_t* GetNulllableHasValueOffset(void* nullableObj, Il2CppClass* nullableClass)
    {
        uint32_t field_offset = nullableClass->fields[0].offset - sizeof(Il2CppObject); // offset of has_value field
        return (uint8_t*)nullableObj + field_offset;
    }
 
    inline Il2CppString* GetKlassFullName(const Il2CppType* type)
    {
        Il2CppReflectionType* refType = il2cpp::icalls::mscorlib::System::Type::internal_from_handle((intptr_t)type);
        return il2cpp::icalls::mscorlib::System::RuntimeType::getFullName((Il2CppReflectionRuntimeType*)refType, false, false);
    }
 
}
#endif