initial commit
This commit is contained in:
commit
1b60743303
274 changed files with 25866 additions and 0 deletions
145
Explorer/ShellDataTransfert/DataObjectEx.cs
Normal file
145
Explorer/ShellDataTransfert/DataObjectEx.cs
Normal file
|
@ -0,0 +1,145 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.DataObjectEx
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public class DataObjectEx : DataObject, System.Runtime.InteropServices.ComTypes.IDataObject
|
||||
{
|
||||
private static readonly TYMED[] ALLOWED_TYMEDS = new TYMED[5]
|
||||
{
|
||||
TYMED.TYMED_HGLOBAL,
|
||||
TYMED.TYMED_ISTREAM,
|
||||
TYMED.TYMED_ENHMF,
|
||||
TYMED.TYMED_MFPICT,
|
||||
TYMED.TYMED_GDI
|
||||
};
|
||||
private FileDescriptor[] fileDescriptors;
|
||||
private int fileDescriptorIndex;
|
||||
|
||||
public void SetItems(FileDescriptor[] FileDescriptors)
|
||||
{
|
||||
this.fileDescriptors = FileDescriptors;
|
||||
this.SetData("FileGroupDescriptorW", (object) null);
|
||||
this.SetData("FileContents", (object) null);
|
||||
this.SetData("Performed DropEffect", (object) null);
|
||||
}
|
||||
|
||||
public override object GetData(string format, bool autoConvert)
|
||||
{
|
||||
if (string.Compare(format, "FileGroupDescriptorW", StringComparison.OrdinalIgnoreCase) == 0 && this.fileDescriptors != null)
|
||||
this.SetData("FileGroupDescriptorW", (object) this.GetFileDescriptor(this.fileDescriptors));
|
||||
else if (string.Compare(format, "FileContents", StringComparison.OrdinalIgnoreCase) == 0)
|
||||
this.SetData("FileContents", (object) this.GetFileContents(this.fileDescriptors, this.fileDescriptorIndex));
|
||||
else
|
||||
string.Compare(format, "Performed DropEffect", StringComparison.OrdinalIgnoreCase);
|
||||
return base.GetData(format, autoConvert);
|
||||
}
|
||||
|
||||
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||
void System.Runtime.InteropServices.ComTypes.IDataObject.GetData(
|
||||
ref FORMATETC formatetc,
|
||||
out STGMEDIUM medium)
|
||||
{
|
||||
if ((int) formatetc.cfFormat == (int) (short) DataFormats.GetFormat("FileContents").Id)
|
||||
this.fileDescriptorIndex = formatetc.lindex;
|
||||
medium = new STGMEDIUM();
|
||||
if (DataObjectEx.GetTymedUseable(formatetc.tymed))
|
||||
{
|
||||
if ((formatetc.tymed & TYMED.TYMED_ISTREAM) != TYMED.TYMED_NULL)
|
||||
{
|
||||
medium.tymed = TYMED.TYMED_ISTREAM;
|
||||
medium.unionmember = IntPtr.Zero;
|
||||
System.Runtime.InteropServices.ComTypes.IStream fileContents = this.GetFileContents(this.fileDescriptors, this.fileDescriptorIndex);
|
||||
if (fileContents == null)
|
||||
return;
|
||||
medium.unionmember = Marshal.GetComInterfaceForObject((object) fileContents, typeof (System.Runtime.InteropServices.ComTypes.IStream));
|
||||
}
|
||||
else
|
||||
{
|
||||
medium.tymed = formatetc.tymed;
|
||||
((System.Runtime.InteropServices.ComTypes.IDataObject) this).GetDataHere(ref formatetc, ref medium);
|
||||
}
|
||||
}
|
||||
else
|
||||
Marshal.ThrowExceptionForHR(-2147221399);
|
||||
}
|
||||
|
||||
private static bool GetTymedUseable(TYMED tymed)
|
||||
{
|
||||
for (int index = 0; index < DataObjectEx.ALLOWED_TYMEDS.Length; ++index)
|
||||
{
|
||||
if ((tymed & DataObjectEx.ALLOWED_TYMEDS[index]) != TYMED.TYMED_NULL)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private MemoryStream GetFileDescriptor(FileDescriptor[] FileDescriptors)
|
||||
{
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
memoryStream.Write(BitConverter.GetBytes(FileDescriptors.Length), 0, 4);
|
||||
DataObjectEx.FILEDESCRIPTOR filedescriptor = new DataObjectEx.FILEDESCRIPTOR();
|
||||
foreach (FileDescriptor fileDescriptor in FileDescriptors)
|
||||
{
|
||||
filedescriptor.cFileName = fileDescriptor.FileName;
|
||||
filedescriptor.dwFlags = 16384U;
|
||||
filedescriptor.dwFlags |= 68U;
|
||||
filedescriptor.dwFlags |= 56U;
|
||||
filedescriptor.dwFileAttributes = fileDescriptor.IsDirectory ? 16U : 128U;
|
||||
long fileTime = fileDescriptor.WriteTime.ToFileTime();
|
||||
System.Runtime.InteropServices.ComTypes.FILETIME filetime = new System.Runtime.InteropServices.ComTypes.FILETIME()
|
||||
{
|
||||
dwLowDateTime = (int) (fileTime & (long) uint.MaxValue),
|
||||
dwHighDateTime = (int) (fileTime >> 32)
|
||||
};
|
||||
filedescriptor.ftLastWriteTime = filetime;
|
||||
filedescriptor.ftCreationTime = filetime;
|
||||
filedescriptor.nFileSizeHigh = (uint) (fileDescriptor.FileSize >> 32);
|
||||
filedescriptor.nFileSizeLow = (uint) ((ulong) fileDescriptor.FileSize & (ulong) uint.MaxValue);
|
||||
int length = Marshal.SizeOf((object) filedescriptor);
|
||||
IntPtr num = Marshal.AllocHGlobal(length);
|
||||
Marshal.StructureToPtr((object) filedescriptor, num, true);
|
||||
byte[] numArray = new byte[length];
|
||||
Marshal.Copy(num, numArray, 0, length);
|
||||
Marshal.FreeHGlobal(num);
|
||||
memoryStream.Write(numArray, 0, numArray.Length);
|
||||
}
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private System.Runtime.InteropServices.ComTypes.IStream GetFileContents(
|
||||
FileDescriptor[] FileDescriptors,
|
||||
int FileNumber)
|
||||
{
|
||||
return FileNumber >= FileDescriptors.Length || FileDescriptors[FileNumber].Data == null ? (System.Runtime.InteropServices.ComTypes.IStream) null : (System.Runtime.InteropServices.ComTypes.IStream) new StreamWrapper(FileDescriptors[FileNumber].Data, FileDescriptors[FileNumber].FileName);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
private struct FILEDESCRIPTOR
|
||||
{
|
||||
public uint dwFlags;
|
||||
public Guid clsid;
|
||||
public Size sizel;
|
||||
public Point pointl;
|
||||
public uint dwFileAttributes;
|
||||
public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime;
|
||||
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime;
|
||||
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime;
|
||||
public uint nFileSizeHigh;
|
||||
public uint nFileSizeLow;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string cFileName;
|
||||
}
|
||||
}
|
||||
}
|
24
Explorer/ShellDataTransfert/FileDescriptor.cs
Normal file
24
Explorer/ShellDataTransfert/FileDescriptor.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.FileDescriptor
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public class FileDescriptor
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public long FileSize { get; set; }
|
||||
|
||||
public DateTime WriteTime { get; set; }
|
||||
|
||||
public Stream Data { get; set; }
|
||||
|
||||
public bool IsDirectory { get; set; }
|
||||
}
|
||||
}
|
112
Explorer/ShellDataTransfert/FileDescriptorFactory.cs
Normal file
112
Explorer/ShellDataTransfert/FileDescriptorFactory.cs
Normal file
|
@ -0,0 +1,112 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.FileDescriptorFactory
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
using ImageReader.ISO9660.DirectoryRecords;
|
||||
using ImageReader.Stream;
|
||||
using SEGATools.DiscFileSystem;
|
||||
using SEGATools.Security;
|
||||
using SEGATools.VirtualFile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public class FileDescriptorFactory
|
||||
{
|
||||
private static readonly string DEFAULT_FILENAME = "no_name";
|
||||
|
||||
public static FileDescriptor createFromVirtualFile(IVirtualFile virtualFile)
|
||||
{
|
||||
FileDescriptor fileDescriptor = new FileDescriptor();
|
||||
System.IO.Stream fileInputStream = virtualFile.FileInputStream;
|
||||
fileDescriptor.FileName = virtualFile.VirtualName;
|
||||
fileDescriptor.WriteTime = DateTime.Now;
|
||||
fileDescriptor.IsDirectory = false;
|
||||
fileDescriptor.Data = fileInputStream;
|
||||
fileDescriptor.FileSize = fileInputStream.Length;
|
||||
return fileDescriptor;
|
||||
}
|
||||
|
||||
private static FileDescriptor createFromDirectoryRecord(
|
||||
DirectoryRecord directoryRecord,
|
||||
IDiscFileSystem discFileSystem,
|
||||
string directoryRecordFileName)
|
||||
{
|
||||
string str = directoryRecordFileName;
|
||||
if (string.Empty.Equals(directoryRecordFileName))
|
||||
str = FileDescriptorFactory.DEFAULT_FILENAME;
|
||||
FileDescriptor fileDescriptor = new FileDescriptor();
|
||||
DiscSectorStream forDirectoryRecord = discFileSystem.GetDiscStreamForDirectoryRecord(directoryRecord);
|
||||
fileDescriptor.FileName = str;
|
||||
fileDescriptor.WriteTime = directoryRecord.RecordingDateTime.HasValue ? directoryRecord.RecordingDateTime.Value : DateTime.Now;
|
||||
fileDescriptor.IsDirectory = directoryRecord.IsDirectory;
|
||||
fileDescriptor.Data = (System.IO.Stream) forDirectoryRecord;
|
||||
fileDescriptor.FileSize = directoryRecord.IsDirectory ? 0L : forDirectoryRecord.Length;
|
||||
return fileDescriptor;
|
||||
}
|
||||
|
||||
public static FileDescriptor[] createFromDirectoryRecordTree(
|
||||
DirectoryRecord directoryRecord,
|
||||
IDiscFileSystem discFileSystem)
|
||||
{
|
||||
List<FileDescriptor> fileDescriptorList = new List<FileDescriptor>();
|
||||
int count = 1;
|
||||
if (!directoryRecord.IsRoot)
|
||||
{
|
||||
count = directoryRecord.ParentDirectory.FullPath.Length;
|
||||
if (!directoryRecord.ParentDirectory.IsRoot)
|
||||
++count;
|
||||
fileDescriptorList.Add(FileDescriptorFactory.createFromDirectoryRecord(directoryRecord, discFileSystem, directoryRecord.Name));
|
||||
}
|
||||
foreach (DirectoryRecord allSubDirectory in directoryRecord.GetAllSubDirectories())
|
||||
{
|
||||
string directoryRecordFileName = allSubDirectory.FullPath.Remove(0, count);
|
||||
fileDescriptorList.Add(FileDescriptorFactory.createFromDirectoryRecord(allSubDirectory, discFileSystem, directoryRecordFileName));
|
||||
}
|
||||
return fileDescriptorList.ToArray();
|
||||
}
|
||||
|
||||
public static DataObject createDataObject(object Handle, IDiscFileSystem Disc)
|
||||
{
|
||||
DataObjectEx dataObjectEx = new DataObjectEx();
|
||||
FileDescriptor[] FileDescriptors;
|
||||
switch (Handle)
|
||||
{
|
||||
case DirectoryRecord _:
|
||||
FileDescriptors = FileDescriptorFactory.createFromDirectoryRecordTree(Handle as DirectoryRecord, Disc);
|
||||
break;
|
||||
case InitialProgramExtended _:
|
||||
FileDescriptors = new FileDescriptor[1]
|
||||
{
|
||||
FileDescriptorFactory.createFromVirtualFile((IVirtualFile) VirtualFileFactory.createVirtualFile(Handle as InitialProgramExtended))
|
||||
};
|
||||
break;
|
||||
case IVirtualFile _:
|
||||
FileDescriptors = new FileDescriptor[1]
|
||||
{
|
||||
FileDescriptorFactory.createFromVirtualFile(Handle as IVirtualFile)
|
||||
};
|
||||
break;
|
||||
case IList<DirectoryRecord> _:
|
||||
IList<DirectoryRecord> directoryRecordList = Handle as IList<DirectoryRecord>;
|
||||
List<FileDescriptor> fileDescriptorList = new List<FileDescriptor>(directoryRecordList.Count);
|
||||
foreach (DirectoryRecord directoryRecord in (IEnumerable<DirectoryRecord>) directoryRecordList)
|
||||
{
|
||||
FileDescriptor[] directoryRecordTree = FileDescriptorFactory.createFromDirectoryRecordTree(directoryRecord, Disc);
|
||||
fileDescriptorList.AddRange((IEnumerable<FileDescriptor>) ((IEnumerable<FileDescriptor>) directoryRecordTree).ToList<FileDescriptor>());
|
||||
}
|
||||
FileDescriptors = fileDescriptorList.ToArray();
|
||||
break;
|
||||
default:
|
||||
return (DataObject) null;
|
||||
}
|
||||
dataObjectEx.SetItems(FileDescriptors);
|
||||
return (DataObject) dataObjectEx;
|
||||
}
|
||||
}
|
||||
}
|
15
Explorer/ShellDataTransfert/LOCKTYPE.cs
Normal file
15
Explorer/ShellDataTransfert/LOCKTYPE.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.LOCKTYPE
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public enum LOCKTYPE
|
||||
{
|
||||
LOCK_WRITE = 1,
|
||||
LOCK_EXCLUSIVE = 2,
|
||||
LOCK_ONLYONCE = 4,
|
||||
}
|
||||
}
|
41
Explorer/ShellDataTransfert/NativeMethods.cs
Normal file
41
Explorer/ShellDataTransfert/NativeMethods.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.NativeMethods
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public class NativeMethods
|
||||
{
|
||||
public const string CFSTR_PREFERREDDROPEFFECT = "Preferred DropEffect";
|
||||
public const string CFSTR_PERFORMEDDROPEFFECT = "Performed DropEffect";
|
||||
public const string CFSTR_FILEDESCRIPTORW = "FileGroupDescriptorW";
|
||||
public const string CFSTR_FILECONTENTS = "FileContents";
|
||||
public const int FD_CLSID = 1;
|
||||
public const int FD_SIZEPOINT = 2;
|
||||
public const int FD_ATTRIBUTES = 4;
|
||||
public const int FD_CREATETIME = 8;
|
||||
public const int FD_ACCESSTIME = 16;
|
||||
public const int FD_WRITESTIME = 32;
|
||||
public const int FD_FILESIZE = 64;
|
||||
public const int FD_PROGRESSUI = 16384;
|
||||
public const int FD_LINKUI = 32768;
|
||||
public const uint FILE_ATTRIBUTE_READONLY = 1;
|
||||
public const uint FILE_ATTRIBUTE_HIDDEN = 2;
|
||||
public const uint FILE_ATTRIBUTE_SYSTEM = 4;
|
||||
public const uint FILE_ATTRIBUTE_DIRECTORY = 16;
|
||||
public const uint FILE_ATTRIBUTE_ARCHIVE = 32;
|
||||
public const uint FILE_ATTRIBUTE_NORMAL = 128;
|
||||
public const int DV_E_TYMED = -2147221399;
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr GlobalAlloc(int uFlags, int dwBytes);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern IntPtr GlobalFree(HandleRef handle);
|
||||
}
|
||||
}
|
16
Explorer/ShellDataTransfert/STGTY.cs
Normal file
16
Explorer/ShellDataTransfert/STGTY.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.STGTY
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public enum STGTY
|
||||
{
|
||||
STGTY_STORAGE = 1,
|
||||
STGTY_STREAM = 2,
|
||||
STGTY_LOCKBYTES = 3,
|
||||
STGTY_PROPERTY = 4,
|
||||
}
|
||||
}
|
53
Explorer/ShellDataTransfert/StreamWrapper.cs
Normal file
53
Explorer/ShellDataTransfert/StreamWrapper.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: GDRomExplorer.ShellDataTransfert.StreamWrapper
|
||||
// Assembly: GD-ROM Explorer, Version=1.6.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
|
||||
// MVID: B7A7D10A-9A63-4E9E-9840-D297E5FC2219
|
||||
// Assembly location: GD-ROM Explorer.exe
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
||||
namespace GDRomExplorer.ShellDataTransfert
|
||||
{
|
||||
public class StreamWrapper : IStream
|
||||
{
|
||||
private Stream fileStream;
|
||||
private string fileName;
|
||||
|
||||
public StreamWrapper(Stream fileStream, string fileName)
|
||||
{
|
||||
this.fileStream = fileStream;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public void Read(byte[] pv, int cb, IntPtr pcbRead) => Marshal.WriteInt32(pcbRead, this.fileStream.Read(pv, 0, cb));
|
||||
|
||||
public void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition) => Marshal.WriteInt32(plibNewPosition, (int) this.fileStream.Seek(dlibMove, (SeekOrigin) dwOrigin));
|
||||
|
||||
public void Clone(out IStream ppstm) => throw new NotImplementedException();
|
||||
|
||||
public void Commit(int grfCommitFlags) => throw new NotImplementedException();
|
||||
|
||||
public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten) => throw new NotImplementedException();
|
||||
|
||||
public void LockRegion(long libOffset, long cb, int dwLockType) => throw new NotImplementedException();
|
||||
|
||||
public void Revert() => throw new NotImplementedException();
|
||||
|
||||
public void SetSize(long libNewSize) => throw new NotImplementedException();
|
||||
|
||||
public void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG pstatstg, int grfStatFlag)
|
||||
{
|
||||
pstatstg = new System.Runtime.InteropServices.ComTypes.STATSTG();
|
||||
pstatstg.type = 2;
|
||||
pstatstg.cbSize = this.fileStream.Length;
|
||||
pstatstg.pwcsName = this.fileName;
|
||||
}
|
||||
|
||||
public void UnlockRegion(long libOffset, long cb, int dwLockType) => throw new NotImplementedException();
|
||||
|
||||
public void Write(byte[] pv, int cb, IntPtr pcbWritten) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue