IL2CPP: Write decrypted strings back to metadata
This commit is contained in:
@@ -530,7 +530,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
// Load from a binary stream and metadata stream
|
// Load from a binary stream and metadata stream
|
||||||
// Must be a seekable stream otherwise we catch a System.IO.NotSupportedException
|
// Must be a seekable stream otherwise we catch a System.IO.NotSupportedException
|
||||||
public static List<Il2CppInspector> LoadFromStream(Stream binaryStream, Stream metadataStream, EventHandler<string> statusCallback = null, bool silent = false) {
|
public static List<Il2CppInspector> LoadFromStream(Stream binaryStream, MemoryStream metadataStream, EventHandler<string> statusCallback = null, bool silent = false) {
|
||||||
|
|
||||||
// Silent operation if requested
|
// Silent operation if requested
|
||||||
var stdout = Console.Out;
|
var stdout = Console.Out;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Il2CppInspector
|
|||||||
// Set if something in the metadata has been modified / decrypted
|
// Set if something in the metadata has been modified / decrypted
|
||||||
public bool IsModified { get; } = false;
|
public bool IsModified { get; } = false;
|
||||||
|
|
||||||
public Metadata(Stream stream, EventHandler<string> statusCallback = null) : base(stream)
|
public Metadata(MemoryStream stream, EventHandler<string> statusCallback = null) : base(stream)
|
||||||
{
|
{
|
||||||
// Read magic bytes
|
// Read magic bytes
|
||||||
if (ReadUInt32() != 0xFAB11BAF) {
|
if (ReadUInt32() != 0xFAB11BAF) {
|
||||||
@@ -192,6 +192,15 @@ namespace Il2CppInspector
|
|||||||
var decryptedString = Encoding.GetString(encryptedString.Select(b => (byte) (b ^ xorKey)).ToArray());
|
var decryptedString = Encoding.GetString(encryptedString.Select(b => (byte) (b ^ xorKey)).ToArray());
|
||||||
Strings.Add(offset.current, decryptedString);
|
Strings.Add(offset.current, decryptedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write changes back in case the user wants to save the metadata file
|
||||||
|
using (var sw = new StreamWriter(BaseStream, System.Text.Encoding.UTF8, bufferSize: -1, leaveOpen: true)) {
|
||||||
|
sw.BaseStream.Position = Header.stringOffset;
|
||||||
|
foreach (var str in Strings.OrderBy(s => s.Key))
|
||||||
|
sw.Write(str.Value + "\0");
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Il2CppInspectorGUI
|
|||||||
return await LoadMetadataAsync(stream);
|
return await LoadMetadataAsync(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> LoadMetadataAsync(Stream metadataStream) =>
|
public Task<bool> LoadMetadataAsync(MemoryStream metadataStream) =>
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
try {
|
try {
|
||||||
OnStatusUpdate?.Invoke(this, "Processing metadata");
|
OnStatusUpdate?.Invoke(this, "Processing metadata");
|
||||||
|
|||||||
Reference in New Issue
Block a user