Skip to content
Permalink
Browse files
Attempt to patch ARM9 secure area if all attempts to match the filesi…
…ze fail.
  • Loading branch information
AdmiralCurtiss committed May 30, 2014
1 parent 8cd1e3c commit 49b55ff173b9e2174037ca553549b871e4e2a81a
Showing with 14 additions and 0 deletions.
  1. +14 −0 Program.cs
@@ -122,6 +122,20 @@ class Program {
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;

0 comments on commit 49b55ff

Please sign in to comment.