ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs
(Generate patch)

Comparing trunk/Win32/Sojaner.MemoryScanner/MemoryScanner.cs (file contents):
Revision 410 by william, Thu Jun 21 20:02:40 2012 UTC vs.
Revision 411 by william, Thu Jun 21 21:07:34 2012 UTC

# Line 23 | Line 23 | namespace Sojaner.MemoryScanner
23      {
24          // constants information can be found in <winnt.h>
25          [Flags]
26 <        public enum ProcessAccessType
26 >        enum ProcessAccessFlags : uint
27          {
28 <            PROCESS_TERMINATE = (0x0001),
29 <            PROCESS_CREATE_THREAD = (0x0002),
30 <            PROCESS_SET_SESSIONID = (0x0004),
31 <            PROCESS_VM_OPERATION = (0x0008),
32 <            PROCESS_VM_READ = (0x0010),
33 <            PROCESS_VM_WRITE = (0x0020),
34 <            PROCESS_DUP_HANDLE = (0x0040),
35 <            PROCESS_CREATE_PROCESS = (0x0080),
36 <            PROCESS_SET_QUOTA = (0x0100),
37 <            PROCESS_SET_INFORMATION = (0x0200),
38 <            PROCESS_QUERY_INFORMATION = (0x0400)
28 >            All = 0x001F0FFF,
29 >            Terminate = 0x00000001,
30 >            CreateThread = 0x00000002,
31 >            VMOperation = 0x00000008,
32 >            VMRead = 0x00000010,
33 >            VMWrite = 0x00000020,
34 >            DupHandle = 0x00000040,
35 >            SetInformation = 0x00000200,
36 >            QueryInformation = 0x00000400,
37 >            Synchronize = 0x00100000
38          }
39          [Flags]
40          public enum AllocationProtect : uint
# Line 99 | Line 98 | namespace Sojaner.MemoryScanner
98                  //{
99                  //    logger.Warn.WriteLine("Failed to set SeDebugPrivilege on current process");
100                  //}
101 <                ProcessAccessType access;
102 <                access = ProcessAccessType.PROCESS_VM_READ
103 <                    | ProcessAccessType.PROCESS_VM_WRITE
104 <                    | ProcessAccessType.PROCESS_VM_OPERATION;
101 >                ProcessAccessFlags access;
102 >                access = ProcessAccessFlags.VMRead
103 >                    | ProcessAccessFlags.VMWrite
104 >                    | ProcessAccessFlags.VMOperation;
105                  //m_hProcess = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
106 <                handle = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
107 <                m_hProcess = new SafeWaitHandle(handle, false);
106 >                handle = ProcessMemoryReaderApi.OpenProcess(access, true, m_ReadProcess.Id);
107 >                //m_hProcess = new SafeWaitHandle(handle, false);
108              }
109              catch (SEHException ex)
110              {
# Line 124 | Line 123 | namespace Sojaner.MemoryScanner
123          {
124              try
125              {
126 <                //if (handle.IsInvalid) { return; }
127 <                //if (handle.IsClosed) { return; }
128 <                m_hProcess.Close();
129 <                m_hProcess.Dispose();
130 <                m_hProcess = null;
131 <                handle = IntPtr.Zero;
132 <                m_ReadProcess = null;
126 >                ////if (handle.IsInvalid) { return; }
127 >                ////if (handle.IsClosed) { return; }
128 >                //m_hProcess.Close();
129 >                //m_hProcess.Dispose();
130 >                //m_hProcess = null;
131 >                //handle = IntPtr.Zero;
132 >                //m_ReadProcess = null;
133                  //string stack_trace = System.Environment.StackTrace;
134 <                //int iRetValue;
135 <                //iRetValue = ProcessMemoryReaderApi.CloseHandle(m_hProcess);
136 <                //if (iRetValue == 0)
137 <                //{
138 <                //    throw new Exception("CloseHandle failed");
139 <                //}
134 >                int iRetValue;
135 >                iRetValue = ProcessMemoryReaderApi.CloseHandle(handle);
136 >                handle = IntPtr.Zero;
137 >                ReadProcess = null;
138 >                if (iRetValue == 0)
139 >                {
140 >                    throw new Exception("CloseHandle failed");
141 >                }
142              }
143              catch (SEHException ex)
144              {
# Line 167 | Line 168 | namespace Sojaner.MemoryScanner
168              //                  DWORD dwProcessId       // process identifier
169              //                  );
170              [DllImport("kernel32.dll")]
171 <            public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
171 >            public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
172  
173              //          BOOL CloseHandle(
174              //                  HANDLE hObject   // handle to object

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines