public static byte[] ReadEntryData(BinaryReader br, TAHEntry e) { br.BaseStream.Seek(e.DataOffset, SeekOrigin.Begin); byte[] output = new byte[br.ReadInt32()]; byte[] input = br.ReadBytes(e.Length - 4); TAHUtil.Decrypt(input, output); return(output); }
public void Read(BinaryReader br, TAHFile file) { // ディレクトリデータの読み込み Files = new List <string>(file.Header.NumEntries); int output_length = br.ReadInt32(); int input_length = (int)(file.EntrySet[0].DataOffset - br.BaseStream.Position); //- 16 - 8 * file.Header.NumEntries; byte[] input = br.ReadBytes(input_length); byte[] output = new byte[output_length]; if (output.Length == 0) { return; } // add konoa:tahdecryptorのバグ回避. if (input.Length == 0) { return; } TAHUtil.Decrypt(input, output); //TAHdecrypt.Decrypter.decrypt(ref input, (uint)input.Length, ref output, (uint)output.Length); MemoryStream ms = new MemoryStream(output); BinaryReader br2 = new BinaryReader(ms); try { string dir = ""; while (ms.Position < ms.Length) { string name = TAHUtil.ReadString(br2); if (name.Length == 0) { } else if (name.EndsWith("/")) { dir = name; //DbgPrint("Directory: " + dir); } else { name = dir + name; uint hash = TAHUtil.CalcHash(name); TAHEntry ent; //DbgPrint(hash.ToString("X").PadLeft(8, '0')); if (file.EntrySet.TryGetValue(hash, out ent)) { ent.FileName = name; //DbgPrint(": Found: " + file); } else { //DbgPrint(": Not Found: " + file); System.Diagnostics.Debug.Assert(false); } //EntryMap[hash].FileName = FileName; } Files.Add(name); } } catch (EndOfStreamException) { } }