From b56e9dd3d419f494500790caa53320a5cdd22d03 Mon Sep 17 00:00:00 2001 From: FrankD Date: Tue, 25 Jun 2024 14:40:13 +0100 Subject: [PATCH] Fix x64 crash: memory addresses are 64 bit integers If the application is built as a 64-bit application, using Scan0.ToInt32() will cause a "Arithmetic operation resulted in an overflow" exception when converting a 64-bit memory address to 32-bit integer --- .../MSR.CVE.BackMaker.ImagePipeline/WPFOpenDocument.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/MapCruncher/MSR.CVE.BackMaker.ImagePipeline/WPFOpenDocument.cs b/Tools/MapCruncher/MSR.CVE.BackMaker.ImagePipeline/WPFOpenDocument.cs index 8a853e64..dfe03b68 100644 --- a/Tools/MapCruncher/MSR.CVE.BackMaker.ImagePipeline/WPFOpenDocument.cs +++ b/Tools/MapCruncher/MSR.CVE.BackMaker.ImagePipeline/WPFOpenDocument.cs @@ -119,7 +119,7 @@ internal Present Render(MapRectangle mapRect, System.Drawing.Size size, bool use System.Drawing.Imaging.PixelFormat.Format32bppArgb); try { - IntPtr buffer = new IntPtr(bitmapData.Scan0.ToInt32() + + IntPtr buffer = new IntPtr(bitmapData.Scan0.ToInt64() + int32Rect.Y * bitmapData.Stride + int32Rect.X * 4); bitmapSource.CopyPixels( new Int32Rect(0, 0, bitmapSource.PixelWidth, bitmapSource.PixelHeight),