HMX Forge (RB4/DCS/Amp16/FME) save game decryptor/encryptor

amp2016 ps3 <-> ps4 save conversion

Changed files
+122
+111
AmpConversion.cs
··· 1 + using davesave.Saves; 2 + using davesave.Saves.Amp2016; 3 + using LibForge.Util; 4 + using System; 5 + using System.Collections.Generic; 6 + using System.Linq; 7 + using System.Text; 8 + using System.Threading.Tasks; 9 + 10 + namespace davesave 11 + { 12 + internal class AmpConversion 13 + { 14 + public static void ConvertAmpSavePS3toPS4(Stream inStream, Stream outStream, bool encrypt = true) 15 + { 16 + Console.WriteLine("Converting PS3 Amplitude save to PS4..."); 17 + // start the stream we're reading from 18 + Stream realIn = inStream; 19 + EncryptedReadRevisionStream? ers = null; 20 + if (encrypt) 21 + { 22 + Console.WriteLine("(encryption enabled)"); 23 + ers = new EncryptedReadRevisionStream(inStream, true); 24 + realIn = ers; 25 + } 26 + // load the profile in from the stream 27 + AmpProfile profile = AmpProfile.ReadFromStream(realIn, true); 28 + if (ers != null) ers.FinishReading(); // we've finished reading, do this as a sanity check 29 + // change some values to properly convert 30 + profile.mVersion = 0x19; 31 + // start an output stream 32 + Stream realOut = outStream; 33 + EncryptedWriteRevisionStream? ews = null; 34 + if (encrypt) 35 + { 36 + ews = new EncryptedWriteRevisionStream(outStream, 0x69696969, false); 37 + realOut = ews; 38 + } 39 + // write our profile to it 40 + profile.WriteToStream(realOut, false); 41 + if (ews != null) ews.FinishWriting(); 42 + // conversion successful? 43 + Console.WriteLine("Conversion completed!"); 44 + } 45 + 46 + public static void ConvertAmpSavePS4toPS3(Stream inStream, Stream outStream, bool encrypt = true) 47 + { 48 + Console.WriteLine("Converting PS4 Amplitude save to PS3..."); 49 + // start the stream we're reading from 50 + Stream realIn = inStream; 51 + EncryptedReadRevisionStream? ers = null; 52 + if (encrypt) 53 + { 54 + Console.WriteLine("(encryption enabled)"); 55 + ers = new EncryptedReadRevisionStream(inStream, false); 56 + realIn = ers; 57 + } 58 + // load the profile in from the stream 59 + AmpProfile profile = AmpProfile.ReadFromStream(realIn, false); 60 + if (ers != null) ers.FinishReading(); // we've finished reading, do this as a sanity check 61 + // change some values to properly convert 62 + profile.mVersion = 0x1A; 63 + profile.mCampaignData.mUnknownPS3Byte = 0x1; 64 + // start an output stream 65 + Stream realOut = outStream; 66 + EncryptedWriteRevisionStream? ews = null; 67 + if (encrypt) 68 + { 69 + ews = new EncryptedWriteRevisionStream(outStream, 0x69696969, true); 70 + realOut = ews; 71 + } 72 + // write our profile to it 73 + profile.WriteToStream(realOut, true); 74 + if (ews != null) ews.FinishWriting(); 75 + // conversion successful? 76 + Console.WriteLine("Conversion completed!"); 77 + } 78 + 79 + public static async Task ConvertAmpSave(string input, string output) 80 + { 81 + FileStream inStream = File.OpenRead(input); 82 + SaveDetection.SaveType type = await SaveDetection.DetectSaveTypeAsync(inStream); 83 + 84 + bool encrypted = false; 85 + bool ps3tops4 = false; 86 + 87 + if (type == SaveDetection.SaveType.AmpPS4 || type == SaveDetection.SaveType.AmpPS4_Decrypted) 88 + { 89 + ps3tops4 = false; 90 + encrypted = (type == SaveDetection.SaveType.AmpPS4); 91 + } else if (type == SaveDetection.SaveType.AmpPS3 || type == SaveDetection.SaveType.AmpPS3_Decrypted) 92 + { 93 + ps3tops4 = true; 94 + encrypted = (type == SaveDetection.SaveType.AmpPS3); 95 + } else 96 + { 97 + Console.WriteLine("Unsupported input file."); 98 + return; 99 + } 100 + 101 + FileStream outStream = File.OpenWrite(output); 102 + outStream.SetLength(0); 103 + if (ps3tops4) 104 + ConvertAmpSavePS3toPS4(inStream, outStream, encrypted); 105 + else 106 + ConvertAmpSavePS4toPS3(inStream, outStream, encrypted); 107 + inStream.Close(); 108 + outStream.Close(); 109 + } 110 + } 111 + }
+11
Program.cs
··· 139 139 outStream.Close(); 140 140 return; 141 141 } 142 + else if (verb == "convert") 143 + { 144 + if (args.Length < 3) 145 + { 146 + Console.WriteLine("Error: not enough filenames provided."); 147 + PrintUsage(false); 148 + return; 149 + } 150 + await AmpConversion.ConvertAmpSave(args[1], args[2]); 151 + return; 152 + } 142 153 else 143 154 { 144 155 Console.WriteLine("Error: unknown command");