From 2305674a0926e27124e3b184faea9bee0070e839 Mon Sep 17 00:00:00 2001 From: Chris Vigelius Date: Thu, 28 Sep 2023 19:31:53 +0200 Subject: [PATCH] fix data corruption when FILEGROUPDESCRIPTOR is larger than 4k Due to missing offset in Marshal.Copy, ReadHGlobalIntoStream replicates the first 4k of the hGlobal, leading to truncated filenames when dragging a lot of mails (10 or more). --- OutlookFileDrag/DataObjectHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OutlookFileDrag/DataObjectHelper.cs b/OutlookFileDrag/DataObjectHelper.cs index 3242d2f..97bb8cd 100644 --- a/OutlookFileDrag/DataObjectHelper.cs +++ b/OutlookFileDrag/DataObjectHelper.cs @@ -392,7 +392,7 @@ private static void ReadHGlobalIntoStream(IntPtr handle, Stream stream) { //Copy buffer length or remaining length, whichever is smaller bytesToCopy = Math.Min(buffer.Length, length - offset); - Marshal.Copy(source, buffer, 0, bytesToCopy); + Marshal.Copy(source + offset, buffer, 0, bytesToCopy); stream.Write(buffer, 0, bytesToCopy); } }