Esempio n. 1
0
        public static DllDeclareInfo[] ReadDllDeclares(BinaryReader reader)
        {
            var headerSize       = reader.ReadInt32();
            int count            = headerSize / 8;
            var ids              = reader.ReadInt32sWithFixedLength(count);
            var unknownsAfterIds = reader.ReadInt32sWithFixedLength(count);
            var dllDeclares      = new DllDeclareInfo[count];

            for (int i = 0; i < count; i++)
            {
                var dllDeclareInfo = new DllDeclareInfo(ids[i])
                {
                    UnknownAfterId = unknownsAfterIds[i],
                    Flags          = reader.ReadInt32(),
                    ReturnDataType = reader.ReadInt32(),
                    Name           = reader.ReadStringWithLengthPrefix(),
                    Comment        = reader.ReadStringWithLengthPrefix(),
                    LibraryFile    = reader.ReadStringWithLengthPrefix(),
                    NameInLibrary  = reader.ReadStringWithLengthPrefix(),
                    Parameters     = VariableInfo.ReadVariables(reader)
                };
                dllDeclares[i] = dllDeclareInfo;
            }

            return(dllDeclares);
        }
Esempio n. 2
0
        public static CodeSectionInfo Parse(byte[] data, Encoding encoding, bool cryptEc = false)
        {
            var codeSectionInfo = new CodeSectionInfo();

            int[]   minRequiredCmds;
            short[] minRequiredDataTypes;
            short[] minRequiredConstants;
            using (var reader = new BinaryReader(new MemoryStream(data, false), encoding))
            {
                codeSectionInfo.allocatedIdNum = reader.ReadInt32();
                reader.ReadInt32(); // 确认于易语言V5.71
                minRequiredCmds = reader.ReadInt32sWithByteSizePrefix();
                if (cryptEc)
                {
                    reader.ReadInt32();
                    reader.ReadInt32();
                    minRequiredDataTypes       = reader.ReadInt16sWithByteSizePrefix();
                    codeSectionInfo.Flag       = reader.ReadInt32();
                    codeSectionInfo.MainMethod = reader.ReadInt32();
                    codeSectionInfo.Libraries  = LibraryRefInfo.ReadLibraries(reader, encoding);
                    minRequiredConstants       = reader.ReadInt16sWithByteSizePrefix();
                }
                else
                {
                    minRequiredDataTypes       = reader.ReadInt16sWithByteSizePrefix();
                    minRequiredConstants       = reader.ReadInt16sWithByteSizePrefix();
                    codeSectionInfo.Libraries  = LibraryRefInfo.ReadLibraries(reader, encoding);
                    codeSectionInfo.Flag       = reader.ReadInt32();
                    codeSectionInfo.MainMethod = reader.ReadInt32();
                }
                LibraryRefInfo.ApplyCompatibilityInfo(codeSectionInfo.Libraries, minRequiredCmds, minRequiredDataTypes, minRequiredConstants);
                if ((codeSectionInfo.Flag & 1) != 0)
                {
                    codeSectionInfo.UnknownBeforeIconData = reader.ReadBytes(16); // Unknown
                }
                codeSectionInfo.IconData = reader.ReadBytesWithLengthPrefix();
                codeSectionInfo.DebugCommandParameters = reader.ReadStringWithLengthPrefix(encoding);
                if (cryptEc)
                {
                    reader.ReadBytes(12);
                    codeSectionInfo.Methods         = MethodInfo.ReadMethods(reader, encoding);
                    codeSectionInfo.DllDeclares     = DllDeclareInfo.ReadDllDeclares(reader, encoding);
                    codeSectionInfo.GlobalVariables = AbstractVariableInfo.ReadVariables(reader, encoding, x => new GlobalVariableInfo(x));
                    codeSectionInfo.Classes         = ClassInfo.ReadClasses(reader, encoding);
                    codeSectionInfo.Structs         = StructInfo.ReadStructs(reader, encoding);
                }
                else
                {
                    codeSectionInfo.Classes         = ClassInfo.ReadClasses(reader, encoding);
                    codeSectionInfo.Methods         = MethodInfo.ReadMethods(reader, encoding);
                    codeSectionInfo.GlobalVariables = AbstractVariableInfo.ReadVariables(reader, encoding, x => new GlobalVariableInfo(x));
                    codeSectionInfo.Structs         = StructInfo.ReadStructs(reader, encoding);
                    codeSectionInfo.DllDeclares     = DllDeclareInfo.ReadDllDeclares(reader, encoding);
                }
            }
            return(codeSectionInfo);
        }
Esempio n. 3
0
        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              = LibraryRefInfo.ReadLibraries(reader);
                    codeSectionInfo.UnknownBeforeLibrary_3 = reader.ReadBytesWithLengthPrefix();//Unknown
                }
                else
                {
                    codeSectionInfo.UnknownBeforeLibrary_2 = reader.ReadBytesWithLengthPrefix(); //Unknown
                    codeSectionInfo.UnknownBeforeLibrary_3 = reader.ReadBytesWithLengthPrefix(); //Unknown
                    codeSectionInfo.Libraries  = LibraryRefInfo.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 = AbstractVariableInfo.ReadVariables(reader, x => new GlobalVariableInfo(x));
                    codeSectionInfo.Classes         = ClassInfo.ReadClasses(reader);
                    codeSectionInfo.Structs         = StructInfo.ReadStructs(reader);
                }
                else
                {
                    codeSectionInfo.Classes         = ClassInfo.ReadClasses(reader);
                    codeSectionInfo.Methods         = MethodInfo.ReadMethods(reader);
                    codeSectionInfo.GlobalVariables = AbstractVariableInfo.ReadVariables(reader, x => new GlobalVariableInfo(x));
                    codeSectionInfo.Structs         = StructInfo.ReadStructs(reader);
                    codeSectionInfo.DllDeclares     = DllDeclareInfo.ReadDllDeclares(reader);
                }
            }
            return(codeSectionInfo);
        }
Esempio n. 4
0
 private void WriteTo(BinaryWriter writer, Encoding encoding)
 {
     writer.Write(allocatedIdNum);
     writer.Write(51113791); // 确认于易语言V5.71
     LibraryRefInfo.WriteLibraries(writer, encoding, Libraries);
     writer.Write(Flag);
     writer.Write(MainMethod);
     if (UnknownBeforeIconData != null)
     {
         writer.WriteBytesWithLengthPrefix(UnknownBeforeIconData);
     }
     writer.WriteBytesWithLengthPrefix(IconData);
     writer.WriteStringWithLengthPrefix(encoding, DebugCommandParameters);
     ClassInfo.WriteClasses(writer, encoding, Classes);
     MethodInfo.WriteMethods(writer, encoding, Methods);
     AbstractVariableInfo.WriteVariables(writer, encoding, GlobalVariables);
     StructInfo.WriteStructs(writer, encoding, Structs);
     DllDeclareInfo.WriteDllDeclares(writer, encoding, DllDeclares);
     writer.Write(new byte[40]); // Unknown(40个0)
 }
Esempio n. 5
0
 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)
 }