added a temporary string finder for locres files

This commit is contained in:
Asval
2019-06-10 01:59:31 +02:00
parent c8e5587d9e
commit d1cefd889e
7 changed files with 153 additions and 18 deletions

View File

@@ -128,6 +128,7 @@
<Compile Include="Methods\DLLImport.cs" />
<Compile Include="Methods\IconGenerator\DrawText.cs" />
<Compile Include="Methods\ImagesMerger\ImagesMerger.cs" />
<Compile Include="Methods\LocRes\TempStringFinder.cs" />
<Compile Include="Methods\Scintilla\MyScintilla.cs" />
<Compile Include="Methods\Utilities\FontUtilities.cs" />
<Compile Include="Methods\IconGenerator\ItemIcon.cs" />

View File

@@ -37,7 +37,7 @@ namespace FModel.Forms
checkBox8.Checked = Properties.Settings.Default.loadFeaturedImage;
if (Properties.Settings.Default.loadFeaturedImage == false)
{
if (!string.IsNullOrEmpty(Properties.Settings.Default.wFilename))
if (File.Exists(Properties.Settings.Default.wFilename))
{
filenameLabel.Text = @"File Name: " + Path.GetFileName(Properties.Settings.Default.wFilename);
@@ -53,7 +53,7 @@ namespace FModel.Forms
}
if (Properties.Settings.Default.loadFeaturedImage)
{
if (!string.IsNullOrEmpty(Properties.Settings.Default.wFilename))
if (File.Exists(Properties.Settings.Default.wFilename))
{
filenameLabel.Text = @"File Name: " + Path.GetFileName(Properties.Settings.Default.wFilename);

View File

@@ -23,7 +23,7 @@ namespace FModel.Forms
checkBox8.Checked = Properties.Settings.Default.UMFeatured;
if (Properties.Settings.Default.UMFeatured == false)
{
if (!string.IsNullOrEmpty(Properties.Settings.Default.UMFilename))
if (File.Exists(Properties.Settings.Default.UMFilename))
{
filenameLabel.Text = @"File Name: " + Path.GetFileName(Properties.Settings.Default.UMFilename);
@@ -39,7 +39,7 @@ namespace FModel.Forms
}
if (Properties.Settings.Default.UMFeatured)
{
if (!string.IsNullOrEmpty(Properties.Settings.Default.UMFilename))
if (File.Exists(Properties.Settings.Default.UMFilename))
{
filenameLabel.Text = @"File Name: " + Path.GetFileName(Properties.Settings.Default.UMFilename);

View File

@@ -71,6 +71,7 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.backgroundWorker2 = new System.ComponentModel.BackgroundWorker();
this.locresStringFinderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
@@ -203,7 +204,8 @@
// filesToolStripMenuItem
//
this.filesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.searchToolStripMenuItem});
this.searchToolStripMenuItem,
this.locresStringFinderToolStripMenuItem});
this.filesToolStripMenuItem.Name = "filesToolStripMenuItem";
this.filesToolStripMenuItem.Size = new System.Drawing.Size(42, 20);
this.filesToolStripMenuItem.Text = "Files";
@@ -469,6 +471,13 @@
this.backgroundWorker2.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker2_DoWork);
this.backgroundWorker2.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker2_RunWorkerCompleted);
//
// locresStringFinderToolStripMenuItem
//
this.locresStringFinderToolStripMenuItem.Name = "locresStringFinderToolStripMenuItem";
this.locresStringFinderToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
this.locresStringFinderToolStripMenuItem.Text = "LocRes String Finder";
this.locresStringFinderToolStripMenuItem.Click += new System.EventHandler(this.LocresStringFinderToolStripMenuItem_Click);
//
// MainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -543,6 +552,7 @@
private System.ComponentModel.BackgroundWorker backgroundWorker2;
private System.Windows.Forms.ToolStripMenuItem filesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem locresStringFinderToolStripMenuItem;
}
}

