DummyDll添加到Config里

This commit is contained in:
Perfare 2018-01-08 04:49:14 +08:00
parent 633f76140f
commit 8224601928
3 changed files with 36 additions and 33 deletions

View file

@ -7,12 +7,13 @@ namespace Il2CppDumper
{ {
class Config class Config
{ {
public bool dumpmethod = true; public bool DumpMethod = true;
public bool dumpfield = true; public bool DumpField = true;
public bool dumpproperty = false; public bool DumpProperty = false;
public bool dumpattribute = false; public bool DumpAttribute = false;
public bool dumpfieldoffset = true; public bool DumpFieldOffset = true;
public bool forceil2cppversion = false; public bool DummyDll = true;
public int forceversion = 16; public bool ForceIl2CppVersion = false;
public int ForceVersion = 16;
} }
} }

View file

@ -73,7 +73,7 @@ namespace Il2CppDumper
} }
Console.WriteLine(); Console.WriteLine();
key = Console.ReadKey(true); key = Console.ReadKey(true);
var version = config.forceil2cppversion ? config.forceversion : metadata.version; var version = config.ForceIl2CppVersion ? config.ForceVersion : metadata.version;
switch (key.KeyChar) switch (key.KeyChar)
{ {
case '2': case '2':
@ -172,7 +172,7 @@ namespace Il2CppDumper
} }
writer.Write($"\n// Namespace: {metadata.GetStringFromIndex(typeDef.namespaceIndex)}\n"); writer.Write($"\n// Namespace: {metadata.GetStringFromIndex(typeDef.namespaceIndex)}\n");
writer.Write(GetCustomAttribute(typeDef.customAttributeIndex)); writer.Write(GetCustomAttribute(typeDef.customAttributeIndex));
if (config.dumpattribute && (typeDef.flags & TYPE_ATTRIBUTE_SERIALIZABLE) != 0) if (config.DumpAttribute && (typeDef.flags & TYPE_ATTRIBUTE_SERIALIZABLE) != 0)
writer.Write("[Serializable]\n"); writer.Write("[Serializable]\n");
var visibility = typeDef.flags & TYPE_ATTRIBUTE_VISIBILITY_MASK; var visibility = typeDef.flags & TYPE_ATTRIBUTE_VISIBILITY_MASK;
switch (visibility) switch (visibility)
@ -215,7 +215,7 @@ namespace Il2CppDumper
writer.Write($" : {string.Join(", ", extends)}"); writer.Write($" : {string.Join(", ", extends)}");
writer.Write($" // TypeDefIndex: {idx}\n{{\n"); writer.Write($" // TypeDefIndex: {idx}\n{{\n");
//dump field //dump field
if (config.dumpfield && typeDef.field_count > 0) if (config.DumpField && typeDef.field_count > 0)
{ {
writer.Write("\t// Fields\n"); writer.Write("\t// Fields\n");
var fieldEnd = typeDef.fieldStart + typeDef.field_count; var fieldEnd = typeDef.fieldStart + typeDef.field_count;
@ -321,7 +321,7 @@ namespace Il2CppDumper
writer.Write($" = {multi}"); writer.Write($" = {multi}");
} }
} }
if (config.dumpfieldoffset) if (config.DumpFieldOffset)
writer.Write("; // 0x{0:X}\n", il2cpp.GetFieldOffsetFromIndex(idx, i - typeDef.fieldStart, i)); writer.Write("; // 0x{0:X}\n", il2cpp.GetFieldOffsetFromIndex(idx, i - typeDef.fieldStart, i));
else else
writer.Write(";\n"); writer.Write(";\n");
@ -329,7 +329,7 @@ namespace Il2CppDumper
writer.Write("\n"); writer.Write("\n");
} }
//dump property //dump property
if (config.dumpproperty && typeDef.property_count > 0) if (config.DumpProperty && typeDef.property_count > 0)
{ {
writer.Write("\t// Properties\n"); writer.Write("\t// Properties\n");
var propertyEnd = typeDef.propertyStart + typeDef.property_count; var propertyEnd = typeDef.propertyStart + typeDef.property_count;
@ -363,7 +363,7 @@ namespace Il2CppDumper
writer.Write("\n"); writer.Write("\n");
} }
//dump method //dump method
if (config.dumpmethod && typeDef.method_count > 0) if (config.DumpMethod && typeDef.method_count > 0)
{ {
writer.Write("\t// Methods\n"); writer.Write("\t// Methods\n");
var methodEnd = typeDef.methodStart + typeDef.method_count; var methodEnd = typeDef.methodStart + typeDef.method_count;
@ -436,20 +436,21 @@ namespace Il2CppDumper
scriptwriter.Close(); scriptwriter.Close();
Console.WriteLine("Done !"); Console.WriteLine("Done !");
Console.WriteLine("Create DummyDll..."); Console.WriteLine("Create DummyDll...");
//DummyDll if (config.DummyDll)
if (Directory.Exists("DummyDll"))
Directory.Delete("DummyDll", true);
Directory.CreateDirectory("DummyDll");
Directory.SetCurrentDirectory("DummyDll");
var dummy = new DummyAssemblyCreator(metadata, il2cpp);
foreach (var assembly in dummy.Assemblies)
{ {
var stream = new MemoryStream(); if (Directory.Exists("DummyDll"))
assembly.Write(stream); Directory.Delete("DummyDll", true);
File.WriteAllBytes(assembly.MainModule.Name, stream.ToArray()); Directory.CreateDirectory("DummyDll");
Directory.SetCurrentDirectory("DummyDll");
var dummy = new DummyAssemblyCreator(metadata, il2cpp);
foreach (var assembly in dummy.Assemblies)
{
var stream = new MemoryStream();
assembly.Write(stream);
File.WriteAllBytes(assembly.MainModule.Name, stream.ToArray());
}
Console.WriteLine("Done !");
} }
Console.WriteLine("Done !");
//
break; break;
} }
} }
@ -520,7 +521,7 @@ namespace Il2CppDumper
private static string GetCustomAttribute(int index, string padding = "") private static string GetCustomAttribute(int index, string padding = "")
{ {
if (!config.dumpattribute || il2cpp.version < 21) if (!config.DumpAttribute || il2cpp.version < 21)
return ""; return "";
var attributeTypeRange = metadata.attributesInfos[index]; var attributeTypeRange = metadata.attributesInfos[index];
var sb = new StringBuilder(); var sb = new StringBuilder();

View file

@ -1,9 +1,10 @@
{ {
"dumpmethod": true, "DumpMethod": true,
"dumpfield": true, "DumpField": true,
"dumpproperty": false, "DumpProperty": false,
"dumpattribute": false, "DumpAttribute": false,
"dumpfieldoffset": true, "DumpFieldOffset": true,
"forceil2cppversion": false, "DummyDll": true,
"forceversion": 16 "ForceIl2CppVersion": false,
"ForceVersion": 16
} }