il2cpp-object-internals.h 31 KB

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