IL2CPP: Add APIs to save processed metadata and binary to disk
This commit is contained in:
@@ -364,6 +364,8 @@ namespace Il2CppInspector
|
||||
|
||||
xorSection(".text", xorKey, stripeSize);
|
||||
xorSection(".rodata", xorKey, stripeSize);
|
||||
|
||||
IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Il2CppInspector
|
||||
long Length { get; }
|
||||
uint NumImages { get; }
|
||||
string DefaultFilename { get; }
|
||||
bool IsModified { get; }
|
||||
IEnumerable<IFileFormatReader> Images { get; }
|
||||
IFileFormatReader this[uint index] { get; }
|
||||
long Position { get; set; }
|
||||
@@ -125,6 +126,8 @@ namespace Il2CppInspector
|
||||
|
||||
public abstract string DefaultFilename { get; }
|
||||
|
||||
public bool IsModified { get; protected set; } = false;
|
||||
|
||||
public long Length => BaseStream.Length;
|
||||
|
||||
public uint NumImages { get; protected set; } = 1;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -85,7 +86,8 @@ namespace Il2CppInspector
|
||||
private void StatusUpdate(string status) => OnStatusUpdate?.Invoke(this, status);
|
||||
|
||||
// Set if something in the binary has been modified / decrypted
|
||||
public bool IsModified { get; private set; } = false;
|
||||
private bool isModified = false;
|
||||
public bool IsModified => Image.IsModified || isModified;
|
||||
|
||||
protected Il2CppBinary(IFileFormatReader stream, EventHandler<string> statusCallback = null) {
|
||||
Image = stream;
|
||||
@@ -130,6 +132,14 @@ namespace Il2CppInspector
|
||||
return inst.Initialize(metadata) ? inst : null;
|
||||
}
|
||||
|
||||
// Save binary to file, overwriting if necessary
|
||||
// Save metadata to file, overwriting if necessary
|
||||
public void SaveToFile(string pathname) {
|
||||
Image.Position = 0;
|
||||
using (var outFile = new FileStream(pathname, FileMode.Create, FileAccess.Write))
|
||||
Image.Stream.BaseStream.CopyTo(outFile);
|
||||
}
|
||||
|
||||
// Initialize binary without a global-metadata.dat available
|
||||
public bool Initialize(double metadataVersion, EventHandler<string> statusCallback = null) {
|
||||
Image.Version = metadataVersion;
|
||||
|
||||
@@ -594,6 +594,10 @@ namespace Il2CppInspector
|
||||
Console.SetOut(stdout);
|
||||
return processors;
|
||||
}
|
||||
|
||||
// Savers
|
||||
public void SaveMetadataToFile(string pathname) => Metadata.SaveToFile(pathname);
|
||||
public void SaveBinaryToFile(string pathname) => Binary.SaveToFile(pathname);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +203,13 @@ namespace Il2CppInspector
|
||||
StringLiterals[i] = ReadFixedLengthString(Header.stringLiteralDataOffset + stringLiteralList[i].dataIndex, stringLiteralList[i].length);
|
||||
}
|
||||
|
||||
// Save metadata to file, overwriting if necessary
|
||||
public void SaveToFile(string pathname) {
|
||||
Position = 0;
|
||||
using (var outFile = new FileStream(pathname, FileMode.Create, FileAccess.Write))
|
||||
BaseStream.CopyTo(outFile);
|
||||
}
|
||||
|
||||
internal int Sizeof(Type type) => Sizeof(type, Version);
|
||||
|
||||
public static int Sizeof(Type type, double metadataVersion, int longSizeBytes = 8) {
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace Il2CppInspector
|
||||
CodeRegistration.interopDataCount = 0;
|
||||
|
||||
// TODO: Write changes to stream
|
||||
IsModified = true;
|
||||
isModified = true;
|
||||
|
||||
// Things we need from Il2CppMetadataRegistration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user