Пример #1
0
 public static bool IsPicture(IDataStream stream)
 {
     stream.Open();
     bool res = IsJpeg(stream) || IsPng(stream) || IsBmp(stream) || IsGif(stream) || IsTif(stream);
     stream.Close();
     return res;
 }
Пример #2
0
 public void View(IDataStream stream)
 {
     foreach (PictureControl old in flowLayoutPanel1.Controls) {
         old.Dispose();
     }
     flowLayoutPanel1.Controls.Clear();
     m_Folder = stream as Folder;
     if (m_Folder != null) {
         PictureControl previous = null;
         PictureControl first = null;
         foreach (FileSystemNode f in m_Folder.GetChildren()) {
             if (f is File && FileTypes.IsPicture(f)) {
                 PictureControl control = new PictureControl();
                 flowLayoutPanel1.Controls.Add(control);
                 control.SetDataStream(f);
                 if (previous != null) {
                     previous.SetNextPictureControl(control);
                 }
                 previous = control;
                 if (first == null) {
                     first = control;
                 }
             }
         }
         if (first != null) {
             first.ViewDataStream();
         }
     }
 }
Пример #3
0
 public TextSearchResult(IDataStream stream, ulong location, ulong length, String name)
 {
     Name = name;
     m_stream = stream;
     m_location = location;
     m_length = length;
 }
Пример #4
0
        private void btnFindAll_Click(object sender, EventArgs e)
        {
            stream = hierarchy.First(x => x.StreamName.Equals(comboBox1.Text));
            Find(stream, true);

            //ulong result = new
        }
Пример #5
0
 public void SetDataStream(IDataStream stream)
 {
     m_Stream = stream;
     if (m_Stream is FileSystemNode) {
         lCaption.Text = ((FileSystemNode)m_Stream).Name;
     }
 }
Пример #6
0
        private void Find(IDataStream stream, bool findAll)
        {
            CaseForm.Instance.ActiveCase.LogAction(String.Format("Finding text/hex string {0} in {1}", textBoxSearchTerm.Text, stream.StreamName), ActionType.StreamViewed);

            finder = new Thread(delegate() {
                try {
                    this.Invoke(new Action(delegate() {
                        btnCancel.Enabled = true;
                        btnFind.Enabled = false;
                        btnFindAll.Enabled = false;
                    }));
                    if (findAll) {
                        List<ulong> results = new List<ulong>();
                        ulong result = FindNextResult();
                        while (result != ulong.MaxValue) {
                            results.Add(result);
                            result = FindNextResult();
                        }
                        FoundAll(results);
                        this.Invoke(new Action(delegate() {
                            this.Dispose();
                        }));
                    } else {
                        ulong result = FindNextResult();
                        FoundOne(result);
                        this.Invoke(new Action(delegate() {
                            btnCancel.Enabled = false;
                            btnFind.Enabled = true;
                            btnFindAll.Enabled = true;
                        }));
                    }
                } catch (ThreadAbortException) { }
            });
            finder.Start();
        }
