diff --git a/Il2CppDumper/Il2CppDumper.csproj b/Il2CppDumper/Il2CppDumper.csproj
index e0343f05..ec2113c5 100644
--- a/Il2CppDumper/Il2CppDumper.csproj
+++ b/Il2CppDumper/Il2CppDumper.csproj
@@ -15,6 +15,21 @@
+
+
+ True
+ True
+ Resource1.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resource1.Designer.cs
+
+
+
PreserveNewest
diff --git a/Il2CppDumper/Libraries/Il2CppDummyDll.dll b/Il2CppDumper/Libraries/Il2CppDummyDll.dll
new file mode 100644
index 00000000..eb9f77f2
Binary files /dev/null and b/Il2CppDumper/Libraries/Il2CppDummyDll.dll differ
diff --git a/Il2CppDumper/Resource1.Designer.cs b/Il2CppDumper/Resource1.Designer.cs
new file mode 100644
index 00000000..b887e61b
--- /dev/null
+++ b/Il2CppDumper/Resource1.Designer.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace Il2CppDumper {
+ using System;
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource1 {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource1() {
+ }
+
+ ///
+ /// 返回此类使用的缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Il2CppDumper.Resource1", typeof(Resource1).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] Il2CppDummyDll {
+ get {
+ object obj = ResourceManager.GetObject("Il2CppDummyDll", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+ }
+}
diff --git a/Il2CppDumper/Resource1.resx b/Il2CppDumper/Resource1.resx
new file mode 100644
index 00000000..ae103cac
--- /dev/null
+++ b/Il2CppDumper/Resource1.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ Libraries\Il2CppDummyDll.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs
index 1d22fc5e..e5f037a0 100644
--- a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs
+++ b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs
@@ -3,6 +3,7 @@
using Mono.Collections.Generic;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
namespace Il2CppDumper
@@ -18,6 +19,7 @@ public class DummyAssemblyGenerator
private Dictionary genericParameterDic = new Dictionary();
private MethodDefinition attributeAttribute;
private TypeReference stringType;
+ private TypeSystem typeSystem;
private Dictionary fieldDefinitionDic = new Dictionary();
private Dictionary propertyDefinitionDic = new Dictionary();
private Dictionary methodDefinitionDic = new Dictionary();
@@ -29,14 +31,16 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor, bool addToken)
il2Cpp = il2CppExecutor.il2Cpp;
//Il2CppDummyDll
- var il2CppDummyDll = Il2CppDummyDll.Create();
+ var il2CppDummyDll = AssemblyDefinition.ReadAssembly(new MemoryStream(Resource1.Il2CppDummyDll));
Assemblies.Add(il2CppDummyDll);
- var addressAttribute = il2CppDummyDll.MainModule.Types.First(x => x.Name == "AddressAttribute").Methods[0];
- var fieldOffsetAttribute = il2CppDummyDll.MainModule.Types.First(x => x.Name == "FieldOffsetAttribute").Methods[0];
- attributeAttribute = il2CppDummyDll.MainModule.Types.First(x => x.Name == "AttributeAttribute").Methods[0];
- var metadataOffsetAttribute = il2CppDummyDll.MainModule.Types.First(x => x.Name == "MetadataOffsetAttribute").Methods[0];
- var tokenAttribute = il2CppDummyDll.MainModule.Types.First(x => x.Name == "TokenAttribute").Methods[0];
- stringType = il2CppDummyDll.MainModule.TypeSystem.String;
+ var dummyMD = il2CppDummyDll.MainModule;
+ var addressAttribute = dummyMD.Types.First(x => x.Name == "AddressAttribute").Methods[0];
+ var fieldOffsetAttribute = dummyMD.Types.First(x => x.Name == "FieldOffsetAttribute").Methods[0];
+ attributeAttribute = dummyMD.Types.First(x => x.Name == "AttributeAttribute").Methods[0];
+ var metadataOffsetAttribute = dummyMD.Types.First(x => x.Name == "MetadataOffsetAttribute").Methods[0];
+ var tokenAttribute = dummyMD.Types.First(x => x.Name == "TokenAttribute").Methods[0];
+ stringType = dummyMD.TypeSystem.String;
+ typeSystem = dummyMD.TypeSystem;
var resolver = new MyAssemblyResolver();
var moduleParameters = new ModuleParameters
@@ -217,7 +221,7 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor, bool addToken)
{
var methodDef = metadata.methodDefs[i];
var methodName = metadata.GetStringFromIndex(methodDef.nameIndex);
- var methodDefinition = new MethodDefinition(methodName, (MethodAttributes)methodDef.flags, typeDefinition.Module.ImportReference(typeof(void)));
+ var methodDefinition = new MethodDefinition(methodName, (MethodAttributes)methodDef.flags, typeDefinition.Module.ImportReference(typeSystem.Void));
methodDefinition.ImplAttributes = (MethodImplAttributes)methodDef.iflags;
typeDefinition.Methods.Add(methodDefinition);
//genericParameter
@@ -462,41 +466,41 @@ private TypeReference GetTypeReference(MemberReference memberReference, Il2CppTy
switch (il2CppType.type)
{
case Il2CppTypeEnum.IL2CPP_TYPE_OBJECT:
- return moduleDefinition.ImportReference(typeof(object));
+ return moduleDefinition.ImportReference(typeSystem.Object);
case Il2CppTypeEnum.IL2CPP_TYPE_VOID:
- return moduleDefinition.ImportReference(typeof(void));
+ return moduleDefinition.ImportReference(typeSystem.Void);
case Il2CppTypeEnum.IL2CPP_TYPE_BOOLEAN:
- return moduleDefinition.ImportReference(typeof(bool));
+ return moduleDefinition.ImportReference(typeSystem.Boolean);
case Il2CppTypeEnum.IL2CPP_TYPE_CHAR:
- return moduleDefinition.ImportReference(typeof(char));
+ return moduleDefinition.ImportReference(typeSystem.Char);
case Il2CppTypeEnum.IL2CPP_TYPE_I1:
- return moduleDefinition.ImportReference(typeof(sbyte));
+ return moduleDefinition.ImportReference(typeSystem.SByte);
case Il2CppTypeEnum.IL2CPP_TYPE_U1:
- return moduleDefinition.ImportReference(typeof(byte));
+ return moduleDefinition.ImportReference(typeSystem.Byte);
case Il2CppTypeEnum.IL2CPP_TYPE_I2:
- return moduleDefinition.ImportReference(typeof(short));
+ return moduleDefinition.ImportReference(typeSystem.Int16);
case Il2CppTypeEnum.IL2CPP_TYPE_U2:
- return moduleDefinition.ImportReference(typeof(ushort));
+ return moduleDefinition.ImportReference(typeSystem.UInt16);
case Il2CppTypeEnum.IL2CPP_TYPE_I4:
- return moduleDefinition.ImportReference(typeof(int));
+ return moduleDefinition.ImportReference(typeSystem.Int32);
case Il2CppTypeEnum.IL2CPP_TYPE_U4:
- return moduleDefinition.ImportReference(typeof(uint));
+ return moduleDefinition.ImportReference(typeSystem.UInt32);
case Il2CppTypeEnum.IL2CPP_TYPE_I:
- return moduleDefinition.ImportReference(typeof(IntPtr));
+ return moduleDefinition.ImportReference(typeSystem.IntPtr);
case Il2CppTypeEnum.IL2CPP_TYPE_U:
- return moduleDefinition.ImportReference(typeof(UIntPtr));
+ return moduleDefinition.ImportReference(typeSystem.UIntPtr);
case Il2CppTypeEnum.IL2CPP_TYPE_I8:
- return moduleDefinition.ImportReference(typeof(long));
+ return moduleDefinition.ImportReference(typeSystem.Int64);
case Il2CppTypeEnum.IL2CPP_TYPE_U8:
- return moduleDefinition.ImportReference(typeof(ulong));
+ return moduleDefinition.ImportReference(typeSystem.UInt64);
case Il2CppTypeEnum.IL2CPP_TYPE_R4:
- return moduleDefinition.ImportReference(typeof(float));
+ return moduleDefinition.ImportReference(typeSystem.Single);
case Il2CppTypeEnum.IL2CPP_TYPE_R8:
- return moduleDefinition.ImportReference(typeof(double));
+ return moduleDefinition.ImportReference(typeSystem.Double);
case Il2CppTypeEnum.IL2CPP_TYPE_STRING:
- return moduleDefinition.ImportReference(typeof(string));
+ return moduleDefinition.ImportReference(typeSystem.String);
case Il2CppTypeEnum.IL2CPP_TYPE_TYPEDBYREF:
- return moduleDefinition.ImportReference(typeof(TypedReference));
+ return moduleDefinition.ImportReference(typeSystem.TypedReference);
case Il2CppTypeEnum.IL2CPP_TYPE_CLASS:
case Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE:
{
diff --git a/Il2CppDumper/Utils/Il2CppDummyDll.cs b/Il2CppDumper/Utils/Il2CppDummyDll.cs
deleted file mode 100644
index a349a5a2..00000000
--- a/Il2CppDumper/Utils/Il2CppDummyDll.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Mono.Cecil;
-using Mono.Cecil.Cil;
-using System;
-using System.Reflection;
-using FieldAttributes = Mono.Cecil.FieldAttributes;
-using MethodAttributes = Mono.Cecil.MethodAttributes;
-using TypeAttributes = Mono.Cecil.TypeAttributes;
-
-namespace Il2CppDumper
-{
- internal static class Il2CppDummyDll
- {
- private static Type attributeType;
- private static ConstructorInfo attributeConstructor;
-
- static Il2CppDummyDll()
- {
- attributeType = typeof(Attribute);
- attributeConstructor = attributeType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0];
- }
-
- public static AssemblyDefinition Create()
- {
- var assemblyName = new AssemblyNameDefinition("Il2CppDummyDll", new Version("3.7.1.6"));
- var assemblyDefinition = AssemblyDefinition.CreateAssembly(assemblyName, "Il2CppDummyDll.dll", ModuleKind.Dll);
- var stringTypeReference = assemblyDefinition.MainModule.TypeSystem.String;
- var attributeTypeReference = assemblyDefinition.MainModule.ImportReference(attributeType);
- var types = assemblyDefinition.MainModule.Types;
- var namespaceName = "Il2CppDummyDll";
- var addressAttribute = new TypeDefinition(namespaceName, "AddressAttribute", (TypeAttributes)0x100001, attributeTypeReference);
- addressAttribute.Fields.Add(new FieldDefinition("RVA", FieldAttributes.Public, stringTypeReference));
- addressAttribute.Fields.Add(new FieldDefinition("Offset", FieldAttributes.Public, stringTypeReference));
- addressAttribute.Fields.Add(new FieldDefinition("VA", FieldAttributes.Public, stringTypeReference));
- addressAttribute.Fields.Add(new FieldDefinition("Slot", FieldAttributes.Public, stringTypeReference));
- types.Add(addressAttribute);
- CreateDefaultConstructor(addressAttribute);
- var fieldOffsetAttribute = new TypeDefinition(namespaceName, "FieldOffsetAttribute", (TypeAttributes)0x100001, attributeTypeReference);
- fieldOffsetAttribute.Fields.Add(new FieldDefinition("Offset", FieldAttributes.Public, stringTypeReference));
- types.Add(fieldOffsetAttribute);
- CreateDefaultConstructor(fieldOffsetAttribute);
- var attributeAttribute = new TypeDefinition(namespaceName, "AttributeAttribute", (TypeAttributes)0x100001, attributeTypeReference);
- attributeAttribute.Fields.Add(new FieldDefinition("Name", FieldAttributes.Public, stringTypeReference));
- attributeAttribute.Fields.Add(new FieldDefinition("RVA", FieldAttributes.Public, stringTypeReference));
- attributeAttribute.Fields.Add(new FieldDefinition("Offset", FieldAttributes.Public, stringTypeReference));
- types.Add(attributeAttribute);
- CreateDefaultConstructor(attributeAttribute);
- var metadataOffsetAttribute = new TypeDefinition(namespaceName, "MetadataOffsetAttribute", (TypeAttributes)0x100001, attributeTypeReference);
- metadataOffsetAttribute.Fields.Add(new FieldDefinition("Offset", FieldAttributes.Public, stringTypeReference));
- types.Add(metadataOffsetAttribute);
- CreateDefaultConstructor(metadataOffsetAttribute);
- var tokenAttribute = new TypeDefinition(namespaceName, "TokenAttribute", (TypeAttributes)0x100001, attributeTypeReference);
- tokenAttribute.Fields.Add(new FieldDefinition("Token", FieldAttributes.Public, stringTypeReference));
- types.Add(tokenAttribute);
- CreateDefaultConstructor(tokenAttribute);
- return assemblyDefinition;
- }
-
- private static void CreateDefaultConstructor(TypeDefinition typeDefinition)
- {
- var module = typeDefinition.Module;
- var defaultConstructor = new MethodDefinition(".ctor",
- MethodAttributes.Public | MethodAttributes.HideBySig |
- MethodAttributes.SpecialName | MethodAttributes.RTSpecialName,
- module.ImportReference(typeof(void)));
- var processor = defaultConstructor.Body.GetILProcessor();
- processor.Emit(OpCodes.Ldarg_0);
- processor.Emit(OpCodes.Call, module.ImportReference(attributeConstructor));
- processor.Emit(OpCodes.Ret);
- typeDefinition.Methods.Add(defaultConstructor);
- }
- }
-}