View File

@@ -22,6 +22,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Image = System.Drawing.Image;
using Settings = FModel.Properties.Settings;
using System.Text;
namespace FModel
{
@@ -252,6 +253,8 @@ namespace FModel
//METHODS
private void RegisterPaKsinDict(string[] allYourPaKs, ToolStripItemClickedEventArgs theSinglePak = null, bool loadAllPaKs = false)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < allYourPaKs.Length; i++)
{
string arCurrentUsedPak = allYourPaKs[i]; //SET CURRENT PAK
@@ -272,15 +275,17 @@ namespace FModel
{
ThePak.PaksMountPoint.Add(arCurrentUsedPak, JohnWick.MyExtractor.GetMountPoint().Substring(9));
if (loadAllPaKs)
if (!File.Exists(App.DefaultOutputPath + "\\FortnitePAKs.txt"))
File.Create(App.DefaultOutputPath + "\\FortnitePAKs.txt").Dispose();
string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii];
if (loadAllPaKs)
{
sb.Append(CurrentUsedPakLines[ii]);
sb.AppendLine();
}
string CurrentUsedPakFileName = CurrentUsedPakLines[ii].Substring(CurrentUsedPakLines[ii].LastIndexOf("/", StringComparison.Ordinal) + 1);
if (CurrentUsedPakFileName.Contains(".uasset") || CurrentUsedPakFileName.Contains(".uexp") || CurrentUsedPakFileName.Contains(".ubulk"))
{
@@ -301,13 +306,14 @@ namespace FModel
{
UpdateConsole(".PAK mount point: " + JohnWick.MyExtractor.GetMountPoint().Substring(9), Color.FromArgb(255, 244, 132, 66), "Waiting");
File.AppendAllLines(App.DefaultOutputPath + "\\FortnitePAKs.txt", CurrentUsedPakLines);
File.WriteAllText(App.DefaultOutputPath + "\\FortnitePAKs.txt", sb.ToString());
ThePak.CurrentUsedPak = null;
ThePak.CurrentUsedPakGuid = null;
}
}
}
if (theSinglePak != null)
{
ThePak.CurrentUsedPak = theSinglePak.ClickedItem.Text;
@@ -521,6 +527,7 @@ namespace FModel
private void CreateBackupList(string[] allYourPaKs)
{
_backupDynamicKeys = null;
StringBuilder sb = new StringBuilder();
if (DLLImport.IsInternetAvailable() && (!string.IsNullOrWhiteSpace(Settings.Default.eEmail) || !string.IsNullOrWhiteSpace(Settings.Default.ePassword)))
{
@@ -560,10 +567,11 @@ namespace FModel
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii]);
sb.AppendLine();
}
UpdateConsole(".PAK mount point: " + JohnWick.MyExtractor.GetMountPoint().Substring(9), Color.FromArgb(255, 244, 132, 66), "Waiting");
File.AppendAllLines(App.DefaultOutputPath + "\\Backup" + _backupFileName, CurrentUsedPakLines);
}
}
else if (_backupDynamicKeys != null)
@@ -596,23 +604,22 @@ namespace FModel
if (JohnWick.MyExtractor.GetFileList() != null)
{
if (!File.Exists(App.DefaultOutputPath + "\\Backup" + _backupFileName))
File.Create(App.DefaultOutputPath + "\\Backup" + _backupFileName).Dispose();
string[] CurrentUsedPakLines = JohnWick.MyExtractor.GetFileList().ToArray();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = JohnWick.MyExtractor.GetMountPoint().Substring(6) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii]);
sb.AppendLine();
}
AppendText("Backing up ", Color.Black);
AppendText(arCurrentUsedPak, Color.DarkRed, true);
File.AppendAllLines(App.DefaultOutputPath + "\\Backup" + _backupFileName, CurrentUsedPakLines);
}
}
}
}
}
File.WriteAllText(App.DefaultOutputPath + "\\Backup" + _backupFileName, sb.ToString());
if (File.Exists(App.DefaultOutputPath + "\\Backup" + _backupFileName))
UpdateConsole("\\Backup" + _backupFileName + " successfully created", Color.FromArgb(255, 66, 244, 66), "Success");
@@ -1476,5 +1483,20 @@ namespace FModel
ImagesMerger.AskMergeImages();
}
#endregion
private void LocresStringFinderToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Directory.Exists(App.DefaultOutputPath + "\\Extracted\\FortniteGame\\Content\\Localization\\"))
{
Invoke(new Action(() =>
{
scintilla1.Text = TempStringFinder.locresOpenFile(App.DefaultOutputPath + "\\Extracted\\FortniteGame\\Content\\Localization\\");
}));
}
else
{
AppendText("No .locres file currently extracted", Color.DarkRed, true);
}
}
}
}