Пример #7
0
        public void View(IDataStream stream)
        {
            if (stream != m_CurrentStream) {
                m_CurrentStream = stream;
                lvHistory.Items.Clear();
                if (stream is IFileSystemStore) {
                    fileSystem = (stream as IFileSystemStore).FS;
                    if (fileSystem != null) {
                        // set up Explorer
                        ListViewItem explorerGroup = new ListViewItem(new string[] { "Windows Explorer/IE", "", "" });
                        explorerGroup.Font = new Font(explorerGroup.Font, FontStyle.Bold);
                        lvHistory.Items.Add(explorerGroup);

                        foreach (ExplorerHistoryFile file in History.GetExplorerHistoryFiles(fileSystem)) {
                            ListViewItem fileItem = new ListViewItem(new string[] { file.Path, "", "" });
                            fileItem.Tag = file.Stream;
                            lvHistory.Items.Add(fileItem);
                            foreach (ExplorerHistoryRecord record in file.GetRecords()) {
                                ListViewItem recordItem = new ListViewItem(
                                    new string[] {  record.Description,
                                            record.LastAccessed.ToString(),
                                            record.LastModified.ToString() });
                                recordItem.Tag = record;
                                lvHistory.Items.Add(recordItem);
                            }
                        }

                        // set up Firefox (TODO in future)
                        //ListViewItem firefoxGroup = new ListViewItem(new string[] { "Firefox", "", "" });
                        //firefoxGroup.Font = new Font(firefoxGroup.Font, FontStyle.Bold);
                        //lvHistory.Items.Add(firefoxGroup);
                    }
                }
            }
        }
			public IndexBuffer(IDataStream stream, ulong vcn, FolderNTFS folder) {
				_folder = folder;
				_clusterStart = vcn * (ulong)(_folder._record.SectorsPerCluster * _folder._record.BytesPerSector);
				String magic = Util.GetASCIIString(stream, _clusterStart + 0x0, 4);

				if (!magic.Equals("INDX")) {
					throw new Exception("Magic INDX value not present");
				}

				_entriesStart = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x18) + 0x18);
				_entriesEnd = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x1c) + _entriesStart);

				ushort updateSequenceOffset = Util.GetUInt16(stream, _clusterStart + 0x04);
				ushort updateSequenceLength = Util.GetUInt16(stream, _clusterStart + 0x06);

				ushort updateSequenceNumber = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset);
				ushort[] updateSequenceArray = new ushort[updateSequenceLength - 1];
				ushort read = 1;
				while (read < updateSequenceLength) {
					updateSequenceArray[read - 1] = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset + (ushort)(read * 2));
					read++;
				}

				_stream = new FixupStream(stream, _clusterStart, _entriesEnd, updateSequenceNumber, updateSequenceArray, (ulong)folder.BytesPerSector);

				if (_entriesEnd == _entriesStart) {
					throw new Exception("Entry size was 0");
				}
			}
Пример #9
0
 public RegistryKey(IDataStream stream, ulong offset)
 {
     m_Stream = stream;
     m_blockOffset = offset;
     m_keyBlock = LoadBlock(stream, offset);
     Name = m_keyBlock.name;
 }
		public FixupStream(IDataStream stream, ulong start, ulong length,
						ushort updateSequenceNumber, ushort[] updateSequenceArray, ulong sectorSize)
			: base(stream, start, length) {
			_number = updateSequenceNumber;
			_array = updateSequenceArray;
			_sectorSize = sectorSize;
		}
Пример #11
0
 public bool CanView(IDataStream stream)
 {
     stream.Open();
     bool res = stream.StreamLength < 100 * 1024 // Don't bother with files over 100K
         && IsHtml(stream);
     stream.Close();
     return res;
 }
Пример #12
0
 public RegistryHive(File file)
 {
     m_stream = file;
     try {
         m_root = new RegistryKey(m_stream);
     } catch {
         throw new Exception("Not a valid hive");
     }
 }
Пример #13
0
        public void View(IDataStream stream)
        {
            if (stream != null) {
                m_dataStream = stream;

                updateScroll();
                update(0);
            }
        }
Пример #14
0
 public static ulong FindHexString(IDataStream stream, String searchString, ulong start, ProgressCallback callback)
 {
     searchString = searchString.Replace(" ", "");
     Byte[] search = new Byte[searchString.Length / 2];
     for (int i = 0; i < search.Length; i++) {
         search[i] = Byte.Parse(searchString.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
     }
     return FindBytes(stream, search, start, callback);
 }
Пример #15
0
 public static ulong[] simpleFindAll(IDataStream stream, byte[] search)
 {
     List<ulong> all = new List<ulong>();
     ulong l = SimpleFind(stream, search, 0, null);
     while (l != UInt64.MaxValue) {
         all.Add(l);
         l = SimpleFind(stream, search, l, null);
     }
     return all.ToArray();
 }
Пример #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicEventStream"/> class.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="separator">The separator.</param>
        public BasicEventStream(IDataStream dataStream, string separator)
        {
            _dataStream = dataStream;
            _separator = separator;

            _contextGenerator = new BasicContextGenerator(_separator);
            if (_dataStream.HasNext())
            {
                _nextEvent = CreateEvent((string)_dataStream.NextToken());
            }
        }
Пример #17
0
        public void View(IDataStream stream)
        {
            if (stream != m_CurrentStream) {
                m_CurrentStream = stream;
                if (((IFileSystemStore)stream).FS != null) {
                    m_EventStore = new TimelineEventStore(((IFileSystemStore)stream).FS);
                }

                UpdateGUI();
            }
        }
Пример #18
0
 internal void SaveSecondPart(IDataStream DataStream, TSaveData SaveData)
 {
     InterfaceHdr.SaveToStream(DataStream, SaveData, 0);
     if (WriteAccess != null)
     {
         WriteAccess.SaveToStream(DataStream, SaveData, 0);
     }
     if (FileSharing != null)
     {
         FileSharing.SaveToStream(DataStream, SaveData, 0);
     }
 }
Пример #19
0
        public TextSearchForm(IDataStream stream)
        {
            InitializeComponent();
            m_pos = 0;

            hierarchy = CaseForm.Instance.GetStreamHeirachy();
            foreach(IDataStream s in hierarchy) {
                comboBox1.Items.Add(s.StreamName);
            }
            comboBox1.Text = comboBox1.Items[0].ToString();
            this.Text = "Text Search";
        }
Пример #20
0
        public static SortedMap <TKey, TValue> ToSortedMap <TKey, TValue>(
            this IDataStream <TKey, TValue> dataStream)
        {
            var sm = new SortedMap <TKey, TValue>(dataStream.Comparer);

            foreach (var keyValuePair in dataStream)
            {
                sm.AddLast(keyValuePair.Key, keyValuePair.Value);
            }

            return(sm);
        }
Пример #21
0
 internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row)
 {
     Workbook.WriteHeader((UInt16)Id, (UInt16)CalcBiff8Len());
     SaveBiff8Data(Workbook, true);
     if (Hint != null)
     {
         Hint.FirstRow = FirstRow;
         Hint.FirstCol = FirstCol;
         Hint.LastRow  = LastRow;
         Hint.LastCol  = LastCol;
         Hint.SaveToStream(Workbook, SaveData, Row);
     }
 }
