Files
Il2CppInspectorRedux/Il2CppDumper/Program.cs

77 lines
2.4 KiB
C#

// Copyright (c) 2017-2019 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
// All rights reserved
using System;
using System.Collections.Generic;
using System.IO;
using Il2CppInspector.Reflection;
namespace Il2CppInspector
{
public class App
{
static void Main(string[] args) {
// Banner
Console.WriteLine("Il2CppDumper");
Console.WriteLine("(c) 2017-2019 Katy Coe - www.djkaty.com");
Console.WriteLine("");
// Command-line usage: dotnet run [<binary-file> [<metadata-file> [<output-file>]]]
// Defaults to libil2cpp.so or GameAssembly.dll if binary file not specified
string imageFile = "libil2cpp.so";
string metaFile = "global-metadata.dat";
string outFile = "types.cs";
if (args.Length == 0)
if (!File.Exists(imageFile))
imageFile = "GameAssembly.dll";
if (args.Length >= 1)
imageFile = args[0];
if (args.Length >= 2)
metaFile = args[1];
if (args.Length >= 3)
outFile = args[2];
// Check files
if (!File.Exists(imageFile)) {
Console.Error.WriteLine($"File {imageFile} does not exist");
Environment.Exit(1);
}
if (!File.Exists(metaFile)) {
Console.Error.WriteLine($"File {metaFile} does not exist");
Environment.Exit(1);
}
// Analyze data
var il2cppInspectors = Il2CppInspector.LoadFromFile(imageFile, metaFile);
if (il2cppInspectors == null)
Environment.Exit(1);
// Exclusions
var excludedNamespaces = new List<string> {
"System",
"UnityEngine",
"Mono",
"Microsoft.Win32"
};
// Write output file
int i = 0;
foreach (var il2cpp in il2cppInspectors) {
// Create model
var model = new Il2CppModel(il2cpp);
// C# signatures output
new Il2CppCSharpDumper(model) {ExcludedNamespaces = excludedNamespaces}.WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : ""));
// IDA Python script output
// TODO: IDA Python script output
}
}
}
}