Exemplo n.º 1
0
        private List <BulkDataInfo> ReadExportBlocks(UpkObject upk)
        {
            var rawDataStart = upk.DataOffset + upk.AttributeOffset + 20;

            var blockOffset    = BitConverter.ToInt32(Data, rawDataStart);
            var numberOfBlocks = BitConverter.ToInt32(Data, blockOffset);
            var bulkdata       = new List <BulkDataInfo>();
            var bulkoffset     = blockOffset + 4;

            for (var i = 0; i < numberOfBlocks; i++)
            {
                var newBulk = new BulkDataInfo
                {
                    Format           = BitConverter.ToInt32(Data, bulkoffset),
                    UncompressedSize = BitConverter.ToInt32(Data, bulkoffset + 4),
                    CompressedSize   = BitConverter.ToInt32(Data, bulkoffset + 8),
                    OffsetToData     = BitConverter.ToInt32(Data, bulkoffset + 12)
                };

                if (newBulk.Format == 16 || newBulk.Format == 0)
                {
                    bulkoffset             = newBulk.OffsetToData + newBulk.CompressedSize;
                    newBulk.Width          = BitConverter.ToInt32(Data, bulkoffset + 0);
                    newBulk.Height         = BitConverter.ToInt32(Data, bulkoffset + 4);
                    newBulk.CompressedData = new byte[newBulk.CompressedSize];
                    Array.Copy(Data, newBulk.OffsetToData, newBulk.CompressedData, 0, newBulk.CompressedSize);
                    bulkoffset += 8;
                }
                else
                {
                    newBulk.Width  = BitConverter.ToInt32(Data, bulkoffset + 16);
                    newBulk.Height = BitConverter.ToInt32(Data, bulkoffset + 20);
                    bulkoffset    += 24;
                }

                bulkdata.Add(newBulk);
            }
            return(bulkdata);
        }
Exemplo n.º 2
0
        private Dictionary <string, int> ReadExportAttributes(UpkObject upk)
        {
            var result          = new Dictionary <string, int>();
            var attributeOffset = 4;
            var attrName        = "";

            while (attrName != "SourceFileTimestamp" && attrName != "None")
            {
                attrName = Names[BitConverter.ToInt32(Data, upk.DataOffset + attributeOffset)];
                // var attrType = Names[BitConverter.ToInt32(Data, upk.dataOffset + attributeOffset + 8)];
                var attrLength = BitConverter.ToInt32(Data, upk.DataOffset + attributeOffset + 16);
                var attrValue  = BitConverter.ToInt32(Data, upk.DataOffset + attributeOffset + 24);
                result[attrName] = attrValue;
                attributeOffset += 24;
                attributeOffset += attrLength;
                if (attrLength == 0)
                {
                    attributeOffset += 4;
                }
            }
            upk.AttributeOffset = attributeOffset;
            return(result);
        }