Пример #22
0
        public virtual void SaveToStream(IDataStream DataStream, TSaveData SaveData, int Row)
        {
            int aCount = FList.Count;

            for (int i = 0; i < aCount; i++)
            {
                T it = (T)FList[i];
                if (it != null)
                {
                    it.SaveToStream(DataStream, SaveData, Row);
                }
            }
        }
Пример #23
0
 internal void SaveTabIds(IDataStream DataStream)
 {
     CheckTabId();
     if (FTabList.Count > XlsConsts.MaxTabIdCount || FTabList.Count != FBoundSheets.Count)
     {
         return;
     }
     DataStream.WriteHeader((UInt16)xlr.TABID, (UInt16)(2 * FTabList.Count));
     for (int i = 0; i < FTabList.Count; i++)
     {
         DataStream.Write16((UInt16)FTabList[i]);
     }
 }
Пример #24
0
        private void ComponentSystems_DataStreamChanged(IDataStream <string> sender, EntityChangedArgs <string> args)// DSChangedArgs<string, IDataStream<long>> args)
        {
            var myargs = args as DSChangedArgs <string, IDataStream <long> >;

            if (myargs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                myargs.NewVal.DataStreamChanged += ComponentChange;
            }
            else if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
            {
                myargs.NewVal.DataStreamChanged -= ComponentChange;
            }
        }
Пример #25
0
 public void WriteToDataStream(IDataStream s)
 {
     s.WriteByte((byte)Command.GetDesktopInfo);
     if (screens.Length > 255)
     {
         throw new Exception("Number of screens may not be greater than 255");
     }
     s.WriteByte((byte)screens.Length);
     foreach (DesktopScreen screen in screens)
     {
         screen.WriteToDataStream(s);
     }
 }
Пример #26
0
        public void View(IDataStream stream)
        {
            if (stream != m_CurrentStream) {
                m_CurrentStream = stream;
                m_image = (IHasSectors)stream;

                vScrollBar.Value = 0;
                UpdateScrollbar();
                //viewSector(0);
                UpdateDiagram(0);
                this.Refresh();
            }
        }
Пример #27
0
        internal override void SaveToStream(IDataStream Workbook, TSaveData SaveData, int Row)
        {
            //We can't check for ColSplit/RowSplit since we don't know what it is. It doesn't really matter either.
            Biff8Utils.CheckRow(FirstVisibleRow);
            Biff8Utils.CheckCol(FirstVisibleCol);

            Workbook.WriteHeader((UInt16)Id, (UInt16)TotalSizeNoHeaders());
            Workbook.Write16((UInt16)ColSplit);
            Workbook.Write16((UInt16)RowSplit);
            Workbook.Write16((UInt16)FirstVisibleRow);
            Workbook.Write16((UInt16)FirstVisibleCol);
            Workbook.Write16((UInt16)ActivePane);
        }
