Ejemplo n.º 1
0
        internal void WriteTo(byte[] mainStream, int offset, HWPFStream tableStream)
        {
            int length = _fields.Length / 2;

            LittleEndian.PutShort(mainStream, offset, (short)length);
            offset += LittleEndianConsts.SHORT_SIZE;

            for (int x = 0; x < length; x++)
            {
                UnhandledDataStructure ds = (UnhandledDataStructure)_unknownMap[x];
                if (ds != null)
                {
                    LittleEndian.PutInt(mainStream, offset, tableStream.Offset);
                    offset += LittleEndianConsts.INT_SIZE;
                    byte[] buf = ds.GetBuf();
                    tableStream.Write(buf);
                    LittleEndian.PutInt(mainStream, offset, buf.Length);
                    offset += LittleEndianConsts.INT_SIZE;
                }
                else
                {
                    LittleEndian.PutInt(mainStream, offset, _fields[x * 2]);
                    offset += LittleEndianConsts.INT_SIZE;
                    LittleEndian.PutInt(mainStream, offset, _fields[(x * 2) + 1]);
                    offset += LittleEndianConsts.INT_SIZE;
                }
            }
        }
Ejemplo n.º 2
0
        public FIBFieldHandler(byte[] mainStream, int offset, byte[] tableStream,
                               List <int> offsetList, bool areKnown)
        {
            int numFields = LittleEndian.GetShort(mainStream, offset);

            offset += LittleEndianConsts.SHORT_SIZE;
            _fields = new int[numFields * 2];

            for (int x = 0; x < numFields; x++)
            {
                int fieldOffset = (x * FIELD_SIZE) + offset;
                int dsOffset    = LittleEndian.GetInt(mainStream, fieldOffset);
                fieldOffset += LittleEndianConsts.INT_SIZE;
                int dsSize = LittleEndian.GetInt(mainStream, fieldOffset);

                if (offsetList.Contains(x) ^ areKnown)
                {
                    if (dsSize > 0)
                    {
                        if (dsOffset + dsSize > tableStream.Length)
                        {
                            //log.log(POILogger.WARN, "Unhandled data structure points to outside the buffer. " +
                            //                        "offset = " + dsOffset + ", length = " + dsSize +
                            //                        ", buffer length = " + tableStream.Length);
                        }
                        else
                        {
                            UnhandledDataStructure unhandled = new UnhandledDataStructure(
                                tableStream, dsOffset, dsSize);
                            _unknownMap.Add(x, unhandled);
                        }
                    }
                }
                _fields[x * 2]       = dsOffset;
                _fields[(x * 2) + 1] = dsSize;
            }
        }
Ejemplo n.º 3
0
        public FIBFieldHandler(byte[] mainStream, int offset, byte[] tableStream,
                               List<int> offsetList, bool areKnown)
        {
            int numFields = LittleEndian.GetShort(mainStream, offset);
            offset += LittleEndianConsts.SHORT_SIZE;
            _fields = new int[numFields * 2];

            for (int x = 0; x < numFields; x++)
            {
                int fieldOffset = (x * FIELD_SIZE) + offset;
                int dsOffset = LittleEndian.GetInt(mainStream, fieldOffset);
                fieldOffset += LittleEndianConsts.INT_SIZE;
                int dsSize = LittleEndian.GetInt(mainStream, fieldOffset);

                if (offsetList.Contains(x) ^ areKnown)
                {
                    if (dsSize > 0)
                    {
                        if (dsOffset + dsSize > tableStream.Length)
                        {
                            //log.log(POILogger.WARN, "Unhandled data structure points to outside the buffer. " +
                            //                        "offset = " + dsOffset + ", length = " + dsSize +
                            //                        ", buffer length = " + tableStream.Length);
                        }
                        else
                        {
                            UnhandledDataStructure unhandled = new UnhandledDataStructure(
                              tableStream, dsOffset, dsSize);
                            _unknownMap.Add(x, unhandled);
                        }
                    }
                }
                _fields[x * 2] = dsOffset;
                _fields[(x * 2) + 1] = dsSize;
            }
        }