ReClassNET/ReClass.NET

I Fixed ---- Arithmetic operation resulted in an overflow. (ReClass.NET)

chrisjd20 opened this issue · 0 comments

I got this error on 64bit compiled version against a 64 bit process I was memory searching (had to change it to a long):

===================================

Arithmetic operation resulted in an overflow. (ReClass.NET)

------------------------------
For help, click: https://github.com/ReClassNET/ReClass.NET/issues

------------------------------
Program Location:

   at ReClassNET.MemoryScanner.Scanner.ConsolidateSections(IList`1 sections) in C:\Users\chris\Downloads\ReClass.NET-master\ReClass.NET\MemoryScanner\Scanner.cs:line 344
   at ReClassNET.MemoryScanner.Scanner.FirstScan(IScanComparer comparer, IProgress`1 progress, CancellationToken ct) in C:\Users\chris\Downloads\ReClass.NET-master\ReClass.NET\MemoryScanner\Scanner.cs:line 201
   at ReClassNET.Forms.ScannerForm.<StartFirstScanEx>d__43.MoveNext() in C:\Users\chris\Downloads\ReClass.NET-master\ReClass.NET\Forms\ScannerForm.cs:line 0
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at ReClassNET.Forms.ScannerForm.<firstScanButton_Click>d__17.MoveNext() in C:\Users\chris\Downloads\ReClass.NET-master\ReClass.NET\Forms\ScannerForm.cs:line 142

I fixed it by changing Scanner.cs

		class ConsolidatedMemoryRegion
		{
			public IntPtr Address { get; set; }
			public int Size { get; set; } // Keep as int
		}

Also in that same file:

		private static List<ConsolidatedMemoryRegion> ConsolidateSections(IList<Section> sections)
		{
			var regions = new List<ConsolidatedMemoryRegion>();

			if (sections.Count > 0)
			{
				var address = sections[0].Start;
				long size = sections[0].Size.ToInt64(); // Updated to long

				for (var i = 1; i < sections.Count; ++i)
				{
					var section = sections[i];
					if (address + (int)size != section.Start) // Updated to cast to int
					{
						regions.Add(new ConsolidatedMemoryRegion { Address = address, Size = (int)size }); // Updated to cast to int

						address = section.Start;
						size = section.Size.ToInt64(); // Updated to long
					}
					else
					{
						size += section.Size.ToInt64(); // Updated to long
					}
				}

				regions.Add(new ConsolidatedMemoryRegion { Address = address, Size = (int)size }); // Updated to cast to int
			}

			return regions;
		}