public IntPtr[] FindInMemoryRegion(byte[] Needle, MEMORY_BASIC_INFORMATION MemoryRegion) { byte[] Memory = ReadMemoryRegion(MemoryRegion); long[] ByteLocations = FindInBytes(Needle, Memory); IntPtr[] Locations = new IntPtr[ByteLocations.LongLength]; for (long index = 0; index < ByteLocations.LongLength; index++) { Locations[index] = (IntPtr)((long)MemoryRegion.BaseAddress + ByteLocations[index]); } return(Locations); }
public MEMORY_BASIC_INFORMATION[] GetMemoryRegions() { ArrayList locations = new ArrayList(); long address = 0; long lastAddress = 0x7fffffff; while (address < lastAddress) { MEMORY_BASIC_INFORMATION meminfo = new MEMORY_BASIC_INFORMATION(); uint result = VirtualQueryEx(TargetHandle, (IntPtr)address, out meminfo, (uint)Marshal.SizeOf(meminfo)); //if((uint)meminfo.RegionSize < 1) { if (result == 0) { break; } address = (long)((long)meminfo.BaseAddress + (long)meminfo.RegionSize); locations.Add(meminfo); } return((MEMORY_BASIC_INFORMATION[])locations.ToArray(typeof(MEMORY_BASIC_INFORMATION))); }
private static extern UInt32 VirtualQueryEx(IntPtr hProcess, IntPtr lpBaseAddress, out MEMORY_BASIC_INFORMATION lpBuffer, UInt32 dwLength);
public byte[] ReadMemoryRegion(MEMORY_BASIC_INFORMATION MemoryRegion) { return ReadMemory(MemoryRegion.BaseAddress, (uint)MemoryRegion.RegionSize); }
public MEMORY_BASIC_INFORMATION[] GetMemoryRegions() { ArrayList locations = new ArrayList(); long address = 0; long lastAddress = 0x7fffffff; while(address < lastAddress) { MEMORY_BASIC_INFORMATION meminfo = new MEMORY_BASIC_INFORMATION(); uint result = VirtualQueryEx(TargetHandle, (IntPtr)address, out meminfo, (uint)Marshal.SizeOf(meminfo)); //if((uint)meminfo.RegionSize < 1) { if(result == 0) { break; } address = (long)((long)meminfo.BaseAddress + (long)meminfo.RegionSize); locations.Add(meminfo); } return (MEMORY_BASIC_INFORMATION[])locations.ToArray(typeof(MEMORY_BASIC_INFORMATION)); }
public IntPtr[] FindInMemoryRegion(byte[] Needle, MEMORY_BASIC_INFORMATION MemoryRegion) { byte[] Memory = ReadMemoryRegion(MemoryRegion); long[] ByteLocations = FindInBytes(Needle, Memory); IntPtr[] Locations = new IntPtr[ByteLocations.LongLength]; for(long index = 0; index < ByteLocations.LongLength; index++) { Locations[index] = (IntPtr)((long)MemoryRegion.BaseAddress+ByteLocations[index]); } return Locations; }
public byte[] ReadMemoryRegion(MEMORY_BASIC_INFORMATION MemoryRegion) { return(ReadMemory(MemoryRegion.BaseAddress, (uint)MemoryRegion.RegionSize)); }