Пример #28
0
 private static void AddContinue(IDataStream DataStream, byte[] Buffer, ref int BufferPos, ref long BeginRecordPos, ref long TotalSize)
 {
     if (DataStream != null)
     {
         Array.Copy(BitConverter.GetBytes((UInt16)(BufferPos - 4)), 0, Buffer, 2, 2);                 //Adapt the record size before writing it.
         DataStream.WriteHeader((UInt16)(Buffer[0] + (Buffer[1] << 8)), (UInt16)(Buffer[2] + (Buffer[3] << 8)));
         DataStream.Write(Buffer, 4, BufferPos - 4);
         BeginRecordPos = DataStream.Position;
         Array.Copy(BitConverter.GetBytes((UInt16)xlr.CONTINUE), 0, Buffer, 0, 2);
         Buffer[4] = 0; Buffer[5] = 0;             //Clear the OptionFlags.
     }
     TotalSize += BufferPos;
     BufferPos  = 4;
 }
Пример #29
0
 /// <summary>
 /// Creates a response from current parser
 /// </summary>
 /// <param name="headerData"></param>
 /// <param name="bodyData"></param>
 /// <param name="messageData"></param>
 /// <returns>parsed http response</returns>
 /// <exception cref="ParsingNotFinishedException">if this method is called before parsing is finished</exception>
 public HttpData Create(IDataStream headerData, IDataStream bodyData, IDataStream messageData = null)
 {
     lock (builder)
     {
         if (stage == ParsingStage.Finished)
         {
             return(builder.CreateAndClear(bodyData, headerData, messageData));
         }
         else
         {
             throw new ParsingNotFinishedException();
         }
     }
 }
		public NTFSFileStream(IDataStream partition, MFTRecord record, MFTAttribute attr) {
			if (attr != null) {
				_nonResident = attr.NonResident;
				if (_nonResident) {
					_runs = attr.Runs;
					_length = attr.DataSize;
				} else {
					_residentStream = attr.ResidentData;
					_length = attr.ResidentData.StreamLength;
				}
			}
			_record = record;
			_partitionStream = partition;
		}
Пример #31
0
        internal void SaveRangeToStream(IDataStream DataStream, TSaveData SaveData, int SheetIndex, TXlsCellRange CellRange)
        {
            FixNames();
            FixCodeNames(); //before fixing offsets.
            FixRows();      //Should be before calculating the offset. It is needed because some non-excel generated files might not have all rows.
            FixRangeBoundSheetsOffset(SheetIndex, CellRange, DataStream.Encryption, SaveData.Repeatable);
            FixNotes();
            FixRadioButtons();

            FGlobals.SaveRangeToStream(DataStream, SaveData, SheetIndex, CellRange);
            //we don't have to check SheetIndex is ok. this was done on FGlobals.SaveRangetoStream
            SaveData.SavingSheet = FSheets[SheetIndex];
            FSheets[SheetIndex].SaveRangeToStream(DataStream, SaveData, SheetIndex, CellRange);
        }
Пример #32
0
        private static IDataStream streamEnd = new ByteArray(new byte[] { 48, 13, 10, 13, 10 }); //0\r\n\r\n

        public ChunkedStream(IDataStream s, int chunkSize)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }
            if (chunkSize <= 0)
            {
                throw new ArgumentOutOfRangeException("chunkSize must be positive");
            }
            this.innerStream = s;
            this.chunkSize   = chunkSize;
            init();
        }
Пример #33
0
        internal int Read(IDataStream data)
        {
            int count  = 0;
            int length = data.Get16();

            count += 2;

            NumComponents = data.Get8();
            count++;

            components = new ScanComponent[NumComponents];

            for (int i = 0; i < NumComponents; i++)
            {
                components[i] = new ScanComponent();

                if (count > length)
                {
                    throw new IOException("ERROR: scan header format error");
                }

                components[i].ScanCompSel = data.Get8();
                count++;

                int tempval = data.Get8();
                count++;

                components[i].DcTabSel = tempval >> 4;
                components[i].AcTabSel = tempval & 0x0F;
            }

            Selection = data.Get8();
            count++;

            SpectralEnd = data.Get8();
            count++;

            int temp = data.Get8();

            Ah = temp >> 4;
            Al = temp & 0x0F;
            count++;

            if (count != length)
            {
                throw new IOException("ERROR: scan header format error [count!=Ns]");
            }

            return(1);
        }
