@@ -66,51 +66,51 @@ public override void Decompress(string inputFilePath, string outputFilePath)
6666
6767 /// <summary>
6868 /// Recompresses a zone file back to MW2 FastFile format.
69- /// Preserves the original file's signed/unsigned status .
70- /// Xbox 360 signed files use IWffs100 streaming format.
69+ /// MW2 Xbox 360 uses XBlock format (different from CoD4/WaW IWffs100) .
70+ /// Since XEX is patched to skip RSA, we use unsigned block format for all platforms .
7171 /// </summary>
7272 public override void Recompress ( string ffFilePath , string zoneFilePath , FastFile openedFastFile )
7373 {
74- if ( openedFastFile . IsSigned )
74+ // MW2 Xbox 360 signed files use XBlock format with RSA signatures.
75+ // Unlike CoD4/WaW which use simple IWffs100 streaming, MW2 XBlocks are complex.
76+ // Since XEX is patched, we save as unsigned block format which works on modded consoles.
77+
78+ using var binaryReader = new BinaryReader ( new FileStream ( zoneFilePath , FileMode . Open , FileAccess . Read ) , Encoding . Default ) ;
79+ using var binaryWriter = new BinaryWriter ( new FileStream ( ffFilePath , FileMode . Create , FileAccess . Write ) , Encoding . Default ) ;
80+
81+ // Use unsigned header (IWffu100) - works with patched XEX
82+ binaryWriter . Write ( HeaderBytes ) ;
83+
84+ // Use original version bytes to preserve platform compatibility
85+ int originalVersion = openedFastFile . GameVersion ;
86+ byte [ ] versionBytes = new byte [ 4 ] ;
87+ versionBytes [ 0 ] = ( byte ) ( ( originalVersion >> 24 ) & 0xFF ) ;
88+ versionBytes [ 1 ] = ( byte ) ( ( originalVersion >> 16 ) & 0xFF ) ;
89+ versionBytes [ 2 ] = ( byte ) ( ( originalVersion >> 8 ) & 0xFF ) ;
90+ versionBytes [ 3 ] = ( byte ) ( originalVersion & 0xFF ) ;
91+ binaryWriter . Write ( versionBytes ) ;
92+
93+ // MW2 needs extended header
94+ WriteMinimalExtendedHeader ( binaryWriter ) ;
95+
96+ // Standard 64KB block compression (same format as PS3)
97+ int chunkSize = 65536 ;
98+ while ( binaryReader . BaseStream . Position < binaryReader . BaseStream . Length )
7599 {
76- // Xbox 360 signed files use streaming format - use library method
77- // Build version bytes from original file's version
78- int originalVersion = openedFastFile . GameVersion ;
79- byte [ ] versionBytes = new byte [ 4 ] ;
80- versionBytes [ 0 ] = ( byte ) ( ( originalVersion >> 24 ) & 0xFF ) ;
81- versionBytes [ 1 ] = ( byte ) ( ( originalVersion >> 16 ) & 0xFF ) ;
82- versionBytes [ 2 ] = ( byte ) ( ( originalVersion >> 8 ) & 0xFF ) ;
83- versionBytes [ 3 ] = ( byte ) ( originalVersion & 0xFF ) ;
84-
85- FastFileProcessor . CompressXbox360Signed ( zoneFilePath , ffFilePath , versionBytes , openedFastFile . FfFilePath ) ;
86- }
87- else
88- {
89- // PS3/Xbox 360 unsigned: standard block format with extended header
90- using var binaryReader = new BinaryReader ( new FileStream ( zoneFilePath , FileMode . Open , FileAccess . Read ) , Encoding . Default ) ;
91- using var binaryWriter = new BinaryWriter ( new FileStream ( ffFilePath , FileMode . Create , FileAccess . Write ) , Encoding . Default ) ;
92-
93- // Write header and version value
94- binaryWriter . Write ( HeaderBytes ) ;
95- binaryWriter . Write ( VersionBytes ) ;
96-
97- // MW2 needs a minimal extended header for the game to accept it
98- WriteMinimalExtendedHeader ( binaryWriter ) ;
100+ byte [ ] chunk = binaryReader . ReadBytes ( chunkSize ) ;
101+ byte [ ] compressedChunk = CompressMW2 ( chunk ) ;
99102
100- int chunkSize = 65536 ;
101- while ( binaryReader . BaseStream . Position < binaryReader . BaseStream . Length )
102- {
103- byte [ ] chunk = binaryReader . ReadBytes ( chunkSize ) ;
104- byte [ ] compressedChunk = CompressMW2 ( chunk ) ;
105-
106- int compressedLength = compressedChunk . Length ;
107- byte [ ] lengthBytes = BitConverter . GetBytes ( compressedLength ) ;
108- Array . Reverse ( lengthBytes ) ;
109- binaryWriter . Write ( lengthBytes , 2 , 2 ) ;
103+ int compressedLength = compressedChunk . Length ;
104+ byte [ ] lengthBytes = BitConverter . GetBytes ( compressedLength ) ;
105+ Array . Reverse ( lengthBytes ) ;
106+ binaryWriter . Write ( lengthBytes , 2 , 2 ) ;
110107
111- binaryWriter . Write ( compressedChunk ) ;
112- }
108+ binaryWriter . Write ( compressedChunk ) ;
113109 }
110+
111+ // Write end marker
112+ binaryWriter . Write ( ( byte ) 0x00 ) ;
113+ binaryWriter . Write ( ( byte ) 0x01 ) ;
114114 }
115115
116116 /// <summary>
0 commit comments