Exemplo n.º 1
0
        public object[] infomodelarray(EBK3HeadInfoModel infomodel)
        {
            object[]          objArray = new object[infomodel.modellenth];
            EBK3HeadByteModel model    = new EBK3HeadByteModel {
                bytemin_version1 = BitConverter.GetBytes(infomodel.min_version1)
            };

            objArray[0] = model.bytemin_version1;
            model.byteunique_identifier2 = Encoding.Unicode.GetBytes(infomodel.unique_identifier2);
            objArray[1] = model.byteunique_identifier2;
            model.bytebook_file_type3 = BitConverter.GetBytes(infomodel.book_file_type3);
            objArray[2] = model.bytebook_file_type3;
            model.bytechapter_list_offset4 = BitConverter.GetBytes(infomodel.chapter_list_offset4);
            objArray[3] = model.bytechapter_list_offset4;
            model.bytechapter_dyn_info_offset5 = BitConverter.GetBytes(infomodel.chapter_dyn_info_offset5);
            objArray[4] = model.bytechapter_dyn_info_offset5;
            model.bytecover_data_offset6 = BitConverter.GetBytes(infomodel.cover_data_offset6);
            objArray[5]                = model.bytecover_data_offset6;
            model.bytecreator7         = Encoding.Unicode.GetBytes(infomodel.creator7);
            objArray[6]                = model.bytecreator7;
            model.bytecreate_timer8    = Encoding.Unicode.GetBytes(infomodel.create_timer8);
            objArray[7]                = model.bytecreate_timer8;
            model.bytename9            = Encoding.Unicode.GetBytes(infomodel.name);
            objArray[8]                = model.bytename9;
            model.byteauthor10         = Encoding.Unicode.GetBytes(infomodel.author);
            objArray[9]                = model.byteauthor10;
            model.bytesubject11        = Encoding.Unicode.GetBytes(infomodel.subject);
            objArray[10]               = model.bytesubject11;
            model.bytepublisher12      = Encoding.Unicode.GetBytes(infomodel.publisher);
            objArray[11]               = model.bytepublisher12;
            model.byteisbn13           = Encoding.Unicode.GetBytes(infomodel.isbn13);
            objArray[12]               = model.byteisbn13;
            model.bytefile_size14      = BitConverter.GetBytes(infomodel.file_size14);
            objArray[13]               = model.bytefile_size14;
            model.byterevise_version16 = BitConverter.GetBytes(infomodel.revise_version16);
            objArray[14]               = model.byterevise_version16;
            return(objArray);
        }
Exemplo n.º 2
0
        public byte[] GetEbk3HeadData(EBK3HeadInfoModel infomodel, uint time)
        {
            EBK3HeadStruct struct2 = new EBK3HeadStruct();

            new Model();
            GetEbk3HeadArray array = new GetEbk3HeadArray();
            Ebk3_Data        data  = new Ebk3_Data();

            byte[] buffer = new byte[4];
            Encoding.UTF8.GetBytes("EBK3").CopyTo(buffer, 0);
            struct2.identifier = buffer;
            struct2.header_key = 0;
            struct2.decode_key = time;
            object[] infomodellist = array.infomodelarray(infomodel);
            byte[]   recodeByte    = this.GetRecodeByte(infomodellist);
            byte[]   buffer3       = data.pbk_sys_data_encode(recodeByte, (int)struct2.decode_key);
            struct2.header_length = (uint)(0x10 + recodeByte.Length);
            byte[] buffer4 = new byte[struct2.header_length];
            byte[] buffer5 = Ebk3Make.StrucTObytes(struct2);
            Array.Copy(buffer5, 0, buffer4, 0, buffer5.Length);
            Array.Copy(buffer3, 0, buffer4, buffer5.Length, buffer3.Length);
            return(buffer4);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public static EBK3HeadInfoModel GetRecodeModel(byte[] allbuffer, int count)
        {
            byte[] buffer  = new byte[allbuffer.Length - 4];
            byte[] buffer2 = new byte[4];
            Array.Copy(allbuffer, 0, buffer2, 0, 4);
            BitConverter.ToUInt32(buffer2, 0);
            Array.Copy(allbuffer, 4, buffer, 0, buffer.Length);
            EBK3HeadInfoModel model = new EBK3HeadInfoModel();
            int num = 0;

            for (int i = 0; i < count; i++)
            {
                byte[] buffer3 = new byte[4];
                byte[] buffer4 = new byte[4];
                Array.Copy(buffer, num, buffer3, 0, buffer3.Length);
                uint num3 = BitConverter.ToUInt32(buffer3, 0);
                Array.Copy(buffer, num + 4, buffer4, 0, buffer4.Length);
                uint   num4    = BitConverter.ToUInt32(buffer4, 0);
                byte[] buffer5 = new byte[num4 - 8];
                Array.Copy(buffer, num + 8, buffer5, 0, buffer5.Length);
                num += (int)num4;
                switch (num3)
                {
                case 1:
                    model.min_version1 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 2:
                    model.unique_identifier2 = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 3:
                    model.book_file_type3 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 4:
                    model.chapter_list_offset4 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 5:
                    model.chapter_dyn_info_offset5 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 6:
                    model.cover_data_offset6 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 7:
                    model.creator7 = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 8:
                    model.create_timer8 = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 9:
                    model.name = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 10:
                    model.author = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 11:
                    model.subject = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 12:
                    model.publisher = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 13:
                    model.isbn13 = Encoding.Unicode.GetString(buffer5, 0, buffer5.Length);
                    break;

                case 14:
                    model.file_size14 = BitConverter.ToUInt32(buffer5, 0);
                    break;

                case 15:
                    model.revise_version16 = BitConverter.ToUInt32(buffer5, 0);
                    break;
                }
            }
            return(model);
        }