private static int UnlockRegion(IntPtr thisPtr, ulong libOffset, ulong cb, uint dwLockType) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.UnlockRegion(libOffset, cb, dwLockType)); } catch (Exception ex) { return(ex.HResult); } }
private static int CopyTo(IntPtr thisPtr, IntPtr pstm, ulong cb, ulong *pcbRead, ulong *pcbWritten) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.CopyTo(pstm, cb, pcbRead, pcbWritten)); } catch (Exception e) { return(e.HResult); } }
private static int Clone(IntPtr thisPtr, IntPtr *ppstm) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); return((int)inst.Clone(ppstm)); } catch (Exception e) { return(e.HResult); } }
internal static IStreamWrapper GetComWrapper(Interop.Ole32.IStream stream) { IntPtr streamWrapperPtr = Instance.GetOrCreateComInterfaceForObject(stream, CreateComInterfaceFlags.None); Guid streamIID = IID_IStream; int result = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr); Marshal.Release(streamWrapperPtr); ThrowExceptionForHR(result); return(new IStreamWrapper(streamPtr)); }
private static int Stat(IntPtr thisPtr, Interop.Ole32.STATSTG *pstatstg, Interop.Ole32.STATFLAG grfStatFlag) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Stat(pstatstg, grfStatFlag); } catch (Exception e) { return(e.HResult); } return(S_OK); }
private static int Revert(IntPtr thisPtr) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Revert(); } catch (Exception e) { return(e.HResult); } return(S_OK); }
private static int Commit(IntPtr thisPtr, uint grfCommitFlags) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Commit(grfCommitFlags); } catch (Exception e) { return(e.HResult); } return(S_OK); }
private static int Read(IntPtr thisPtr, byte *pv, uint cb, uint *pcbRead) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.Read(pv, cb, pcbRead); } catch (Exception ex) { return(ex.HResult); } return(S_OK); }
private static int SetSize(IntPtr thisPtr, ulong libNewSize) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.SetSize(libNewSize); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int SetSize(IntPtr thisPtr, ulong libNewSize) { try { Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); inst.SetSize(libNewSize); } catch (Exception e) { return(e.HResult); } return(S_OK); }
private static int Revert(IntPtr thisPtr) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Revert(); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Commit(IntPtr thisPtr, uint grfCommitFlags) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Commit((Interop.Ole32.STGC)grfCommitFlags); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Write(IntPtr thisPtr, byte *pv, uint cb, uint *pcbWritten) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Write(pv, cb, pcbWritten); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Stat(IntPtr thisPtr, Interop.Ole32.STATSTG *pstatstg, Interop.Ole32.STATFLAG grfStatFlag) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Stat(out *pstatstg, grfStatFlag); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Seek(IntPtr thisPtr, long dlibMove, SeekOrigin dwOrigin, ulong *plibNewPosition) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); instance.Seek(dlibMove, dwOrigin, plibNewPosition); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
public void Load(Interop.Ole32.IStream pstm) { Guid persistedStreamIID = IID.IPersistStream; Guid streamIID = IID.IStream; IntPtr streamUnknownPtr = IntPtr.Zero; IntPtr streamPtr = IntPtr.Zero; IntPtr persistedStreamPtr = IntPtr.Zero; try { int errorCode = Marshal.QueryInterface(_wrappedInstance, ref persistedStreamIID, out persistedStreamPtr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } streamUnknownPtr = WinFormsComWrappers.Instance.GetOrCreateComInterfaceForObject(pstm, CreateComInterfaceFlags.None); errorCode = Marshal.QueryInterface(streamUnknownPtr, ref streamIID, out streamPtr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } errorCode = ((delegate * unmanaged <IntPtr, IntPtr, int>)(*(*(void ***)persistedStreamPtr + 5 /* IPersistStream.Load slot */))) (persistedStreamPtr, streamPtr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } } finally { if (streamPtr != IntPtr.Zero) { Marshal.Release(streamPtr); } if (streamUnknownPtr != IntPtr.Zero) { int count = Marshal.Release(streamUnknownPtr); Debug.Assert(count == 0, $"streamUnknownPtr = {count}"); } if (persistedStreamPtr != IntPtr.Zero) { Marshal.Release(persistedStreamPtr); } } }
private static int CopyTo(IntPtr thisPtr, IntPtr pstm, ulong cb, ulong *pcbRead, ulong *pcbWritten) { try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); Interop.Ole32.IStream pstmStream = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)pstm); instance.CopyTo(pstmStream, cb, pcbRead, pcbWritten); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
private static int Clone(IntPtr thisPtr, IntPtr *ppstm) { if (ppstm is null) { return((int)Interop.HRESULT.STG_E_INVALIDPOINTER); } try { Interop.Ole32.IStream instance = ComInterfaceDispatch.GetInstance <Interop.Ole32.IStream>((ComInterfaceDispatch *)thisPtr); *ppstm = Instance.GetOrCreateComInterfaceForObject(instance.Clone(), CreateComInterfaceFlags.None); return(S_OK); } catch (Exception ex) { Debug.WriteLine(ex); return(ex.HResult); } }
public unsafe void CopyTo(Interop.Ole32.IStream pstm, ulong cb, ulong *pcbRead, ulong *pcbWritten) { byte[] buffer = ArrayPool <byte> .Shared.Rent(4096); ulong remaining = cb; ulong totalWritten = 0; ulong totalRead = 0; fixed(byte *b = buffer) { while (remaining > 0) { uint read = remaining < (ulong)buffer.Length ? (uint)remaining : (uint)buffer.Length; Read(b, read, &read); remaining -= read; totalRead += read; if (read == 0) { break; } uint written; pstm.Write(b, read, &written); totalWritten += written; } } ArrayPool <byte> .Shared.Return(buffer); if (pcbRead != null) { *pcbRead = totalRead; } if (pcbWritten != null) { *pcbWritten = totalWritten; } }
protected override void Dispose(bool disposing) { try { if (disposing && comStream != null) { try { comStream.Commit(Interop.Ole32.STGC.STGC_DEFAULT); } catch (Exception) { } } // Can't release a COM stream from the finalizer thread. comStream = null; } finally { base.Dispose(disposing); } }
public DataStreamFromComStream(Interop.Ole32.IStream comStream) : base() { this.comStream = comStream; }
internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string?description, out IntPtr metafile);
internal static extern int GdipLoadImageFromStreamICM(Interop.Ole32.IStream stream, out IntPtr image);
internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
internal static extern int GdipSaveImageToStream(HandleRef image, Interop.Ole32.IStream stream, ref Guid classId, HandleRef encoderParams);
internal static extern int GdipGetMetafileHeaderFromStream(Interop.Ole32.IStream stream, IntPtr header);
internal static extern int GdipCreateMetafileFromStream(Interop.Ole32.IStream stream, out IntPtr metafile);
public void Save(Interop.Ole32.IStream pstm, Interop.BOOL fClearDirty) { throw new NotImplementedException(); }
internal static extern int GdipCreateBitmapFromStreamICM(Interop.Ole32.IStream stream, out IntPtr bitmap);