コード例 #1
0
            public void Read(XmbFile xmb, XmbFileContext xmbContext, IO.EndianReader s)
            {
                s.Read(out RootElementIndex);
                XmbVariantSerialization.Read(s, out NameVariant);
                XmbVariantSerialization.Read(s, out InnerTextVariant);
                if (xmbContext.PointerSize == Shell.ProcessorSize.x64)
                {
                    s.Pad32();
                }

                #region Attributes header
                int count;
                s.Read(out count);
                if (xmbContext.PointerSize == Shell.ProcessorSize.x64)
                {
                    s.Pad32();
                }
                s.ReadVirtualAddress(out mAttributesOffset);
                Attributes = new List <KeyValuePair <XmbVariant, XmbVariant> >(count);
                #endregion

                #region Children header
                s.Read(out count);
                if (xmbContext.PointerSize == Shell.ProcessorSize.x64)
                {
                    s.Pad32();
                }
                s.ReadVirtualAddress(out mChildrenOffset);
                ChildrenIndices = new List <int>(count);
                #endregion

                if (NameVariant.HasUnicodeData || InnerTextVariant.HasUnicodeData)
                {
                    xmb.mHasUnicodeStrings = true;
                }
            }
コード例 #2
0
        public void Read(IO.EndianReader s)
        {
            var context = s.UserData as XmbFileContext;

            using (s.ReadSignatureWithByteSwapSupport(kSignature))
            {
                if (context.PointerSize == Shell.ProcessorSize.x64)
                {
                    // #HACK to deal with xmb files which weren't updated with new tools
                    if (s.ByteOrder == Shell.EndianFormat.Big)
                    {
                        context.PointerSize = Shell.ProcessorSize.x32;
                    }
                }

                s.VirtualAddressTranslationInitialize(context.PointerSize);

                Values.PtrHandle elements_offset_pos;

                if (context.PointerSize == Shell.ProcessorSize.x64)
                {
                    s.Pad32();
                }
                #region Initialize elements
                {
                    int count = s.ReadInt32();
                    if (context.PointerSize == Shell.ProcessorSize.x64)
                    {
                        s.Pad32();
                    }
                    s.ReadVirtualAddress(out elements_offset_pos);

                    mElements = new List <Element>(count);
                }
                #endregion
                #region Initialize and read pool
                {
                    int size = s.ReadInt32();
                    if (context.PointerSize == Shell.ProcessorSize.x64)
                    {
                        s.Pad32();
                    }
                    Values.PtrHandle pool_offset_pos = s.ReadVirtualAddress();

                    s.Seek((long)pool_offset_pos);
                    byte[] buffer = s.ReadBytes(size);

                    mPool = new XmbVariantMemoryPool(buffer, s.ByteOrder);
                }
                #endregion

                if (context.PointerSize == Shell.ProcessorSize.x64)
                {
                    s.Pad64();
                }

                s.Seek((long)elements_offset_pos);
                for (int x = 0; x < mElements.Capacity; x++)
                {
                    var e = new Element();
                    mElements.Add(e);

                    e.Index = x;
                    e.Read(this, context, s);
                }

                foreach (var e in mElements)
                {
                    e.ReadAttributes(this, s);
                    e.ReadChildren(s);
                }
            }
        }