Exemple #1
0
        internal static void StaticDispose(ref StreamDescriptor pSD)
        {
            Debug.Assert(((IntPtr)pSD.m_handle) != IntPtr.Zero, "If this asserts fires: why is it firing. It might be legal in future.");
            StreamAsIStream sais = (StreamAsIStream)(pSD.m_handle.Target);

            ((System.Runtime.InteropServices.GCHandle)(pSD.m_handle)).Free();
        }
Exemple #2
0
        internal static IntPtr IStreamFrom(System.IO.Stream stream)
        {
            if (stream == null)
            {
                throw new System.ArgumentNullException("stream");
            }

            IntPtr pStream = IntPtr.Zero;

            StreamAsIStream  sais = new StreamAsIStream(stream);
            StreamDescriptor sd   = new StreamDescriptor();

            sd.pfnDispose = StaticPtrs.pfnDispose;

            sd.pfnClone      = StaticPtrs.pfnClone;
            sd.pfnCommit     = StaticPtrs.pfnCommit;
            sd.pfnCopyTo     = StaticPtrs.pfnCopyTo;
            sd.pfnLockRegion = StaticPtrs.pfnLockRegion;
            sd.pfnRead       = StaticPtrs.pfnRead;
            sd.pfnRevert     = StaticPtrs.pfnRevert;
            unsafe
            {
                sd.pfnSeek = StaticPtrs.pfnSeek;
            }
            sd.pfnSetSize      = StaticPtrs.pfnSetSize;
            sd.pfnStat         = StaticPtrs.pfnStat;
            sd.pfnUnlockRegion = StaticPtrs.pfnUnlockRegion;
            sd.pfnWrite        = StaticPtrs.pfnWrite;
            sd.pfnCanWrite     = StaticPtrs.pfnCanWrite;
            sd.pfnCanSeek      = StaticPtrs.pfnCanSeek;

            sd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(sais, System.Runtime.InteropServices.GCHandleType.Normal);

            HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MILCreateStreamFromStreamDescriptor(ref sd, out pStream));

            return(pStream);
        }
Exemple #3
0
 internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek)
 {
     return((StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek));
 }
Exemple #4
0
 internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
 {
     return((StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType));
 }
Exemple #5
0
 internal static int Write(ref StreamDescriptor pSD, byte[] buffer, uint cb, out uint cbWritten)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Write(buffer, cb, out cbWritten));
 }
Exemple #6
0
 internal static int SetSize(ref StreamDescriptor pSD, long value)
 {
     return((StreamAsIStream.FromSD(ref pSD)).SetSize(value));
 }
Exemple #7
0
 internal static int Stat(ref StreamDescriptor pSD, out System.Runtime.InteropServices.ComTypes.STATSTG statstg, uint grfStatFlag)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Stat(out statstg, grfStatFlag));
 }
Exemple #8
0
 internal static int Revert(ref StreamDescriptor pSD)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Revert());
 }
Exemple #9
0
 internal unsafe static int Seek(ref StreamDescriptor pSD, long offset, uint origin, long *plibNewPostion)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Seek(offset, origin, plibNewPostion));
 }
Exemple #10
0
 internal static int Read(ref StreamDescriptor pSD, byte[] buffer, uint cb, out uint cbRead)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Read(buffer, cb, out cbRead));
 }
Exemple #11
0
 internal static int CopyTo(ref StreamDescriptor pSD, IntPtr pstm, long cb, out long cbRead, out long cbWritten)
 {
     return((StreamAsIStream.FromSD(ref pSD)).CopyTo(pstm, cb, out cbRead, out cbWritten));
 }
Exemple #12
0
 internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags));
 }
Exemple #13
0
 internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Clone(out stream));
 }
Exemple #14
0
        internal static IntPtr IStreamFrom(System.IO.Stream stream)
        {
            if (stream == null) 
            {
                throw new System.ArgumentNullException("stream"); 
            } 

            IntPtr pStream = IntPtr.Zero; 

            StreamAsIStream sais = new StreamAsIStream(stream);
            StreamDescriptor sd = new StreamDescriptor();
 
            sd.pfnDispose = StaticPtrs.pfnDispose;
 
            sd.pfnClone = StaticPtrs.pfnClone; 
            sd.pfnCommit = StaticPtrs.pfnCommit;
            sd.pfnCopyTo = StaticPtrs.pfnCopyTo; 
            sd.pfnLockRegion = StaticPtrs.pfnLockRegion;
            sd.pfnRead = StaticPtrs.pfnRead;
            sd.pfnRevert = StaticPtrs.pfnRevert;
            unsafe 
            {
                sd.pfnSeek = StaticPtrs.pfnSeek; 
            } 
            sd.pfnSetSize = StaticPtrs.pfnSetSize;
            sd.pfnStat = StaticPtrs.pfnStat; 
            sd.pfnUnlockRegion = StaticPtrs.pfnUnlockRegion;
            sd.pfnWrite = StaticPtrs.pfnWrite;
            sd.pfnCanWrite = StaticPtrs.pfnCanWrite;
            sd.pfnCanSeek = StaticPtrs.pfnCanSeek; 

            sd.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(sais, System.Runtime.InteropServices.GCHandleType.Normal); 
 
            HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MILCreateStreamFromStreamDescriptor(ref sd, out pStream));
 
            return pStream;
        }