コード例 #1
0
        public bool ReadMemory(uint memoryLocation, int bufferLength, out byte[] lpBuffer)
        {
            int lpBytesRead;

            lpBuffer = new byte[bufferLength];
            if (this.m_lpHandle.ToInt32() == 0)
            {
                return(false);
            }
            try
            {
                UIntPtr lpAddress = (UIntPtr)memoryLocation;
                Imports.MEMORY_BASIC_INFORMATION memory_basic_information = new Imports.MEMORY_BASIC_INFORMATION();
                Imports.VirtualQueryEx(this.m_lpHandle, lpAddress, out memory_basic_information, (uint)bufferLength);
                if (!Imports.ReadProcessMemory(this.m_lpHandle, lpAddress, lpBuffer, bufferLength, out lpBytesRead))
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public bool ReadMemory(uint memoryLocation, int bufferLength, out byte[] lpBuffer)
        {
            lpBuffer = new byte[bufferLength];
            if (m_lpHandle.ToInt32() == 0)
            {
                return(false);
            }
            try
            {
                UIntPtr memloc = (UIntPtr)memoryLocation;

                Imports.MEMORY_BASIC_INFORMATION mbi = new Imports.MEMORY_BASIC_INFORMATION();
                Imports.VirtualQueryEx(m_lpHandle, memloc, out mbi, (uint)bufferLength);

                if (Imports.ReadProcessMemory(m_lpHandle, memloc, lpBuffer, bufferLength, out m_lpBytesRead) == false)
                {
                    //Console.WriteLine("Failed to read from Address: {0:X}. Error: {1}", memoryLocation, Imports.GetLastError());
                    return(false);
                }
            }
            catch
            {
                //Console.WriteLine("Failed to read from Address: {0:X}. Error: {1}", memoryLocation, Imports.GetLastError());
                return(false);
            }
            return(true);
        }
コード例 #3
0
        public static List <uint[]> getProcessDynamicMemoryRegions(IntPtr ProcessHandle)
        {
            long MaxAddress     = 0x7fffffffL;
            long CurrentAddress = 0L;

            List <uint[]> ReturnVal = new List <uint[]>();

            do
            {
                Imports.MEMORY_BASIC_INFORMATION lpBuffer = new Imports.MEMORY_BASIC_INFORMATION();
                bool flag = Imports.VirtualQueryEx(ProcessHandle, (IntPtr)CurrentAddress, out lpBuffer, (uint)Marshal.SizeOf(lpBuffer));

                if (flag && lpBuffer.State == 0x1000 && (uint)lpBuffer.RegionSize > 0 &&
                    lpBuffer.Protect == (uint)Imports.MemoryProtection.ReadWrite && lpBuffer.Type == 0x20000)
                {
                    uint[] temp = new uint[2];
                    temp[0] = (uint)lpBuffer.BaseAddress;
                    temp[1] = (uint)lpBuffer.RegionSize;
                    ReturnVal.Add(temp);
                }
                CurrentAddress = lpBuffer.BaseAddress.ToInt64() + lpBuffer.RegionSize.ToInt64();
            }while (CurrentAddress <= MaxAddress);

            return(ReturnVal);
        }
コード例 #4
0
        public void getProcessMemoryRegions()
        {
            long MaxAddress = 0x7fffffff;
            long address    = 0;

            do
            {
                Imports.MEMORY_BASIC_INFORMATION m = new Imports.MEMORY_BASIC_INFORMATION();
                bool result = Imports.VirtualQueryEx(System.Diagnostics.Process.GetProcessesByName("SC2")[0].Handle, (IntPtr)address, out m, (uint)Marshal.SizeOf(m));
                Console.WriteLine("{0}-{1} : {2} bytes result={3}", m.BaseAddress, (uint)m.BaseAddress + (uint)m.RegionSize, m.RegionSize, result);
                address = (long)(m.BaseAddress.ToInt64() + m.RegionSize.ToInt64());
            } while (address <= MaxAddress);
        }
コード例 #5
0
        public void getProcessMemoryRegions()
        {
            long num  = 0x7fffffffL;
            long num2 = 0L;

            do
            {
                Imports.MEMORY_BASIC_INFORMATION lpBuffer = new Imports.MEMORY_BASIC_INFORMATION();
                bool flag = Imports.VirtualQueryEx(Process.GetProcessesByName("SC2")[0].Handle, (IntPtr)num2, out lpBuffer, (uint)Marshal.SizeOf(lpBuffer));
                Console.WriteLine("{0}-{1} : {2} bytes result={3}", new object[] { lpBuffer.BaseAddress, (uint)(((int)lpBuffer.BaseAddress) + ((int)lpBuffer.RegionSize)), lpBuffer.RegionSize, flag });
                num2 = lpBuffer.BaseAddress.ToInt64() + lpBuffer.RegionSize.ToInt64();
            }while (num2 <= num);
        }
コード例 #6
0
        public bool ReadMemory(uint memoryLocation, int bufferLength, out byte[] lpBuffer)
        {
            lpBuffer = new byte[bufferLength];
            if (m_lpHandle.ToInt32() == 0) return false;
            try
            {
                UIntPtr memloc = (UIntPtr)memoryLocation;

                Imports.MEMORY_BASIC_INFORMATION mbi = new Imports.MEMORY_BASIC_INFORMATION();
                Imports.VirtualQueryEx(m_lpHandle, memloc, out mbi, (uint)bufferLength);

                if (Imports.ReadProcessMemory(m_lpHandle, memloc, lpBuffer, bufferLength, out m_lpBytesRead) == false)
                {
                    //Console.WriteLine("Failed to read from Address: {0:X}. Error: {1}", memoryLocation, Imports.GetLastError());
                    return false;
                }
            }
            catch
            {
                //Console.WriteLine("Failed to read from Address: {0:X}. Error: {1}", memoryLocation, Imports.GetLastError());
                return false;
            }
            return true;
        }
コード例 #7
0
 public void getProcessMemoryRegions()
 {
     long MaxAddress = 0x7fffffff;
     long address = 0;
     do
     {
         Imports.MEMORY_BASIC_INFORMATION m = new Imports.MEMORY_BASIC_INFORMATION();
         bool result = Imports.VirtualQueryEx(System.Diagnostics.Process.GetProcessesByName("SC2")[0].Handle, (IntPtr)address, out m, (uint)Marshal.SizeOf(m));
         Console.WriteLine("{0}-{1} : {2} bytes result={3}", m.BaseAddress, (uint)m.BaseAddress + (uint)m.RegionSize, m.RegionSize, result);
         address = (long)(m.BaseAddress.ToInt64() + m.RegionSize.ToInt64());
     } while (address <= MaxAddress);
 }