Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chrisjd20 opened this issue Aug 17, 2023 · 1 comment

Comments

@chrisjd20
Copy link

chrisjd20 commented Aug 17, 2023

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;
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@chrisjd20 and others