public EBK3HeadStruct GetHeadStruct(byte[] buffs) { EBK3HeadStruct struct2 = new EBK3HeadStruct(); int offset = 0; struct2.identifier = GetBytes(4, ref offset, buffs); struct2.header_key = (uint)GetInt32(4, ref offset, buffs); struct2.header_length = (uint)GetInt32(4, ref offset, buffs); struct2.decode_key = (uint)GetInt32(4, ref offset, buffs); return(struct2); }
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); }
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); }