Ejemplo n.º 1
0
 public object ReadInstance(UnPackage package, BinaryReader reader, UnExport export)
 {
     reader.ReadInt32();
     int superIndex = reader.ReadInt32();
     reader.ReadInt32();
     int scriptTextIndex = reader.ReadInt32();
     for (int i = 0; i < 4; i++)
         reader.ReadInt32();
     int scriptSize = reader.ReadInt32();
     var bytecode = reader.ReadBytes(scriptSize);
     for (int i = 0; i < 4; i++)
         reader.ReadInt32();
     reader.ReadInt16();
     reader.ReadInt32();
     int methodCount = reader.ReadInt32();
     for (int i = 0; i < methodCount * 3; i++)
         reader.ReadInt32();
     int flags = reader.ReadInt32();
     reader.ReadByte();
     int outerIndex = reader.ReadInt32();
     var outerInstance = package.ResolveClassItem(outerIndex);
     var configNameIndex = reader.ReadInt64();
     var config = package.Names[(int) configNameIndex].Name;
     int hideCategoriesCount = reader.ReadInt32();
     var hideCategories = new List<string>();
     for (int i = 0; i < hideCategoriesCount; i++)
     {
         var nameIndex = reader.ReadInt64();
         var name = package.Names[(int) nameIndex].Name;
         hideCategories.Add(name);
     }
     int c3 = reader.ReadInt32();
     for (int i = 0; i < c3 * 3; i++)
         reader.ReadInt32();
     var interfaceCount = reader.ReadInt32();
     var interfaces = new List<UnPackageItem>();
     for(int i=0; i<interfaceCount; i++)
     {
         var intfIndex = reader.ReadInt32();
         reader.ReadInt32();
         interfaces.Add(package.ResolveClassItem(intfIndex));
     }
     reader.ReadInt32();
     int defaultPropertiesIndex = reader.ReadInt32();
     UnExport defaultProperties = defaultPropertiesIndex == 0
         ? null : package.ResolveClassItem(defaultPropertiesIndex).Resolve();
     return new UnClass(export, superIndex, outerInstance, bytecode, new FlagValues(flags, _flagSet), defaultProperties, config, hideCategories, interfaces);
 }
Ejemplo n.º 2
0
        public object ReadInstance(UnPackage package, BinaryReader reader, UnExport export)
        {
            reader.ReadInt32();
            int superIndex = reader.ReadInt32();

            reader.ReadInt32();
            int scriptTextIndex = reader.ReadInt32();

            for (int i = 0; i < 4; i++)
            {
                reader.ReadInt32();
            }
            int scriptSize = reader.ReadInt32();
            var bytecode   = reader.ReadBytes(scriptSize);

            for (int i = 0; i < 4; i++)
            {
                reader.ReadInt32();
            }
            reader.ReadInt16();
            reader.ReadInt32();
            int methodCount = reader.ReadInt32();

            for (int i = 0; i < methodCount * 3; i++)
            {
                reader.ReadInt32();
            }
            int flags = reader.ReadInt32();

            reader.ReadByte();
            int outerIndex          = reader.ReadInt32();
            var outerInstance       = package.ResolveClassItem(outerIndex);
            var configNameIndex     = reader.ReadInt64();
            var config              = package.Names[(int)configNameIndex].Name;
            int hideCategoriesCount = reader.ReadInt32();
            var hideCategories      = new List <string>();

            for (int i = 0; i < hideCategoriesCount; i++)
            {
                var nameIndex = reader.ReadInt64();
                var name      = package.Names[(int)nameIndex].Name;
                hideCategories.Add(name);
            }
            int c3 = reader.ReadInt32();

            for (int i = 0; i < c3 * 3; i++)
            {
                reader.ReadInt32();
            }
            var interfaceCount = reader.ReadInt32();
            var interfaces     = new List <UnPackageItem>();

            for (int i = 0; i < interfaceCount; i++)
            {
                var intfIndex = reader.ReadInt32();
                reader.ReadInt32();
                interfaces.Add(package.ResolveClassItem(intfIndex));
            }
            reader.ReadInt32();
            int      defaultPropertiesIndex = reader.ReadInt32();
            UnExport defaultProperties      = defaultPropertiesIndex == 0
                ? null : package.ResolveClassItem(defaultPropertiesIndex).Resolve();

            return(new UnClass(export, superIndex, outerInstance, bytecode, new FlagValues(flags, _flagSet), defaultProperties, config, hideCategories, interfaces));
        }
Ejemplo n.º 3
0
        private object ReadSingleValue(UnContainer owner, string name, string type)
        {
            if (type == "FloatProperty")
            {
                return(_reader.ReadSingle());
            }
            if (type == "BoolProperty")
            {
                return(_reader.ReadInt32() != 0);
            }
            if (type == "IntProperty")
            {
                return(_reader.ReadInt32());
            }
            if (type == "StrProperty")
            {
                var    valueLength = _reader.ReadInt32();
                object value;
                if (valueLength < 0)
                {
                    var s = _reader.ReadBytes(-2 * valueLength);
                    value = new string(Encoding.Unicode.GetChars(s));
                }
                else
                {
                    value = new string(_reader.ReadChars(valueLength));
                }
                return(((string)value).Trim('\0'));
            }
            if (type == "NameProperty")
            {
                var valueNameIndex = _reader.ReadInt64();
                return(_package.Names[(int)valueNameIndex].Name);
            }
            if (type == "ByteProperty")
            {
                var export      = owner.FindMemberExport(name);
                var declaration = (UnTypedClassProperty)export.ReadInstance();
                if (declaration.Type == null)
                {
                    return(_reader.ReadByte());
                }

                var valueNameIndex = _reader.ReadInt64();
                if (valueNameIndex < 0 || valueNameIndex >= _package.Names.Count)
                {
                    return(null);
                }
                return(_package.Names[(int)valueNameIndex].Name);
            }
            if (type == "ObjectProperty")
            {
                var export = owner.FindMemberExport(name);
                var index  = _reader.ReadInt32();
                if (index == 0)
                {
                    return("None");
                }
                var item = _package.ResolveClassItem(index);
                if (export.ClassName == "ClassProperty")
                {
                    return("class'" + item.ObjectName + "'");
                }
                return(item.ClassName + "'" + item.ObjectName + "'");
            }
            if (type == "ClassProperty")
            {
                var index = _reader.ReadInt32();
                if (index == 0)
                {
                    return("None");
                }
                var item = _package.ResolveClassItem(index);
                return("class'" + item.ObjectName + "'");
            }
            if (type == "ArrayProperty")
            {
                var export   = owner.FindMemberExport(name);
                var prop     = (UnArrayClassProperty)export.ReadInstance();
                var propType = prop.Type.Resolve();

                var count  = _reader.ReadInt32();
                var result = new UnPropertyArray(propType.ClassName);
                for (int i = 0; i < count; i++)
                {
                    var value = ReadSingleValue(owner, name, propType.ClassName);
                    if (value == null)
                    {
                        return(null);
                    }
                    result.Add(value);
                }
                return(result);
            }
            if (type == "DelegateProperty")
            {
                var v1        = _reader.ReadInt32();
                var nameIndex = _reader.ReadInt64();
                return(_package.Names[(int)nameIndex].Name);
            }
            return(null);
        }