Update constants from Unity 2017.2 headers

This commit is contained in:
Katy Coe
2017-11-09 12:46:44 +01:00
parent 8cf13a0b87
commit b6f34bf486
8 changed files with 260 additions and 120 deletions

View File

@@ -1,98 +0,0 @@
using System.Collections.Generic;
public static class DefineConstants
{
public const int FIELD_ATTRIBUTE_PRIVATE = 0x0001;
public const int FIELD_ATTRIBUTE_PUBLIC = 0x0006;
public const int FIELD_ATTRIBUTE_STATIC = 0x0010;
public const int FIELD_ATTRIBUTE_INIT_ONLY = 0x0020;
public const int METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK = 0x0007;
public const int METHOD_ATTRIBUTE_PRIVATE = 0x0001;
public const int METHOD_ATTRIBUTE_PUBLIC = 0x0006;
public const int METHOD_ATTRIBUTE_STATIC = 0x0010;
public const int METHOD_ATTRIBUTE_VIRTUAL = 0x0040;
public const int TYPE_ATTRIBUTE_VISIBILITY_MASK = 0x00000007;
public const int TYPE_ATTRIBUTE_PUBLIC = 0x00000001;
public const int TYPE_ATTRIBUTE_INTERFACE = 0x00000020;
public const int TYPE_ATTRIBUTE_ABSTRACT = 0x00000080;
public const int TYPE_ATTRIBUTE_SEALED = 0x00000100;
public const int TYPE_ATTRIBUTE_SERIALIZABLE = 0x00002000;
public const int PARAM_ATTRIBUTE_OUT = 0x0002;
public const int PARAM_ATTRIBUTE_OPTIONAL = 0x0010;
public static List<string> CSharpTypeString = new List<string>
{
"END",
"void",
"bool",
"char",
"sbyte",
"byte",
"short",
"ushort",
"int",
"uint",
"long",
"ulong",
"float",
"double",
"string",
"PTR", // Processed separately
"BYREF",
"ValueType", // Processed separately
"CLASS", // Processed separately
"T",
"Array", // Processed separately
"GENERICINST", // Processed separately
"TYPEDBYREF",
"None",
"IntPtr",
"UIntPtr",
"None",
"delegate",
"object",
"SZARRAY", // Processed separately
"T",
"CMOD_REQD",
"CMOD_OPT",
"INTERNAL",
};
public static List<string> FullNameTypeString = new List<string>
{
"END",
"System.Void",
"System.Boolean",
"System.Char",
"System.SByte",
"System.Byte",
"System.Int16",
"System.UInt16",
"System.Int32",
"System.UInt32",
"System.Int64",
"System.UInt64",
"System.Single",
"System.Double",
"System.String",
"PTR", // Processed separately
"BYREF",
"System.ValueType", // Processed separately
"CLASS", // Processed separately
"T",
"System.Array", // Processed separately
"GENERICINST", // Processed separately
"TYPEDBYREF",
"None",
"System.IntPtr",
"System.UIntPtr",
"None",
"System.Delegate",
"System.Object",
"SZARRAY", // Processed separately
"T",
"CMOD_REQD",
"CMOD_OPT",
"INTERNAL",
};
}

View File

@@ -0,0 +1,238 @@
using System.Collections.Generic;
// Constants from il2cpp/tabledefs.h
namespace Il2CppInspector
{
public static class Il2CppConstants
{
/*
* Field Attributes (21.1.5).
*/
public const int FIELD_ATTRIBUTE_FIELD_ACCESS_MASK = 0x0007;
public const int FIELD_ATTRIBUTE_COMPILER_CONTROLLED = 0x0000;
public const int FIELD_ATTRIBUTE_PRIVATE = 0x0001;
public const int FIELD_ATTRIBUTE_FAM_AND_ASSEM = 0x0002;
public const int FIELD_ATTRIBUTE_ASSEMBLY = 0x0003;
public const int FIELD_ATTRIBUTE_FAMILY = 0x0004;
public const int FIELD_ATTRIBUTE_FAM_OR_ASSEM = 0x0005;
public const int FIELD_ATTRIBUTE_PUBLIC = 0x0006;
public const int FIELD_ATTRIBUTE_STATIC = 0x0010;
public const int FIELD_ATTRIBUTE_INIT_ONLY = 0x0020;
public const int FIELD_ATTRIBUTE_LITERAL = 0x0040;
public const int FIELD_ATTRIBUTE_NOT_SERIALIZED = 0x0080;
public const int FIELD_ATTRIBUTE_SPECIAL_NAME = 0x0200;
public const int FIELD_ATTRIBUTE_PINVOKE_IMPL = 0x2000;
/* For runtime use only */
public const int FIELD_ATTRIBUTE_RESERVED_MASK = 0x9500;
public const int FIELD_ATTRIBUTE_RT_SPECIAL_NAME = 0x0400;
public const int FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL = 0x1000;
public const int FIELD_ATTRIBUTE_HAS_DEFAULT = 0x8000;
public const int FIELD_ATTRIBUTE_HAS_FIELD_RVA = 0x0100;
/*
* Method Attributes (22.1.9)
*/
public const int METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK = 0x0003;
public const int METHOD_IMPL_ATTRIBUTE_IL = 0x0000;
public const int METHOD_IMPL_ATTRIBUTE_NATIVE = 0x0001;
public const int METHOD_IMPL_ATTRIBUTE_OPTIL = 0x0002;
public const int METHOD_IMPL_ATTRIBUTE_RUNTIME = 0x0003;
public const int METHOD_IMPL_ATTRIBUTE_MANAGED_MASK = 0x0004;
public const int METHOD_IMPL_ATTRIBUTE_UNMANAGED = 0x0004;
public const int METHOD_IMPL_ATTRIBUTE_MANAGED = 0x0000;
public const int METHOD_IMPL_ATTRIBUTE_FORWARD_REF = 0x0010;
public const int METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG = 0x0080;
public const int METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL = 0x1000;
public const int METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED = 0x0020;
public const int METHOD_IMPL_ATTRIBUTE_NOINLINING = 0x0008;
public const int METHOD_IMPL_ATTRIBUTE_MAX_METHOD_IMPL_VAL = 0xffff;
public const int METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK = 0x0007;
public const int METHOD_ATTRIBUTE_COMPILER_CONTROLLED = 0x0000;
public const int METHOD_ATTRIBUTE_PRIVATE = 0x0001;
public const int METHOD_ATTRIBUTE_FAM_AND_ASSEM = 0x0002;
public const int METHOD_ATTRIBUTE_ASSEM = 0x0003;
public const int METHOD_ATTRIBUTE_FAMILY = 0x0004;
public const int METHOD_ATTRIBUTE_FAM_OR_ASSEM = 0x0005;
public const int METHOD_ATTRIBUTE_PUBLIC = 0x0006;
public const int METHOD_ATTRIBUTE_STATIC = 0x0010;
public const int METHOD_ATTRIBUTE_FINAL = 0x0020;
public const int METHOD_ATTRIBUTE_VIRTUAL = 0x0040;
public const int METHOD_ATTRIBUTE_HIDE_BY_SIG = 0x0080;
public const int METHOD_ATTRIBUTE_VTABLE_LAYOUT_MASK = 0x0100;
public const int METHOD_ATTRIBUTE_REUSE_SLOT = 0x0000;
public const int METHOD_ATTRIBUTE_NEW_SLOT = 0x0100;
public const int METHOD_ATTRIBUTE_STRICT = 0x0200;
public const int METHOD_ATTRIBUTE_ABSTRACT = 0x0400;
public const int METHOD_ATTRIBUTE_SPECIAL_NAME = 0x0800;
public const int METHOD_ATTRIBUTE_PINVOKE_IMPL = 0x2000;
public const int METHOD_ATTRIBUTE_UNMANAGED_EXPORT = 0x0008;
/*
* For runtime use only
*/
public const int METHOD_ATTRIBUTE_RESERVED_MASK = 0xd000;
public const int METHOD_ATTRIBUTE_RT_SPECIAL_NAME = 0x1000;
public const int METHOD_ATTRIBUTE_HAS_SECURITY = 0x4000;
public const int METHOD_ATTRIBUTE_REQUIRE_SEC_OBJECT = 0x8000;
/*
* Type Attributes (21.1.13).
*/
public const int TYPE_ATTRIBUTE_VISIBILITY_MASK = 0x00000007;
public const int TYPE_ATTRIBUTE_NOT_PUBLIC = 0x00000000;
public const int TYPE_ATTRIBUTE_PUBLIC = 0x00000001;
public const int TYPE_ATTRIBUTE_NESTED_PUBLIC = 0x00000002;
public const int TYPE_ATTRIBUTE_NESTED_PRIVATE = 0x00000003;
public const int TYPE_ATTRIBUTE_NESTED_FAMILY = 0x00000004;
public const int TYPE_ATTRIBUTE_NESTED_ASSEMBLY = 0x00000005;
public const int TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM = 0x00000006;
public const int TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM = 0x00000007;
public const int TYPE_ATTRIBUTE_LAYOUT_MASK = 0x00000018;
public const int TYPE_ATTRIBUTE_AUTO_LAYOUT = 0x00000000;
public const int TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT = 0x00000008;
public const int TYPE_ATTRIBUTE_EXPLICIT_LAYOUT = 0x00000010;
public const int TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK = 0x00000020;
public const int TYPE_ATTRIBUTE_CLASS = 0x00000000;
public const int TYPE_ATTRIBUTE_INTERFACE = 0x00000020;
public const int TYPE_ATTRIBUTE_ABSTRACT = 0x00000080;
public const int TYPE_ATTRIBUTE_SEALED = 0x00000100;
public const int TYPE_ATTRIBUTE_SPECIAL_NAME = 0x00000400;
public const int TYPE_ATTRIBUTE_IMPORT = 0x00001000;
public const int TYPE_ATTRIBUTE_SERIALIZABLE = 0x00002000;
public const int TYPE_ATTRIBUTE_STRING_FORMAT_MASK = 0x00030000;
public const int TYPE_ATTRIBUTE_ANSI_CLASS = 0x00000000;
public const int TYPE_ATTRIBUTE_UNICODE_CLASS = 0x00010000;
public const int TYPE_ATTRIBUTE_AUTO_CLASS = 0x00020000;
public const int TYPE_ATTRIBUTE_BEFORE_FIELD_INIT = 0x00100000;
public const int TYPE_ATTRIBUTE_FORWARDER = 0x00200000;
public const int TYPE_ATTRIBUTE_RESERVED_MASK = 0x00040800;
public const int TYPE_ATTRIBUTE_RT_SPECIAL_NAME = 0x00000800;
public const int TYPE_ATTRIBUTE_HAS_SECURITY = 0x00040000;
/*
* Flags for Params (22.1.12)
*/
public const int PARAM_ATTRIBUTE_IN = 0x0001;
public const int PARAM_ATTRIBUTE_OUT = 0x0002;
public const int PARAM_ATTRIBUTE_OPTIONAL = 0x0010;
public const int PARAM_ATTRIBUTE_RESERVED_MASK = 0xf000;
public const int PARAM_ATTRIBUTE_HAS_DEFAULT = 0x1000;
public const int PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL = 0x2000;
public const int PARAM_ATTRIBUTE_UNUSED = 0xcfe0;
// Flags for Generic Parameters (II.23.1.7)
public const int GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT = 0x00;
public const int GENERIC_PARAMETER_ATTRIBUTE_COVARIANT = 0x01;
public const int GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT = 0x02;
public const int GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK = 0x03;
public const int GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT = 0x04;
public const int GENERIC_PARAMETER_ATTRIBUTE_NOT_NULLABLE_VALUE_TYPE_CONSTRAINT = 0x08;
public const int GENERIC_PARAMETER_ATTRIBUTE_DEFAULT_CONSTRUCTOR_CONSTRAINT = 0x10;
public const int GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINT_MASK = 0x1C;
/**
* 21.5 AssemblyRefs
*/
public const int ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG = 0x00000001;
public const int ASSEMBLYREF_RETARGETABLE_FLAG = 0x00000100;
public const int ASSEMBLYREF_ENABLEJITCOMPILE_TRACKING_FLAG = 0x00008000;
public const int ASSEMBLYREF_DISABLEJITCOMPILE_OPTIMIZER_FLAG = 0x00004000;
// Naming conventions (follows order of Il2CppTypeEnum)
public static List<string> CSharpTypeString = new List<string>
{
"END",
"void",
"bool",
"char",
"sbyte",
"byte",
"short",
"ushort",
"int",
"uint",
"long",
"ulong",
"float",
"double",
"string",
"PTR", // Processed separately
"BYREF",
"ValueType", // Processed separately
"CLASS", // Processed separately
"T",
"Array", // Processed separately
"GENERICINST", // Processed separately
"TYPEDBYREF",
"None",
"IntPtr",
"UIntPtr",
"None",
"delegate",
"object",
"SZARRAY", // Processed separately
"T",
"CMOD_REQD",
"CMOD_OPT",
"INTERNAL",
};
public static List<string> FullNameTypeString = new List<string>
{
"END",
"System.Void",
"System.Boolean",
"System.Char",
"System.SByte",
"System.Byte",
"System.Int16",
"System.UInt16",
"System.Int32",
"System.UInt32",
"System.Int64",
"System.UInt64",
"System.Single",
"System.Double",
"System.String",
"PTR", // Processed separately
"BYREF",
"System.ValueType", // Processed separately
"CLASS", // Processed separately
"T",
"System.Array", // Processed separately
"GENERICINST", // Processed separately
"TYPEDBYREF",
"None",
"System.IntPtr",
"System.UIntPtr",
"None",
"System.Delegate",
"System.Object",
"SZARRAY", // Processed separately
"T",
"CMOD_REQD",
"CMOD_OPT",
"INTERNAL",
};
}
}

View File

@@ -208,10 +208,10 @@ namespace Il2CppInspector
ret = $"{GetTypeName(type)}[]"; ret = $"{GetTypeName(type)}[]";
} }
else { else {
if ((int) pType.type >= DefineConstants.CSharpTypeString.Count) if ((int) pType.type >= Il2CppConstants.CSharpTypeString.Count)
ret = "unknow"; ret = "unknow";
else else
ret = DefineConstants.CSharpTypeString[(int) pType.type]; ret = Il2CppConstants.CSharpTypeString[(int) pType.type];
} }
return ret; return ret;
} }

View File

@@ -49,10 +49,10 @@ namespace Il2CppInspector.Reflection
default: default:
// Basic primitive types // Basic primitive types
if ((int) pType.type >= DefineConstants.FullNameTypeString.Count) if ((int) pType.type >= Il2CppConstants.FullNameTypeString.Count)
return null; return null;
return Assemblies.SelectMany(x => x.DefinedTypes).First(x => x.FullName == DefineConstants.FullNameTypeString[(int)pType.type]); return Assemblies.SelectMany(x => x.DefinedTypes).First(x => x.FullName == Il2CppConstants.FullNameTypeString[(int)pType.type]);
} }
} }
} }

View File

@@ -63,14 +63,14 @@ namespace Il2CppInspector.Reflection {
Name = pkg.Strings[Definition.nameIndex]; Name = pkg.Strings[Definition.nameIndex];
fieldType = pkg.TypeUsages[Definition.typeIndex]; fieldType = pkg.TypeUsages[Definition.typeIndex];
if ((fieldType.attrs & DefineConstants.FIELD_ATTRIBUTE_PRIVATE) == DefineConstants.FIELD_ATTRIBUTE_PRIVATE) if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_PRIVATE) == Il2CppConstants.FIELD_ATTRIBUTE_PRIVATE)
Attributes |= FieldAttributes.Private; Attributes |= FieldAttributes.Private;
if ((fieldType.attrs & DefineConstants.FIELD_ATTRIBUTE_PUBLIC) == DefineConstants.FIELD_ATTRIBUTE_PUBLIC) if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_PUBLIC) == Il2CppConstants.FIELD_ATTRIBUTE_PUBLIC)
Attributes |= FieldAttributes.Public; Attributes |= FieldAttributes.Public;
if ((fieldType.attrs & DefineConstants.FIELD_ATTRIBUTE_STATIC) == DefineConstants.FIELD_ATTRIBUTE_STATIC) if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_STATIC) == Il2CppConstants.FIELD_ATTRIBUTE_STATIC)
Attributes |= FieldAttributes.Static; Attributes |= FieldAttributes.Static;
if ((fieldType.attrs & DefineConstants.FIELD_ATTRIBUTE_INIT_ONLY) == if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_INIT_ONLY) ==
DefineConstants.FIELD_ATTRIBUTE_INIT_ONLY) Il2CppConstants.FIELD_ATTRIBUTE_INIT_ONLY)
Attributes |= FieldAttributes.InitOnly; Attributes |= FieldAttributes.InitOnly;
// Default initialization value if present // Default initialization value if present

