Esempio n. 1
0
 void IStream.Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG()
     {
         cbSize = 0
     };
 }
Esempio n. 2
0
        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            pstatstg         = new STATSTG();
            pstatstg.type    = (int)STGTY.STGTY_STREAM;
            pstatstg.cbSize  = _stream.Length;
            pstatstg.grfMode = 0;

            if (_stream.CanRead && _stream.CanWrite)
            {
                pstatstg.grfMode |= (int)STGM.STGM_READWRITE;
                return;
            }

            if (_stream.CanRead)
            {
                pstatstg.grfMode |= (int)STGM.STGM_READ;
                return;
            }

            if (_stream.CanWrite)
            {
                pstatstg.grfMode |= (int)STGM.STGM_WRITE;
                return;
            }

            throw new IOException();
        }
Esempio n. 3
0
            public unsafe HRESULT Stat(STATSTG *pstatstg, STATFLAG grfStatFlag)
            {
                if (pstatstg == null)
                {
                    return(HRESULT.E_POINTER);
                }

                *pstatstg = new STATSTG
                {
                    cbSize = (ulong)_dataStream.Length,
                    type   = STGTY.STREAM,

                    // Default read/write access is STGM_READ, which == 0
                    grfMode = _dataStream.CanWrite
                        ? _dataStream.CanRead
                            ? STGM.READWRITE
                            : STGM.WRITE
                        : STGM.Default
                };

                if (grfStatFlag == STATFLAG.DEFAULT)
                {
                    // Caller wants a name
                    pstatstg->AllocName(_dataStream is FileStream fs ? fs.Name : _dataStream.ToString());
                }

                return(HRESULT.S_OK);
            }
Esempio n. 4
0
        public void Stat(IntPtr pstatstg, int grfStatFlag)
        {
            STATSTG stats = new STATSTG();

            stats.cbSize = dataStream.Length;
            Marshal.StructureToPtr(stats, pstatstg, true);
        }
        private void PopulateTree(IStorage stg, TreeNode root)
        {
            IEnumSTATSTG enum_stg;

            stg.EnumElements(0, IntPtr.Zero, 0, out enum_stg);
            STATSTG[] stat = new STATSTG[1];
            uint      fetched;

            while (enum_stg.Next(1, stat, out fetched) == 0)
            {
                STGTY    type  = (STGTY)stat[0].type;
                TreeNode node  = new TreeNode(stat[0].pwcsName);
                byte[]   bytes = new byte[0];
                node.ImageIndex         = 2;
                node.SelectedImageIndex = 2;
                switch (type)
                {
                case STGTY.Storage:
                    PopulateTree(stg.OpenStorage(stat[0].pwcsName, IntPtr.Zero, STGM.READ | STGM.SHARE_EXCLUSIVE, IntPtr.Zero, 0), node);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    break;

                case STGTY.Stream:
                    bytes = ReadStream(stg, stat[0].pwcsName, (int)stat[0].cbSize);
                    break;

                default:
                    break;
                }
                node.Tag = new STATSTGWrapper(stat[0], bytes);

                root.Nodes.Add(node);
            }
        }
Esempio n. 6
0
        public void Stat(out STATSTG streamStats, int grfStatFlag)
        {
            streamStats = new STATSTG
            {
                type    = 2,
                cbSize  = _stream.Length,
                grfMode = 0
            };

            if (_stream.CanRead && _stream.CanWrite)
            {
                streamStats.grfMode |= 0x00000002;
            }
            else if (_stream.CanRead)
            {
                streamStats.grfMode |= 0x00000000;
            }
            else if (_stream.CanWrite)
            {
                streamStats.grfMode |= 0x00000001;
            }
            else
            {
                throw new IOException();
            }
        }
Esempio n. 7
0
        void IStream.Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            const int STGM_READ      = 0x00000000;
            const int STGM_WRITE     = 0x00000001;
            const int STGM_READWRITE = 0x00000002;

            var tmp = new STATSTG {
                type = 2, cbSize = Length, grfMode = 0
            };

            if (CanWrite && CanRead)
            {
                tmp.grfMode |= STGM_READWRITE;
            }
            else if (CanRead)
            {
                tmp.grfMode |= STGM_READ;
            }
            else if (CanWrite)
            {
                tmp.grfMode |= STGM_WRITE;
            }
            else
            {
                throw new ObjectDisposedException("Stream");
            }

            pstatstg = tmp;
        }