View File

@@ -131,7 +131,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABa
CAAAAk1TRnQBSQFMAgEBAgEAAcgBAAHIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAdgBAAHYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FModel
{
static class TempStringFinder
{
private static List<string> weirdStrings;
private static bool previousByteWasValid = false;
/// <summary>
///
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
private static string StringFinder(string filepath)
{
StringBuilder sb = new StringBuilder();
using (BinaryReader reader = new BinaryReader(File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.GetEncoding(1252)))
{
byte[] MagicNumber = reader.ReadBytes(16);
byte VersionNumber = reader.ReadByte();
//Console.WriteLine("VersionNumber: " + VersionNumber);
long LocalizedStringArrayOffset = -1;
LocalizedStringArrayOffset = reader.ReadInt64();
//Console.WriteLine("LocalizedStringArrayOffset: " + LocalizedStringArrayOffset);
uint EntriesCount = reader.ReadUInt32();
//Console.WriteLine("EntriesCount: " + EntriesCount);
uint NamespaceCount = reader.ReadUInt32();
//Console.WriteLine("NamespaceCount: " + NamespaceCount);
/*reader.BaseStream.Position = 50;
ByteArrayToString(reader, (int)LocalizedStringArrayOffset);*/
weirdStrings = new List<string>();
reader.BaseStream.Position = LocalizedStringArrayOffset;
byte[] LocalizedStringArray = reader.ReadBytes((int)reader.BaseStream.Length - (int)LocalizedStringArrayOffset);
string pattern = @"^[\w.:',+-=!?\""{}()\[\]|>«»#&% ]";
Regex regex = new Regex(pattern);
foreach (byte b in LocalizedStringArray) // Iterate throught all the bytes of the array
{
string byteString = string.Empty;
if (b == 0x00) { continue; } //skip if empty byte
if (b == 0xA0) { byteString = " "; } //weird spaces
else
{
byteString = Encoding.GetEncoding(1252).GetString(new[] { b }); //generate string for single byte
}
bool valid = regex.IsMatch(byteString);
if (valid)
{
if (previousByteWasValid) weirdStrings[weirdStrings.Count - 1] += byteString;
else weirdStrings.Add(byteString);
}
previousByteWasValid = valid;
}
foreach (string str in weirdStrings)
{
if (str.Length > 2)
{
if (str.Contains("ÿÿ")) { sb.Append(str.Substring(str.LastIndexOf("ÿ") + 1) + "\n"); }
else { sb.Append(str + "\n"); }
}
}
}
return sb.ToString();
}
public static string locresOpenFile(string defaultPath)
{
OpenFileDialog theDialog = new OpenFileDialog();
theDialog.Multiselect = false;
theDialog.InitialDirectory = defaultPath;
theDialog.Title = @"Choose your LocRes file";
theDialog.Filter = @"All Files (*.*)|*.*";
if (theDialog.ShowDialog() == DialogResult.OK)
{
return StringFinder(theDialog.FileName);
}
else { return null; }
}
}
}