Skip to content

Commit

Permalink
Fix file handle and performance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bbepis committed Sep 18, 2020
1 parent 6810a8d commit 585cc52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Il2CppDumper/Il2CppDumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static bool PerformDump(string gameAssemblyPath, string metadataDatPath,
reportProgressAction("Dumping...");
var executor = new Il2CppExecutor(metadata, il2Cpp);
var decompiler = new Il2CppDecompiler(executor);
decompiler.Decompile(config, outputDirectoryPath, reportProgressAction);
reportProgressAction("Done!");
if (config.GenerateScript)
{
reportProgressAction("Generate script...");
decompiler.Decompile(config, outputDirectoryPath, reportProgressAction);
reportProgressAction("Generate script...");
var scriptGenerator = new ScriptGenerator(executor);
scriptGenerator.WriteScript(outputDirectoryPath);
reportProgressAction("Done!");
Expand Down
17 changes: 10 additions & 7 deletions Il2CppDumper/Outputs/DummyAssemblyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ public static class DummyAssemblyExporter
{
public static void Export(Il2CppExecutor il2CppExecutor, string outputDir)
{
Directory.SetCurrentDirectory(outputDir);
if (Directory.Exists("DummyDll"))
Directory.Delete("DummyDll", true);
Directory.CreateDirectory("DummyDll");
Directory.SetCurrentDirectory("DummyDll");
string dummyDllPath = Path.Combine(outputDir, "DummyDll");

if (Directory.Exists(dummyDllPath))
Directory.Delete(dummyDllPath, true);
Directory.CreateDirectory(dummyDllPath);

var dummy = new DummyAssemblyGenerator(il2CppExecutor);
foreach (var assembly in dummy.Assemblies)
{
using (var stream = new MemoryStream())
string path = Path.Combine(dummyDllPath, assembly.MainModule.Name);

using (var stream = new FileStream(path, FileMode.Create))
{
assembly.Write(stream);
File.WriteAllBytes(assembly.MainModule.Name, stream.ToArray());
assembly.Dispose();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Il2CppDumper/Outputs/Il2CppDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Il2CppDecompiler(Il2CppExecutor il2CppExecutor)

public void Decompile(Config config, string outputDir, Action<string> reportProgressAction)
{
var writer = new StreamWriter(new FileStream(outputDir + "dump.cs", FileMode.Create), new UTF8Encoding(false));
var writer = new StreamWriter(new FileStream(Path.Combine(outputDir, "dump.cs"), FileMode.Create), new UTF8Encoding(false), 4096, false);
//dump image
for (var imageIndex = 0; imageIndex < metadata.imageDefs.Length; imageIndex++)
{
Expand Down

0 comments on commit 585cc52

Please sign in to comment.