Esempio n. 8
0
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG
     {
         cbSize = _Cache.Length
     };
 }
 public HRESULT Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG
     {
         type    = (int)STGTY.STGTY_STREAM,
         cbSize  = _stream.Length,
         grfMode = (int)STGM.STGM_READ
     };
     if (_stream.CanRead && _stream.CanWrite)
     {
         pstatstg.grfMode |= (int)STGM.STGM_READWRITE;
     }
     else if (_stream.CanRead)
     {
         pstatstg.grfMode |= (int)STGM.STGM_READ;
     }
     else if (_stream.CanWrite)
     {
         pstatstg.grfMode |= (int)STGM.STGM_WRITE;
     }
     else
     {
         return(HRESULT.E_ACCESSDENIED);
     }
     return(HRESULT.S_OK);
 }
 void IUnsafeComStream.Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG()
     {
         cbSize = _length
     };
 }
Esempio n. 11
0
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG()
     {
         cbSize = stream.Length
     };
 }
Esempio n. 12
0
        public void Stat(IntPtr pstatstg, int grfStatFlag)
        {
            var stats = new STATSTG {
                cbSize = DataStream.Length
            };

            Marshal.StructureToPtr(stats, pstatstg, true);
        }
        public void Stat(IntPtr pstatstg, int grfStatFlag)
        {
            STATSTG structure = new STATSTG {
                cbSize = this.dataStream.Length
            };

            Marshal.StructureToPtr(structure, pstatstg, true);
        }
        /// <summary>
        /// Sets the length of the stream
        /// </summary>
        /// <param name="pstatstg"></param>
        /// <param name="grfStatFlag"></param>
        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            // IStreamWrapper wants the length
            var tempStatstg = new STATSTG {
                cbSize = _stream.Length
            };

            pstatstg = tempStatstg;
        }
Esempio n. 15
0
        /// <summary>
        /// Retrieves the STATSTG structure for this stream.
        /// </summary>
        /// <param name="pstatstg">Upon return, contains the stat information.</param>
        /// <param name="grfStatFlag">
        /// Filter of members to not return in the struct thus saving memory.
        /// </param>

        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            pstatstg        = new STATSTG();
            pstatstg.cbSize = stream.Length;
            if ((grfStatFlag & 0x0001 /* STATFLAG_NONAME */) == 0)
            {
                pstatstg.pwcsName = stream.ToString();
            }
        }
 //
 // Summary:
 //     Retrieves the System.Runtime.InteropServices.STATSTG structure for this stream.
 //
 // Parameters:
 //   pstatstg:
 //     When this method returns, contains a STATSTG structure that describes this
 //     stream object. This parameter is passed uninitialized.
 //
 //   grfStatFlag:
 //     Members in the STATSTG structure that this method does not return, thus saving
 //     some memory allocation operations.
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg        = new STATSTG();
     pstatstg.cbSize = this._stream.Length;
     if ((grfStatFlag & 1) == 0)
     {
         pstatstg.pwcsName = this._stream.ToString();
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Retrieves the STATSTG structure for this stream.
        /// </summary>
        /// <param name="pstatstg">
        /// When this method returns, contains a STATSTG structure that describes this stream object.
        /// This parameter is passed uninitialized.
        /// </param>
        /// <param name="grfStatFlag">
        /// Members in the STATSTG structure that this method does not return, thus saving some memory allocation operations.
        /// </param>
        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            pstatstg = default(STATSTG);
            _Validate();

            pstatstg.type              = STGTY_STREAM;
            pstatstg.cbSize            = _source.Length;
            pstatstg.grfMode           = STGM_READWRITE;
            pstatstg.grfLocksSupported = LOCK_EXCLUSIVE;
        }
Esempio n. 18
0
        protected override void GivenThat()
        {
            base.GivenThat();

            var streamStat = new STATSTG
            {
                cbSize = 55667788
            };

            Stream.Stub(stream => stream.Stat(out Arg <STATSTG> .Out(streamStat).Dummy, Arg <int> .Is.Equal(1)));
        }
Esempio n. 19
0
    public unsafe void Stat(STATSTG *pstatstg, uint grfStatFlag)
    {
        var statStg = new STATSTG
        {
            type    = 2,
            cbSize  = (ulong)_baseStream.Length,
            grfMode = 0
        };

        Marshal.StructureToPtr(statStg, new IntPtr(pstatstg), false);
    }
