示例#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();
        }
示例#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);
        }
示例#3
0
 internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).Clone(out stream); 
 } 
示例#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));
 }
示例#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));
 }
示例#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));
 }
示例#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));
 }
示例#8
0
 internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags));
 }
示例#9
0
 internal static int SetSize(ref StreamDescriptor pSD, long value)
 {
     return (StreamAsIStream.FromSD(ref pSD)).SetSize(value); 
 }
示例#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);
 } 
示例#11
0
 internal static int Revert(ref StreamDescriptor pSD) 
 { 
     return (StreamAsIStream.FromSD(ref pSD)).Revert();
 } 
示例#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);
 } 
示例#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);
 }
示例#14
0
 internal static int Commit(ref StreamDescriptor pSD, UInt32 grfCommitFlags) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).Commit(grfCommitFlags);
 }
示例#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));
 }
示例#16
0
 internal static int Clone(ref StreamDescriptor pSD, out IntPtr stream)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Clone(out stream));
 }
示例#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); 
 }
示例#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));
 }
示例#19
0
 internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
 { 
     return (StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType);
 } 
示例#20
0
 internal static int Revert(ref StreamDescriptor pSD)
 {
     return((StreamAsIStream.FromSD(ref pSD)).Revert());
 }
示例#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);
 }
示例#22
0
 internal static int SetSize(ref StreamDescriptor pSD, long value)
 {
     return((StreamAsIStream.FromSD(ref pSD)).SetSize(value));
 }
示例#23
0
 internal static int CanWrite(ref StreamDescriptor pSD, out bool canWrite) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).CanWrite(out canWrite); 
 } 
示例#24
0
 internal static int UnlockRegion(ref StreamDescriptor pSD, long libOffset, long cb, uint dwLockType)
 {
     return((StreamAsIStream.FromSD(ref pSD)).UnlockRegion(libOffset, cb, dwLockType));
 }
示例#25
0
 internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek) 
 {
     return (StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek);
 }
示例#26
0
 internal static int CanSeek(ref StreamDescriptor pSD, out bool canSeek)
 {
     return((StreamAsIStream.FromSD(ref pSD)).CanSeek(out canSeek));
 }
示例#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;
        }
示例#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(); 
 }
示例#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);
 }