// Convert button private void btnImport_Click(object sender, EventArgs e) { if (sourcePath.Text == "") { MessageBox.Show("Select a game save data path first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (tbxSourceSaveFile.Text == "") { MessageBox.Show("Select a source save file first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cbxSlotsSelect.SelectedItem == null || cbxSlotsSelect.SelectedItem.ToString() == "") { MessageBox.Show("Select a slot first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var choice = MessageBox.Show("It will overwrite your save data on your save data path. Are you sure?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (choice == DialogResult.Yes) { string baseFinalPath = $"{sourcePath.Text}\\data00{cbxSlotsSelect.SelectedItem.ToString()}.bin"; Debug.WriteLine($"Saving to {baseFinalPath}"); // Pick the binslot first Binslot binslot = new Binslot($"{baseFinalPath}slot"); // Calculating new hash byte[] newHash = HashMD5.getMd5BytesHash(File.ReadAllBytes(tbxSourceSaveFile.Text)); string strHash = HashMD5.getMd5StringHash(File.ReadAllBytes(tbxSourceSaveFile.Text)); Debug.WriteLine($"New hash: {strHash}"); // Storing the newer hash binslot.saveFileHash = newHash; // Saving the new file binslot binslot.saveBinslot(); // Copying the save into save file path File.Copy(tbxSourceSaveFile.Text, baseFinalPath, true); MessageBox.Show("Save import finished", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Calculate mystery hash /// </summary> /// <returns>byte array of mystery hash</returns> public byte[] calculateMysteryHash() { byte[] calcluation; MemoryStream ms = new MemoryStream(); ms.Write(this.sdSlotData, 0, this.sdSlotData.Length); ms.Write(this.wtfMagic, 0, this.wtfMagic.Length); calcluation = ms.ToArray(); ms.Dispose(); return(HashMD5.getMd5BytesHash(calcluation)); }
/// <summary> /// Convert the sdslot.bin (Vita) into *.binslot (Steam). Save files must follow the data00XX.bin pattern. /// </summary> /// <param name="outputPath">Output result</param> /// <param name="inputSavePath">Input path of the save files</param> public void convertToBinslot(string outputPath, string inputSavePath) { for (int i = 1; i <= 16; i++) { if (this.usedSlots[i] == 0x00) { continue; } if (!File.Exists($@"{inputSavePath}\data00{i}.bin") && !File.Exists($@"{inputSavePath}\data000{i}.bin")) { throw new FileNotFoundException($"File data00XX.bin not found (index {i})"); } Binslot binslot = new Binslot(this.dataBinSlots[i - 1], false); binslot.mysteryHash = binslot.calculateMysteryHash(); binslot.saveFileHash = HashMD5.getMd5BytesHash(File.ReadAllBytes($@"{inputSavePath}\data00{(i < 10 ? $"0{i}" : i.ToString())}.bin")); binslot.originPath = outputPath + $@"\data00{(i < 10 ? $"0{i}": i.ToString())}.binslot"; binslot.saveBinslot(); } }