first commit

This commit is contained in:
dasha 2026-01-05 23:50:53 +03:00
commit 7dd9dd689e
40 changed files with 4100 additions and 0 deletions

View file

@ -0,0 +1,158 @@
#include "pch.h"
#pragma once
#include <cstdint>
#include "il2cpp-metadata.h"
// il2cpp-types.h
// Add forward declarations for all referenced types
struct Il2CppType;
struct Il2CppGenericClass;
struct Il2CppTypeDefinition;
struct Il2CppInteropData;
struct FieldInfo;
struct EventInfo;
struct PropertyInfo;
struct Il2CppRuntimeInterfaceOffsetPair;
struct Il2CppRGCTXData;
struct VirtualInvokeData;
struct Il2CppMethodDefinition;
struct Il2CppGenericMethod;
struct Il2CppGenericContainer;
struct ParameterInfo;
// Define function pointer types
typedef void (*Il2CppMethodPointer)();
typedef void* (*InvokerMethod)(Il2CppMethodPointer, const struct MethodInfo*, void*, void**);
// Add this before Il2CppClass definition
#ifdef _MSC_VER
#define ALIGN_TYPE(n) __declspec(align(n))
#else
#define ALIGN_TYPE(n) __attribute__((aligned(n)))
#endif
// Add VirtualInvokeData definition
struct VirtualInvokeData {
void* methodPtr;
const struct MethodInfo* method;
};
// Define IL2CPP_ZERO_LEN_ARRAY if missing
#ifndef IL2CPP_ZERO_LEN_ARRAY
#define IL2CPP_ZERO_LEN_ARRAY 1
#endif
struct Il2CppClass
{
// The following fields are always valid for a Il2CppClass structure
const Il2CppImage* image;
void* gc_desc;
const char* name;
const char* namespaze;
const Il2CppType* byval_arg;
const Il2CppType* this_arg;
Il2CppClass* element_class;
Il2CppClass* castClass;
Il2CppClass* declaringType;
Il2CppClass* parent;
const Il2CppTypeDefinition* typeDefinition; // non-NULL for Il2CppClass's constructed from type defintions
Il2CppGenericClass* generic_class;
const Il2CppInteropData* interopData;
// End always valid fields
// The following fields need initialized before access. This can be done per field or as an aggregate via a call to Class::Init
FieldInfo* fields; // Initialized in SetupFields
const EventInfo* events; // Initialized in SetupEvents
const PropertyInfo* properties; // Initialized in SetupProperties
const MethodInfo** methods; // Initialized in SetupMethods
Il2CppClass** nestedTypes; // Initialized in SetupNestedTypes
Il2CppClass** implementedInterfaces; // Initialized in SetupInterfaces
Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets; // Initialized in Init
void* static_fields; // Initialized in Init
const Il2CppRGCTXData* rgctx_data; // Initialized in Init
// used for fast parent checks
Il2CppClass** typeHierarchy; // Initialized in SetupTypeHierachy
// End initialization required fields
uint32_t cctor_started;
uint32_t cctor_finished;
ALIGN_TYPE(8) uint64_t cctor_thread;
// Remaining fields are always valid except where noted
GenericContainerIndex genericContainerIndex;
CustomAttributeIndex customAttributeIndex;
uint32_t instance_size;
uint32_t actualSize;
uint32_t element_size;
int32_t native_size;
uint32_t static_fields_size;
uint32_t thread_static_fields_size;
int32_t thread_static_fields_offset;
uint32_t flags;
uint32_t token;
uint16_t method_count; // lazily calculated for arrays, i.e. when rank > 0
uint16_t property_count;
uint16_t field_count;
uint16_t event_count;
uint16_t nested_type_count;
uint16_t vtable_count; // lazily calculated for arrays, i.e. when rank > 0
uint16_t interfaces_count;
uint16_t interface_offsets_count; // lazily calculated for arrays, i.e. when rank > 0
uint8_t typeHierarchyDepth; // Initialized in SetupTypeHierachy
uint8_t genericRecursionDepth;
uint8_t rank;
uint8_t minimumAlignment;
uint8_t packingSize;
uint8_t valuetype : 1;
uint8_t initialized : 1;
uint8_t enumtype : 1;
uint8_t is_generic : 1;
uint8_t has_references : 1;
uint8_t init_pending : 1;
uint8_t size_inited : 1;
uint8_t has_finalize : 1;
uint8_t has_cctor : 1;
uint8_t is_blittable : 1;
uint8_t is_import_or_windows_runtime : 1;
uint8_t is_vtable_initialized : 1;
VirtualInvokeData vtable[IL2CPP_ZERO_LEN_ARRAY];
};
typedef struct MethodInfo
{
void* methodPointer;
char _padding[8]; // Added 8 bytes of padding for methodPointer
char invoker_method;
const char* name;
void* klass;
Il2CppType* return_type;
const void* parameters;
union
{
const void* rgctx_data; /* is_inflated is true and is_generic is false, i.e. a generic instance method */
const void* methodDefinition;
};
/* note, when is_generic == true and is_inflated == true the method represents an uninflated generic method on an inflated type. */
union
{
const void* genericMethod; /* is_inflated is true */
const void* genericContainer; /* is_inflated is false and is_generic is true */
};
uint32_t token;
uint16_t flags;
uint16_t iflags;
uint16_t slot;
uint8_t parameters_count;
uint8_t is_generic : 1; /* true if method is a generic method definition */
uint8_t is_inflated : 1; /* true if declaring_type is a generic instance or if method is a generic instance*/
uint8_t wrapper_type : 1; /* always zero (MONO_WRAPPER_NONE) needed for the debugger */
uint8_t is_marshaled_from_native : 1; /* a fake MethodInfo wrapping a native function pointer */
} MethodInfo;

