private string DecryptBinFile(string binFile, string subdir) { var binFileWOE = Path.GetFileNameWithoutExtension(binFile); var outSubdirs = Path.GetDirectoryName(Path.Combine(Program.OutputFolderPath, subdir)); Console.Out.WriteLine("Extracting " + binFileWOE + ".bin..."); if (outSubdirs != "") { Directory.CreateDirectory(outSubdirs); } var finalOutPath = Path.Combine(outSubdirs, binFileWOE); var finalXmlPath = finalOutPath + ".xml"; var finalJsonPath = finalOutPath + ".json"; using (var outputXmlFile = File.Create(finalXmlPath)) { BinaryDecrypter.DecryptBinaryFile(binFile, outputXmlFile); } if (string.Equals("world", binFileWOE, StringComparison.OrdinalIgnoreCase) || (!subdir.StartsWith("cluster") && !subdir.StartsWith("templates"))) { var xmlDocument = new XmlDocument(); var xmlReaderSettings = new XmlReaderSettings { IgnoreComments = true }; var xmlReader = XmlReader.Create(finalXmlPath, xmlReaderSettings); xmlDocument.Load(xmlReader); File.WriteAllText(finalJsonPath, JsonConvert.SerializeXmlNode(xmlDocument, Newtonsoft.Json.Formatting.Indented, false)); } return(finalOutPath); }
private string DecryptBinFile(string binFile) { string output = BinaryDecrypter.DecryptBinaryFile(binFile); string binFileWOE = Path.GetFileNameWithoutExtension(binFile); StreamWriter sw = File.CreateText(binFileWOE + ".xml"); sw.Write(output); sw.Close(); return(binFileWOE + ".xml"); }
//public List<IDContainer> PureExtract(bool withLocal = true) //{ // using (var ms = new MemoryStream()) // { // DecryptBinFile(GetBinFilePath(), ms); // ms.Flush(); // ms.Position = 0; // return ExtractFromXML(ms, withLocal); // } //} public static string DecryptBinFile(string binFile) { var binFileWOE = Path.GetFileNameWithoutExtension(binFile); Console.Out.WriteLine("Extracting " + binFileWOE + ".bin..."); var finalOutPath = Path.ChangeExtension(Path.Combine(Program.OutputFolderPath, binFile.Substring(binFile.LastIndexOf("GameData\\") + 9)), ".xml"); Directory.CreateDirectory(Path.GetDirectoryName(finalOutPath)); using (var outputStream = File.Create(finalOutPath)) { BinaryDecrypter.DecryptBinaryFile(binFile, outputStream); } return(finalOutPath); }
private string DecryptBinFile(string binFile) { string output = BinaryDecrypter.DecryptBinaryFile(binFile); string binFileWOE = Path.GetFileNameWithoutExtension(binFile); Console.Out.WriteLine("Extracting " + binFileWOE + ".bin..."); string finalOutPath = Path.Combine(Program.OutputFolderPath, binFileWOE + ".xml"); Directory.CreateDirectory(Path.GetDirectoryName(finalOutPath)); StreamWriter sw = File.CreateText(finalOutPath); sw.Write(output); sw.Close(); return(finalOutPath); }
private void ExtractAndSetLocalization(List <IDContainer> itemsList) { string localizationXML = BinaryDecrypter.DecryptBinaryFile(Path.Combine(AOLauncherFolder, @"..\game\Albion-Online_Data\StreamingAssets\GameData\localization.bin")); // Param 0 is the xml file byte[] encodedString = Encoding.UTF8.GetBytes(localizationXML); // Put the byte array into a stream and rewind it to the beginning MemoryStream ms = new MemoryStream(encodedString); ms.Flush(); ms.Position = 0; // Build the XmlDocument from the MemorySteam of UTF-8 encoded bytes XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ms); XmlNode rootNode = xmlDoc.LastChild.LastChild; foreach (XmlNode node in rootNode.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { XmlAttribute tuid = node.Attributes["tuid"]; if (tuid != null) { if (tuid.Value.StartsWith(LocalizationItemPrefix)) { // is the item description if (tuid.Value.EndsWith(LocalizationItemDescPostfix)) { List <IDContainer> item = itemsList.FindAll(cont => ((ItemContainer)cont).LocalizationDescriptionVariable == tuid.Value); Dictionary <string, string> descDict = new Dictionary <string, string>(); foreach (XmlNode n in node.ChildNodes) { string lang = n.Attributes["xml:lang"].Value; string desc = n.LastChild.InnerText; descDict.Add(lang, desc); } foreach (ItemContainer cont in item) { cont.LocalizedDescriptions = descDict; } } // is item name else { List <IDContainer> item = itemsList.FindAll(cont => ((ItemContainer)cont).LocalizationNameVariable == tuid.Value); Dictionary <string, string> nameDict = new Dictionary <string, string>(); foreach (XmlNode n in node.ChildNodes) { string lang = n.Attributes["xml:lang"].Value; string name = n.LastChild.InnerText; nameDict.Add(lang, name); } foreach (ItemContainer cont in item) { cont.LocalizedNames = nameDict; } } } else { continue; } } } } foreach (ItemContainer cont in itemsList) { if (cont.LocalizedDescriptions == null) { cont.LocalizationDescriptionVariable = null; } if (cont.LocalizedNames == null) { cont.LocalizationNameVariable = null; } } }