Example #1
0
        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);
        }
Example #2
0
        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)));
        }
Example #3
0
        private static extern UInt32 VirtualQueryEx(IntPtr hProcess, IntPtr lpBaseAddress,
		out MEMORY_BASIC_INFORMATION lpBuffer, UInt32 dwLength);
Example #4
0
 public byte[] ReadMemoryRegion(MEMORY_BASIC_INFORMATION MemoryRegion)
 {
     return ReadMemory(MemoryRegion.BaseAddress, (uint)MemoryRegion.RegionSize);
 }
Example #5
0
        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));
        }
Example #6
0
        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;
        }
Example #7
0
 private static extern UInt32 VirtualQueryEx(IntPtr hProcess, IntPtr lpBaseAddress,
                                             out MEMORY_BASIC_INFORMATION lpBuffer, UInt32 dwLength);
Example #8
0
 public byte[] ReadMemoryRegion(MEMORY_BASIC_INFORMATION MemoryRegion)
 {
     return(ReadMemory(MemoryRegion.BaseAddress, (uint)MemoryRegion.RegionSize));
 }