Il2CppDumper: More robust command-line processing
This commit is contained in:
@@ -15,4 +15,8 @@
|
|||||||
<DotNetCliToolReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="2.0.0" />
|
<DotNetCliToolReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="2.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
@@ -17,24 +19,26 @@ namespace Il2CppInspector
|
|||||||
Console.WriteLine("(c) 2017-2019 Katy Coe - www.djkaty.com");
|
Console.WriteLine("(c) 2017-2019 Katy Coe - www.djkaty.com");
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
|
|
||||||
// Command-line usage: dotnet run [<binary-file> [<metadata-file> [<output-file>]]]
|
// Command-line usage: dotnet run [--bin=<binary-file>] [--metadata=<metadata-file>] [--cs-out=<output-file>] [--py-out=<output-file>] [--exclude-namespaces=<ns1,n2,...>|none]
|
||||||
// Defaults to libil2cpp.so or GameAssembly.dll if binary file not specified
|
// Defaults to libil2cpp.so or GameAssembly.dll if binary file not specified
|
||||||
string imageFile = "libil2cpp.so";
|
IConfiguration config = new ConfigurationBuilder().AddCommandLine(args).Build();
|
||||||
string metaFile = "global-metadata.dat";
|
|
||||||
string outFile = "types.cs";
|
|
||||||
|
|
||||||
if (args.Length == 0)
|
string imageFile = config["bin"] ?? "libil2cpp.so";
|
||||||
if (!File.Exists(imageFile))
|
string metaFile = config["metadata"] ?? "global-metadata.dat";
|
||||||
imageFile = "GameAssembly.dll";
|
string outCsFile = config["cs-out"] ?? "types.cs";
|
||||||
|
string outPythonFile = config["py-out"] ?? "ida.py";
|
||||||
|
|
||||||
if (args.Length >= 1)
|
// Exclusions
|
||||||
imageFile = args[0];
|
var excludedNamespaces = config["exclude-namespaces"]?.Split(',').ToList() ??
|
||||||
|
new List<string> {
|
||||||
|
"System",
|
||||||
|
"UnityEngine",
|
||||||
|
"Mono",
|
||||||
|
"Microsoft.Win32"
|
||||||
|
};
|
||||||
|
|
||||||
if (args.Length >= 2)
|
if (excludedNamespaces.Count == 1 && excludedNamespaces[0].ToLower() == "none")
|
||||||
metaFile = args[1];
|
excludedNamespaces = null;
|
||||||
|
|
||||||
if (args.Length >= 3)
|
|
||||||
outFile = args[2];
|
|
||||||
|
|
||||||
// Check files
|
// Check files
|
||||||
if (!File.Exists(imageFile)) {
|
if (!File.Exists(imageFile)) {
|
||||||
@@ -51,14 +55,6 @@ namespace Il2CppInspector
|
|||||||
if (il2cppInspectors == null)
|
if (il2cppInspectors == null)
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
// Exclusions
|
|
||||||
var excludedNamespaces = new List<string> {
|
|
||||||
"System",
|
|
||||||
"UnityEngine",
|
|
||||||
"Mono",
|
|
||||||
"Microsoft.Win32"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Write output file
|
// Write output file
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var il2cpp in il2cppInspectors) {
|
foreach (var il2cpp in il2cppInspectors) {
|
||||||
@@ -66,7 +62,7 @@ namespace Il2CppInspector
|
|||||||
var model = new Il2CppModel(il2cpp);
|
var model = new Il2CppModel(il2cpp);
|
||||||
|
|
||||||
// C# signatures output
|
// C# signatures output
|
||||||
new Il2CppCSharpDumper(model) {ExcludedNamespaces = excludedNamespaces}.WriteFile(outFile + (i++ > 0 ? "-" + (i-1) : ""));
|
new Il2CppCSharpDumper(model) {ExcludedNamespaces = excludedNamespaces}.WriteFile(outCsFile + (i++ > 0 ? "-" + (i-1) : ""));
|
||||||
|
|
||||||
// IDA Python script output
|
// IDA Python script output
|
||||||
// TODO: IDA Python script output
|
// TODO: IDA Python script output
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -31,18 +31,30 @@ The output binary is placed in `Il2CppInspector/Il2CppDumper/bin/Release/netcore
|
|||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
Il2CppDumper [<binary-file> [<metadata-file> [<output-file>]]]
|
Il2CppDumper [--bin=<binary-file>] [--metadata=<metadata-file>] [--cs-out=<output-file>] [--exclude-namespaces=<ns1,ns2,...>|none]
|
||||||
```
|
```
|
||||||
|
|
||||||
Defaults if not specified:
|
Defaults if not specified:
|
||||||
|
|
||||||
- _binary-file_ - searches for `libil2cpp.so` and `GameAssembly.dll`
|
- _binary-file_ - searches for `libil2cpp.so`
|
||||||
- _metadata-file_ - `global-metadata.dat`
|
- _metadata-file_ - `global-metadata.dat`
|
||||||
- _output-file_ - `types.cs`
|
- _output-file_ - `types.cs`
|
||||||
|
|
||||||
|
To exclude types from certain namespaces from being generated in the C<> source file output, provide a comma-separated list of case-sensitive namespaces in `--exclude-namespaces`. The following namespaces will be excluded if no argument is specified:
|
||||||
|
|
||||||
|
```
|
||||||
|
System
|
||||||
|
Mono
|
||||||
|
UnityEngine
|
||||||
|
Microsoft.Win32
|
||||||
|
```
|
||||||
|
|
||||||
|
Providing an argument to `--exclude-namespaces` will override the default list. To output all namespaces, use `--exclude-namespaces=none`.
|
||||||
|
|
||||||
|
|
||||||
File format and architecture are automatically detected.
|
File format and architecture are automatically detected.
|
||||||
|
|
||||||
For Apple Universal Binaries, multiple output files will be generated, with each filename suffixed by the index of the image in the Universal Binary. Unsupported images will be skipped.
|
For Apple Universal Binaries, multiple output files will be generated, with each filename besides the first suffixed by the index of the image in the Universal Binary. Unsupported images will be skipped.
|
||||||
|
|
||||||
### Running tests
|
### Running tests
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user