Пример #34
0
 public void View(IDataStream stream)
 {
     if (stream != m_CurrentStream) {
         m_CurrentStream = stream;
         m_registry = new Registry((stream as IFileSystemStore).FS);
         radioViewSimple.Checked = true;
         cmbUser.Items.Clear();
         foreach (String user in m_registry.GetUsers()) {
             cmbUser.Items.Add(user);
             cmbUser.SelectedIndex = 0;
         }
         UpdateTree();
     }
 }
Пример #35
0
 private bool IsHtml(IDataStream stream)
 {
     File file = stream as File;
     if (file != null) {
         string name = file.Name.ToLower();
         return name.EndsWith(".html")
             || name.EndsWith(".htm")
             || name.EndsWith(".php")
             || name.EndsWith(".asp")
             || name.EndsWith(".aspx");
     } else {
         return false;
     }
 }
Пример #36
0
        private IDataStream applyWrappers(IDataStream s)
        {
            if (s == null)
            {
                return(null);
            }
            var tmp = s;

            foreach (var w in usedWrappers)
            {
                tmp = w.Wrap(tmp);
            }
            return(tmp);
        }
Пример #37
0
 /// <inheritdoc/>
 public void Send(IDataStream response)
 {
     try
     {
         // TODO: improve this
         socket.SendTo(response.ReadBytes(), remoteEP);
         OnResponseSent(response);
     }
     catch (ObjectDisposedException)
     { }
     catch (Exception e)
     {
         OnErrorOccured(e);
     }
 }
Пример #38
0
        protected override IDataStream responseMapper(IProxyChannel c, IDataStream s)
        {
            var channel = c as DefaultProxyChannel;
            var data    = s as HttpData;

            if (channel != null && data != null && data.Code == 101)
            {
                string upgrade;
                if (data.Headers.TryGetValue("Upgrade", out upgrade) && upgrade.ToLower() == "websocket")
                {
                    channel.ReplaceInnerChannels(upgradeServer, upgradeClient);
                }
            }
            return(s);
        }
Пример #39
0
        internal static void SaveToStream(TNameRecordList Names, IDataStream Workbook, TFormulaType FmlaType, TParsedTokenList Data, bool WriteLen)
        {
            if (Data.TextLenght > FlxConsts.Max_FormulaLen97_2003)
            {
                FlxMessages.ThrowException(FlxErr.ErrFormulaTooLong, TFormulaConvertInternalToText.AsString(Data, 0, 0, null));
            }
            int FmlaNoArrayLen;

            byte[] bData = TFormulaConvertInternalToBiff8.GetTokenData(Names, Data, FmlaType, out FmlaNoArrayLen);
            if (WriteLen)
            {
                Workbook.Write16((UInt16)FmlaNoArrayLen);
            }
            Workbook.Write(bData, bData.Length);
        }
Пример #40
0
        private void SaveToStreamExt(IDataStream DataStream, TSaveData SaveData, int FirstRecord, int RecordCount)
        {
            if (RecordCount > 0)
            {
                Sort(); //just in case...
                int MyRecordCount = RecordCount;

                DataStream.WriteHeader((UInt16)RecordId, (UInt16)(2 + RecordCount * TPageBreak.Biff8Length));
                DataStream.Write16((UInt16)MyRecordCount);
                for (int i = FirstRecord; i < FirstRecord + RecordCount; i++)
                {
                    DataStream.Write(FList[i].Biff8Data(), TPageBreak.Biff8Length);
                }
            }
        }
Пример #41
0
        private void treeFiles_AfterSelect(object sender, TreeViewEventArgs e)
        {
            IDescribable fsNode = e.Node.Tag as IDescribable;

            if (fsNode != null)
            {
                tbDescription.Text = fsNode.TextDescription;
            }
            IDataStream stream = e.Node.Tag as IDataStream;

            if (stream != null)
            {
                OnStreamSelected(stream);
            }
        }
Пример #42
0
        public static int GetInt24(IDataStream stream, ulong offset)
        {
            byte[] bytes32 = new byte[4];
            byte[] bytes24 = stream.GetBytes(offset, 3);
            Array.Copy(bytes24, bytes32, 3);
            int res = BitConverter.ToInt32(bytes32, 0);

            if ((bytes32[2] & 0x80) == 0x80)
            {
                return(res - 0x1000000);
            }
            else
            {
                return(res);
            }
        }