Esempio n. 20
0
        /// <summary>
        /// Constructor of the class
        /// </summary>
        /// <param name="workPath">workpath of the storage</param>
        /// <param name="enumStorage">true if the storage should be enumerated automatically</param>
        public IStorageWrapper(string workPath, bool enumStorage)
        {
            Interop.StgOpenStorage(workPath, null, 16, IntPtr.Zero, 0, out storage);
            IBaseStorageWrapper.BaseUrl = workPath;
            STATSTG sTATSTG = new STATSTG();

            storage.Stat(out sTATSTG, 1);
            if (enumStorage)
            {
                base.EnumIStorageObject();
            }
        }
Esempio n. 21
0
 public STATSTGWrapper(STATSTG stat, byte[] bytes)
 {
     Name           = stat.pwcsName;
     Type           = (STGTY)stat.type;
     Size           = stat.cbSize;
     ModifiedTime   = FromFileTime(stat.mtime);
     CreationTime   = FromFileTime(stat.ctime);
     AccessTime     = FromFileTime(stat.atime);
     Mode           = (STGM)stat.grfMode;
     LocksSupported = stat.grfLocksSupported;
     Clsid          = stat.clsid;
     StateBits      = stat.grfStateBits;
     Bytes          = bytes;
 }
Esempio n. 22
0
        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            const int STATFLAG_NONAME = 0x0001;

            pstatstg        = new STATSTG();
            pstatstg.cbSize = m_Stream.Length;

            if ((grfStatFlag & STATFLAG_NONAME) != 0)
            {
                return;
            }

            pstatstg.pwcsName = m_Stream.ToString();
        }
Esempio n. 23
0
        private void PopulateTree(IStorage stg, TreeNode root)
        {
            STATSTG stg_stat = new STATSTG();

            stg.Stat(stg_stat, 0);
            root.Tag = new STATSTGWrapper(EscapeStorageName(stg_stat.pwcsName), stg_stat, new byte[0]);
            IEnumSTATSTG enum_stg;

            stg.EnumElements(0, IntPtr.Zero, 0, out enum_stg);
            STATSTG[] stat = new STATSTG[1];
            uint      fetched;

            while (enum_stg.Next(1, stat, out fetched) == 0)
            {
                STGTY    type  = (STGTY)stat[0].type;
                TreeNode node  = new TreeNode(EscapeStorageName(stat[0].pwcsName));
                byte[]   bytes = new byte[0];
                node.ImageIndex         = 2;
                node.SelectedImageIndex = 2;
                switch (type)
                {
                case STGTY.Storage:
                    IStorage child_stg = stg.OpenStorage(stat[0].pwcsName, IntPtr.Zero, STGM.READ | STGM.SHARE_EXCLUSIVE, IntPtr.Zero, 0);
                    try
                    {
                        PopulateTree(child_stg, node);
                    }
                    finally
                    {
                        IS.Marshal.ReleaseComObject(child_stg);
                    }
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    break;

                case STGTY.Stream:
                    bytes = ReadStream(stg, stat[0].pwcsName, (int)stat[0].cbSize);
                    break;

                default:
                    break;
                }
                node.Tag = new STATSTGWrapper(EscapeStorageName(stat[0].pwcsName), stat[0], bytes);

                root.Nodes.Add(node);
            }
        }
Esempio n. 24
0
            public void Stat(out STATSTG pstatstg, STATFLAG grfStatFlag)
            {
                pstatstg = new STATSTG
                {
                    cbSize = (ulong)_dataStream.Length,
                    type   = STGTY.STREAM,

                    // Default read/write access is READ, which == 0
                    grfMode = _dataStream.CanWrite
                        ? _dataStream.CanRead
                            ? STGM.READWRITE
                            : STGM.WRITE
                        : STGM.Default
                };

                if (grfStatFlag == STATFLAG.DEFAULT)
                {
                    // Caller wants a name
                    pstatstg.AllocName(_dataStream is FileStream fs ? fs.Name : _dataStream.ToString());
                }
            }
Esempio n. 25
0
        public void Stat(out STATSTG pstatstg, int grfStatFlag)
        {
            pstatstg = new STATSTG {
                type    = 2,
                cbSize  = this.stream.Length,
                grfMode = 0
            };

            if (this.stream.CanRead && this.stream.CanWrite)
            {
                pstatstg.grfMode |= 2;
            }

            else if (this.stream.CanWrite && !this.stream.CanRead)
            {
                pstatstg.grfMode |= 1;
            }

            else
            {
                throw new IOException();
            }
        }
 public virtual void Stat(STATSTG pstatstg, int grfStatFlag)
 {
 }
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     throw new NotImplementedException("The method or operation is not implemented.");
 }
