il2cpp-object-internals.h 28 KB

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