Пример #43
0
        public static string CreateTemporaryFile(IDataStream stream)
        {
            ulong        BLOCK_SIZE = 1024 * 1024;      // Write 1MB at a time
            string       tempFile   = Path.GetTempFileName();
            BinaryWriter writer     = new BinaryWriter(new FileStream(tempFile, FileMode.Create));
            ulong        offset     = 0;

            while (offset < stream.StreamLength)
            {
                ulong read = Math.Min(BLOCK_SIZE, stream.StreamLength - offset);
                writer.Write(stream.GetBytes(offset, read));
                offset += read;
            }
            writer.Close();
            return(tempFile);
        }
Пример #44
0
        public HandshakeMessage(IDataStream stream)
        {
            msg_type = (HandshakeType)stream.ReadByte();

            byte[] lengthData = new byte[] { 0, (byte)stream.ReadByte(), (byte)stream.ReadByte(), (byte)stream.ReadByte() };
            length = ByteUtil.ReadUInt32(lengthData, 0);

            if (msg_type == HandshakeType.client_hello)
            {
                body = new ClientHello(stream);
            }
            else
            {
                throw new Exception("TLS Handshake type \"" + msg_type + "\" is not supported.");
            }
        }
Пример #45
0
 public static string DetectFSType(IDataStream stream)
 {
     if (GetASCIIString(stream, 3, 4) == "NTFS")
     {
         return("NTFS");
     }
     if (GetASCIIString(stream, 0x36, 5) == "FAT16")
     {
         return("FAT16");
     }
     if (GetASCIIString(stream, 0x52, 5) == "FAT32")
     {
         return("FAT16");
     }
     return("Unknown");
 }
Пример #46
0
        public object Clone()
        {
            IDataStream nd = null;
            ICloneable  ns = null;

            if (Data != null)
            {
                nd = (IDataStream)Data.Clone();
            }
            if (State != null)
            {
                ns = (ICloneable)ns.Clone();
            }
            return(new DataEventArgs {
                Data = nd, State = ns
            });
        }
Пример #47
0
        public void View(IDataStream stream)
        {
            if (stream != m_CurrentStream) {
                m_CurrentStream = stream;
                if (stream is IDescribable) {
                    tbDescription.Text = ((IDescribable)stream).TextDescription;
                }

                if (stream is IPhysicalDisk) {
                    partitionDiagram1.Disk = stream as IPhysicalDisk;
                } else if (stream is PhysicalDiskSection) {
                    partitionDiagram1.ActiveSection = stream as PhysicalDiskSection;
                } else {
                    partitionDiagram1.ActiveSection = null;
                }
            }
        }
Пример #48
0
        public DesktopScreen(IDataStream s)
        {
            adapterIndex = (byte)s.ReadByte();
            outputIndex  = (byte)s.ReadByte();

            ushort strLength = s.ReadUInt16();

            adapterName = Encoding.UTF8.GetString(ByteUtil.ReadNBytes(s, strLength));

            strLength  = s.ReadUInt16();
            outputName = Encoding.UTF8.GetString(ByteUtil.ReadNBytes(s, strLength));

            X      = s.ReadInt16();
            Y      = s.ReadInt16();
            Width  = s.ReadUInt16();
            Height = s.ReadUInt16();
        }
