public void Unpack(string in_path, string out_path, string KOMFileName) { System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead(in_path), System.Text.Encoding.ASCII); reader.BaseStream.Position += 52; int entry_count = (int)reader.ReadUInt64(); // trying to understand this crap... This is where it starts to fail // for KOM V4 on Elsword's current data036.kom. int compressed = reader.ReadInt32(); int file_time = reader.ReadInt32(); int xml_size = reader.ReadInt32(); byte[] xmldatabuffer = reader.ReadBytes(xml_size); Els_kom_Core.Classes.KOMStream kOMStream = new Els_kom_Core.Classes.KOMStream(); kOMStream.DecryptCRCXml(compressed, ref xmldatabuffer, xml_size, System.Text.Encoding.ASCII); string xmldata = System.Text.Encoding.ASCII.GetString(xmldatabuffer); try { System.Collections.Generic.List <Els_kom_Core.Classes.EntryVer> entries = kOMStream.Make_entries_v4(xmldata, entry_count); foreach (var entry in entries) { // we iterate through every entry here and unpack the data. kOMStream.WriteOutput(reader, out_path, entry, SupportedKOMVersion); } } catch (System.Xml.XmlException) { throw new Els_kom_Core.Classes.UnpackingError("failure with xml entry data reading..."); } kOMStream.Dispose(); reader.Dispose(); }
public void Unpack(string in_path, string out_path, string KOMFileName) { System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead(in_path), System.Text.Encoding.ASCII); reader.BaseStream.Position = 52; Els_kom_Core.Classes.KOMStream kOMStream = new Els_kom_Core.Classes.KOMStream(); kOMStream.ReadInFile(reader, out int entry_count); // without this dummy read the entry instances would not get the correct // data leading to an crash when tring to make an file with the entry name in the output path. kOMStream.ReadInFile(reader, out int size); System.Collections.Generic.List <Els_kom_Core.Classes.EntryVer> entries = kOMStream.Make_entries_v2(entry_count, reader); foreach (var entry in entries) { // we iterate through every entry here and unpack the data. kOMStream.WriteOutput(reader, out_path, entry, SupportedKOMVersion); } kOMStream.Dispose(); reader.Dispose(); }
public void Unpack(string in_path, string out_path, string KOMFileName) { System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead(in_path), System.Text.Encoding.ASCII); reader.BaseStream.Position += 52; int entry_count = (int)reader.ReadUInt64(); reader.BaseStream.Position += 4; int file_time = reader.ReadInt32(); int xml_size = reader.ReadInt32(); byte[] xmldatabuffer = reader.ReadBytes(xml_size); string xmldata = System.Text.Encoding.ASCII.GetString(xmldatabuffer); Els_kom_Core.Classes.KOMStream kOMStream = new Els_kom_Core.Classes.KOMStream(); System.Collections.Generic.List <Els_kom_Core.Classes.EntryVer> entries = kOMStream.Make_entries_v3(xmldata, entry_count); foreach (var entry in entries) { // we iterate through every entry here and unpack the data. kOMStream.WriteOutput(reader, out_path, entry, SupportedKOMVersion); } kOMStream.Dispose(); reader.Dispose(); }