152
Il2cpp-Data/il2cpp-class.h Normal file
View file

@ -0,0 +1,152 @@
#pragma once
#include <cstdint>
typedef uint16_t Il2CppChar;
typedef uintptr_t il2cpp_array_size_t;
typedef int32_t TypeDefinitionIndex;
typedef int32_t GenericParameterIndex;
typedef char Il2CppNativeChar;
typedef struct Il2CppMemoryCallbacks Il2CppMemoryCallbacks;
typedef struct Il2CppMethod Il2CppMethod;
typedef struct Il2CppField Il2CppField;
typedef struct Il2CppClass Il2CppClass;
typedef struct Il2CppArrayBounds Il2CppArrayBounds;
typedef struct Il2CppAssembly Il2CppAssembly;
typedef struct Il2CppArrayType Il2CppArrayType;
typedef struct Il2CppGenericClass Il2CppGenericClass;
typedef struct Il2CppReflectionType Il2CppReflectionType;
typedef struct MonitorData MonitorData;
typedef Il2CppClass Il2CppVTable;
typedef struct EventInfo EventInfo;
typedef struct FieldInfo FieldInfo;
typedef struct PropertyInfo PropertyInfo;
typedef struct Il2CppDomain Il2CppDomain;
typedef struct Il2CppException Il2CppException;
typedef struct Il2CppObject Il2CppObject;
typedef struct Il2CppReflectionMethod Il2CppReflectionMethod;
typedef struct Il2CppString Il2CppString;
typedef struct Il2CppThread Il2CppThread;
typedef struct Il2CppStackFrameInfo Il2CppStackFrameInfo;
typedef struct Il2CppManagedMemorySnapshot Il2CppManagedMemorySnapshot;
typedef struct Il2CppDebuggerTransport Il2CppDebuggerTransport;
typedef struct Il2CppMethodDebugInfo Il2CppMethodDebugInfo;
typedef struct Il2CppCustomAttrInfo Il2CppCustomAttrInfo;
typedef const struct ___Il2CppMetadataTypeHandle* Il2CppMetadataTypeHandle;
typedef const struct ___Il2CppMetadataGenericParameterHandle* Il2CppMetadataGenericParameterHandle;
typedef void (*Il2CppMethodPointer)();
typedef void (*il2cpp_register_object_callback)(Il2CppObject** arr, int size, void* userdata);
typedef void* (*il2cpp_liveness_reallocate_callback)(void* ptr, size_t size, void* userdata);
typedef void (*Il2CppFrameWalkFunc)(const Il2CppStackFrameInfo* info, void* user_data);
typedef size_t(*Il2CppBacktraceFunc)(Il2CppMethodPointer* buffer, size_t maxSize);
typedef const Il2CppNativeChar* (*Il2CppSetFindPlugInCallback)(const Il2CppNativeChar*);
typedef void (*Il2CppLogCallback)(const char*);
typedef enum {
IL2CPP_UNHANDLED_POLICY_LEGACY,
IL2CPP_UNHANDLED_POLICY_CURRENT
} Il2CppRuntimeUnhandledExceptionPolicy;
typedef enum {
IL2CPP_GC_MODE_DISABLED = 0,
IL2CPP_GC_MODE_ENABLED = 1,
IL2CPP_GC_MODE_MANUAL = 2
} Il2CppGCMode;
typedef enum Il2CppStat {
IL2CPP_STAT_NEW_OBJECT_COUNT,
IL2CPP_STAT_INITIALIZED_CLASS_COUNT,
IL2CPP_STAT_METHOD_COUNT,
IL2CPP_STAT_CLASS_STATIC_DATA_SIZE,
IL2CPP_STAT_GENERIC_INSTANCE_COUNT,
IL2CPP_STAT_GENERIC_CLASS_COUNT,
IL2CPP_STAT_INFLATED_METHOD_COUNT,
IL2CPP_STAT_INFLATED_TYPE_COUNT,
} Il2CppStat;
typedef enum Il2CppTypeEnum {
IL2CPP_TYPE_END = 0x00,
IL2CPP_TYPE_VOID = 0x01,
IL2CPP_TYPE_BOOLEAN = 0x02,
IL2CPP_TYPE_CHAR = 0x03,
IL2CPP_TYPE_I1 = 0x04,
IL2CPP_TYPE_U1 = 0x05,
IL2CPP_TYPE_I2 = 0x06,
IL2CPP_TYPE_U2 = 0x07,
IL2CPP_TYPE_I4 = 0x08,
IL2CPP_TYPE_U4 = 0x09,
IL2CPP_TYPE_I8 = 0x0a,
IL2CPP_TYPE_U8 = 0x0b,
IL2CPP_TYPE_R4 = 0x0c,
IL2CPP_TYPE_R8 = 0x0d,
IL2CPP_TYPE_STRING = 0x0e,
IL2CPP_TYPE_PTR = 0x0f,
//updated to current version
IL2CPP_TYPE_BYREF = 0x40,
IL2CPP_TYPE_VALUETYPE = 0x11,
IL2CPP_TYPE_CLASS = 0x12,
IL2CPP_TYPE_VAR = 0x13,
IL2CPP_TYPE_ARRAY = 0x14,
IL2CPP_TYPE_GENERICINST = 0x15,
IL2CPP_TYPE_TYPEDBYREF = 0x16,
IL2CPP_TYPE_I = 0x18,
IL2CPP_TYPE_U = 0x19,
IL2CPP_TYPE_FNPTR = 0x1b,
IL2CPP_TYPE_OBJECT = 0x1c,
IL2CPP_TYPE_SZARRAY = 0x1d,
IL2CPP_TYPE_MVAR = 0x1e,
IL2CPP_TYPE_CMOD_REQD = 0x1f,
IL2CPP_TYPE_CMOD_OPT = 0x20,
IL2CPP_TYPE_INTERNAL = 0x21,
IL2CPP_TYPE_MODIFIER = 0x40,
IL2CPP_TYPE_SENTINEL = 0x41,
IL2CPP_TYPE_PINNED = 0x45,
IL2CPP_TYPE_ENUM = 0x55,
IL2CPP_TYPE_IL2CPP_TYPE_INDEX = 0xff
} Il2CppTypeEnum;
typedef struct Il2CppType {
char pad[8];
unsigned int attrs;
Il2CppTypeEnum type : 8;
} Il2CppType;
typedef struct Il2CppObject {
union {
Il2CppClass* klass;
Il2CppVTable* vtable;
};
MonitorData* monitor;
} Il2CppObject;
typedef struct Il2CppArray {
Il2CppObject obj;
Il2CppArrayBounds* bounds;
il2cpp_array_size_t max_length;
void* vector[32];
} Il2CppArray;
typedef struct Il2CppImage {
const char* name;
TypeDefinitionIndex typeStart;
void* typeHierarchy;
uint32_t typeCount;
uint32_t exportedTypeCount;
} Il2CppImage;
typedef struct Il2CppGenericContainer {
uint32_t type_argc;
const void** type_argv;
} Il2CppGenericContainer;
typedef struct Il2CppGenericClass {
Il2CppGenericContainer* genericContainer;
} Il2CppGenericClass;

