mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-25 02:03:02 -03:00
添加更多的头文件版本
This commit is contained in:
parent
502f7215bd
commit
805bd90fa2
2 changed files with 219 additions and 33 deletions
|
@ -8,7 +8,27 @@ namespace Il2CppDumper
|
|||
{
|
||||
public static class HeaderConstants
|
||||
{
|
||||
public readonly static string HeaderV242 =
|
||||
public readonly static string TypedefHeader =
|
||||
@"typedef signed char int8_t;
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
#ifdef _WIN64
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
typedef __int64 intptr_t;
|
||||
#else
|
||||
typedef unsigned int uintptr_t;
|
||||
typedef int intptr_t;
|
||||
#endif
|
||||
|
||||
";
|
||||
|
||||
public readonly static string GenericHeader =
|
||||
@"struct VirtualInvokeData
|
||||
{
|
||||
uintptr_t methodPtr;
|
||||
|
@ -23,7 +43,29 @@ struct Il2CppType
|
|||
|
||||
struct Il2CppClass;
|
||||
|
||||
struct Il2CppClass_1
|
||||
struct Il2CppObject
|
||||
{
|
||||
Il2CppClass *klass;
|
||||
void *monitor;
|
||||
};
|
||||
|
||||
struct Il2CppArrayBounds
|
||||
{
|
||||
uintptr_t length;
|
||||
int32_t lower_bound;
|
||||
};
|
||||
|
||||
struct Il2CppArray
|
||||
{
|
||||
Il2CppObject obj;
|
||||
Il2CppArrayBounds *bounds;
|
||||
uintptr_t max_length;
|
||||
};
|
||||
|
||||
";
|
||||
|
||||
public readonly static string HeaderV242 =
|
||||
@"struct Il2CppClass_1
|
||||
{
|
||||
void* image;
|
||||
void* gc_desc;
|
||||
|
@ -67,7 +109,6 @@ struct Il2CppClass_2
|
|||
int32_t thread_static_fields_offset;
|
||||
uint32_t flags;
|
||||
uint32_t token;
|
||||
|
||||
uint16_t method_count;
|
||||
uint16_t property_count;
|
||||
uint16_t field_count;
|
||||
|
@ -76,7 +117,6 @@ struct Il2CppClass_2
|
|||
uint16_t vtable_count;
|
||||
uint16_t interfaces_count;
|
||||
uint16_t interface_offsets_count;
|
||||
|
||||
uint8_t typeHierarchyDepth;
|
||||
uint8_t genericRecursionDepth;
|
||||
uint8_t rank;
|
||||
|
@ -95,23 +135,146 @@ struct Il2CppClass
|
|||
VirtualInvokeData vtable[255];
|
||||
};
|
||||
|
||||
struct Il2CppObject
|
||||
";
|
||||
|
||||
public readonly static string HeaderV241 =
|
||||
@"struct Il2CppClass_1
|
||||
{
|
||||
Il2CppClass *klass;
|
||||
void *monitor;
|
||||
void* image;
|
||||
void* gc_desc;
|
||||
const char* name;
|
||||
const char* namespaze;
|
||||
Il2CppType byval_arg;
|
||||
Il2CppType this_arg;
|
||||
Il2CppClass* element_class;
|
||||
Il2CppClass* castClass;
|
||||
Il2CppClass* declaringType;
|
||||
Il2CppClass* parent;
|
||||
void *generic_class;
|
||||
void* typeDefinition;
|
||||
void* interopData;
|
||||
Il2CppClass* klass;
|
||||
void* fields;
|
||||
void* events;
|
||||
void* properties;
|
||||
void* methods;
|
||||
Il2CppClass** nestedTypes;
|
||||
Il2CppClass** implementedInterfaces;
|
||||
void* interfaceOffsets;
|
||||
};
|
||||
|
||||
struct Il2CppArrayBounds
|
||||
struct Il2CppClass_2
|
||||
{
|
||||
uintptr_t length;
|
||||
int32_t lower_bound;
|
||||
void* rgctx_data;
|
||||
Il2CppClass** typeHierarchy;
|
||||
uint32_t initializationExceptionGCHandle;
|
||||
uint32_t cctor_started;
|
||||
uint32_t cctor_finished;
|
||||
uint64_t cctor_thread;
|
||||
int32_t genericContainerIndex;
|
||||
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;
|
||||
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;
|
||||
uint8_t typeHierarchyDepth;
|
||||
uint8_t genericRecursionDepth;
|
||||
uint8_t rank;
|
||||
uint8_t minimumAlignment;
|
||||
uint8_t naturalAligment;
|
||||
uint8_t packingSize;
|
||||
uint8_t bitflags1;
|
||||
uint8_t bitflags2;
|
||||
};
|
||||
|
||||
struct Il2CppArray
|
||||
struct Il2CppClass
|
||||
{
|
||||
Il2CppObject obj;
|
||||
Il2CppArrayBounds *bounds;
|
||||
uintptr_t max_length;
|
||||
Il2CppClass_1 _1;
|
||||
void* static_fields;
|
||||
Il2CppClass_2 _2;
|
||||
VirtualInvokeData vtable[255];
|
||||
};
|
||||
|
||||
";
|
||||
|
||||
public readonly static string HeaderV240 =
|
||||
@"struct Il2CppClass_1
|
||||
{
|
||||
void* image;
|
||||
void* gc_desc;
|
||||
const char* name;
|
||||
const char* namespaze;
|
||||
Il2CppType* byval_arg;
|
||||
Il2CppType* this_arg;
|
||||
Il2CppClass* element_class;
|
||||
Il2CppClass* castClass;
|
||||
Il2CppClass* declaringType;
|
||||
Il2CppClass* parent;
|
||||
void *generic_class;
|
||||
void* typeDefinition;
|
||||
void* interopData;
|
||||
void* fields;
|
||||
void* events;
|
||||
void* properties;
|
||||
void* methods;
|
||||
Il2CppClass** nestedTypes;
|
||||
Il2CppClass** implementedInterfaces;
|
||||
void* interfaceOffsets;
|
||||
};
|
||||
|
||||
struct Il2CppClass_2
|
||||
{
|
||||
void* rgctx_data;
|
||||
Il2CppClass** typeHierarchy;
|
||||
uint32_t cctor_started;
|
||||
uint32_t cctor_finished;
|
||||
uint64_t cctor_thread;
|
||||
int32_t genericContainerIndex;
|
||||
int32_t 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;
|
||||
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;
|
||||
uint8_t typeHierarchyDepth;
|
||||
uint8_t genericRecursionDepth;
|
||||
uint8_t rank;
|
||||
uint8_t minimumAlignment;
|
||||
uint8_t packingSize;
|
||||
uint8_t bitflags1;
|
||||
uint8_t bitflags2;
|
||||
};
|
||||
|
||||
struct Il2CppClass
|
||||
{
|
||||
Il2CppClass_1 _1;
|
||||
void* static_fields;
|
||||
Il2CppClass_2 _2;
|
||||
VirtualInvokeData vtable[255];
|
||||
};
|
||||
|
||||
";
|
||||
|
|
|
@ -239,7 +239,7 @@ namespace Il2CppDumper
|
|||
AddGenericClassStruct(pointer);
|
||||
}
|
||||
//TODO 处理数组类型
|
||||
var preHeader = new StringBuilder(HeaderConstants.HeaderV242);
|
||||
var preHeader = new StringBuilder();
|
||||
var headerStruct = new StringBuilder();
|
||||
var headerClass = new StringBuilder();
|
||||
foreach (var info in StructInfo)
|
||||
|
@ -278,33 +278,56 @@ namespace Il2CppDumper
|
|||
|
||||
foreach (var field in info.Fields)
|
||||
{
|
||||
if (field.FieldName == "klass") //hack
|
||||
{
|
||||
field.FieldName = "_klass";
|
||||
}
|
||||
if (field.FieldName == "monitor") //hack
|
||||
{
|
||||
field.FieldName = "_monitor";
|
||||
}
|
||||
if (field.FieldName == "register") //hack
|
||||
{
|
||||
field.FieldName = "_register";
|
||||
}
|
||||
if (field.FieldName == "_cs") //hack
|
||||
{
|
||||
field.FieldName = "__cs";
|
||||
}
|
||||
headerClass.Append($"\t{field.FieldTypeName} {field.FieldName};\n");
|
||||
}
|
||||
headerClass.Append("};\n");
|
||||
}
|
||||
}
|
||||
var str = preHeader.Append(headerStruct).Append(headerClass).ToString();
|
||||
File.WriteAllText("il2cpp.h", str);
|
||||
var sb = new StringBuilder();
|
||||
if (il2Cpp is PE)
|
||||
{
|
||||
sb.Append(HeaderConstants.TypedefHeader);
|
||||
}
|
||||
sb.Append(HeaderConstants.GenericHeader);
|
||||
switch (il2Cpp.Version)
|
||||
{
|
||||
case 24f:
|
||||
sb.Append(HeaderConstants.HeaderV240);
|
||||
break;
|
||||
case 24.1f:
|
||||
sb.Append(HeaderConstants.HeaderV241);
|
||||
break;
|
||||
case 24.2f:
|
||||
sb.Append(HeaderConstants.HeaderV242);
|
||||
break;
|
||||
default:
|
||||
sb.Append(HeaderConstants.HeaderV242);
|
||||
break;
|
||||
}
|
||||
sb.Append(preHeader);
|
||||
sb.Append(headerStruct);
|
||||
sb.Append(headerClass);
|
||||
File.WriteAllText("il2cpp.h", sb.ToString());
|
||||
}
|
||||
|
||||
private static string FixName(string str)
|
||||
{
|
||||
if (str == "klass")
|
||||
{
|
||||
str = "_klass";
|
||||
}
|
||||
if (str == "monitor")
|
||||
{
|
||||
str = "_monitor";
|
||||
}
|
||||
if (str == "register")
|
||||
{
|
||||
str = "_register";
|
||||
}
|
||||
if (str == "_cs")
|
||||
{
|
||||
str = "__cs";
|
||||
}
|
||||
if (Regex.IsMatch(str, "^[0-9]"))
|
||||
{
|
||||
return "_" + str;
|
||||
|
|
Loading…
Add table
Reference in a new issue