Esempio n. 1
0
 /// <summary>
 /// </summary>
 private void LoadRegions()
 {
     try
     {
         _regions = new List <UnsafeNativeMethods.MEMORY_BASIC_INFORMATION>();
         var address = new IntPtr();
         while (true)
         {
             var info   = new UnsafeNativeMethods.MEMORY_BASIC_INFORMATION();
             var result = UnsafeNativeMethods.VirtualQueryEx(MemoryHandler.Instance.ProcessHandle, address, out info, (uint)Marshal.SizeOf(info));
             if (0 == result)
             {
                 break;
             }
             if (0 != (info.State & MemCommit) && 0 != (info.Protect & Writable) && 0 == (info.Protect & PageGuard))
             {
                 _regions.Add(info);
             }
             else
             {
                 MemoryHandler.Instance.RaiseException(Logger, new Exception(info.ToString()));
             }
             address = IntPtr.Add(info.BaseAddress, info.RegionSize.ToInt32());
         }
     }
     catch (Exception ex)
     {
         MemoryHandler.Instance.RaiseException(Logger, ex, true);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// </summary>
 private void LoadRegions()
 {
     try
     {
         _regions = new List<UnsafeNativeMethods.MEMORY_BASIC_INFORMATION>();
         var address = new IntPtr();
         while (true)
         {
             var info = new UnsafeNativeMethods.MEMORY_BASIC_INFORMATION();
             var result = UnsafeNativeMethods.VirtualQueryEx(MemoryHandler.Instance.ProcessHandle, address, out info, (uint) Marshal.SizeOf(info));
             if (0 == result)
             {
                 break;
             }
             if (0 != (info.State & MemCommit) && 0 != (info.Protect & Writable) && 0 == (info.Protect & PageGuard))
             {
                 _regions.Add(info);
             }
             address = IntPtr.Add(info.BaseAddress, info.RegionSize.ToInt32());
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }