// Decompiled with JetBrains decompiler // Type: Rei.Com.DataObjectHelper // Assembly: Rei.Com, Version=1.13.2.9255, Culture=neutral, PublicKeyToken=null // MVID: 608BC623-FF3D-4118-BA82-AC691A688790 // Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Com.dll using Microsoft.VisualBasic.CompilerServices; using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Windows.Forms; namespace Rei.Com { public class DataObjectHelper { public static VirtualFileInfo[] GetVirtualFileInfo(System.Windows.Forms.IDataObject dobj) { IntPtr zero = IntPtr.Zero; List virtualFileInfoList = new List(); using (MemoryStream data = (MemoryStream) dobj.GetData("FileGroupDescriptorW")) { if (data == null) return new VirtualFileInfo[0]; byte[] numArray1 = new byte[checked ((int) (data.Length - 1L) + 1)]; data.Read(numArray1, 0, numArray1.Length); int int32 = BitConverter.ToInt32(numArray1, 0); IntPtr num1 = Marshal.AllocHGlobal(numArray1.Length); try { Marshal.Copy(numArray1, 0, num1, numArray1.Length); IntPtr ptr = new IntPtr(checked (num1.ToInt64() + (long) Marshal.SizeOf((object) int32))); int num2 = 0; int num3 = checked (int32 - 1); int num4 = num2; while (num4 <= num3) { object structure = Marshal.PtrToStructure(ptr, typeof (FileDescriptor)); FileDescriptor fileDescriptor1 = new FileDescriptor(); FileDescriptor fileDescriptor2 = structure != null ? (FileDescriptor) structure : fileDescriptor1; VirtualFileInfo virtualFileInfo = new VirtualFileInfo(); virtualFileInfo.FileName = fileDescriptor2.cFileName; virtualFileInfo.Flags = fileDescriptor2.dwFlags; if ((fileDescriptor2.dwFlags & FDFlags.FD_CLSID) == (FDFlags) 0) ; if ((fileDescriptor2.dwFlags & FDFlags.FD_SIZEPOINT) == (FDFlags) 0) ; if ((fileDescriptor2.dwFlags & FDFlags.FD_ATTRIBUTES) != (FDFlags) 0) virtualFileInfo.FileAttributes = fileDescriptor2.dwFileAttributes; if ((fileDescriptor2.dwFlags & FDFlags.FD_CREATETIME) != (FDFlags) 0) virtualFileInfo.CreationTime = DateTime.FromFileTime(fileDescriptor2.ftCreationTime); if ((fileDescriptor2.dwFlags & FDFlags.FD_ACCESSTIME) != (FDFlags) 0) virtualFileInfo.LastAccessTime = DateTime.FromFileTime(fileDescriptor2.ftLastAccessTime); if ((fileDescriptor2.dwFlags & FDFlags.FD_WRITESTIME) != (FDFlags) 0) virtualFileInfo.LastWriteTime = DateTime.FromFileTime(fileDescriptor2.ftLastWriteTime); if ((fileDescriptor2.dwFlags & FDFlags.FD_FILESIZE) != (FDFlags) 0) virtualFileInfo.FileSize = fileDescriptor2.FileSize; FORMATETC format = new FORMATETC(); format.cfFormat = BitConverter.ToInt16(BitConverter.GetBytes(DataFormats.GetFormat("FileContents").Id), 0); format.dwAspect = DVASPECT.DVASPECT_CONTENT; format.lindex = num4; format.ptd = IntPtr.Zero; format.tymed = TYMED.TYMED_HGLOBAL | TYMED.TYMED_ISTREAM; STGMEDIUM medium = new STGMEDIUM(); try { ((System.Runtime.InteropServices.ComTypes.IDataObject) dobj).GetData(ref format, out medium); } catch (Exception ex) { ProjectData.SetProjectError(ex); virtualFileInfo.FileAttributes = virtualFileInfo.FileAttributes | FileAttributes.System; ProjectData.ClearProjectError(); } if (medium.tymed == TYMED.TYMED_HGLOBAL) { IntPtr unionmember = medium.unionmember; if (unionmember == IntPtr.Zero) return (VirtualFileInfo[]) null; int length = DataObject.GlobalSize(unionmember); byte[] numArray2 = new byte[checked (length - 1 + 1)]; Marshal.Copy(unionmember, numArray2, 0, length); virtualFileInfo.ManageStream = (Stream) new MemoryStream(numArray2); } else { if (medium.tymed == TYMED.TYMED_ISTORAGE) throw new Exception("doesn't support IStorage"); if (medium.tymed == TYMED.TYMED_ISTREAM) { System.Runtime.InteropServices.ComTypes.IStream objectForIunknown = (System.Runtime.InteropServices.ComTypes.IStream) Marshal.GetObjectForIUnknown(medium.unionmember); Marshal.Release(medium.unionmember); virtualFileInfo.ManageStream = (Stream) new ComStreamAdapterStream(objectForIunknown); } } if (virtualFileInfo.ManageStream == null) virtualFileInfo.ManageStream = (Stream) new MemoryStream(); virtualFileInfoList.Add(virtualFileInfo); ptr = new IntPtr(checked (ptr.ToInt64() + (long) Marshal.SizeOf((object) fileDescriptor2))); checked { ++num4; } } } finally { Marshal.FreeHGlobal(num1); } } return virtualFileInfoList.ToArray(); } public static DragDropEffects GetPreferredDragEffect(System.Windows.Forms.IDataObject dataobject) { DragDropEffects dragDropEffects = DragDropEffects.None; if (dataobject.GetDataPresent(ShellClipboardFormats.PreferredDropEffect)) { MemoryStream data = dataobject.GetData(ShellClipboardFormats.PreferredDropEffect) as MemoryStream; try { if (data != null) { byte[] buffer = new byte[4]; data.Read(buffer, 0, 4); data.Dispose(); dragDropEffects = (DragDropEffects) BitConverter.ToInt32(buffer, 0); } } finally { if (data != null) data.Dispose(); } } return dragDropEffects; } public static Uri GetUniformResourceLocator(System.Windows.Forms.IDataObject dataobject) { Uri result = (Uri) null; string uriString; if (dataobject.GetDataPresent(ShellClipboardFormats.UniformResourceLocatorW)) { MemoryStream data = dataobject.GetData(ShellClipboardFormats.UniformResourceLocatorW) as MemoryStream; if (data != null) { using (StreamReader streamReader = new StreamReader((Stream) data, Encoding.Unicode)) uriString = streamReader.ReadToEnd(); int length = uriString.IndexOf(char.MinValue); if (length >= 0) uriString = uriString.Substring(0, length); if (Uri.TryCreate(uriString, UriKind.Absolute, out result)) return result; } } if (dataobject.GetDataPresent(ShellClipboardFormats.UniformResourceLocator)) { MemoryStream data = dataobject.GetData(ShellClipboardFormats.UniformResourceLocator) as MemoryStream; if (data != null) { using (StreamReader streamReader = new StreamReader((Stream) data, Encoding.Default)) uriString = streamReader.ReadToEnd(); int length = uriString.IndexOf(char.MinValue); if (length >= 0) uriString = uriString.Substring(0, length); if (Uri.TryCreate(uriString, UriKind.Absolute, out result)) return result; } } return (Uri) null; } public static void SetPerformedDragEffect(System.Windows.Forms.IDataObject dataobject, DragDropEffects effect) { System.Runtime.InteropServices.ComTypes.IDataObject dataObject = dataobject as System.Runtime.InteropServices.ComTypes.IDataObject; if (dataObject == null) return; FORMATETC formatIn; formatIn.cfFormat = DataObject.MakecfFormat(ShellClipboardFormats.PerformedDropEffect); formatIn.dwAspect = DVASPECT.DVASPECT_CONTENT; formatIn.lindex = -1; formatIn.ptd = new IntPtr(); formatIn.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM medium; medium.tymed = TYMED.TYMED_HGLOBAL; medium.pUnkForRelease = (object) null; medium.unionmember = Marshal.AllocHGlobal(4); Marshal.WriteInt32(medium.unionmember, 0, (int) effect); dataObject.SetData(ref formatIn, ref medium, true); } public static void SetLogicalPerformedDragEffect(System.Windows.Forms.IDataObject dataobject, DragDropEffects effect) { System.Runtime.InteropServices.ComTypes.IDataObject dataObject = dataobject as System.Runtime.InteropServices.ComTypes.IDataObject; if (dataObject == null) return; FORMATETC formatIn; formatIn.cfFormat = DataObject.MakecfFormat(ShellClipboardFormats.LogicalPerformedDropEffect); formatIn.dwAspect = DVASPECT.DVASPECT_CONTENT; formatIn.lindex = -1; formatIn.ptd = new IntPtr(); formatIn.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM medium; medium.tymed = TYMED.TYMED_HGLOBAL; medium.pUnkForRelease = (object) null; medium.unionmember = Marshal.AllocHGlobal(4); Marshal.WriteInt32(medium.unionmember, 0, (int) effect); dataObject.SetData(ref formatIn, ref medium, true); } public static void SetPasteSucceeded(System.Windows.Forms.IDataObject dataobject, DragDropEffects effect) { System.Runtime.InteropServices.ComTypes.IDataObject dataObject = dataobject as System.Runtime.InteropServices.ComTypes.IDataObject; if (dataObject == null) return; FORMATETC formatIn; formatIn.cfFormat = DataObject.MakecfFormat(ShellClipboardFormats.PasteSucceeded); formatIn.dwAspect = DVASPECT.DVASPECT_CONTENT; formatIn.lindex = -1; formatIn.ptd = new IntPtr(); formatIn.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM medium; medium.tymed = TYMED.TYMED_HGLOBAL; medium.pUnkForRelease = (object) null; medium.unionmember = Marshal.AllocHGlobal(4); Marshal.WriteInt32(medium.unionmember, 0, (int) effect); dataObject.SetData(ref formatIn, ref medium, true); } public static bool CanAsync(System.Windows.Forms.IDataObject dobj) { object objectValue1 = RuntimeHelpers.GetObjectValue(typeof (System.Windows.Forms.DataObject).GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue((object) dobj)); IAsyncOperation objectValue2 = RuntimeHelpers.GetObjectValue(objectValue1.GetType().GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(RuntimeHelpers.GetObjectValue(objectValue1))) as IAsyncOperation; if (objectValue2 == null) return false; bool pfIsOpAsync; objectValue2.GetAsyncMode(out pfIsOpAsync); return pfIsOpAsync; } public static void SetAsyncMode(System.Windows.Forms.IDataObject dobj, bool r) { object objectValue1 = RuntimeHelpers.GetObjectValue(typeof (System.Windows.Forms.DataObject).GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue((object) dobj)); IAsyncOperation objectValue2 = RuntimeHelpers.GetObjectValue(objectValue1.GetType().GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(RuntimeHelpers.GetObjectValue(objectValue1))) as IAsyncOperation; if (objectValue2 == null) return; objectValue2.SetAsyncMode(r); } public static bool StartAsyncOperation(System.Windows.Forms.IDataObject dobj) { object objectValue1 = RuntimeHelpers.GetObjectValue(typeof (System.Windows.Forms.DataObject).GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue((object) dobj)); IAsyncOperation objectValue2 = RuntimeHelpers.GetObjectValue(objectValue1.GetType().GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(RuntimeHelpers.GetObjectValue(objectValue1))) as IAsyncOperation; if (objectValue2 != null) { bool pfIsOpAsync = false; objectValue2.GetAsyncMode(out pfIsOpAsync); if (pfIsOpAsync) { objectValue2.StartOperation(IntPtr.Zero); return true; } } return false; } public static void EndAsyncOperation(System.Windows.Forms.IDataObject dobj, DragDropEffects dwEffect) { object objectValue1 = RuntimeHelpers.GetObjectValue(typeof (System.Windows.Forms.DataObject).GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue((object) dobj)); IAsyncOperation objectValue2 = RuntimeHelpers.GetObjectValue(objectValue1.GetType().GetField("innerData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(RuntimeHelpers.GetObjectValue(objectValue1))) as IAsyncOperation; if (objectValue2 == null) return; bool pfIsOpAsync = false; objectValue2.GetAsyncMode(out pfIsOpAsync); if (!pfIsOpAsync) return; objectValue2.EndOperation(IntPtr.Zero, IntPtr.Zero, (int) dwEffect); } } }