Esempio n. 28
0
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 public virtual void Stat(STATSTG pstatstg, int grfStatFlag)
 {
 }
Esempio n. 30
0
 public unsafe int Stat(STATSTG* pstatstg, uint grfStatFlag)
 {
     IStream_vtbl** @this = (IStream_vtbl**)reference;
     IStream_vtbl* vtbl = *@this;
     if (vtbl == null)
         throw new InvalidComObjectException();
     Delegate genericDelegate = Marshal.GetDelegateForFunctionPointer(vtbl->method_12, typeof(delegate_12));
     delegate_12 method = (delegate_12)genericDelegate;
     return method(@this, pstatstg, grfStatFlag);
 }
 /// <summary>
 /// Retrieves the STATSTG structure for this stream object.
 /// </summary>
 public void Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG();
 }
        private static string GetSolutionConfiguration(string storageFile)
        {
            if (!File.Exists(storageFile))
            {
                return(String.Empty);
            }

            byte[] storageBytes = null;

            try
            {
                // Open the COM structured storage for reading...
                StorageInterop.IStorage storage = null;
                StorageInterop.StgOpenStorage(storageFile, null, 16,
                                              IntPtr.Zero, 0, out storage);

                if (storage != null)
                {
                    // Set the storage parameters...
                    STATSTG storageTATSTG = new STATSTG();
                    storage.Stat(out storageTATSTG, 1);

                    // Set the file information...
                    STATSTG sTATSTG;
                    sTATSTG.pwcsName = "SolutionConfiguration";
                    sTATSTG.type     = 2;

                    // Read the file stream...
                    IStream stream = storage.OpenStream(sTATSTG.pwcsName,
                                                        IntPtr.Zero, 16, 0);
                    if (stream != null)
                    {
                        // It is successful, read the size and its contents
                        STATSTG stat;
                        stream.Stat(out stat, 0);
                        long   size   = stat.cbSize;
                        byte[] buffer = new byte[size];

                        stream.Read(buffer, (int)size, IntPtr.Zero);
                        storageBytes = buffer;
                    }
                }
            }
            catch
            {
                return(String.Empty);
            }

            if (storageBytes == null || storageBytes.Length == 0)
            {
                return(String.Empty);
            }

            string slnConfig = String.Empty;

            foreach (Match mx in _binaryRx.Matches(
                         Encoding.UTF8.GetString(storageBytes)))
            {
                slnConfig += mx.Value.Trim();
            }

            string[] slnParts = slnConfig.Split(';');
            if (slnParts == null || slnParts.Length == 0)
            {
                return(String.Empty);
            }

            string activeConfig = String.Empty;

            for (int i = slnParts.Length - 1; i >= 0; i--)
            {
                string slnPart = slnParts[i];

                if (slnPart.StartsWith("ActiveCfg",
                                       StringComparison.OrdinalIgnoreCase) && slnPart.Length > 10)
                {
                    activeConfig = slnPart.Substring(10).Trim();
                    break;
                }
            }

            return(activeConfig);
        }
Esempio n. 33
0
 void IUnsafeComStream.Stat(out STATSTG pstatstg, int grfStatFlag)
 {
     pstatstg = new STATSTG()
     {
         cbSize = _length
     };
 }
Esempio n. 34
0
 void IStream.Stat(out System.Runtime.InteropServices.ComTypes.STATSTG streamStats, int grfStatFlag)
 {
     streamStats = new STATSTG();
     ISLogger.Write("STAT CALLED");
 }
Esempio n. 35
0
 public unsafe int RemoteNext(uint celt, STATSTG* rgelt, uint* pceltFetched)
 {
     IEnumSTATSTG_vtbl** @this = (IEnumSTATSTG_vtbl**)reference;
     IEnumSTATSTG_vtbl* vtbl = *@this;
     if (vtbl == null)
         throw new InvalidComObjectException();
     Delegate genericDelegate = Marshal.GetDelegateForFunctionPointer(vtbl->method_3, typeof(delegate_3));
     delegate_3 method = (delegate_3)genericDelegate;
     return method(@this, celt, rgelt, pceltFetched);
 }