diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 4eea5cd6..04c07e21 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -468,29 +468,12 @@ namespace FModel #region PAKLIST & FILL TREE //METHODS - private string ReadPakGuid(string pakPath) - { - using (BinaryReader reader = new BinaryReader(File.Open(pakPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) - { - reader.BaseStream.Seek(reader.BaseStream.Length - 61 - 160, SeekOrigin.Begin); - uint g1 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 57 - 160, SeekOrigin.Begin); - uint g2 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 53 - 160, SeekOrigin.Begin); - uint g3 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 49 - 160, SeekOrigin.Begin); - uint g4 = reader.ReadUInt32(); - - var guid = g1 + "-" + g2 + "-" + g3 + "-" + g4; - return guid; - } - } private void RegisterPaKsinDict(string[] allYourPaKs, ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false) { for (int i = 0; i < allYourPaKs.Length; i++) { string arCurrentUsedPak = allYourPaKs[i]; //SET CURRENT PAK - string arCurrentUsedPakGuid = ReadPakGuid(Settings.Default.PAKsPath + "\\" + arCurrentUsedPak); //SET CURRENT PAK GUID + string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + arCurrentUsedPak); //SET CURRENT PAK GUID if (arCurrentUsedPakGuid == "0-0-0-0") //NO DYNAMIC PAK IN DICTIONARY { @@ -546,16 +529,16 @@ namespace FModel if (theSinglePak != null) { ThePak.CurrentUsedPak = theSinglePak.ClickedItem.Text; - ThePak.CurrentUsedPakGuid = ReadPakGuid(Settings.Default.PAKsPath + "\\" + ThePak.CurrentUsedPak); + ThePak.CurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + ThePak.CurrentUsedPak); if (arCurrentUsedPak == theSinglePak.ClickedItem.Text && JohnWick.MyExtractor.GetFileList() != null) PakAsTxt = JohnWick.MyExtractor.GetFileList().ToArray(); } } - if (theSinglePak != null && ReadPakGuid(Settings.Default.PAKsPath + "\\" + theSinglePak.ClickedItem.Text) != "0-0-0-0") //LOADING DYNAMIC PAK + if (theSinglePak != null && ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + theSinglePak.ClickedItem.Text) != "0-0-0-0") //LOADING DYNAMIC PAK { ThePak.CurrentUsedPak = theSinglePak.ClickedItem.Text; - ThePak.CurrentUsedPakGuid = ReadPakGuid(Settings.Default.PAKsPath + "\\" + ThePak.CurrentUsedPak); + ThePak.CurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + ThePak.CurrentUsedPak); try { @@ -774,7 +757,7 @@ namespace FModel for (int i = 0; i < allYourPaKs.Length; i++) { string arCurrentUsedPak = allYourPaKs[i]; //SET CURRENT PAK - string arCurrentUsedPakGuid = ReadPakGuid(Settings.Default.PAKsPath + "\\" + arCurrentUsedPak); //SET CURRENT PAK GUID + string arCurrentUsedPakGuid = ThePak.ReadPakGuid(Settings.Default.PAKsPath + "\\" + arCurrentUsedPak); //SET CURRENT PAK GUID if (arCurrentUsedPakGuid == "0-0-0-0") //NO DYNAMIC PAK { diff --git a/FModel/Methods/JohnWick/JohnWick.cs b/FModel/Methods/JohnWick/JohnWick.cs index 16dc05f8..6e8075a5 100644 --- a/FModel/Methods/JohnWick/JohnWick.cs +++ b/FModel/Methods/JohnWick/JohnWick.cs @@ -13,6 +13,8 @@ namespace FModel { public static PakAsset MyAsset; public static PakExtractor MyExtractor; + private static string[] myArray { get; set; } + private static string currentPakToCheck { get; set; } private static string GetMountPointFromDict(string currentItem, bool DynamicPak = false) { @@ -41,8 +43,11 @@ namespace FModel public static string ExtractAsset(string currentPak, string currentItem) { - MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, Settings.Default.AESKey); - string[] myArray = MyExtractor.GetFileList().ToArray(); + if (currentPak != currentPakToCheck) + { + MyExtractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + currentPak, Settings.Default.AESKey); + myArray = MyExtractor.GetFileList().ToArray(); + } string[] results; if (currentItem.Contains(".")) @@ -60,6 +65,8 @@ namespace FModel AssetPath = WriteFile(currentItem, results[i], b).Replace("/", "\\"); } + + currentPakToCheck = currentPak; return AssetPath; } public static string AssetToTexture2D(string AssetName) diff --git a/FModel/Methods/VarApp.cs b/FModel/Methods/VarApp.cs index 21755a2c..10c84be7 100644 --- a/FModel/Methods/VarApp.cs +++ b/FModel/Methods/VarApp.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; namespace FModel { @@ -10,6 +11,34 @@ namespace FModel public static Dictionary PaksMountPoint { get; set; } public static Dictionary AllpaksDictionary { get; set; } + + public static string ReadPakGuid(string pakPath) + { + using (BinaryReader reader = new BinaryReader(File.Open(pakPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) + { + reader.BaseStream.Seek(reader.BaseStream.Length - 61 - 160, SeekOrigin.Begin); + uint g1 = reader.ReadUInt32(); + reader.BaseStream.Seek(reader.BaseStream.Length - 57 - 160, SeekOrigin.Begin); + uint g2 = reader.ReadUInt32(); + reader.BaseStream.Seek(reader.BaseStream.Length - 53 - 160, SeekOrigin.Begin); + uint g3 = reader.ReadUInt32(); + reader.BaseStream.Seek(reader.BaseStream.Length - 49 - 160, SeekOrigin.Begin); + uint g4 = reader.ReadUInt32(); + + var guid = g1 + "-" + g2 + "-" + g3 + "-" + g4; + return guid; + } + } + public static string ReadPakVersion(string pakPath) + { + using (BinaryReader reader = new BinaryReader(File.Open(pakPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) + { + reader.BaseStream.Seek(reader.BaseStream.Length - 40 - 160, SeekOrigin.Begin); + uint guid = reader.ReadUInt32(); + + return guid.ToString(); + } + } } class App diff --git a/README.md b/README.md index f068811e..bd8ae959 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Also if you find this project useful, feel free to give it a :star: thank you :k 8. Load difference between current .PAK files and backup file 9. Load, Extract and Save Assets automatically between current .PAK files and backup file ### What i'm using - - [Fortnite Asset Parser](https://github.com/SirWaddles/JohnWickParse) - Custom Version With Output Control And No `key.txt` + - C# bindings for the [Fortnite Asset Parser](https://github.com/SirWaddles/JohnWickParse) - [AutoUpdater.NET](https://github.com/ravibpatel/AutoUpdater.NET) - [JSON Parser](https://app.quicktype.io/) - [ScintillaNET](https://www.nuget.org/packages/jacobslusser.ScintillaNET)