/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/05 00:13:29	280
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2012/06/05 00:19:36	281
@@ -929,11 +929,23 @@
             int STEP_SIZE = (int)SearchArgs.DataType / 8;
 
             GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this);
-            provider.OpenProvider();
-            int bytes_read = 0;
-            byte[] buffered_mem = new byte[int.MaxValue];
-            provider.ReadProcessMemory(0, int.MaxValue, out bytes_read, out buffered_mem);
-            provider.CloseProvider();
+            byte[] buffered_mem = new byte[0];
+            try
+            {
+                provider.OpenProvider();
+                int bytes_read = 0;
+                buffered_mem = new byte[int.MaxValue]; // throws OutOfMemoryException if size is over 2G
+                provider.ReadProcessMemory(0, int.MaxValue, out bytes_read, out buffered_mem);
+                provider.CloseProvider();
+            }
+            catch (OutOfMemoryException ex)
+            {
+                throw ex;
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
             if (buffered_mem.Length == 0) { logger.Warn.WriteLine("Buffered Memory is Zero Length."); return; }
             MemoryStream ms = new MemoryStream(buffered_mem);
             BinaryReader r_ms = new BinaryReader(ms);

 

  ViewVC Help
Powered by ViewVC 1.1.22