View file

@ -0,0 +1,464 @@
#include "pch.h"
#pragma once
#include <stdint.h>
// This file contains the structures specifying how we store converted metadata.
// These structures have 3 constraints:
// 1. These structures will be stored in an external file, and as such must not contain any pointers.
// All references to other metadata should occur via an index into a corresponding table.
// 2. These structures are assumed to be const. Either const structures in the binary or mapped as
// readonly memory from an external file. Do not add any 'calculated' fields which will be written to at runtime.
// 3. These structures should be optimized for size. Other structures are used at runtime which can
// be larger to store cached information
typedef int32_t TypeIndex;
typedef int32_t TypeDefinitionIndex;
typedef int32_t FieldIndex;
typedef int32_t DefaultValueIndex;
typedef int32_t DefaultValueDataIndex;
typedef int32_t CustomAttributeIndex;
typedef int32_t ParameterIndex;
typedef int32_t MethodIndex;
typedef int32_t GenericMethodIndex;
typedef int32_t PropertyIndex;
typedef int32_t EventIndex;
typedef int32_t GenericContainerIndex;
typedef int32_t GenericParameterIndex;
typedef int16_t GenericParameterConstraintIndex;
typedef int32_t NestedTypeIndex;
typedef int32_t InterfacesIndex;
typedef int32_t VTableIndex;
typedef int32_t InterfaceOffsetIndex;
typedef int32_t RGCTXIndex;
typedef int32_t StringIndex;
typedef int32_t StringLiteralIndex;
typedef int32_t GenericInstIndex;
typedef int32_t ImageIndex;
typedef int32_t AssemblyIndex;
typedef int32_t InteropDataIndex;
const TypeIndex kTypeIndexInvalid = -1;
const TypeDefinitionIndex kTypeDefinitionIndexInvalid = -1;
const DefaultValueDataIndex kDefaultValueIndexNull = -1;
const EventIndex kEventIndexInvalid = -1;
const FieldIndex kFieldIndexInvalid = -1;
const MethodIndex kMethodIndexInvalid = -1;
const PropertyIndex kPropertyIndexInvalid = -1;
const GenericContainerIndex kGenericContainerIndexInvalid = -1;
const GenericParameterIndex kGenericParameterIndexInvalid = -1;
const RGCTXIndex kRGCTXIndexInvalid = -1;
const StringLiteralIndex kStringLiteralIndexInvalid = -1;
const InteropDataIndex kInteropDataIndexInvalid = -1;
// Encoded index (1 bit)
// MethodDef - 0
// MethodSpec - 1
// We use the top 3 bits to indicate what table to index into
// Type Binary Hex
// Il2CppClass 001 0x20000000
// Il2CppType 010 0x40000000
// MethodInfo 011 0x60000000
// FieldInfo 100 0x80000000
// StringLiteral 101 0xA0000000
// MethodRef 110 0xC0000000
typedef uint32_t EncodedMethodIndex;
enum Il2CppMetadataUsage
{
kIl2CppMetadataUsageInvalid,
kIl2CppMetadataUsageTypeInfo,
kIl2CppMetadataUsageIl2CppType,
kIl2CppMetadataUsageMethodDef,
kIl2CppMetadataUsageFieldInfo,
kIl2CppMetadataUsageStringLiteral,
kIl2CppMetadataUsageMethodRef,
};
static inline Il2CppMetadataUsage GetEncodedIndexType(EncodedMethodIndex index)
{
return (Il2CppMetadataUsage)((index & 0xE0000000) >> 29);
}
static inline uint32_t GetDecodedMethodIndex(EncodedMethodIndex index)
{
return index & 0x1FFFFFFFU;
}
struct Il2CppImage;
struct Il2CppType;
struct Il2CppTypeDefinitionMetadata;
union Il2CppRGCTXDefinitionData
{
int32_t rgctxDataDummy;
MethodIndex methodIndex;
TypeIndex typeIndex;
};
enum Il2CppRGCTXDataType
{
IL2CPP_RGCTX_DATA_INVALID,
IL2CPP_RGCTX_DATA_TYPE,
IL2CPP_RGCTX_DATA_CLASS,
IL2CPP_RGCTX_DATA_METHOD,
IL2CPP_RGCTX_DATA_ARRAY,
};
struct Il2CppRGCTXDefinition
{
Il2CppRGCTXDataType type;
Il2CppRGCTXDefinitionData data;
};
struct Il2CppInterfaceOffsetPair
{
TypeIndex interfaceTypeIndex;
int32_t offset;
};
struct Il2CppTypeDefinition
{
StringIndex nameIndex;
StringIndex namespaceIndex;
CustomAttributeIndex customAttributeIndex;
TypeIndex byvalTypeIndex;
TypeIndex byrefTypeIndex;
TypeIndex declaringTypeIndex;
TypeIndex parentIndex;
TypeIndex elementTypeIndex; // we can probably remove this one. Only used for enums
RGCTXIndex rgctxStartIndex;
int32_t rgctxCount;
GenericContainerIndex genericContainerIndex;
uint32_t flags;
FieldIndex fieldStart;
MethodIndex methodStart;
EventIndex eventStart;
PropertyIndex propertyStart;
NestedTypeIndex nestedTypesStart;
InterfacesIndex interfacesStart;
VTableIndex vtableStart;
InterfacesIndex interfaceOffsetsStart;
uint16_t method_count;
uint16_t property_count;
uint16_t field_count;
uint16_t event_count;
uint16_t nested_type_count;
uint16_t vtable_count;
uint16_t interfaces_count;
uint16_t interface_offsets_count;
// bitfield to portably encode boolean values as single bits
// 01 - valuetype;
// 02 - enumtype;
// 03 - has_finalize;
// 04 - has_cctor;
// 05 - is_blittable;
// 06 - is_import_or_windows_runtime;
// 07-10 - One of nine possible PackingSize values (0, 1, 2, 4, 8, 16, 32, 64, or 128)
uint32_t bitfield;
uint32_t token;
};
struct Il2CppFieldDefinition
{
StringIndex nameIndex;
TypeIndex typeIndex;
CustomAttributeIndex customAttributeIndex;
uint32_t token;
};
struct Il2CppFieldDefaultValue
{
FieldIndex fieldIndex;
TypeIndex typeIndex;
DefaultValueDataIndex dataIndex;
};
struct Il2CppFieldMarshaledSize
{
FieldIndex fieldIndex;
TypeIndex typeIndex;
int32_t size;
};
struct Il2CppFieldRef
{
TypeIndex typeIndex;
FieldIndex fieldIndex; // local offset into type fields
};
struct Il2CppParameterDefinition
{
StringIndex nameIndex;
uint32_t token;
CustomAttributeIndex customAttributeIndex;
TypeIndex typeIndex;
};
struct Il2CppParameterDefaultValue
{
ParameterIndex parameterIndex;
TypeIndex typeIndex;
DefaultValueDataIndex dataIndex;
};
struct Il2CppMethodDefinition
{
StringIndex nameIndex;
TypeDefinitionIndex declaringType;
TypeIndex returnType;
ParameterIndex parameterStart;
CustomAttributeIndex customAttributeIndex;
GenericContainerIndex genericContainerIndex;
MethodIndex methodIndex;
MethodIndex invokerIndex;
MethodIndex reversePInvokeWrapperIndex;
RGCTXIndex rgctxStartIndex;
int32_t rgctxCount;
uint32_t token;
uint16_t flags;
uint16_t iflags;
uint16_t slot;
uint16_t parameterCount;
};
struct Il2CppEventDefinition
{
StringIndex nameIndex;
TypeIndex typeIndex;
MethodIndex add;
MethodIndex remove;
MethodIndex raise;
CustomAttributeIndex customAttributeIndex;
uint32_t token;
};
struct Il2CppPropertyDefinition
{
StringIndex nameIndex;
MethodIndex get;
MethodIndex set;
uint32_t attrs;
CustomAttributeIndex customAttributeIndex;
uint32_t token;
};
struct Il2CppMethodSpec
{
MethodIndex methodDefinitionIndex;
GenericInstIndex classIndexIndex;
GenericInstIndex methodIndexIndex;
};
struct Il2CppStringLiteral
{
uint32_t length;
StringLiteralIndex dataIndex;
};
struct Il2CppGenericMethodIndices
{
MethodIndex methodIndex;
MethodIndex invokerIndex;
};
struct Il2CppGenericMethodFunctionsDefinitions
{
GenericMethodIndex genericMethodIndex;
Il2CppGenericMethodIndices indices;
};
const int kPublicKeyByteLength = 8;
struct Il2CppAssemblyName
{
StringIndex nameIndex;
StringIndex cultureIndex;
StringIndex hashValueIndex;
StringIndex publicKeyIndex;
uint32_t hash_alg;
int32_t hash_len;
uint32_t flags;
int32_t major;
int32_t minor;
int32_t build;
int32_t revision;
uint8_t publicKeyToken[kPublicKeyByteLength];
};
struct Il2CppImageDefinition
{
StringIndex nameIndex;
AssemblyIndex assemblyIndex;
TypeDefinitionIndex typeStart;
uint32_t typeCount;
TypeDefinitionIndex exportedTypeStart;
uint32_t exportedTypeCount;
MethodIndex entryPointIndex;
uint32_t token;
};
struct Il2CppAssembly
{
Il2CppImage* image;
ImageIndex imageIndex;
CustomAttributeIndex customAttributeIndex;
int32_t referencedAssemblyStart;
int32_t referencedAssemblyCount;
Il2CppAssemblyName aname;
};
struct Il2CppMetadataUsageList
{
uint32_t start;
uint32_t count;
};
struct Il2CppMetadataUsagePair
{
uint32_t destinationIndex;
uint32_t encodedSourceIndex;
};
struct Il2CppCustomAttributeTypeRange
{
int32_t start;
int32_t count;
};
struct Il2CppRange
{
int32_t start;
int32_t length;
};
struct Il2CppWindowsRuntimeTypeNamePair
{
StringIndex nameIndex;
TypeIndex typeIndex;
};
#pragma pack(push, p1,4)
struct Il2CppGlobalMetadataHeader
{
int32_t sanity;
int32_t version;
int32_t stringLiteralOffset; // string data for managed code
int32_t stringLiteralCount;
int32_t stringLiteralDataOffset;
int32_t stringLiteralDataCount;
int32_t stringOffset; // string data for metadata
int32_t stringCount;
int32_t eventsOffset; // Il2CppEventDefinition
int32_t eventsCount;
int32_t propertiesOffset; // Il2CppPropertyDefinition
int32_t propertiesCount;
int32_t methodsOffset; // Il2CppMethodDefinition
int32_t methodsCount;
int32_t parameterDefaultValuesOffset; // Il2CppParameterDefaultValue
int32_t parameterDefaultValuesCount;
int32_t fieldDefaultValuesOffset; // Il2CppFieldDefaultValue
int32_t fieldDefaultValuesCount;
int32_t fieldAndParameterDefaultValueDataOffset; // uint8_t
int32_t fieldAndParameterDefaultValueDataCount;
int32_t fieldMarshaledSizesOffset; // Il2CppFieldMarshaledSize
int32_t fieldMarshaledSizesCount;
int32_t parametersOffset; // Il2CppParameterDefinition
int32_t parametersCount;
int32_t fieldsOffset; // Il2CppFieldDefinition
int32_t fieldsCount;
int32_t genericParametersOffset; // Il2CppGenericParameter
int32_t genericParametersCount;
int32_t genericParameterConstraintsOffset; // TypeIndex
int32_t genericParameterConstraintsCount;
int32_t genericContainersOffset; // Il2CppGenericContainer
int32_t genericContainersCount;
int32_t nestedTypesOffset; // TypeDefinitionIndex
int32_t nestedTypesCount;
int32_t interfacesOffset; // TypeIndex
int32_t interfacesCount;
int32_t vtableMethodsOffset; // EncodedMethodIndex
int32_t vtableMethodsCount;
int32_t interfaceOffsetsOffset; // Il2CppInterfaceOffsetPair
int32_t interfaceOffsetsCount;
int32_t typeDefinitionsOffset; // Il2CppTypeDefinition
int32_t typeDefinitionsCount;
int32_t rgctxEntriesOffset; // Il2CppRGCTXDefinition
int32_t rgctxEntriesCount;
int32_t imagesOffset; // Il2CppImageDefinition
int32_t imagesCount;
int32_t assembliesOffset; // Il2CppAssemblyDefinition
int32_t assembliesCount;
int32_t metadataUsageListsOffset; // Il2CppMetadataUsageList
int32_t metadataUsageListsCount;
int32_t metadataUsagePairsOffset; // Il2CppMetadataUsagePair
int32_t metadataUsagePairsCount;
int32_t fieldRefsOffset; // Il2CppFieldRef
int32_t fieldRefsCount;
int32_t referencedAssembliesOffset; // int32_t
int32_t referencedAssembliesCount;
int32_t attributesInfoOffset; // Il2CppCustomAttributeTypeRange
int32_t attributesInfoCount;
int32_t attributeTypesOffset; // TypeIndex
int32_t attributeTypesCount;
int32_t unresolvedVirtualCallParameterTypesOffset; // TypeIndex
int32_t unresolvedVirtualCallParameterTypesCount;
int32_t unresolvedVirtualCallParameterRangesOffset; // Il2CppRange
int32_t unresolvedVirtualCallParameterRangesCount;
int32_t windowsRuntimeTypeNamesOffset; // Il2CppWindowsRuntimeTypeNamePair
int32_t windowsRuntimeTypeNamesSize;
int32_t exportedTypeDefinitionsOffset; // TypeDefinitionIndex
int32_t exportedTypeDefinitionsCount;
};
#pragma pack(pop, p1)
#if RUNTIME_MONO
#pragma pack(push, p1,4)
struct Il2CppGlobalMonoMetadataHeader
{
int32_t sanity;
int32_t version;
int32_t stringOffset; // string data for metadata
int32_t stringCount;
int32_t methodInfoMappingOffset; // hash -> MonoMethodInfo mapping
int32_t methodInfoMappingCount;
int32_t genericMethodInfoMappingOffset; // hash -> generic MonoMethodInfo mapping
int32_t genericMethodInfoMappingCount;
int32_t rgctxIndicesOffset; // runtime generic context indices
int32_t rgctxIndicesCount;
int32_t rgctxInfoOffset; // runtime generic context info
int32_t rgctxInfoCount;
int32_t monoStringOffset; // mono strings
int32_t monoStringCount;
int32_t methodMetadataOffset; // method metadata
int32_t methodMetadataCount;
int32_t genericArgumentIndicesOffset; // generic argument indices
int32_t genericArgumentIndicesCount;
int32_t typeTableOffset; // type table
int32_t typeTableCount;
int32_t fieldTableOffset; // field table
int32_t fieldTableCount;
int32_t methodIndexTableOffset; // method index table
int32_t methodIndexTableCount;
int32_t genericMethodIndexTableOffset; // generic method index table
int32_t genericMethodIndexTableCount;
int32_t metaDataUsageListsTableOffset; // meta data usage lists table
int32_t metaDataUsageListsTableCount;
int32_t metaDataUsagePairsTableOffset; // meta data usage pairs table
int32_t metaDataUsagePairsTableCount;
int32_t assemblyNameTableOffset; // assembly names
int32_t assemblyNameTableCount;
};
#pragma pack(pop, p1)
#endif

View file

@ -0,0 +1,154 @@
#include "pch.h"
#pragma once
/*
* Field Attributes (21.1.5).
*/
#define FIELD_ATTRIBUTE_FIELD_ACCESS_MASK 0x0007
#define FIELD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000
#define FIELD_ATTRIBUTE_PRIVATE 0x0001
#define FIELD_ATTRIBUTE_FAM_AND_ASSEM 0x0002
#define FIELD_ATTRIBUTE_ASSEMBLY 0x0003
#define FIELD_ATTRIBUTE_FAMILY 0x0004
#define FIELD_ATTRIBUTE_FAM_OR_ASSEM 0x0005
#define FIELD_ATTRIBUTE_PUBLIC 0x0006
#define FIELD_ATTRIBUTE_STATIC 0x0010
#define FIELD_ATTRIBUTE_INIT_ONLY 0x0020
#define FIELD_ATTRIBUTE_LITERAL 0x0040
#define FIELD_ATTRIBUTE_NOT_SERIALIZED 0x0080
#define FIELD_ATTRIBUTE_SPECIAL_NAME 0x0200
#define FIELD_ATTRIBUTE_PINVOKE_IMPL 0x2000
/* For runtime use only */
#define FIELD_ATTRIBUTE_RESERVED_MASK 0x9500
#define FIELD_ATTRIBUTE_RT_SPECIAL_NAME 0x0400
#define FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL 0x1000
#define FIELD_ATTRIBUTE_HAS_DEFAULT 0x8000
#define FIELD_ATTRIBUTE_HAS_FIELD_RVA 0x0100
/*
* Method Attributes (22.1.9)
*/
#define METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK 0x0003
#define METHOD_IMPL_ATTRIBUTE_IL 0x0000
#define METHOD_IMPL_ATTRIBUTE_NATIVE 0x0001
#define METHOD_IMPL_ATTRIBUTE_OPTIL 0x0002
#define METHOD_IMPL_ATTRIBUTE_RUNTIME 0x0003
#define METHOD_IMPL_ATTRIBUTE_MANAGED_MASK 0x0004
#define METHOD_IMPL_ATTRIBUTE_UNMANAGED 0x0004
#define METHOD_IMPL_ATTRIBUTE_MANAGED 0x0000
#define METHOD_IMPL_ATTRIBUTE_FORWARD_REF 0x0010
#define METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG 0x0080
#define METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL 0x1000
#define METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED 0x0020
#define METHOD_IMPL_ATTRIBUTE_NOINLINING 0x0008
#define METHOD_IMPL_ATTRIBUTE_MAX_METHOD_IMPL_VAL 0xffff
#define METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK 0x0007
#define METHOD_ATTRIBUTE_COMPILER_CONTROLLED 0x0000
#define METHOD_ATTRIBUTE_PRIVATE 0x0001
#define METHOD_ATTRIBUTE_FAM_AND_ASSEM 0x0002
#define METHOD_ATTRIBUTE_ASSEM 0x0003
#define METHOD_ATTRIBUTE_FAMILY 0x0004
#define METHOD_ATTRIBUTE_FAM_OR_ASSEM 0x0005
#define METHOD_ATTRIBUTE_PUBLIC 0x0006
#define METHOD_ATTRIBUTE_STATIC 0x0010
#define METHOD_ATTRIBUTE_FINAL 0x0020
#define METHOD_ATTRIBUTE_VIRTUAL 0x0040
#define METHOD_ATTRIBUTE_HIDE_BY_SIG 0x0080
#define METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK 0x0100
#define METHOD_ATTRIBUTE_REUSE_SLOT 0x0000
#define METHOD_ATTRIBUTE_NEW_SLOT 0x0100
#define METHOD_ATTRIBUTE_STRICT 0x0200
#define METHOD_ATTRIBUTE_ABSTRACT 0x0400
#define METHOD_ATTRIBUTE_SPECIAL_NAME 0x0800
#define METHOD_ATTRIBUTE_PINVOKE_IMPL 0x2000
#define METHOD_ATTRIBUTE_UNMANAGED_EXPORT 0x0008
/*
* For runtime use only
*/
#define METHOD_ATTRIBUTE_RESERVED_MASK 0xd000
#define METHOD_ATTRIBUTE_RT_SPECIAL_NAME 0x1000
#define METHOD_ATTRIBUTE_HAS_SECURITY 0x4000
#define METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT 0x8000
/*
* Type Attributes (21.1.13).
*/
#define TYPE_ATTRIBUTE_VISIBILITY_MASK 0x00000007
#define TYPE_ATTRIBUTE_NOT_PUBLIC 0x00000000
#define TYPE_ATTRIBUTE_PUBLIC 0x00000001
#define TYPE_ATTRIBUTE_NESTED_PUBLIC 0x00000002
#define TYPE_ATTRIBUTE_NESTED_PRIVATE 0x00000003
#define TYPE_ATTRIBUTE_NESTED_FAMILY 0x00000004
#define TYPE_ATTRIBUTE_NESTED_ASSEMBLY 0x00000005
#define TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM 0x00000006
#define TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM 0x00000007
#define TYPE_ATTRIBUTE_LAYOUT_MASK 0x00000018
#define TYPE_ATTRIBUTE_AUTO_LAYOUT 0x00000000
#define TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT 0x00000008
#define TYPE_ATTRIBUTE_EXPLICIT_LAYOUT 0x00000010
#define TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK 0x00000020
#define TYPE_ATTRIBUTE_CLASS 0x00000000
#define TYPE_ATTRIBUTE_INTERFACE 0x00000020
#define TYPE_ATTRIBUTE_ABSTRACT 0x00000080
#define TYPE_ATTRIBUTE_SEALED 0x00000100
#define TYPE_ATTRIBUTE_SPECIAL_NAME 0x00000400
#define TYPE_ATTRIBUTE_IMPORT 0x00001000
#define TYPE_ATTRIBUTE_SERIALIZABLE 0x00002000
#define TYPE_ATTRIBUTE_STRING_FORMAT_MASK 0x00030000
#define TYPE_ATTRIBUTE_ANSI_CLASS 0x00000000
#define TYPE_ATTRIBUTE_UNICODE_CLASS 0x00010000
#define TYPE_ATTRIBUTE_AUTO_CLASS 0x00020000
#define TYPE_ATTRIBUTE_BEFORE_FIELD_INIT 0x00100000
#define TYPE_ATTRIBUTE_FORWARDER 0x00200000
#define TYPE_ATTRIBUTE_RESERVED_MASK 0x00040800
#define TYPE_ATTRIBUTE_RT_SPECIAL_NAME 0x00000800
#define TYPE_ATTRIBUTE_HAS_SECURITY 0x00040000
/*
* Flags for Params (22.1.12)
*/
#define PARAM_ATTRIBUTE_IN 0x0001
#define PARAM_ATTRIBUTE_OUT 0x0002
#define PARAM_ATTRIBUTE_OPTIONAL 0x0010
#define PARAM_ATTRIBUTE_RESERVED_MASK 0xf000
#define PARAM_ATTRIBUTE_HAS_DEFAULT 0x1000
#define PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL 0x2000
#define PARAM_ATTRIBUTE_UNUSED 0xcfe0
// Flags for Generic Parameters (II.23.1.7)
#define GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT 0x00
#define GENERIC_PARAMETER_ATTRIBUTE_COVARIANT 0x01
#define GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT 0x02
#define GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK 0x03
#define GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT 0x04
#define GENERIC_PARAMETER_ATTRIBUTE_NOT_NULLABLE_VALUE_TYPE_CONSTRAINT 0x08
#define GENERIC_PARAMETER_ATTRIBUTE_DEFAULT_CONSTRUCTOR_CONSTRAINT 0x10
#define GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINT_MASK 0x1C
/**
* 21.5 AssemblyRefs
*/
#define ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG 0x00000001
#define ASSEMBLYREF_RETARGETABLE_FLAG 0x00000100
#define ASSEMBLYREF_ENABLEJITCOMPILE_TRACKING_FLAG 0x00008000
#define ASSEMBLYREF_DISABLEJITCOMPILE_OPTIMIZER_FLAG 0x00004000