il2cpp-metadata.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #include <stdint.h>
  4. #include "il2cpp-tokentype.h"
  5. #if SLIM_GLOBAL_METADATA_FILE
  6. typedef uint16_t slim_int32_t;
  7. #define slim_int32_t_invalid UINT16_MAX;
  8. #else
  9. typedef int32_t slim_int32_t;
  10. #define slim_int32_t_invalid -1;
  11. #endif
  12. typedef slim_int32_t TypeIndex;
  13. typedef slim_int32_t TypeDefinitionIndex;
  14. typedef int32_t FieldIndex;
  15. typedef int32_t DefaultValueIndex;
  16. typedef int32_t DefaultValueDataIndex;
  17. typedef int32_t CustomAttributeIndex;
  18. typedef int32_t ParameterIndex;
  19. typedef int32_t MethodIndex;
  20. typedef int32_t GenericMethodIndex;
  21. typedef slim_int32_t PropertyIndex;
  22. typedef slim_int32_t EventIndex;
  23. typedef slim_int32_t GenericContainerIndex;
  24. typedef slim_int32_t GenericParameterIndex;
  25. typedef int16_t GenericParameterConstraintIndex;
  26. typedef slim_int32_t NestedTypeIndex;
  27. typedef slim_int32_t InterfacesIndex;
  28. typedef int32_t VTableIndex;
  29. typedef int32_t RGCTXIndex;
  30. typedef int32_t StringIndex;
  31. typedef int32_t StringLiteralIndex;
  32. typedef int32_t GenericInstIndex;
  33. typedef int32_t ImageIndex;
  34. typedef int32_t AssemblyIndex;
  35. typedef int32_t InteropDataIndex;
  36. // "Relative" indexes - based on their parent
  37. typedef int32_t TypeFieldIndex;
  38. typedef int32_t TypeMethodIndex;
  39. typedef int32_t MethodParameterIndex;
  40. typedef int32_t TypePropertyIndex;
  41. typedef int32_t TypeEventIndex;
  42. typedef int32_t TypeInterfaceIndex;
  43. typedef int32_t TypeNestedTypeIndex;
  44. typedef int32_t TypeInterfaceOffsetIndex;
  45. typedef int32_t GenericContainerParameterIndex;
  46. typedef int32_t AssemblyTypeIndex;
  47. typedef int32_t AssemblyExportedTypeIndex;
  48. static const TypeIndex kTypeIndexInvalid = slim_int32_t_invalid;
  49. static const TypeDefinitionIndex kTypeDefinitionIndexInvalid = slim_int32_t_invalid;
  50. static const DefaultValueDataIndex kDefaultValueIndexNull = -1;
  51. static const CustomAttributeIndex kCustomAttributeIndexInvalid = -1;
  52. static const EventIndex kEventIndexInvalid = slim_int32_t_invalid;
  53. static const FieldIndex kFieldIndexInvalid = -1;
  54. static const MethodIndex kMethodIndexInvalid = -1;
  55. static const PropertyIndex kPropertyIndexInvalid = slim_int32_t_invalid;
  56. static const GenericContainerIndex kGenericContainerIndexInvalid = slim_int32_t_invalid;
  57. static const GenericParameterIndex kGenericParameterIndexInvalid = slim_int32_t_invalid;
  58. static const RGCTXIndex kRGCTXIndexInvalid = -1;
  59. static const StringLiteralIndex kStringLiteralIndexInvalid = -1;
  60. static const InteropDataIndex kInteropDataIndexInvalid = -1;
  61. #define PUBLIC_KEY_BYTE_LENGTH 8
  62. static const int kPublicKeyByteLength = PUBLIC_KEY_BYTE_LENGTH;
  63. typedef struct Il2CppMethodSpec
  64. {
  65. MethodIndex methodDefinitionIndex;
  66. GenericInstIndex classIndexIndex;
  67. GenericInstIndex methodIndexIndex;
  68. } Il2CppMethodSpec;
  69. typedef enum Il2CppRGCTXDataType
  70. {
  71. IL2CPP_RGCTX_DATA_INVALID,
  72. IL2CPP_RGCTX_DATA_TYPE,
  73. IL2CPP_RGCTX_DATA_CLASS,
  74. IL2CPP_RGCTX_DATA_METHOD,
  75. IL2CPP_RGCTX_DATA_ARRAY,
  76. IL2CPP_RGCTX_DATA_CONSTRAINED,
  77. } Il2CppRGCTXDataType;
  78. typedef union Il2CppRGCTXDefinitionData
  79. {
  80. int32_t rgctxDataDummy;
  81. MethodIndex __methodIndex;
  82. TypeIndex __typeIndex;
  83. } Il2CppRGCTXDefinitionData;
  84. typedef struct Il2CppRGCTXConstrainedData
  85. {
  86. TypeIndex __typeIndex;
  87. uint32_t __encodedMethodIndex;
  88. } Il2CppRGCTXConstrainedData;
  89. typedef struct Il2CppRGCTXDefinition
  90. {
  91. Il2CppRGCTXDataType type;
  92. const void* data;
  93. } Il2CppRGCTXDefinition;
  94. typedef struct
  95. {
  96. MethodIndex methodIndex;
  97. MethodIndex invokerIndex;
  98. MethodIndex adjustorThunkIndex;
  99. } Il2CppGenericMethodIndices;
  100. typedef struct Il2CppGenericMethodFunctionsDefinitions
  101. {
  102. GenericMethodIndex genericMethodIndex;
  103. Il2CppGenericMethodIndices indices;
  104. } Il2CppGenericMethodFunctionsDefinitions;
  105. static inline uint32_t GetTokenType(uint32_t token)
  106. {
  107. return token & 0xFF000000;
  108. }
  109. static inline uint32_t GetTokenRowId(uint32_t token)
  110. {
  111. return token & 0x00FFFFFF;
  112. }
  113. /* Runtime metadata tokens */
  114. typedef const struct ___Il2CppMetadataImageHandle* Il2CppMetadataImageHandle;
  115. typedef const struct ___Il2CppMetadataCustomAttributeHandle* Il2CppMetadataCustomAttributeHandle;
  116. typedef const struct ___Il2CppMetadataTypeHandle* Il2CppMetadataTypeHandle;
  117. typedef const struct ___Il2CppMetadataMethodHandle* Il2CppMetadataMethodDefinitionHandle;
  118. typedef const struct ___Il2CppMetadataGenericContainerHandle* Il2CppMetadataGenericContainerHandle;
  119. typedef const struct ___Il2CppMetadataGenericParameterHandle* Il2CppMetadataGenericParameterHandle;