No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

il2cpp-object-internals.h 30KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include "il2cpp-class-internals.h"
  6. #include "il2cpp-windowsruntime-types.h"
  7. typedef struct Il2CppClass Il2CppClass;
  8. typedef struct MethodInfo MethodInfo;
  9. typedef struct PropertyInfo PropertyInfo;
  10. typedef struct FieldInfo FieldInfo;
  11. typedef struct EventInfo EventInfo;
  12. typedef struct Il2CppType Il2CppType;
  13. typedef struct Il2CppAssembly Il2CppAssembly;
  14. typedef struct Il2CppException Il2CppException;
  15. typedef struct Il2CppImage Il2CppImage;
  16. typedef struct Il2CppDomain Il2CppDomain;
  17. typedef struct Il2CppString Il2CppString;
  18. typedef struct Il2CppReflectionMethod Il2CppReflectionMethod;
  19. typedef struct Il2CppAsyncCall Il2CppAsyncCall;
  20. typedef struct Il2CppIUnknown Il2CppIUnknown;
  21. typedef struct Il2CppWaitHandle Il2CppWaitHandle;
  22. typedef struct MonitorData MonitorData;
  23. #ifdef __cplusplus
  24. namespace il2cpp
  25. {
  26. namespace os
  27. {
  28. class Thread;
  29. }
  30. }
  31. namespace baselib
  32. {
  33. inline namespace il2cpp_baselib
  34. {
  35. class ReentrantLock;
  36. }
  37. }
  38. #endif //__cplusplus
  39. typedef struct Il2CppReflectionAssembly Il2CppReflectionAssembly;
  40. typedef Il2CppClass Il2CppVTable;
  41. typedef struct Il2CppObject
  42. {
  43. union
  44. {
  45. Il2CppClass *klass;
  46. Il2CppVTable *vtable;
  47. };
  48. MonitorData *monitor;
  49. } Il2CppObject;
  50. typedef int32_t il2cpp_array_lower_bound_t;
  51. #define IL2CPP_ARRAY_MAX_INDEX ((int32_t) 0x7fffffff)
  52. #define IL2CPP_ARRAY_MAX_SIZE ((uint32_t) 0xffffffff)
  53. typedef struct Il2CppArrayBounds
  54. {
  55. il2cpp_array_size_t length;
  56. il2cpp_array_lower_bound_t lower_bound;
  57. } Il2CppArrayBounds;
  58. #if IL2CPP_COMPILER_MSVC
  59. #pragma warning( push )
  60. #pragma warning( disable : 4200 )
  61. #elif defined(__clang__)
  62. #pragma clang diagnostic push
  63. #pragma clang diagnostic ignored "-Winvalid-offsetof"
  64. #endif
  65. //Warning: Updates to this struct must also be made to IL2CPPArraySize C code
  66. #ifdef __cplusplus
  67. typedef struct Il2CppArray : public Il2CppObject
  68. {
  69. #else
  70. typedef struct Il2CppArray
  71. {
  72. Il2CppObject obj;
  73. #endif //__cplusplus
  74. /* bounds is NULL for szarrays */
  75. Il2CppArrayBounds *bounds;
  76. /* total number of elements of the array */
  77. il2cpp_array_size_t max_length;
  78. } Il2CppArray;
  79. #ifdef __cplusplus
  80. typedef struct Il2CppArraySize : public Il2CppArray
  81. {
  82. #else
  83. //mono code has no inheritance, so its members must be available from this type
  84. typedef struct Il2CppArraySize
  85. {
  86. Il2CppObject obj;
  87. Il2CppArrayBounds *bounds;
  88. il2cpp_array_size_t max_length;
  89. #endif //__cplusplus
  90. ALIGN_TYPE(8) void* vector[IL2CPP_ZERO_LEN_ARRAY];
  91. } Il2CppArraySize;
  92. static const size_t kIl2CppSizeOfArray = (offsetof(Il2CppArraySize, vector));
  93. static const size_t kIl2CppOffsetOfArrayBounds = (offsetof(Il2CppArray, bounds));
  94. static const size_t kIl2CppOffsetOfArrayLength = (offsetof(Il2CppArray, max_length));
  95. #define il2cpp_array_addr_with_size(arr, idx, size) ((((uint8_t*)(arr)) + kIl2CppSizeOfArray) + ((size_t)(size) * (idx)))
  96. // System.String
  97. typedef struct Il2CppString
  98. {
  99. Il2CppObject object;
  100. int32_t length; ///< Length of string *excluding* the trailing null (which is included in 'chars').
  101. Il2CppChar chars[IL2CPP_ZERO_LEN_ARRAY];
  102. } Il2CppString;
  103. #if IL2CPP_COMPILER_MSVC
  104. #pragma warning( pop )
  105. #elif defined(__clang__)
  106. #pragma clang diagnostic pop
  107. #endif
  108. typedef struct Il2CppReflectionType
  109. {
  110. Il2CppObject object;
  111. const Il2CppType *type;
  112. } Il2CppReflectionType;
  113. // IMPORTANT: All managed types corresponding to the objects below must be blacklisted in mscorlib.xml
  114. // System.RuntimeType
  115. typedef struct Il2CppReflectionRuntimeType
  116. {
  117. Il2CppReflectionType type;
  118. Il2CppObject* type_info;
  119. Il2CppObject* genericCache;
  120. Il2CppObject* serializationCtor;
  121. } Il2CppReflectionRuntimeType;
  122. // System.MonoType
  123. typedef struct Il2CppReflectionMonoType
  124. {
  125. Il2CppReflectionRuntimeType type;
  126. #ifdef __cplusplus
  127. const Il2CppType* GetIl2CppType() const
  128. {
  129. return type.type.type;
  130. }
  131. #endif //__cplusplus
  132. } Il2CppReflectionMonoType;
  133. // System.Reflection.EventInfo
  134. typedef struct Il2CppReflectionEvent
  135. {
  136. Il2CppObject object;
  137. Il2CppObject *cached_add_event;
  138. } Il2CppReflectionEvent;
  139. // System.Reflection.MonoEvent
  140. typedef struct Il2CppReflectionMonoEvent
  141. {
  142. Il2CppReflectionEvent event;
  143. Il2CppReflectionType* reflectedType;
  144. const EventInfo* eventInfo;
  145. } Il2CppReflectionMonoEvent;
  146. // System.Reflection.MonoEventInfo
  147. typedef struct Il2CppReflectionMonoEventInfo
  148. {
  149. Il2CppReflectionType* declaringType;
  150. Il2CppReflectionType* reflectedType;
  151. Il2CppString* name;
  152. Il2CppReflectionMethod* addMethod;
  153. Il2CppReflectionMethod* removeMethod;
  154. Il2CppReflectionMethod* raiseMethod;
  155. uint32_t eventAttributes;
  156. Il2CppArray* otherMethods;
  157. } Il2CppReflectionMonoEventInfo;
  158. // System.Reflection.MonoField
  159. typedef struct Il2CppReflectionField
  160. {
  161. Il2CppObject object;
  162. Il2CppClass *klass;
  163. FieldInfo *field;
  164. Il2CppString *name;
  165. Il2CppReflectionType *type;
  166. uint32_t attrs;
  167. } Il2CppReflectionField;
  168. // System.Reflection.MonoProperty
  169. typedef struct Il2CppReflectionProperty
  170. {
  171. Il2CppObject object;
  172. Il2CppClass *klass;
  173. const PropertyInfo *property;
  174. } Il2CppReflectionProperty;
  175. // System.Reflection.MonoMethod
  176. typedef struct Il2CppReflectionMethod
  177. {
  178. Il2CppObject object;
  179. const MethodInfo *method;
  180. Il2CppString *name;
  181. Il2CppReflectionType *reftype;
  182. } Il2CppReflectionMethod;
  183. // System.Reflection.MonoGenericMethod
  184. typedef struct Il2CppReflectionGenericMethod
  185. {
  186. Il2CppReflectionMethod base;
  187. } Il2CppReflectionGenericMethod;
  188. // System.Reflection.MonoMethodInfo
  189. typedef struct Il2CppMethodInfo
  190. {
  191. Il2CppReflectionType *parent;
  192. Il2CppReflectionType *ret;
  193. uint32_t attrs;
  194. uint32_t implattrs;
  195. uint32_t callconv;
  196. } Il2CppMethodInfo;
  197. // System.Reflection.MonoPropertyInfo
  198. typedef struct Il2CppPropertyInfo
  199. {
  200. Il2CppReflectionType* parent;
  201. Il2CppReflectionType* declaringType;
  202. Il2CppString *name;
  203. Il2CppReflectionMethod *get;
  204. Il2CppReflectionMethod *set;
  205. uint32_t attrs;
  206. } Il2CppPropertyInfo;
  207. // System.Reflection.ParameterInfo
  208. typedef struct Il2CppReflectionParameter
  209. {
  210. Il2CppObject object;
  211. uint32_t AttrsImpl;
  212. Il2CppReflectionType *ClassImpl;
  213. Il2CppObject *DefaultValueImpl;
  214. Il2CppObject *MemberImpl;
  215. Il2CppString *NameImpl;
  216. int32_t PositionImpl;
  217. Il2CppObject* MarshalAs;
  218. } Il2CppReflectionParameter;
  219. // System.Reflection.RuntimeModule
  220. typedef struct Il2CppReflectionModule
  221. {
  222. Il2CppObject obj;
  223. const Il2CppImage* image;
  224. Il2CppReflectionAssembly* assembly;
  225. Il2CppString* fqname;
  226. Il2CppString* name;
  227. Il2CppString* scopename;
  228. bool is_resource;
  229. uint32_t token;
  230. } Il2CppReflectionModule;
  231. // System.Reflection.AssemblyName
  232. typedef struct Il2CppReflectionAssemblyName
  233. {
  234. Il2CppObject obj;
  235. Il2CppString *name;
  236. Il2CppString *codebase;
  237. int32_t major, minor, build, revision;
  238. Il2CppObject *cultureInfo;
  239. uint32_t flags;
  240. uint32_t hashalg;
  241. Il2CppObject *keypair;
  242. Il2CppArray *publicKey;
  243. Il2CppArray *keyToken;
  244. uint32_t versioncompat;
  245. Il2CppObject *version;
  246. uint32_t processor_architecture;
  247. uint32_t contentType;
  248. } Il2CppReflectionAssemblyName;
  249. // System.RuntimeAssembly
  250. typedef struct Il2CppReflectionAssembly
  251. {
  252. Il2CppObject object;
  253. const Il2CppAssembly *assembly;
  254. /* CAS related */
  255. Il2CppObject *evidence; /* Evidence */
  256. Il2CppObject *resolve_event_holder;
  257. Il2CppObject *minimum; /* PermissionSet - for SecurityAction.RequestMinimum */
  258. Il2CppObject *optional; /* PermissionSet - for SecurityAction.RequestOptional */
  259. Il2CppObject *refuse; /* PermissionSet - for SecurityAction.RequestRefuse */
  260. Il2CppObject *granted; /* PermissionSet - for the resolved assembly granted permissions */
  261. Il2CppObject *denied; /* PermissionSet - for the resolved assembly denied permissions */
  262. /* */
  263. bool from_byte_array;
  264. Il2CppString *name;
  265. } Il2CppReflectionAssembly;
  266. // System.Reflection.Emit.UnmanagedMarshal
  267. typedef struct Il2CppReflectionMarshal
  268. {
  269. Il2CppObject object;
  270. int32_t count;
  271. int32_t type;
  272. int32_t eltype;
  273. Il2CppString* guid;
  274. Il2CppString* mcookie;
  275. Il2CppString* marshaltype;
  276. Il2CppObject* marshaltyperef;
  277. int32_t param_num;
  278. bool has_size;
  279. } Il2CppReflectionMarshal;
  280. // System.Reflection.Pointer
  281. typedef struct Il2CppReflectionPointer
  282. {
  283. Il2CppObject object;
  284. void* data;
  285. Il2CppReflectionType* type;
  286. } Il2CppReflectionPointer;
  287. typedef struct Il2CppThreadName
  288. {
  289. Il2CppChar* chars;
  290. int32_t unused;
  291. int32_t length;
  292. } Il2CppThreadName;
  293. typedef struct
  294. {
  295. uint32_t ref;
  296. void (*destructor)(void* data);
  297. } Il2CppRefCount;
  298. /* Data owned by a MonoInternalThread that must live until both the finalizer
  299. * for MonoInternalThread has run, and the underlying machine thread has
  300. * detached.
  301. *
  302. * Normally a thread is first detached and then the InternalThread object is
  303. * finalized and collected. However during shutdown, when the root domain is
  304. * finalized, all the InternalThread objects are finalized first and the
  305. * machine threads are detached later.
  306. */
  307. typedef struct
  308. {
  309. Il2CppRefCount ref;
  310. #ifdef __cplusplus
  311. baselib::ReentrantLock* synch_cs;
  312. #else
  313. void* synch_cs;
  314. #endif
  315. } Il2CppLongLivedThreadData;
  316. // System.Threading.InternalThread
  317. typedef struct Il2CppInternalThread
  318. {
  319. Il2CppObject obj;
  320. int lock_thread_id;
  321. #ifdef __cplusplus
  322. il2cpp::os::Thread* handle;
  323. #else
  324. void* handle;
  325. #endif //__cplusplus
  326. void* native_handle;
  327. Il2CppThreadName name;
  328. uint32_t state;
  329. Il2CppObject* abort_exc;
  330. int abort_state_handle;
  331. uint64_t tid;
  332. intptr_t debugger_thread;
  333. void* static_data;
  334. void* runtime_thread_info;
  335. Il2CppObject* current_appcontext;
  336. Il2CppObject* root_domain_thread;
  337. Il2CppArray* _serialized_principal;
  338. int _serialized_principal_version;
  339. void* appdomain_refs;
  340. int32_t interruption_requested;
  341. #ifdef __cplusplus
  342. Il2CppLongLivedThreadData *longlived;
  343. #else
  344. void* longlived;
  345. #endif //__cplusplus
  346. bool threadpool_thread;
  347. bool thread_interrupt_requested;
  348. int stack_size;
  349. uint8_t apartment_state;
  350. int critical_region_level;
  351. int managed_id;
  352. uint32_t small_id;
  353. void* manage_callback;
  354. intptr_t flags;
  355. void* thread_pinning_ref;
  356. void* abort_protected_block_count;
  357. int32_t priority;
  358. void* owned_mutexes;
  359. void * suspended;
  360. int32_t self_suspended;
  361. size_t thread_state;
  362. void* unused[3]; // same size as netcore
  363. void* last;
  364. } Il2CppInternalThread;
  365. /* Keep in sync with System.IOSelectorJob in mcs/class/System/System/IOSelectorJob.cs */
  366. typedef struct Il2CppIOSelectorJob
  367. {
  368. Il2CppObject object;
  369. int32_t operation;
  370. Il2CppObject *callback;
  371. Il2CppObject *state;
  372. } Il2CppIOSelectorJob;
  373. /* This is a copy of System.Runtime.Remoting.Messaging.CallType */
  374. typedef enum
  375. {
  376. Il2Cpp_CallType_Sync = 0,
  377. Il2Cpp_CallType_BeginInvoke = 1,
  378. Il2Cpp_CallType_EndInvoke = 2,
  379. Il2Cpp_CallType_OneWay = 3
  380. } Il2CppCallType;
  381. typedef struct Il2CppMethodMessage
  382. {
  383. Il2CppObject obj;
  384. Il2CppReflectionMethod *method;
  385. Il2CppArray *args;
  386. Il2CppArray *names;
  387. Il2CppArray *arg_types;
  388. Il2CppObject *ctx;
  389. Il2CppObject *rval;
  390. Il2CppObject *exc;
  391. Il2CppAsyncResult *async_result;
  392. uint32_t call_type;
  393. } Il2CppMethodMessage;
  394. /* This is a copy of System.AppDomainSetup */
  395. typedef struct Il2CppAppDomainSetup
  396. {
  397. Il2CppObject object;
  398. Il2CppString* application_base;
  399. Il2CppString* application_name;
  400. Il2CppString* cache_path;
  401. Il2CppString* configuration_file;
  402. Il2CppString* dynamic_base;
  403. Il2CppString* license_file;
  404. Il2CppString* private_bin_path;
  405. Il2CppString* private_bin_path_probe;
  406. Il2CppString* shadow_copy_directories;
  407. Il2CppString* shadow_copy_files;
  408. uint8_t publisher_policy;
  409. uint8_t path_changed;
  410. int loader_optimization;
  411. uint8_t disallow_binding_redirects;
  412. uint8_t disallow_code_downloads;
  413. Il2CppObject* activation_arguments; /* it is System.Object in 1.x, ActivationArguments in 2.0 */
  414. Il2CppObject* domain_initializer;
  415. Il2CppObject* application_trust; /* it is System.Object in 1.x, ApplicationTrust in 2.0 */
  416. Il2CppArray* domain_initializer_args;
  417. uint8_t disallow_appbase_probe;
  418. Il2CppArray* configuration_bytes;
  419. Il2CppArray* serialized_non_primitives;
  420. } Il2CppAppDomainSetup;
  421. // System.Threading.Thread
  422. typedef struct Il2CppThread
  423. {
  424. Il2CppObject obj;
  425. Il2CppInternalThread* internal_thread;
  426. Il2CppObject* start_obj;
  427. Il2CppException* pending_exception;
  428. Il2CppObject* principal;
  429. int32_t principal_version;
  430. Il2CppDelegate* delegate;
  431. Il2CppObject* executionContext;
  432. bool executionContextBelongsToOuterScope;
  433. #ifdef __cplusplus
  434. Il2CppInternalThread* GetInternalThread() const
  435. {
  436. return internal_thread;
  437. }
  438. #endif //__cplusplus
  439. } Il2CppThread;
  440. #ifdef __cplusplus
  441. // System.Exception
  442. typedef struct Il2CppException : public Il2CppObject
  443. {
  444. #else
  445. typedef struct Il2CppException
  446. {
  447. Il2CppObject object;
  448. #endif //__cplusplus
  449. Il2CppString* className;
  450. Il2CppString* message;
  451. Il2CppObject* _data;
  452. Il2CppException* inner_ex;
  453. Il2CppString* _helpURL;
  454. Il2CppArray* trace_ips;
  455. Il2CppString* stack_trace;
  456. Il2CppString* remote_stack_trace;
  457. int remote_stack_index;
  458. Il2CppObject* _dynamicMethods;
  459. il2cpp_hresult_t hresult;
  460. Il2CppString* source;
  461. Il2CppObject* safeSerializationManager;
  462. Il2CppArray* captured_traces;
  463. Il2CppArray* native_trace_ips;
  464. int32_t caught_in_unmanaged;
  465. } Il2CppException;
  466. // System.SystemException
  467. typedef struct Il2CppSystemException
  468. {
  469. Il2CppException base;
  470. } Il2CppSystemException;
  471. // System.ArgumentException
  472. typedef struct Il2CppArgumentException
  473. {
  474. Il2CppException base;
  475. Il2CppString *argName;
  476. } Il2CppArgumentException;
  477. // System.TypedReference
  478. typedef struct Il2CppTypedRef
  479. {
  480. const Il2CppType *type;
  481. void* value;
  482. Il2CppClass *klass;
  483. } Il2CppTypedRef;
  484. // System.Delegate
  485. typedef struct Il2CppDelegate
  486. {
  487. Il2CppObject object;
  488. /* The compiled code of the target method */
  489. Il2CppMethodPointer method_ptr;
  490. /* The invoke code */
  491. Il2CppMethodPointer invoke_impl;
  492. Il2CppObject *target;
  493. const MethodInfo *method;
  494. // This is used in PlatformInvoke.cpp to store the native function pointer
  495. // IMPORTANT: It is assumed to NULL otherwise! See PlatformInvoke::IsFakeDelegateMethodMarshaledFromNativeCode
  496. void* delegate_trampoline;
  497. // Used to store the mulicast_invoke_impl
  498. intptr_t extraArg;
  499. /* MONO:
  500. * If non-NULL, this points to a memory location which stores the address of
  501. * the compiled code of the method, or NULL if it is not yet compiled.
  502. * uint8_t **method_code;
  503. */
  504. // IL2CPP: Points to the "this" method pointer we use when calling invoke_impl
  505. // For closed delegates invoke_impl_this points to target and invoke_impl is method pointer so we just do a single indirect call
  506. // For all other delegates invoke_impl_this is points to it's owning delegate an invoke_impl is a delegate invoke stub
  507. // NOTE: This field is NOT VISIBLE to the GC because its not a managed field in the classlibs
  508. // Our usages are safe becuase we either pointer to ourself or whats stored in the target field
  509. Il2CppObject* invoke_impl_this;
  510. void* interp_method;
  511. /* Interp method that is executed when invoking the delegate */
  512. void* interp_invoke_impl;
  513. Il2CppReflectionMethod *method_info;
  514. Il2CppReflectionMethod *original_method_info;
  515. Il2CppObject *data;
  516. bool method_is_virtual;
  517. } Il2CppDelegate;
  518. typedef struct Il2CppMulticastDelegate
  519. {
  520. Il2CppDelegate delegate;
  521. Il2CppArray *delegates;
  522. } Il2CppMulticastDelegate;
  523. // System.MarshalByRefObject
  524. typedef struct Il2CppMarshalByRefObject
  525. {
  526. Il2CppObject obj;
  527. Il2CppObject *identity;
  528. } Il2CppMarshalByRefObject;
  529. #ifdef __cplusplus
  530. struct QICache
  531. {
  532. const Il2CppGuid* iid;
  533. Il2CppIUnknown* qiResult;
  534. };
  535. // System.__Il2CppComObject (dummy type that replaces System.__ComObject)
  536. struct Il2CppComObject : Il2CppObject
  537. {
  538. Il2CppIUnknown* identity;
  539. QICache qiShortCache[8];
  540. QICache* qiLongCache;
  541. int32_t qiShortCacheSize;
  542. int32_t qiLongCacheSize;
  543. int32_t qiLongCacheCapacity;
  544. // Same native object can be marshaled to managed code several times. If that happens,
  545. // we have to marshal it to the same RCW (same Il2CppComObject). We use a map of
  546. // IUnknown pointer -> weak GC handles to achieve it, and that works. When managed code
  547. // stops referencing the RCW, GC just garbage collects it and the finalizer will clean it
  548. // from our map. So far so good, eh?
  549. //
  550. // Enter Marshal.ReleaseComObject. This beast is designed to release the underlying COM object,
  551. // but ONLY after we used N amount of times (where N is the amount of times we marshaled
  552. // IUnknown into Il2CppComObject). In order to make it work, we need to implement ref counting.
  553. // This ref count gets incremented each time we marshal IUnknown to Il2CppComObject,
  554. // and gets decremented when Marshal.ReleaseComObject gets called. Fortunately, since we
  555. // live in a world of fairies and garbage collectors, we don't actually have to release it
  556. // manually in order for it to get cleaned up automatically in the future.
  557. int32_t refCount;
  558. };
  559. #endif //__cplusplus
  560. // Fully Shared GenericTypes
  561. // Il2CppFullySharedGenericAny comes from a generic paramter - it can by any type
  562. // Il2CppFullySharedGenericStruct comes from a generic struct - e.g. struct MyStruct<T> {}. We don't know it's size - it's a void*
  563. // Fully shared classes will inherit from System.Object
  564. typedef void* Il2CppFullySharedGenericAny;
  565. typedef void* Il2CppFullySharedGenericStruct;
  566. // System.AppDomain
  567. typedef struct Il2CppAppDomain
  568. {
  569. Il2CppMarshalByRefObject mbr;
  570. Il2CppDomain *data;
  571. } Il2CppAppDomain;
  572. // System.Diagnostics.StackFrame
  573. typedef struct Il2CppStackFrame
  574. {
  575. Il2CppObject obj;
  576. int32_t il_offset;
  577. int32_t native_offset;
  578. uint64_t methodAddress;
  579. uint32_t methodIndex;
  580. Il2CppReflectionMethod *method;
  581. Il2CppString *filename;
  582. int32_t line;
  583. int32_t column;
  584. Il2CppString *internal_method_name;
  585. } Il2CppStackFrame;
  586. // System.Globalization.DateTimeFormatInfo
  587. typedef struct Il2CppDateTimeFormatInfo
  588. {
  589. Il2CppObject obj;
  590. Il2CppObject* CultureData;
  591. Il2CppString* Name;
  592. Il2CppString* LangName;
  593. Il2CppObject* CompareInfo;
  594. Il2CppObject* CultureInfo;
  595. Il2CppString* AMDesignator;
  596. Il2CppString* PMDesignator;
  597. Il2CppString* DateSeparator;
  598. Il2CppString* GeneralShortTimePattern;
  599. Il2CppString* GeneralLongTimePattern;
  600. Il2CppString* TimeSeparator;
  601. Il2CppString* MonthDayPattern;
  602. Il2CppString* DateTimeOffsetPattern;
  603. Il2CppObject* Calendar;
  604. uint32_t FirstDayOfWeek;
  605. uint32_t CalendarWeekRule;
  606. Il2CppString* FullDateTimePattern;
  607. Il2CppArray* AbbreviatedDayNames;
  608. Il2CppArray* ShortDayNames;
  609. Il2CppArray* DayNames;
  610. Il2CppArray* AbbreviatedMonthNames;
  611. Il2CppArray* MonthNames;
  612. Il2CppArray* GenitiveMonthNames;
  613. Il2CppArray* GenitiveAbbreviatedMonthNames;
  614. Il2CppArray* LeapYearMonthNames;
  615. Il2CppString* LongDatePattern;
  616. Il2CppString* ShortDatePattern;
  617. Il2CppString* YearMonthPattern;
  618. Il2CppString* LongTimePattern;
  619. Il2CppString* ShortTimePattern;
  620. Il2CppArray* YearMonthPatterns;
  621. Il2CppArray* ShortDatePatterns;
  622. Il2CppArray* LongDatePatterns;
  623. Il2CppArray* ShortTimePatterns;
  624. Il2CppArray* LongTimePatterns;
  625. Il2CppArray* EraNames;
  626. Il2CppArray* AbbrevEraNames;
  627. Il2CppArray* AbbrevEnglishEraNames;
  628. Il2CppArray* OptionalCalendars;
  629. bool readOnly;
  630. int32_t FormatFlags;
  631. int32_t CultureID;
  632. bool UseUserOverride;
  633. bool UseCalendarInfo;
  634. int32_t DataItem;
  635. bool IsDefaultCalendar;
  636. Il2CppArray* DateWords;
  637. Il2CppString* FullTimeSpanPositivePattern;
  638. Il2CppString* FullTimeSpanNegativePattern;
  639. Il2CppArray* dtfiTokenHash;
  640. } Il2CppDateTimeFormatInfo;
  641. // System.Globalization.NumberFormatInfo
  642. typedef struct Il2CppNumberFormatInfo
  643. {
  644. Il2CppObject obj;
  645. Il2CppArray* numberGroupSizes;
  646. Il2CppArray* currencyGroupSizes;
  647. Il2CppArray* percentGroupSizes;
  648. Il2CppString* positiveSign;
  649. Il2CppString* negativeSign;
  650. Il2CppString* numberDecimalSeparator;
  651. Il2CppString* numberGroupSeparator;
  652. Il2CppString* currencyGroupSeparator;
  653. Il2CppString* currencyDecimalSeparator;
  654. Il2CppString* currencySymbol;
  655. Il2CppString* ansiCurrencySymbol;
  656. Il2CppString* naNSymbol;
  657. Il2CppString* positiveInfinitySymbol;
  658. Il2CppString* negativeInfinitySymbol;
  659. Il2CppString* percentDecimalSeparator;
  660. Il2CppString* percentGroupSeparator;
  661. Il2CppString* percentSymbol;
  662. Il2CppString* perMilleSymbol;
  663. Il2CppArray* nativeDigits;
  664. int dataItem;
  665. int numberDecimalDigits;
  666. int currencyDecimalDigits;
  667. int currencyPositivePattern;
  668. int currencyNegativePattern;
  669. int numberNegativePattern;
  670. int percentPositivePattern;
  671. int percentNegativePattern;
  672. int percentDecimalDigits;
  673. int digitSubstitution;
  674. bool readOnly;
  675. bool useUserOverride;
  676. bool isInvariant;
  677. bool validForParseAsNumber;
  678. bool validForParseAsCurrency;
  679. } Il2CppNumberFormatInfo;
  680. typedef struct NumberFormatEntryManaged
  681. {
  682. int32_t currency_decimal_digits;
  683. int32_t currency_decimal_separator;
  684. int32_t currency_group_separator;
  685. int32_t currency_group_sizes0;
  686. int32_t currency_group_sizes1;
  687. int32_t currency_negative_pattern;
  688. int32_t currency_positive_pattern;
  689. int32_t currency_symbol;
  690. int32_t nan_symbol;
  691. int32_t negative_infinity_symbol;
  692. int32_t negative_sign;
  693. int32_t number_decimal_digits;
  694. int32_t number_decimal_separator;
  695. int32_t number_group_separator;
  696. int32_t number_group_sizes0;
  697. int32_t number_group_sizes1;
  698. int32_t number_negative_pattern;
  699. int32_t per_mille_symbol;
  700. int32_t percent_negative_pattern;
  701. int32_t percent_positive_pattern;
  702. int32_t percent_symbol;
  703. int32_t positive_infinity_symbol;
  704. int32_t positive_sign;
  705. } NumberFormatEntryManaged;
  706. typedef struct Il2CppCultureData
  707. {
  708. Il2CppObject obj;
  709. Il2CppString *AMDesignator;
  710. Il2CppString *PMDesignator;
  711. Il2CppString *TimeSeparator;
  712. Il2CppArray *LongTimePatterns;
  713. Il2CppArray *ShortTimePatterns;
  714. uint32_t FirstDayOfWeek;
  715. uint32_t CalendarWeekRule;
  716. } Il2CppCultureData;
  717. typedef struct Il2CppCalendarData
  718. {
  719. Il2CppObject obj;
  720. Il2CppString *NativeName;
  721. Il2CppArray *ShortDatePatterns;
  722. Il2CppArray *YearMonthPatterns;
  723. Il2CppArray *LongDatePatterns;
  724. Il2CppString *MonthDayPattern;
  725. Il2CppArray *EraNames;
  726. Il2CppArray *AbbreviatedEraNames;
  727. Il2CppArray *AbbreviatedEnglishEraNames;
  728. Il2CppArray *DayNames;
  729. Il2CppArray *AbbreviatedDayNames;
  730. Il2CppArray *SuperShortDayNames;
  731. Il2CppArray *MonthNames;
  732. Il2CppArray *AbbreviatedMonthNames;
  733. Il2CppArray *GenitiveMonthNames;
  734. Il2CppArray *GenitiveAbbreviatedMonthNames;
  735. } Il2CppCalendarData;
  736. // System.Globalization.CultureInfo
  737. typedef struct Il2CppCultureInfo
  738. {
  739. Il2CppObject obj;
  740. bool is_read_only;
  741. int32_t lcid;
  742. int32_t parent_lcid;
  743. int32_t datetime_index;
  744. int32_t number_index;
  745. int32_t default_calendar_type;
  746. bool use_user_override;
  747. Il2CppNumberFormatInfo* number_format;
  748. Il2CppDateTimeFormatInfo* datetime_format;
  749. Il2CppObject* textinfo;
  750. Il2CppString* name;
  751. Il2CppString* englishname;
  752. Il2CppString* nativename;
  753. Il2CppString* iso3lang;
  754. Il2CppString* iso2lang;
  755. Il2CppString* win3lang;
  756. Il2CppString* territory;
  757. Il2CppArray* native_calendar_names;
  758. Il2CppString* compareinfo;
  759. const void* text_info_data;
  760. int dataItem;
  761. Il2CppObject* calendar;
  762. Il2CppObject* parent_culture;
  763. bool constructed;
  764. Il2CppArray* cached_serialized_form;
  765. Il2CppObject* cultureData;
  766. bool isInherited;
  767. } Il2CppCultureInfo;
  768. // System.Globalization.RegionInfo
  769. typedef struct Il2CppRegionInfo
  770. {
  771. Il2CppObject obj;
  772. int32_t geo_id;
  773. Il2CppString* iso2name;
  774. Il2CppString* iso3name;
  775. Il2CppString* win3name;
  776. Il2CppString* english_name;
  777. Il2CppString* native_name;
  778. Il2CppString* currency_symbol;
  779. Il2CppString* iso_currency_symbol;
  780. Il2CppString* currency_english_name;
  781. Il2CppString* currency_native_name;
  782. } Il2CppRegionInfo;
  783. // System.Runtime.InteropServices.SafeHandle
  784. // Inherited by Microsoft.Win32.SafeHandles.SafeWaitHandle
  785. typedef struct Il2CppSafeHandle
  786. {
  787. Il2CppObject base;
  788. void* handle;
  789. int state;
  790. bool owns_handle;
  791. bool fullyInitialized;
  792. } Il2CppSafeHandle;
  793. // System.Text.StringBuilder
  794. typedef struct Il2CppStringBuilder Il2CppStringBuilder;
  795. typedef struct Il2CppStringBuilder
  796. {
  797. Il2CppObject object;
  798. Il2CppArray* chunkChars;
  799. Il2CppStringBuilder* chunkPrevious;
  800. int chunkLength;
  801. int chunkOffset;
  802. int maxCapacity;
  803. } Il2CppStringBuilder;
  804. // System.Net.SocketAddress
  805. typedef struct Il2CppSocketAddress
  806. {
  807. Il2CppObject base;
  808. int m_Size;
  809. Il2CppArray* data;
  810. bool m_changed;
  811. int m_hash;
  812. } Il2CppSocketAddress;
  813. // System.Globalization.SortKey
  814. typedef struct Il2CppSortKey
  815. {
  816. Il2CppObject base;
  817. Il2CppString *str;
  818. Il2CppArray *key;
  819. int32_t options;
  820. int32_t lcid;
  821. } Il2CppSortKey;
  822. // System.Runtime.InteropServices.ErrorWrapper
  823. typedef struct Il2CppErrorWrapper
  824. {
  825. Il2CppObject base;
  826. int32_t errorCode;
  827. } Il2CppErrorWrapper;
  828. // System.Runtime.Remoting.Messaging.AsyncResult
  829. typedef struct Il2CppAsyncResult
  830. {
  831. Il2CppObject base;
  832. Il2CppObject *async_state;
  833. Il2CppWaitHandle *handle;
  834. Il2CppDelegate *async_delegate;
  835. void* data; // We pass delegate arguments here. This is repurposed. Depends on Mono C# code not using the field.
  836. Il2CppAsyncCall *object_data;
  837. bool sync_completed;
  838. bool completed;
  839. bool endinvoke_called;
  840. Il2CppObject *async_callback;
  841. Il2CppObject *execution_context;
  842. Il2CppObject *original_context;
  843. } Il2CppAsyncResult;
  844. // System.MonoAsyncCall
  845. typedef struct Il2CppAsyncCall
  846. {
  847. Il2CppObject base;
  848. Il2CppMethodMessage *msg;
  849. MethodInfo *cb_method; // We don't set this.
  850. Il2CppDelegate *cb_target; // We pass the actual delegate here.
  851. Il2CppObject *state;
  852. Il2CppObject *res;
  853. Il2CppArray *out_args;
  854. } Il2CppAsyncCall;
  855. typedef struct Il2CppExceptionWrapper Il2CppExceptionWrapper;
  856. typedef struct Il2CppExceptionWrapper
  857. {
  858. Il2CppException* ex;
  859. #ifdef __cplusplus
  860. Il2CppExceptionWrapper(Il2CppException* ex) : ex(ex) {}
  861. #endif //__cplusplus
  862. } Il2CppExceptionWrapper;
  863. typedef struct Il2CppIOAsyncResult
  864. {
  865. Il2CppObject base;
  866. Il2CppDelegate* callback;
  867. Il2CppObject* state;
  868. Il2CppWaitHandle* wait_handle;
  869. bool completed_synchronously;
  870. bool completed;
  871. } Il2CppIOAsyncResult;
  872. /// Corresponds to Mono's internal System.Net.Sockets.Socket.SocketAsyncResult
  873. /// class. Has no relation to Il2CppAsyncResult.
  874. typedef struct Il2CppSocketAsyncResult
  875. {
  876. Il2CppIOAsyncResult base;
  877. Il2CppObject* socket;
  878. int32_t operation;
  879. Il2CppException* delayedException;
  880. Il2CppObject* endPoint;
  881. Il2CppArray* buffer;
  882. int32_t offset;
  883. int32_t size;
  884. int32_t socket_flags;
  885. Il2CppObject* acceptSocket;
  886. Il2CppArray* addresses;
  887. int32_t port;
  888. Il2CppObject* buffers;
  889. bool reuseSocket;
  890. int32_t currentAddress;
  891. Il2CppObject* acceptedSocket;
  892. int32_t total;
  893. int32_t error;
  894. int32_t endCalled;
  895. } Il2CppSocketAsyncResult;
  896. typedef enum Il2CppResourceLocation
  897. {
  898. IL2CPP_RESOURCE_LOCATION_EMBEDDED = 1,
  899. IL2CPP_RESOURCE_LOCATION_ANOTHER_ASSEMBLY = 2,
  900. IL2CPP_RESOURCE_LOCATION_IN_MANIFEST = 4
  901. } Il2CppResourceLocation;
  902. // System.Reflection.ManifestResourceInfo
  903. typedef struct Il2CppManifestResourceInfo
  904. {
  905. Il2CppObject object;
  906. Il2CppReflectionAssembly* assembly;
  907. Il2CppString* filename;
  908. uint32_t location;
  909. } Il2CppManifestResourceInfo;
  910. #define IL2CPP_CHECK_ARG_NULL(arg) do { \
  911. if (arg == NULL) \
  912. { \
  913. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetArgumentNullException (#arg)); \
  914. }; } while (0)
  915. // System.Runtime.Remoting.Contexts.Context
  916. typedef struct Il2CppAppContext
  917. {
  918. Il2CppObject obj;
  919. int32_t domain_id;
  920. int32_t context_id;
  921. void* static_data;
  922. } Il2CppAppContext;
  923. typedef struct Il2CppDecimal
  924. {
  925. // Decimal.cs treats the first two shorts as one long
  926. // And they seriable the data so we need to little endian
  927. // seriliazation
  928. // The wReserved overlaps with Variant's vt member
  929. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  930. union
  931. {
  932. struct
  933. {
  934. uint8_t sign;
  935. uint8_t scale;
  936. } u;
  937. uint16_t signscale;
  938. } u;
  939. uint16_t reserved;
  940. #else
  941. uint16_t reserved;
  942. union
  943. {
  944. struct
  945. {
  946. uint8_t scale;
  947. uint8_t sign;
  948. } u;
  949. uint16_t signscale;
  950. } u;
  951. #endif
  952. uint32_t Hi32;
  953. union
  954. {
  955. struct
  956. {
  957. uint32_t Lo32;
  958. uint32_t Mid32;
  959. } v;
  960. uint64_t Lo64;
  961. } v;
  962. } Il2CppDecimal;
  963. // Structure to access an encoded double floating point
  964. typedef struct Il2CppDouble
  965. {
  966. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  967. uint32_t sign : 1;
  968. uint32_t exp : 11;
  969. uint32_t mantHi : 20;
  970. uint32_t mantLo : 32;
  971. #else // BIGENDIAN
  972. uint32_t mantLo : 32;
  973. uint32_t mantHi : 20;
  974. uint32_t exp : 11;
  975. uint32_t sign : 1;
  976. #endif
  977. } Il2CppDouble;
  978. typedef union Il2CppDouble_double
  979. {
  980. Il2CppDouble s;
  981. double d;
  982. } Il2CppDouble_double;
  983. typedef enum Il2CppDecimalCompareResult
  984. {
  985. IL2CPP_DECIMAL_CMP_LT = -1,
  986. IL2CPP_DECIMAL_CMP_EQ,
  987. IL2CPP_DECIMAL_CMP_GT
  988. } Il2CppDecimalCompareResult;
  989. // Structure to access an encoded single floating point
  990. typedef struct Il2CppSingle
  991. {
  992. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  993. uint32_t sign : 1;
  994. uint32_t exp : 8;
  995. uint32_t mant : 23;
  996. #else
  997. uint32_t mant : 23;
  998. uint32_t exp : 8;
  999. uint32_t sign : 1;
  1000. #endif
  1001. } Il2CppSingle;
  1002. typedef union Il2CppSingle_float
  1003. {
  1004. Il2CppSingle s;
  1005. float f;
  1006. } Il2CppSingle_float;
  1007. // System.ByReference
  1008. typedef struct Il2CppByReference
  1009. {
  1010. intptr_t value;
  1011. } Il2CppByReference;