private void SaveFileToDisk() { IO io = new IO(filePath, Endian.Little, 0x0000000, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); File.WriteAllBytes(filePath + ".bak", originalBytes); ReadGUIData(); Helpers.WriteGVASSave(io, saveData); byte[] result; using (var stream = new MemoryStream()) { Serializer.Serialize <Profile>(stream, loadedProfile); result = stream.ToArray(); } ProfileBogoCrypt.Encrypt(result, 0, result.Length); io.WriteInt32(result.Length); io.WriteBytes(result); io.Close(); Console.WriteLine("Injecting GR into saves..."); GRInjection(); }
private void LoadFileFromDisk() { Console.WriteLine("\n\nReading new file: \"{0}\"", filePath); IO io = new IO(filePath, Endian.Little, 0x0000000, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); // We're gonna use this byte array for backing up the save file. originalBytes = io.ReadAll(); io.Close(); io = new IO(filePath, Endian.Little, 0x0000000, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); saveData = Helpers.ReadGVASSave(io); if (saveData == null) { Console.WriteLine("Loaded file is not a BL3 profile..."); showMessage("File Error", "Loaded file is not a BL3 profile"); return; } string saveGameType = saveData.sgType; int remainingDataLength = io.ReadInt32(); Console.WriteLine("Length of data: {0}", remainingDataLength); byte[] buf = io.ReadBytes(remainingDataLength); io.Close(); if (!saveGameType.Equals("BP_DefaultOakProfile_C")) { Console.WriteLine("Loaded file is not a profile..."); showMessage("File Error", "Loaded file is not a profile"); return; } ProfileBogoCrypt.Decrypt(buf, 0, remainingDataLength); loadedProfile = Serializer.Deserialize <Profile>(new MemoryStream(buf)); UpdateSaveGUI(); }