コード例 #1
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);
        }
コード例 #2
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);
        }