コード例 #1
0
ファイル: ByteToStructEbk3.cs プロジェクト: dannisliang/VS
        public ChapterHeadModelStruct GetChapterHeadModelStruct(byte[] buffs)
        {
            ChapterHeadModelStruct struct2 = new ChapterHeadModelStruct();
            int offset = 0;

            struct2.chapter_count = (uint)GetInt32(4, ref offset, buffs);
            struct2.chapter_name_header_length = (uint)GetInt32(4, ref offset, buffs);
            return(struct2);
        }
コード例 #2
0
        public BookInfo Open(byte[] buffer)
        {
            EBK3HeadStruct         headStruct             = new EBK3HeadStruct();
            EBK3HeadInfoModel      recodeModel            = new EBK3HeadInfoModel();
            ChapterHeadModelStruct chapterHeadModelStruct = new ChapterHeadModelStruct();

            new blockinfoModel();
            new ChapterListModel();
            DynDataStruct dynDataStruct = new DynDataStruct();

            headStruct = new ByteToStructEbk3().GetHeadStruct(buffer);
            int key = (int)headStruct.decode_key;

            byte[] buffer2 = new byte[headStruct.header_length];
            Array.Copy(buffer, 0, buffer2, 0, buffer2.Length);
            byte[] data = new byte[buffer2.Length - 0x10];
            Array.Copy(buffer, 0x10, data, 0, data.Length);
            recodeModel = GetRecodeModel(this.ebk3_data.pbk_sys_data_decode(data, key), (int)recodeModel.modellenth);
            byte[] buffs = new byte[0x10];
            Array.Copy(buffer, (int)recodeModel.chapter_dyn_info_offset5, buffs, 0, buffs.Length);
            dynDataStruct = new ByteToStructEbk3().GetDynDataStruct(buffs);
            byte[] buffer5 = new byte[dynDataStruct.chapter_list_length];
            Array.Copy(buffer, (int)dynDataStruct.chapter_list_offset, buffer5, 0, buffer5.Length);
            chapterHeadModelStruct = new ByteToStructEbk3().GetChapterHeadModelStruct(buffer5);
            byte[] buff = new byte[buffer5.Length - 8];
            Array.Copy(buffer5, 8, buff, 0, buff.Length);
            this.mChapterList = this.GetChapterList((int)chapterHeadModelStruct.chapter_count, (int)chapterHeadModelStruct.chapter_name_header_length, buff, key);
            this.mChapterList = this.SortChapterList(this.mChapterList);
            BookInfo info = new BookInfo();

            info.BookName = recodeModel.name;
            info.Author   = recodeModel.author;
            for (int i = 0; i < this.mChapterList.Count; i++)
            {
                ChapterListModel model2 = this.mChapterList[i];
                if ((model2.chapter_data_type3 != 0) && (info.Text == ""))
                {
                    byte[] blockdata = new byte[buffer.Length - model2.chapter_data_block_offset4];
                    Array.Copy(buffer, (int)model2.chapter_data_block_offset4, blockdata, 0, blockdata.Length);
                    string chapter = this.Getchapter(blockdata, 1);
                    info.Text = chapter;
                }
            }
            byte[] bytes   = Encoding.Unicode.GetBytes(info.Text);
            int    num3    = 0;
            int    myindex = 0;

            for (int j = 0; j < this.mChapterList.Count; j++)
            {
                ChapterListModel model3 = this.mChapterList[j];
                if (model3.chapter_data_type3 == 1)
                {
                    if (num3 == 0)
                    {
                        BookItems items = new BookItems(model3.chapter_name_data8, 0, model3.chapter_name_data8.Length);
                        info.ChaterList.Add(items);
                    }
                    else
                    {
                        ChapterListModel model4 = this.mChapterList[j - 1];
                        int    num6             = (int)model4.chapter_content_decompresss_offset5;
                        int    num7             = (int)model4.chapter_content_decompress_length6;
                        byte[] buffer9          = new byte[num7];
                        Array.Copy(bytes, num6, buffer9, 0, num7);
                        string str2 = Encoding.Unicode.GetString(buffer9, 0, buffer9.Length);
                        myindex += str2.Replace("\r\n", "\n").Length;
                        BookItems items2 = new BookItems(model3.chapter_name_data8, myindex, model3.chapter_name_data8.Length);
                        info.ChaterList.Add(items2);
                    }
                    num3++;
                }
            }
            return(info);
        }