Exemplo n.º 1
0
        private void ReadRawTextfile()
        {
            PkgFile pkgFile = Calculation.Hash2File(this._d2TextParam.EngFileHash);

            byte[] buffer = new PkgExtract().ToBuffer(pkgFile);
            this._d2TextMs = new MemoryStream(buffer);
        }
Exemplo n.º 2
0
        public void Extract(PkgFile pkgFile, string outputDir)
        {
            byte[] bytes    = this.ToBuffer(pkgFile);
            string filename = pkgFile.Filename;
            string text     = outputDir + filename;

            Helpers.FileExistsDelete(text);
            File.WriteAllBytes(text, bytes);
        }
Exemplo n.º 3
0
            internal void GetFiles0(PkgEntry pkgListEntry)
            {
                PkgFile pkgFile = new PkgFile(this.PkgStream, pkgListEntry.EntryNumber);

                if (pkgFile.PkgFileType == PkgFileType.Text)
                {
                    List <PkgFile> d2Files = this.TextInstance._d2Files;
                    lock (d2Files)
                    {
                        this.TextInstance._d2Files.Add(pkgFile);
                    }
                }
            }
Exemplo n.º 4
0
        public uint GetAudioFile(uint audioCollectionHash)
        {
            PkgFile      pkgFile      = new PkgFile(audioCollectionHash);
            MemoryStream memoryStream = new MemoryStream(new PkgExtract().ToBuffer(pkgFile));

            memoryStream.Seek(0x20L, SeekOrigin.Begin);
            uint num = (uint)memoryStream.Position + Helpers.ReadUInt(memoryStream);

            memoryStream.Seek((long)((ulong)(num + 0x10U)), SeekOrigin.Begin);
            uint result = Helpers.ReadUInt(memoryStream);

            memoryStream.Close();
            return(result);
        }
Exemplo n.º 5
0
        public byte[] ToBuffer(PkgFile pkgFile)
        {
            PkgEntry pkgEntry = pkgFile.PkgEntry;

            byte[] array = new byte[pkgEntry.BlockCount * 0x40000U];
            using (FileStream fileStream = File.OpenRead(Form1.RecD2PkgDir() + pkgEntry.StartBlockPkg))
            {
                foreach (BlockEntry blockEntry in pkgFile.BlockEntries)
                {
                    byte[] array2 = new byte[blockEntry.Size];
                    fileStream.Seek((long)((ulong)blockEntry.Offset), SeekOrigin.Begin);
                    fileStream.Read(array2, 0, (int)blockEntry.Size);
                    if (blockEntry.Encrypted)
                    {
                        if (!blockEntry.AltKey)
                        {
                            array2 = this.DecryptBuffer(array2, pkgFile.Nonce, blockEntry.GcmTag, 1);
                        }
                        else
                        {
                            array2 = this.DecryptBuffer(array2, pkgFile.Nonce, blockEntry.GcmTag, 2);
                        }
                    }
                    uint num = blockEntry.Size;
                    if (blockEntry.Compressed)
                    {
                        array2 = this.DecompressBuffer(array2);
                        num    = 0x40000U;
                    }
                    Array.Copy(array2, 0L, array, (long)((ulong)((blockEntry.BlockNumber - pkgEntry.StartBlock) * 0x40000U)), (long)((ulong)num));
                }
                fileStream.Close();
            }
            byte[] array3 = new byte[pkgEntry.EntrySize];
            Array.Copy(array, (long)((ulong)pkgEntry.InBlockOffset), array3, 0L, (long)((ulong)pkgEntry.EntrySize));
            return(array3);
        }
Exemplo n.º 6
0
 public PkgText(PkgFile pkgFile)
 {
     this._pkgFile = pkgFile;
 }
Exemplo n.º 7
0
 private void TreeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node.Tag != null)
     {
         VoiceEntryLtd voiceEntryLtd = (VoiceEntryLtd)e.Node.Tag;
         string        logText       = voiceEntryLtd.Narrator + ": " + voiceEntryLtd.Text;
         float         length        = voiceEntryLtd.Length;
         uint          entryHash     = voiceEntryLtd.EntryHash;
         string        text          = null;
         this.UpdtEventLogger("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
         this.UpdtEventLogger(logText);
         this.UpdtEventLogger("Entryhash: " + entryHash.ToString("D10"));
         if (voiceEntryLtd.AudioCollectionFileHash != 0xFFFFFFFFU)
         {
             text = string.Concat(new string[]
             {
                 Form1.StdOutputDir,
                 "/",
                 entryHash.ToString(""),
                 "_",
                 Calculation.Hash2File(voiceEntryLtd.AudioCollectionFileHash).Filename.Replace(".bin", ".ogg")
             });
             this.UpdtEventLogger(string.Concat(new string[]
             {
                 "Audio: ",
                 Path.GetFileName(text),
                 "  (",
                 length.ToString("N2"),
                 " s)"
             }));
         }
         this.DisposeWave();
         if (voiceEntryLtd.AudioCollectionFileHash != 0xFFFFFFFFU)
         {
             PkgFile      pkgFile      = new PkgFile(voiceEntryLtd.AudioCollectionFileHash);
             MemoryStream memoryStream = new MemoryStream(new PkgExtract().ToBuffer(pkgFile));
             memoryStream.Seek(0x28L, SeekOrigin.Begin);
             uint num = (uint)memoryStream.Position + Helpers.ReadUInt(memoryStream) + 0x10U;
             memoryStream.Seek((long)((ulong)num), SeekOrigin.Begin);
             uint filehashIn = Helpers.ReadUInt(memoryStream);
             memoryStream.Close();
             PkgFile      pkgFile2      = new PkgFile(filehashIn);
             MemoryStream memoryStream2 = new MemoryStream(new PkgExtract().ToBuffer(pkgFile2));
             if (Helpers.ReadUInt(memoryStream2) != 0x46464952U)
             {
                 this.UpdtEventLogger("No Audiofile for selected Transcript.");
                 return;
             }
             memoryStream2.Seek(0L, SeekOrigin.Begin);
             MemoryStream memoryStream3 = Ww2Ogg.ww2ogg(memoryStream2, new MemoryStream(Resources.CodeBook));
             memoryStream2.Close();
             MemoryStream memoryStream4  = new MemoryStream(memoryStream3.ToArray());
             MemoryStream revorbedStream = new MemoryStream();
             GinsorAudioTool2Plus.Revorb.revorb(memoryStream4, revorbedStream);
             revorbedStream.Seek(0, SeekOrigin.Begin);
             this._waveStream = new VorbisWaveReader(revorbedStream);
             this._wavePlayer = new DirectSoundOut();
             this._wavePlayer.Init(this._waveStream);
             this._wavePlayer.Play();
             if (this.cb_saveAudio.Checked)
             {
                 Helpers.FileExistsDelete(text);
                 Helpers.DirNotExistCreate(Path.GetDirectoryName(text));
                 File.WriteAllBytes(text, revorbedStream.ToArray());
             }
         }
         else
         {
             this.UpdtEventLogger("No Audiofile for selected Transcript.");
         }
     }
 }