Ejemplo n.º 1
0
        public static List <MemoryBasicInformation> LoadRegions(SafeMemoryHandle processHandle, IntPtr startAddress, IntPtr endAddress,
                                                                MemoryAllocationState memoryAllocationState = MemoryAllocationState.MEM_COMMIT,
                                                                MemoryProtectionType memoryProtectionType   = MemoryProtectionType.PAGE_ACCESSIBLE)
        {
            List <MemoryBasicInformation> regions = new List <MemoryBasicInformation>();

            if (startAddress == endAddress)
            {
                return(regions);
            }

            if (endAddress == IntPtr.Zero)
            {
                endAddress = new IntPtr(0x7fffffffffff);
            }

            IntPtr seek = startAddress;

            do
            {
                MemoryBasicInformation region = Native.Query(processHandle, seek, MarshalType <MemoryBasicInformation> .Size);
                if ((region.State & memoryAllocationState) != 0 && (region.Protect & memoryProtectionType) != 0)
                {
                    regions.Add(region);
                }

                seek = IntPtr.Add(region.BaseAddress, region.RegionSize.ToInt32());
            }while (seek.ToInt64() < endAddress.ToInt64());

            return(regions);
        }
Ejemplo n.º 2
0
 internal static extern int VirtualQueryEx(
     SafeMemoryHandle hProcess,
     IntPtr lpAddress,
     out MemoryBasicInformation lpBuffer,
     int dwLength);
Ejemplo n.º 3
0
 internal static extern int VirtualQuery(
     IntPtr lpAddress,
     out MemoryBasicInformation lpBuffer,
     int dwLength);