View File

@@ -39,13 +39,13 @@ namespace Il2CppInspector.Reflection
} }
Name = pkg.Strings[Definition.nameIndex]; Name = pkg.Strings[Definition.nameIndex];
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == DefineConstants.METHOD_ATTRIBUTE_PRIVATE) if ((Definition.flags & Il2CppConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == Il2CppConstants.METHOD_ATTRIBUTE_PRIVATE)
Attributes |= MethodAttributes.Private; Attributes |= MethodAttributes.Private;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == DefineConstants.METHOD_ATTRIBUTE_PUBLIC) if ((Definition.flags & Il2CppConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == Il2CppConstants.METHOD_ATTRIBUTE_PUBLIC)
Attributes |= MethodAttributes.Public; Attributes |= MethodAttributes.Public;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_VIRTUAL) != 0) if ((Definition.flags & Il2CppConstants.METHOD_ATTRIBUTE_VIRTUAL) != 0)
Attributes |= MethodAttributes.Virtual; Attributes |= MethodAttributes.Virtual;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_STATIC) != 0) if ((Definition.flags & Il2CppConstants.METHOD_ATTRIBUTE_STATIC) != 0)
Attributes |= MethodAttributes.Static; Attributes |= MethodAttributes.Static;
// Add return parameter // Add return parameter