Пример #49
0
        internal void SaveToStream(IDataStream DataStream, TSaveData SaveData)
        {
            long BeginRecordPos = DataStream.Position;

            byte[] Buffer = new byte[XlsConsts.MaxRecordDataSize + 4];
            Array.Copy(BitConverter.GetBytes((UInt16)xlr.SST), 0, Buffer, 0, 2);

            bool   Repeatable = SaveData.Repeatable;
            UInt32 TotalRefs;
            IEnumerator <KeyValuePair <TSSTEntry, TSSTEntry> > myEnumerator;

            TSSTEntry[] SortedEntries;
            PrepareToSave(Repeatable, out TotalRefs, out myEnumerator, out SortedEntries);

            Array.Copy(BitConverter.GetBytes(TotalRefs), 0, Buffer, 4, 4);
            Array.Copy(BitConverter.GetBytes((UInt32)Data.Count), 0, Buffer, 8, 4);

            int  BufferPos = 4 + 8;
            long TotalSize = 0;

            if (Repeatable)
            {
                //REPEATABLEWRITES
                foreach (TSSTEntry Se in SortedEntries)
                {
                    Se.SaveToStream(DataStream, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }
            else
            {
                myEnumerator.Reset();
                while (myEnumerator.MoveNext())
                {
                    myEnumerator.Current.Key.SaveToStream(DataStream, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }

            //Flush the buffer.
            Array.Copy(BitConverter.GetBytes((UInt16)(BufferPos - 4)), 0, Buffer, 2, 2);  //Adapt the record size before writing it.
            DataStream.WriteHeader((UInt16)(Buffer[0] + (Buffer[1] << 8)), (UInt16)(Buffer[2] + (Buffer[3] << 8)));
            DataStream.Write(Buffer, 4, BufferPos - 4);
            TotalSize += BufferPos;


            WriteExtSST(DataStream, Repeatable);
        }
Пример #50
0
 public override void Initialize()
 {
     this.streamInitiation = base.im.GetExtension <StreamInitiation>();
     this.streamInitiation.RegisterProfile("http://jabber.org/protocol/si/profile/file-transfer", new Func <Jid, XmlElement, XmlElement>(this.OnStreamInitiationRequest));
     this.ecapa = base.im.GetExtension <EntityCapabilities>();
     foreach (Type type in supportedMethods)
     {
         XmppExtension extension = base.im.GetExtension(type);
         if (!((extension != null) && (extension is IDataStream)))
         {
             throw new XmppException("Invalid data-stream type: " + type);
         }
         IDataStream stream = extension as IDataStream;
         stream.BytesTransferred += new EventHandler <BytesTransferredEventArgs>(this.OnBytesTransferred);
         stream.TransferAborted  += new EventHandler <TransferAbortedEventArgs>(this.OnTransferAborted);
     }
 }
Пример #51
0
        public static HttpData CreateRequest(IReadOnlyDictionary <string, string> headers,
                                             IReadOnlyList <string> headerKeys, string version, HttpRequestMethod method,
                                             string requestTarget, IDataStream payload = null, IDataStream headerData = null, IDataStream messageData = null)
        {
            if (headerData == null)
            {
                var stringBuilder = new StringBuilder(method.ToString() + " " + requestTarget + " HTTP/" + version + "\r\n");
                foreach (var key in headerKeys)
                {
                    stringBuilder.Append(key + ":" + headers[key] + "\r\n");
                }
                stringBuilder.Append("\r\n");
                headerData = new ByteArray(ASCIIEncoding.ASCII.GetBytes(stringBuilder.ToString()));
            }

            return(new HttpData(headerData, headers, headerKeys, true, version, -1, "", method, requestTarget, payload, messageData));
        }
Пример #52
0
        public static HttpData CreateResponse(IReadOnlyDictionary <string, string> headers,
                                              IReadOnlyList <string> headerKeys, string version, int code, string reasonPhrase,
                                              IDataStream payload = null, IDataStream headerData = null, IDataStream messageData = null)
        {
            if (headerData == null)
            {
                var stringBuilder = new StringBuilder("HTTP/" + version + " " + code.ToString() + " " + reasonPhrase + "\r\n");
                foreach (var key in headerKeys)
                {
                    stringBuilder.Append(key + ":" + headers[key] + "\r\n");
                }
                stringBuilder.Append("\r\n");
                headerData = new ByteArray(ASCIIEncoding.ASCII.GetBytes(stringBuilder.ToString()));
            }

            return(new HttpData(headerData, headers, headerKeys, false, version, code, reasonPhrase, HttpRequestMethod.Null, "", payload, messageData));
        }
Пример #53
0
        private static void WriteArray(byte[] DataToWrite, IDataStream DataStream, byte[] Buffer, ref int BufferPos, ref long BeginRecordPos, ref long TotalSize)
        {
            int StPos = 0;

            while (StPos < DataToWrite.Length)
            {
                int BytesLeft = ((Buffer.Length - BufferPos) / 4) * 4;             //RTF runs can only be split on full runs.
                int Chars     = Math.Min(DataToWrite.Length - StPos, BytesLeft);
                Array.Copy(DataToWrite, StPos, Buffer, BufferPos, Chars);
                BufferPos += Chars;
                StPos     += Chars;
                if (StPos < DataToWrite.Length)
                {
                    AddContinue(DataStream, Buffer, ref BufferPos, ref BeginRecordPos, ref TotalSize);
                }
            }
        }
Пример #54
0
        public StreamInfo(IDataStream strm, IDataTarget target, string inName)
        {
            try
            {
                Target = (target as IDataSource).DataSourceGuid;
                Source = strm.Source.DataSourceGuid;
                TargetIn = inName;
                foreach (var outStm in strm.Source.Out)
                    if (outStm.Value == strm)
                        SourceOut = outStm.Key;

                Count = strm.LightList.Count();
            }
            catch
            {
                Error = true;
            }
        }
Пример #55
0
 public void View(IDataStream stream)
 {
     if (stream is FileSystemNode) {
         lCaption.Text = ((FileSystemNode)stream).Name;
     }
     p = new Picture(stream);
     Thread t = new Thread(delegate(object o) {
         Picture pic = (Picture)o;
         System.Drawing.Image i = pic.GetImage();
         if (i != null) {
             this.Invoke(new Action(delegate() {
                 SetImage(i);
                 lLoading.Visible = false;
             }));
         }
     });
     t.Start(p);
 }
Пример #56
0
 private static ulong SimpleFind(IDataStream stream, byte[] search, ulong start, ProgressCallback callback)
 {
     for (ulong l = start; l < stream.StreamLength - (ulong)search.Length; l+=1) {
         if (callback != null && l % 1024 == 0) {
             callback(l);
         }
         bool found = true;
         for (int m = 0; m < search.Length; m++) {
             if (search[m] != Util.GetByte(stream, (ulong) m + l)) {
                 found = false;
                 break;
             }
         }
         if (found) {
             return l;
         }
     }
     return UInt64.MaxValue;
 }
Пример #57
0
		/// <summary>
		/// Initializes a new instance of the SISession class.
		/// </summary>
		/// <param name="sid">The identifier of the session.</param>
		/// <param name="stream">The IO-stream from which data is read, or to
		/// which data is written.</param>
		/// <param name="size">The total number of bytes to read from, or to
		/// write to the stream.</param>
		/// <param name="receiving">true if data is being received over the session;
		/// Otherwise false.</param>
		/// <param name="from">The JID of the XMPP entity that wishes to send data.</param>
		/// <param name="to">The JID of the XMPP entity that wishes to receive
		/// data.</param>
		/// <param name="extension">The instance of the data-stream extension
		/// negotiated during session-initiation.</param>
		/// <exception cref="ArgumentNullException">The sid parameter or the stream
		/// parameter or the from parameter or the to parameter or the extension
		/// parameter is null.</exception>
		/// <exception cref="ArgumentException">The receiving parameter is true, but
		/// the specified stream cannot be written, or the receiving parameter is
		/// false, but the specified stream cannot be read.</exception>
		/// <exception cref="ArgumentOutOfRangeException">The size parameter is
		/// negative.</exception>
		public SISession(string sid, Stream stream, long size, bool receiving,
			Jid from, Jid to, IDataStream extension) {
			sid.ThrowIfNull("sid");
			stream.ThrowIfNull("stream");
			size.ThrowIfOutOfRange(0, Int64.MaxValue);
			from.ThrowIfNull("from");
			to.ThrowIfNull("to");
			extension.ThrowIfNull("extension");
			if (receiving && !stream.CanWrite)
				throw new ArgumentException("The specified stream cannot be written.");
			if (!receiving && !stream.CanRead)
				throw new ArgumentException("The specified stream cannot be read.");
			Sid = sid;
			Stream = stream;
			Size = size;
			Count = 0;
			Receiving = receiving;
			From = from;
			To = to;
			Extension = extension;
		}
			public IndexEntry(IDataStream stream, ulong offset, FolderNTFS folder) {
				_folder = folder;
				_stream = stream;
				_offset = offset;
				ulong mask = 0x0000ffffffffffff; // This is a hack

				_indexedFile = Util.GetUInt64(stream, offset);
				_indexEntryLength = Util.GetUInt16(stream, offset + 8);
				_filenameOffset = Util.GetUInt16(stream, offset + 10);
				_flags = Util.GetByte(stream, offset + 12);
				if (_indexEntryLength > 0x50) {
					_filenameLength = Util.GetByte(stream, offset + 0x50);
					Name = Util.GetUnicodeString(stream, offset + 0x52, (ulong)_filenameLength * 2);
					DummyEntry = false;
				} else {
					// no filename, dummy entry
					DummyEntry = true;
				}

				_recordNum = (_indexedFile & mask);
			}
Пример #59
0
 /// <summary>
 /// Return an object that represents an IDataStream, but is serializable
 /// </summary>
 public IEnumerable<Dictionary<string, object>> Prepare(IDataStream stream)
 {
     return Prepare(stream.LightList);
 }
		public SectorStream(IDataStream stream, ulong start, ulong length, ulong sectorNum) :
			base(stream, start, length) {
			_sectorNum = sectorNum;
		}