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