public void StartExtract() { var selectedPaks = Paks.Where(x => x.IsChecked).ToList(); if (ExtractInOrder) { selectedPaks = selectedPaks.OrderBy(x => _extractOrder.IndexOf(x.Name)).ToList(); } AppController.Main.Data.ProgressValueMax = 100; AppController.Main.StartProgressAsync($"Extracing paks... ", async(t) => await ExtractAsync(selectedPaks, t), "", 0, true); }
private void OnLoaded(object sender, RoutedEventArgs e) { int i = 0; Games_CbBox.ItemsSource = ComboBoxVm.gamesCbViewModel; GamesPath_TxtBox.Text = Properties.Settings.Default.PakPath; string fortniteFilesPath = Paks.GetFortnitePakFilesPath(); if (!string.IsNullOrEmpty(fortniteFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Fortnite found at {fortniteFilesPath}"); Globals.gNotifier.ShowCustomMessage("Fortnite", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/fortnite.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Fortnite", Property = fortniteFilesPath }); } string egl2FilesPath = EGL2.GetEGL2PakFilesPath(); if (!string.IsNullOrEmpty(egl2FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[EGL2]", $"Fortnite found at {egl2FilesPath}"); Globals.gNotifier.ShowCustomMessage("Fortnite", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/egl2.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Fortnite [EGL2]", Property = egl2FilesPath }); } string valorantFilesPath = Paks.GetValorantPakFilesPath(); if (!string.IsNullOrEmpty(valorantFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[RiotClientInstalls.json]", $"Valorant found at {valorantFilesPath}"); Globals.gNotifier.ShowCustomMessage("Valorant", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/valorant.live.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Valorant", Property = valorantFilesPath }); } string borderlands3FilesPath = Paks.GetBorderlands3PakFilesPath(); if (!string.IsNullOrEmpty(borderlands3FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Borderlands 3 found at {borderlands3FilesPath}"); Globals.gNotifier.ShowCustomMessage("Borderlands 3", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/borderlands3.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Borderlands 3", Property = borderlands3FilesPath }); } Games_CbBox.SelectedItem = ComboBoxVm.gamesCbViewModel.Where(x => x.Property.ToString() == Properties.Settings.Default.PakPath).FirstOrDefault(); }
private Dictionary <string, FPakEntry> GetOldFiles(EPakLoader mode) { var diff = new Dictionary <string, FPakEntry>(); var ofd = new OpenFileDialog() { Title = Properties.Resources.SelectFile, InitialDirectory = Properties.Settings.Default.OutputPath + "\\Backups\\", Filter = Properties.Resources.FbkpFilter, Multiselect = false }; if ((bool)ofd.ShowDialog()) { string n = Path.GetFileName(ofd.FileName); StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.Analyzing, n), Properties.Resources.Processing); DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakMenuItemViewModel]", "[Loader]", $"Backup file is {n}"); var oldFilesTemp = new Dictionary <string, FPakEntry>(); using FileStream fileStream = new FileStream(ofd.FileName, FileMode.Open); BinaryReader checkReader = new BinaryReader(fileStream); bool isLz4 = checkReader.ReadUInt32() == 0x184D2204u; fileStream.Seek(0, SeekOrigin.Begin); var target = new MemoryStream(); if (isLz4) { using LZ4DecoderStream compressionStream = LZ4Stream.Decode(fileStream); compressionStream.CopyTo(target); } else { fileStream.CopyTo(target); } using (target) { target.Position = 0; using BinaryReader reader = new BinaryReader(target); while (reader.BaseStream.Position < reader.BaseStream.Length) { // we must follow this order long offset = reader.ReadInt64(); long size = reader.ReadInt64(); long uncompressedSize = reader.ReadInt64(); bool encrypted = reader.ReadBoolean(); long structSize = reader.ReadInt32(); string name = reader.ReadString(); int compressionMethodIndex = reader.ReadInt32(); // we only need name and uncompressedSize to compare FPakEntry entry = new FPakEntry("CatsWillDominateTheWorld.pak", name, offset, size, uncompressedSize, new byte[20], null, 0, (uint)compressionMethodIndex, 0); oldFilesTemp[entry.Name] = entry; } } var newFiles = new Dictionary <string, FPakEntry>(); foreach (var fileReader in Globals.CachedPakFiles) { foreach (var files in fileReader.Value) { newFiles.Add(files.Key, files.Value); } } Paks.Merge(oldFilesTemp, out var oldFiles, string.Empty); switch (mode) { case EPakLoader.New: foreach (var kvp in newFiles) { if (!oldFiles.TryGetValue(kvp.Key, out var entry)) { diff.Add(kvp.Key, kvp.Value); } } break; case EPakLoader.Modified: foreach (var kvp in newFiles) { if (oldFiles.TryGetValue(kvp.Key, out var entry)) { if (entry.UncompressedSize != kvp.Value.UncompressedSize) { diff.Add(kvp.Key, kvp.Value); } } } break; case EPakLoader.NewModified: foreach (var kvp in newFiles) { if (oldFiles.TryGetValue(kvp.Key, out var entry)) { if (entry.UncompressedSize != kvp.Value.UncompressedSize) { diff.Add(kvp.Key, kvp.Value); } } else { diff.Add(kvp.Key, kvp.Value); } } break; } var deleted = oldFiles.Where(kvp => !newFiles.TryGetValue(kvp.Key, out var _) && kvp.Key.StartsWith("/FortniteGame/Content/Athena/Items/Cosmetics/")).ToDictionary(x => x.Key, x => x.Value); if (deleted.Count > 0) { FConsole.AppendText(Properties.Resources.RemovedRenamedCosmetics, FColors.Red, true); foreach (var kvp in deleted) { FConsole.AppendText($" - {kvp.Value.Name.Substring(1)}", FColors.LightGray, true); } } } return(diff); }
private void OnLoaded(object sender, RoutedEventArgs e) { int i = 0; Games_CbBox.ItemsSource = ComboBoxVm.gamesCbViewModel; GamesPath_TxtBox.Text = Properties.Settings.Default.PakPath; string fortniteFilesPath = Paks.GetFortnitePakFilesPath(); if (!string.IsNullOrEmpty(fortniteFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Fortnite found at {fortniteFilesPath}"); Globals.gNotifier.ShowCustomMessage("Fortnite", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/fortnite.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Fortnite", Property = fortniteFilesPath }); } string egl2FilesPath = EGL2.GetEGL2PakFilesPath(); if (!string.IsNullOrEmpty(egl2FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[EGL2]", $"Fortnite found at {egl2FilesPath}"); Globals.gNotifier.ShowCustomMessage("Fortnite", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/egl2.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Fortnite [EGL2]", Property = egl2FilesPath }); } string valorantFilesPath = Paks.GetValorantPakFilesPath(); if (!string.IsNullOrEmpty(valorantFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[RiotClientInstalls.json]", $"Valorant found at {valorantFilesPath}"); Globals.gNotifier.ShowCustomMessage("Valorant", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/valorant.live.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Valorant", Property = valorantFilesPath }); } string borderlands3FilesPath = Paks.GetBorderlands3PakFilesPath(); if (!string.IsNullOrEmpty(borderlands3FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Borderlands 3 found at {borderlands3FilesPath}"); Globals.gNotifier.ShowCustomMessage("Borderlands 3", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/borderlands3.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Borderlands 3", Property = borderlands3FilesPath }); } string minecraftdungeonsFilesPath = Paks.GetMinecraftDungeonsPakFilesPath(); if (!string.IsNullOrEmpty(minecraftdungeonsFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[launcher_settings.json]", $"Minecraft Dungeons found at {minecraftdungeonsFilesPath}"); Globals.gNotifier.ShowCustomMessage("Minecraft Dungeons", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/minecraftdungeons.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Minecraft Dungeons", Property = minecraftdungeonsFilesPath }); } string battlebreakersFilesPath = Paks.GetBattleBreakersPakFilesPath(); if (!string.IsNullOrEmpty(battlebreakersFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Battle Breakers found at {battlebreakersFilesPath}"); Globals.gNotifier.ShowCustomMessage("Battle Breakers", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/battlebreakers.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Battle Breakers", Property = battlebreakersFilesPath }); } string spellbreakerFilesPath = Paks.GetSpellbreakPakFilesPath(); if (!string.IsNullOrEmpty(spellbreakerFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Spellbreak found at {spellbreakerFilesPath}"); Globals.gNotifier.ShowCustomMessage("Spellbreak", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/spellbreak.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "Spellbreak", Property = spellbreakerFilesPath }); } string theCyclePath = Paks.GetTheCyclePakFilesPath(); if (!string.IsNullOrEmpty(theCyclePath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"The Cycle found at {theCyclePath}"); Globals.gNotifier.ShowCustomMessage("The Cycle (EA)", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/thecycle.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "The Cycle (Early Access)", Property = theCyclePath }); } string sod2Path = Paks.GetStateOfDecay2PakFilesPath(); if (!string.IsNullOrEmpty(sod2Path)) { // WIP DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[WindowsApps]", $"State of Decay 2 found at {sod2Path}"); Globals.gNotifier.ShowCustomMessage("State of Decay 2", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/sod2.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "State of Decay 2", Property = sod2Path }); } Games_CbBox.SelectedItem = ComboBoxVm.gamesCbViewModel.Where(x => x.Property.ToString() == Properties.Settings.Default.PakPath).FirstOrDefault(); }
void ReadIndexInternal(byte[] key, PakFilter filter, out Exception exc) { if (Initialized) { exc = new InvalidOperationException("Index is already initialized"); return; } if (Info.bEncryptedIndex && key == null) { exc = new ArgumentException("Index is encrypted but no key was provided", nameof(key)); return; } Stream.Position = Info.IndexOffset; BinaryReader IndexReader; if (Info.bEncryptedIndex) { IndexReader = new BinaryReader(new MemoryStream(AESDecryptor.DecryptAES(Reader.ReadBytes((int)Info.IndexSize), key))); int stringLen = IndexReader.ReadInt32(); if (stringLen > 512 || stringLen < -512) { exc = new ArgumentException("The provided key is invalid", nameof(key)); return; } if (stringLen < 0) { IndexReader.BaseStream.Position += (stringLen - 1) * 2; if (IndexReader.ReadUInt16() != 0) { exc = new ArgumentException("The provided key is invalid", nameof(key)); return; } } else { IndexReader.BaseStream.Position += stringLen - 1; if (IndexReader.ReadByte() != 0) { exc = new ArgumentException("The provided key is invalid", nameof(key)); return; } } IndexReader.BaseStream.Position = 0; } else { IndexReader = Reader; } Dictionary <string, FPakEntry> tempFiles; if (Info.Version >= EPakVersion.PATH_HASH_INDEX) { ReadIndexUpdated(IndexReader, key, out tempFiles, filter); } else { // https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp#L4509 MountPoint = IndexReader.ReadFString(); if (MountPoint.StartsWith("../../..")) { MountPoint = MountPoint.Substring(8); } else { // Weird mount point location... MountPoint = "/"; } if (!CaseSensitive) { MountPoint = MountPoint.ToLowerInvariant(); } var NumEntries = IndexReader.ReadInt32(); tempFiles = new Dictionary <string, FPakEntry>(NumEntries); for (int i = 0; i < NumEntries; i++) { var entry = new FPakEntry(IndexReader, Info.Version, CaseSensitive, FileName); // if there is no filter OR the filter passes if (filter == null || filter.CheckFilter(MountPoint + entry.Name, CaseSensitive)) { // Filename is without the MountPoint concatenated to save memory tempFiles[entry.Name] = entry; } } } Paks.Merge(tempFiles, out var files, MountPoint); Entries = files; DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakFileReader]", "[ReadIndexInternal]", $"{FileName} contains {Entries.Count} files, mount point: \"{this.MountPoint}\", version: {(int)this.Info.Version}"); if (Info.bEncryptedIndex) { // underlying stream is a MemoryStream of the decrypted index, might improve performance with a crypto stream of some sort IndexReader.Dispose(); } Reader.Dispose(); Initialized = true; exc = null; }
private void OnLoaded(object sender, RoutedEventArgs e) { int i = 0; Games_CbBox.ItemsSource = ComboBoxVm.gamesCbViewModel; GamesPath_TxtBox.Text = Properties.Settings.Default.PakPath; string fortniteFilesPath = Paks.GetFortnitePakFilesPath(); if (!string.IsNullOrEmpty(fortniteFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Fortnite found at {fortniteFilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_Fortnite, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/fortnite.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Fortnite, Property = fortniteFilesPath }); } string egl2FilesPath = EGL2.GetEGL2PakFilesPath(); if (!string.IsNullOrEmpty(egl2FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[EGL2]", $"Fortnite found at {egl2FilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_Fortnite, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/egl2.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Fortnite + " [EGL2]", Property = egl2FilesPath }); } ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Fortnite + " [LIVE]", Property = "donotedit-youcanteditanyway-fn.manifest" }); string valorantFilesPath = Paks.GetValorantPakFilesPath(); if (!string.IsNullOrEmpty(valorantFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[RiotClientInstalls.json]", $"Valorant found at {valorantFilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_Valorant, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/valorant.live.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Valorant, Property = valorantFilesPath }); } ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Valorant + " [LIVE]", Property = "donotedit-youcanteditanyway-val.manifest" }); string borderlands3FilesPath = Paks.GetBorderlands3PakFilesPath(); if (!string.IsNullOrEmpty(borderlands3FilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Borderlands 3 found at {borderlands3FilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_Borderlands3, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/borderlands3.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Borderlands3, Property = borderlands3FilesPath }); } string minecraftdungeonsFilesPath = Paks.GetMinecraftDungeonsPakFilesPath(); if (!string.IsNullOrEmpty(minecraftdungeonsFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[launcher_settings.json]", $"Minecraft Dungeons found at {minecraftdungeonsFilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_MinecraftDungeons, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/minecraftdungeons.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_MinecraftDungeons, Property = minecraftdungeonsFilesPath }); } string battlebreakersFilesPath = Paks.GetBattleBreakersPakFilesPath(); if (!string.IsNullOrEmpty(battlebreakersFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Battle Breakers found at {battlebreakersFilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_BattleBreakers, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/battlebreakers.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_BattleBreakers, Property = battlebreakersFilesPath }); } string spellbreakFilesPath = Paks.GetSpellbreakPakFilesPath(); if (!string.IsNullOrEmpty(spellbreakFilesPath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"Spellbreak found at {spellbreakFilesPath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_Spellbreak, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/spellbreak.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_Spellbreak, Property = spellbreakFilesPath }); } string theCyclePath = Paks.GetTheCyclePakFilesPath(); if (!string.IsNullOrEmpty(theCyclePath)) { DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[LauncherInstalled.dat]", $"The Cycle found at {theCyclePath}"); Globals.gNotifier.ShowCustomMessage(Properties.Resources.GameName_TheCycle, Properties.Resources.PathAutoDetected, "/FModel;component/Resources/thecycle.ico"); ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = Properties.Resources.GameName_TheCycle, Property = theCyclePath }); } //string sod2Path = Paks.GetStateOfDecay2PakFilesPath(); //if (!string.IsNullOrEmpty(sod2Path)) //{ // WIP // DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[UWP / LauncherInstalled.dat]", $"State of Decay 2 found at {sod2Path}"); // Globals.gNotifier.ShowCustomMessage("State of Decay 2", Properties.Resources.PathAutoDetected, "/FModel;component/Resources/sod2.ico"); // ComboBoxVm.gamesCbViewModel.Add(new ComboBoxViewModel { Id = i++, Content = "State of Decay 2", Property = sod2Path }); //} Games_CbBox.SelectedItem = ComboBoxVm.gamesCbViewModel.FirstOrDefault(x => x.Property.ToString() == Properties.Settings.Default.PakPath); }