public static CodeSectionInfo Parse(byte[] data, bool cryptEc = false) { var codeSectionInfo = new CodeSectionInfo(); using (var reader = new BinaryReader(new MemoryStream(data, false))) { codeSectionInfo.AllocatedIdNum = reader.ReadInt32(); reader.ReadInt32(); //确认于易语言V5.71 codeSectionInfo.UnknownBeforeLibrary_1 = reader.ReadBytesWithLengthPrefix(); //Unknown if (cryptEc) { reader.ReadInt32(); reader.ReadInt32(); codeSectionInfo.UnknownBeforeLibrary_2 = reader.ReadBytesWithLengthPrefix();//Unknown codeSectionInfo.Flag = reader.ReadInt32(); codeSectionInfo.MainMethod = reader.ReadInt32(); codeSectionInfo.Libraries = LibraryInfo.ReadLibraries(reader); codeSectionInfo.UnknownBeforeLibrary_3 = reader.ReadBytesWithLengthPrefix();//Unknown } else { codeSectionInfo.UnknownBeforeLibrary_2 = reader.ReadBytesWithLengthPrefix(); //Unknown codeSectionInfo.UnknownBeforeLibrary_3 = reader.ReadBytesWithLengthPrefix(); //Unknown codeSectionInfo.Libraries = LibraryInfo.ReadLibraries(reader); codeSectionInfo.Flag = reader.ReadInt32(); codeSectionInfo.MainMethod = reader.ReadInt32(); } ; if ((codeSectionInfo.Flag & 1) != 0) { codeSectionInfo.UnknownBeforeIconData = reader.ReadBytes(16);//Unknown } codeSectionInfo.IconData = reader.ReadBytesWithLengthPrefix(); codeSectionInfo.DebugCommandParameters = reader.ReadStringWithLengthPrefix(); if (cryptEc) { reader.ReadBytes(12); codeSectionInfo.Methods = MethodInfo.ReadMethods(reader); codeSectionInfo.DllDeclares = DllDeclareInfo.ReadDllDeclares(reader); codeSectionInfo.GlobalVariables = VariableInfo.ReadVariables(reader); codeSectionInfo.Classes = ClassInfo.ReadClasses(reader); codeSectionInfo.Structs = StructInfo.ReadStructs(reader); } else { codeSectionInfo.Classes = ClassInfo.ReadClasses(reader); codeSectionInfo.Methods = MethodInfo.ReadMethods(reader); codeSectionInfo.GlobalVariables = VariableInfo.ReadVariables(reader); codeSectionInfo.Structs = StructInfo.ReadStructs(reader); codeSectionInfo.DllDeclares = DllDeclareInfo.ReadDllDeclares(reader); } } return(codeSectionInfo); }
private void WriteTo(BinaryWriter writer) { writer.Write(AllocatedIdNum); writer.Write(51113791);//确认于易语言V5.71 writer.WriteBytesWithLengthPrefix(UnknownBeforeLibrary_1); writer.WriteBytesWithLengthPrefix(UnknownBeforeLibrary_2); writer.WriteBytesWithLengthPrefix(UnknownBeforeLibrary_3); LibraryInfo.WriteLibraries(writer, Libraries); writer.Write(Flag); writer.Write(MainMethod); if (UnknownBeforeIconData != null) { writer.WriteBytesWithLengthPrefix(UnknownBeforeIconData); } writer.WriteBytesWithLengthPrefix(IconData); writer.WriteStringWithLengthPrefix(DebugCommandParameters); ClassInfo.WriteClasses(writer, Classes); MethodInfo.WriteMethods(writer, Methods); VariableInfo.WriteVariables(writer, GlobalVariables); StructInfo.WriteStructs(writer, Structs); DllDeclareInfo.WriteDllDeclares(writer, DllDeclares); writer.Write(new byte[40]);//Unknown(40个0) }