Exemple #1
0
            private static bool IsReadableMemory(IntPtr address, out uint regionSize)
            {
                const int MEM_COMMIT     = 0x00001000;
                const int MEM_PRIVATE    = 0x20000;
                const int MEM_IMAGE      = 0x1000000;
                const int PAGE_NOACCESS  = 0x01;
                const int PAGE_READONLY  = 0x02;
                const int PAGE_READWRITE = 0x04;
                const int PAGE_GUARD     = 0x100;

                var mbi = new MEMORY_BASIC_INFORMATION();

                WinApi.VirtualQuery(address, ref mbi, Marshal.SizeOf <MEMORY_BASIC_INFORMATION>());

                regionSize = (uint)mbi.RegionSize.ToInt32();

                return(mbi.State == MEM_COMMIT &&
                       !Convert.ToBoolean(mbi.Protect & PAGE_GUARD) &&
                       mbi.Protect > PAGE_NOACCESS &&
                       mbi.Type == MEM_PRIVATE);
            }
Exemple #2
0
 public static extern int VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength);
Exemple #3
0
 public static extern int VirtualQuery(
     IntPtr lpAddress,
     ref MEMORY_BASIC_INFORMATION lpBuffer,
     int dwLength
     );