mirror of
https://github.com/AdmiralCurtiss/WfcPatcher.git
synced 2026-09-08 19:26:00 -05:00
Attempt to patch ARM9 secure area if all attempts to match the filesize fail.
This commit is contained in:
14
Program.cs
14
Program.cs
@@ -122,6 +122,20 @@ namespace WfcPatcher {
|
||||
newCompressedSize = (uint)data.Length;
|
||||
}
|
||||
|
||||
if ( newCompressedSize != len ) {
|
||||
// new ARM is (still) different, attempt to find the metadata in the ARM9 secure area and replace that
|
||||
byte[] newCmpSizeBytes = BitConverter.GetBytes( newCompressedSize );
|
||||
for ( int i = 0; i < 0x4000; i += 4 ) {
|
||||
uint maybeSize = BitConverter.ToUInt32( data, i );
|
||||
if ( maybeSize == len + 0x02000000 ) {
|
||||
data[i + 0] = newCmpSizeBytes[0];
|
||||
data[i + 1] = newCmpSizeBytes[1];
|
||||
data[i + 2] = newCmpSizeBytes[2];
|
||||
data[i + 3] = (byte)( newCmpSizeBytes[3] + 0x02 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
uint newDecompressedSize = (uint)decData.Length;
|
||||
uint newAdditionalCompressedSize = newDecompressedSize - newCompressedSize;
|
||||
|
||||
Reference in New Issue
Block a user