/[RomCheater]/trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs
ViewVC logotype

Diff of /trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs

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

--- trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs	2012/06/05 01:50:13	283
+++ trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs	2012/06/05 01:50:38	284
@@ -7,6 +7,7 @@
 using RomCheater.Logging;
 using System.IO;
 using Sojaner.MemoryScanner.MemoryProviers;
+using Microsoft.Win32.SafeHandles;
 
 namespace Sojaner.MemoryScanner
 {
@@ -37,7 +38,7 @@
         }
 
         private Process m_ReadProcess = null;
-
+        
         private static IntPtr m_hProcess = IntPtr.Zero;
 
         public void OpenProcess()
@@ -68,12 +69,16 @@
         {
             try
             {
-                int iRetValue;
-                iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess);
-                if (iRetValue == 0)
-                {
-                    throw new Exception("CloseHandle failed");
-                }
+                SafeWaitHandle handle = new SafeWaitHandle(m_hProcess, true);
+                if (handle.IsClosed) { return; }                
+                handle.Close();
+                //string stack_trace = System.Environment.StackTrace;
+                //int iRetValue;
+                //iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess);
+                //if (iRetValue == 0)
+                //{
+                //    throw new Exception("CloseHandle failed");
+                //}
             }
             catch (SEHException ex)
             {

 

  ViewVC Help
Powered by ViewVC 1.1.22