Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).Clone(out stream); 
 } 
Exemplo n.º 4
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));
 }
Exemplo n.º 5
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));
 }
Exemplo n.º 6
0
 internal unsafe static int Seek(ref StreamDescriptor pSD, long offset, uint origin, long *plibNewPostion)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Seek(offset, origin, plibNewPostion));
 }
Exemplo n.º 7
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));
 }
Exemplo n.º 8
0
 internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags));
 }
Exemplo n.º 9
0
 internal static int SetSize(ref StreamDescriptor pSD, long value)
 {
     return (StreamAsIStream.FromSD(ref pSD)).SetSize(value); 
 }
Exemplo n.º 10
0
 internal unsafe static int Seek(ref StreamDescriptor pSD, long offset, uint origin, long* plibNewPostion) 
 { 
     return (StreamAsIStream.FromSD(ref pSD)).Seek(offset, origin, plibNewPostion);
 } 
Exemplo n.º 11
0
 internal static int Revert(ref StreamDescriptor pSD) 
 { 
     return (StreamAsIStream.FromSD(ref pSD)).Revert();
 } 
Exemplo n.º 12
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);
 } 
Exemplo n.º 13
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);
 }
Exemplo n.º 14
0
 internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags);
 }
Exemplo n.º 15
0
 internal static StreamAsIStream FromSD(ref StreamDescriptor sd)
 {
     Debug.Assert(((IntPtr)sd.m_handle) != IntPtr.Zero, "Stream is disposed.");
     System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(sd.m_handle);
     return((StreamAsIStream)(handle.Target));
 }
Exemplo n.º 16
0
 internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Clone(out stream));
 }
Exemplo n.º 17
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); 
 }
Exemplo n.º 18
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));
 }
Exemplo n.º 19
0
 internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
 { 
     return (StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType);
 } 
Exemplo n.º 20
0
 internal static int Revert(ref StreamDescriptor pSD)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Revert());
 }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
 internal static int SetSize(ref StreamDescriptor pSD, long value)
 {
     return((StreamAsIStream.FromSD(ref pSD)).SetSize(value));
 }
Exemplo n.º 23
0
 internal static int CanWrite(ref StreamDescriptor pSD, out bool canWrite) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).CanWrite(out canWrite); 
 } 
Exemplo n.º 24
0
 internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
 {
     return((StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType));
 }
Exemplo n.º 25
0
 internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek);
 }
Exemplo n.º 26
0
 internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek)
 {
     return((StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek));
 }
Exemplo n.º 27
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;
        }
Exemplo n.º 28
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(); 
 }
Exemplo n.º 29
0
 internal static StreamAsIStream FromSD(ref StreamDescriptor sd) 
 { 
     Debug.Assert(((IntPtr)sd.m_handle) != IntPtr.Zero, "Stream is disposed.");
     System.Runtime.InteropServices.GCHandle handle = (System.Runtime.InteropServices.GCHandle)(sd.m_handle); 
     return (StreamAsIStream)(handle.Target);
 }