View File

@@ -56,9 +56,9 @@ namespace Il2CppInspector.Reflection
Position = paramIndex - declaringMethod.Definition.parameterStart; Position = paramIndex - declaringMethod.Definition.parameterStart;
paramType = pkg.TypeUsages[param.typeIndex]; paramType = pkg.TypeUsages[param.typeIndex];
if ((paramType.attrs & DefineConstants.PARAM_ATTRIBUTE_OPTIONAL) != 0) if ((paramType.attrs & Il2CppConstants.PARAM_ATTRIBUTE_OPTIONAL) != 0)
Attributes |= ParameterAttributes.Optional; Attributes |= ParameterAttributes.Optional;
if ((paramType.attrs & DefineConstants.PARAM_ATTRIBUTE_OUT) != 0) if ((paramType.attrs & Il2CppConstants.PARAM_ATTRIBUTE_OUT) != 0)
Attributes |= ParameterAttributes.Out; Attributes |= ParameterAttributes.Out;
if (Position == -1) if (Position == -1)

View File

@@ -30,8 +30,8 @@ namespace Il2CppInspector.Reflection {
public string CSharpName { public string CSharpName {
get { get {
var s = Namespace + "." + base.Name; var s = Namespace + "." + base.Name;
var i = DefineConstants.FullNameTypeString.IndexOf(s); var i = Il2CppConstants.FullNameTypeString.IndexOf(s);
var n = (i != -1 ? DefineConstants.CSharpTypeString[i] : base.Name); var n = (i != -1 ? Il2CppConstants.CSharpTypeString[i] : base.Name);
if (IsArray) if (IsArray)
n = ElementType.CSharpName; n = ElementType.CSharpName;
var g = (GenericTypeParameters != null ? "<" + string.Join(", ", GenericTypeParameters.Select(x => x.CSharpName)) + ">" : ""); var g = (GenericTypeParameters != null ? "<" + string.Join(", ", GenericTypeParameters.Select(x => x.CSharpName)) + ">" : "");
@@ -121,15 +121,15 @@ namespace Il2CppInspector.Reflection {
Namespace = pkg.Strings[Definition.namespaceIndex]; Namespace = pkg.Strings[Definition.namespaceIndex];
Name = pkg.Strings[pkg.TypeDefinitions[typeIndex].nameIndex]; Name = pkg.Strings[pkg.TypeDefinitions[typeIndex].nameIndex];
if ((Definition.flags & DefineConstants.TYPE_ATTRIBUTE_SERIALIZABLE) != 0) if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_SERIALIZABLE) != 0)
Attributes |= TypeAttributes.Serializable; Attributes |= TypeAttributes.Serializable;
if ((Definition.flags & DefineConstants.TYPE_ATTRIBUTE_VISIBILITY_MASK) == DefineConstants.TYPE_ATTRIBUTE_PUBLIC) if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_VISIBILITY_MASK) == Il2CppConstants.TYPE_ATTRIBUTE_PUBLIC)
Attributes |= TypeAttributes.Public; Attributes |= TypeAttributes.Public;
if ((Definition.flags & DefineConstants.TYPE_ATTRIBUTE_ABSTRACT) != 0) if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_ABSTRACT) != 0)
Attributes |= TypeAttributes.Abstract; Attributes |= TypeAttributes.Abstract;
if ((Definition.flags & DefineConstants.TYPE_ATTRIBUTE_SEALED) != 0) if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_SEALED) != 0)
Attributes |= TypeAttributes.Sealed; Attributes |= TypeAttributes.Sealed;
if ((Definition.flags & DefineConstants.TYPE_ATTRIBUTE_INTERFACE) != 0) if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_INTERFACE) != 0)
Attributes |= TypeAttributes.Interface; Attributes |= TypeAttributes.Interface;
// Not sure about this, works for now // Not sure about this, works for now