改善逻辑

This commit is contained in:
Perfare 2020-02-26 02:00:08 +08:00
parent 14531841d3
commit 411c6897ed
2 changed files with 17 additions and 40 deletions

View file

@ -176,7 +176,7 @@ namespace Il2CppDumper
public override bool PlusSearch(int methodCount, int typeDefinitionsCount) public override bool PlusSearch(int methodCount, int typeDefinitionsCount)
{ {
var data = sections.Where(x => x.sectname == "__const").ToArray(); var data = sections.Where(x => x.sectname == "__const" || x.sectname == "__cstring" || x.sectname == "__data").ToArray();
var code = sections.Where(x => x.flags == 0x80000400).ToArray(); var code = sections.Where(x => x.flags == 0x80000400).ToArray();
var bss = sections.Where(x => x.flags == 1u).ToArray(); var bss = sections.Where(x => x.flags == 1u).ToArray();

View file

@ -17,8 +17,6 @@ namespace Il2CppDumper
config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Application.StartupPath + Path.DirectorySeparatorChar + @"config.json")); config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Application.StartupPath + Path.DirectorySeparatorChar + @"config.json"));
byte[] il2cppBytes = null; byte[] il2cppBytes = null;
byte[] metadataBytes = null; byte[] metadataBytes = null;
string stringVersion = null;
int mode = 0;
if (args.Length == 1) if (args.Length == 1)
{ {
@ -28,15 +26,11 @@ namespace Il2CppDumper
return; return;
} }
} }
if (args.Length > 3) if (args.Length > 2)
{ {
ShowHelp(); ShowHelp();
return; return;
} }
if (args.Length > 2)
{
mode = int.Parse(args[2]);
}
if (args.Length > 1) if (args.Length > 1)
{ {
var file1 = File.ReadAllBytes(args[0]); var file1 = File.ReadAllBytes(args[0]);
@ -76,7 +70,7 @@ namespace Il2CppDumper
} }
try try
{ {
if (Init(il2cppBytes, metadataBytes, stringVersion, mode, out var metadata, out var il2Cpp)) if (Init(il2cppBytes, metadataBytes, out var metadata, out var il2Cpp))
{ {
Dump(metadata, il2Cpp); Dump(metadata, il2Cpp);
} }
@ -95,7 +89,7 @@ namespace Il2CppDumper
Application.ExitThread(); Application.ExitThread();
} }
private static bool Init(byte[] il2cppBytes, byte[] metadataBytes, string stringVersion, int mode, out Metadata metadata, out Il2Cpp il2Cpp) private static bool Init(byte[] il2cppBytes, byte[] metadataBytes, out Metadata metadata, out Il2Cpp il2Cpp)
{ {
var sanity = BitConverter.ToUInt32(metadataBytes, 0); var sanity = BitConverter.ToUInt32(metadataBytes, 0);
if (sanity != 0xFAB11BAF) if (sanity != 0xFAB11BAF)
@ -177,17 +171,23 @@ namespace Il2CppDumper
il2Cpp = new Macho64(il2CppMemory, version, metadata.maxMetadataUsages); il2Cpp = new Macho64(il2CppMemory, version, metadata.maxMetadataUsages);
else else
il2Cpp = new Macho(il2CppMemory, version, metadata.maxMetadataUsages); il2Cpp = new Macho(il2CppMemory, version, metadata.maxMetadataUsages);
Console.WriteLine($"Il2Cpp Version: {il2Cpp.Version}");
if (mode == 0) Console.WriteLine("Searching...");
{
Console.WriteLine("Select Mode: 1.Manual 2.Auto");
var modeKey = Console.ReadKey(true);
mode = int.Parse(modeKey.KeyChar.ToString());
}
try try
{ {
if (mode == 1) var flag = il2Cpp.PlusSearch(metadata.methodDefs.Count(x => x.methodIndex >= 0), metadata.typeDefs.Length);
if (!flag)
{ {
flag = il2Cpp.Search();
}
if (!flag)
{
flag = il2Cpp.SymbolSearch();
}
if (!flag)
{
Console.WriteLine("ERROR: Can't use auto mode to process file, try manual mode.");
Console.Write("Input CodeRegistration: "); Console.Write("Input CodeRegistration: ");
var codeRegistration = Convert.ToUInt64(Console.ReadLine(), 16); var codeRegistration = Convert.ToUInt64(Console.ReadLine(), 16);
Console.Write("Input MetadataRegistration: "); Console.Write("Input MetadataRegistration: ");
@ -195,29 +195,6 @@ namespace Il2CppDumper
il2Cpp.Init(codeRegistration, metadataRegistration); il2Cpp.Init(codeRegistration, metadataRegistration);
return true; return true;
} }
else if (mode == 2)
{
Console.WriteLine("Searching...");
var flag = il2Cpp.PlusSearch(metadata.methodDefs.Count(x => x.methodIndex >= 0), metadata.typeDefs.Length);
if (!flag)
{
flag = il2Cpp.Search();
}
if (!flag)
{
flag = il2Cpp.SymbolSearch();
}
if (!flag)
{
Console.WriteLine("ERROR: Can't use auto mode to process file, try manual mode.");
return false;
}
}
else
{
Console.WriteLine("ERROR: You have to choose a mode.");
return false;
}
} }
catch (Exception e) catch (Exception e)
{ {