@@ -21,6 +21,7 @@ public partial class Form1 : Form
2121 internal DataGridView dataGridView1 ;
2222 internal ColorfulTreeView listView1 ;
2323 internal MenuStrip menuStrip1 ;
24+ internal AC7Decrypt ac7decrypt ;
2425
2526 public TableHandler tableEditor ;
2627 public ByteViewer byteView1 ;
@@ -134,6 +135,8 @@ public Form1()
134135 isDropDownOpened [ entry ] = false ;
135136 } ;
136137 }
138+
139+ ac7decrypt = new AC7Decrypt ( ) ;
137140 }
138141
139142 private static Dictionary < ToolStripItem , bool > isDropDownOpened = new Dictionary < ToolStripItem , bool > ( ) ;
@@ -305,12 +308,25 @@ private void GetUnknownProperties(PropertyData dat)
305308 }
306309 }
307310
311+ public uint GetFileSignature ( string path )
312+ {
313+ byte [ ] buffer = new byte [ 4 ] ;
314+ using ( FileStream fs = new FileStream ( path , FileMode . Open , FileAccess . Read ) )
315+ {
316+ var bytes_read = fs . Read ( buffer , 0 , buffer . Length ) ;
317+ fs . Close ( ) ;
318+ }
319+ return BitConverter . ToUInt32 ( buffer , 0 ) ;
320+ }
321+
308322 public void LoadFileAt ( string filePath )
309323 {
310324 dataGridView1 . Visible = true ;
311325 byteView1 . Visible = false ;
312326 jsonView . Visible = false ;
313327
328+ bool didACE7Decrypt = false ;
329+
314330 try
315331 {
316332 UAsset targetAsset ;
@@ -330,6 +346,13 @@ public void LoadFileAt(string filePath)
330346 default :
331347 MapStructTypeOverrideForm . LoadFromConfig ( ) ;
332348
349+ uint sig = GetFileSignature ( filePath ) ;
350+ if ( sig == UAsset . ACE7_MAGIC )
351+ {
352+ // Decrypt file in-situ
353+ ac7decrypt . Decrypt ( filePath , filePath ) ;
354+ didACE7Decrypt = true ;
355+ }
333356 targetAsset = new UAsset ( ParsingVersion ) ;
334357 targetAsset . FilePath = filePath ;
335358 if ( MapStructTypeOverrideForm . MapStructTypeOverride != null ) targetAsset . MapStructTypeOverride = MapStructTypeOverrideForm . MapStructTypeOverride ;
@@ -376,6 +399,11 @@ public void LoadFileAt(string filePath)
376399
377400 bool failedToMaintainBinaryEquality = ! string . IsNullOrEmpty ( tableEditor . asset . FilePath ) && ! tableEditor . asset . VerifyBinaryEquality ( ) ;
378401
402+ if ( didACE7Decrypt )
403+ {
404+ MessageBox . Show ( "This file uses Ace Combat 7 encryption and was decrypted in-situ." , "Notice" ) ;
405+ }
406+
379407 if ( failedCategoryCount > 0 )
380408 {
381409 MessageBox . Show ( "Failed to parse " + failedCategoryCount + " exports!" , "Notice" ) ;
0 commit comments