internal static int SafeStgOpenStorageOnStream( Stream s, int grfMode, out IStorage ppstgOpen ) { Invariant.Assert(s != null, "s cannot be null"); UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage; UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream lockByteStream = new UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream(s); int result; result = UnsafeNativeCompoundFileMethods.StgOpenStorageOnILockBytes( (UnsafeNativeCompoundFileMethods.UnsafeNativeILockBytes)lockByteStream, null, grfMode, new IntPtr(0), // Pointer to SNB struct, not marshalled, must be null. 0, out storage); if (result == SafeNativeCompoundFileConstants.S_OK) { ppstgOpen = new SafeIStorageImplementation(storage); } else { ppstgOpen = null; lockByteStream.Dispose(); } return(result); }
internal static int SafeStgCreateDocfileOnStream( Stream s, int grfMode, out IStorage ppstgOpen ) { Invariant.Assert(s != null, "s cannot be null"); UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage; UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream lockByteStream = new UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream(s); int result; result = UnsafeNativeCompoundFileMethods.StgCreateDocfileOnILockBytes( (UnsafeNativeCompoundFileMethods.UnsafeNativeILockBytes)lockByteStream, grfMode, 0, // Must be zero out storage); if (result == SafeNativeCompoundFileConstants.S_OK) { ppstgOpen = new SafeIStorageImplementation(storage, lockByteStream); } else { ppstgOpen = null; lockByteStream.Dispose(); } return(result); }
internal SafeIStorageImplementation(UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage, UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream lockBytesStream) { if (storage == null) { throw new ArgumentNullException("storage"); } _unsafeStorage = storage; _unsafePropertySetStorage = (UnsafeNativeCompoundFileMethods.UnsafeNativeIPropertySetStorage)_unsafeStorage; _unsafeLockByteStream = lockBytesStream; }
internal static int SafeStgCreateDocfileOnStream( Stream s, int grfMode, out IStorage ppstgOpen ) { SecurityHelper.DemandCompoundFileIOPermission(); Invariant.Assert(s != null, "s cannot be null"); UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage; UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream lockByteStream = new UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream(s); int result; result = UnsafeNativeCompoundFileMethods.StgCreateDocfileOnILockBytes( (UnsafeNativeCompoundFileMethods.UnsafeNativeILockBytes) lockByteStream, grfMode, 0, // Must be zero out storage); if (result == SafeNativeCompoundFileConstants.S_OK) ppstgOpen = new SafeIStorageImplementation(storage, lockByteStream); else { ppstgOpen = null; lockByteStream.Dispose(); } return result; }
internal static int SafeStgOpenStorageOnStream( Stream s, int grfMode, out IStorage ppstgOpen ) { SecurityHelper.DemandCompoundFileIOPermission(); Invariant.Assert(s != null, "s cannot be null"); UnsafeNativeCompoundFileMethods.UnsafeNativeIStorage storage; UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream lockByteStream = new UnsafeNativeCompoundFileMethods.UnsafeLockBytesOnStream(s); int result; result = UnsafeNativeCompoundFileMethods.StgOpenStorageOnILockBytes( (UnsafeNativeCompoundFileMethods.UnsafeNativeILockBytes) lockByteStream, null, grfMode, new IntPtr(0), // Pointer to SNB struct, not marshalled, must be null. 0, out storage); if (result == SafeNativeCompoundFileConstants.S_OK) ppstgOpen = new SafeIStorageImplementation(storage); else { ppstgOpen = null; lockByteStream.Dispose(); } return result; }