Пример #1
0
        /// <summary>
        /// Changes the protection on a region of committed pages in the virtual address space of a specified process.
        /// </summary>
        /// <param name="processHandle"></param>
        /// <param name="address"></param>
        /// <param name="size"></param>
        /// <param name="newProtect"></param>
        /// <returns>Returns the previous memory access protection.</returns>
        public static MemoryProtect VirtualProtectEx(IntPtr processHandle, UIntPtr address,
                                                     uint size, MemoryProtect newProtect)
        {
            MemoryProtect oldProtect = new MemoryProtect();

            if (!UnmanagedVirtualProtectEx(processHandle, address, size, newProtect, ref oldProtect))
            {
                throw new Win32Exception();
            }
            return(oldProtect);
        }
Пример #2
0
 internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr address, UIntPtr size, AllocationType allocationType, MemoryProtect protect);
Пример #3
0
 private static extern bool UnmanagedVirtualProtectEx(IntPtr hProcess, UIntPtr lpAddress,
    uint dwSize, MemoryProtect flNewProtect, ref MemoryProtect lpflOldProtect);
Пример #4
0
 static extern UIntPtr UnmanagedVirtualAllocEx(IntPtr hProcess, UIntPtr lpAddress,
    uint dwSize, MemoryAllocationType flAllocationType, MemoryProtect flProtect);
Пример #5
0
 /// <summary>
 /// Changes the protection on a region of committed pages in the virtual address space of a specified process.
 /// </summary>
 /// <param name="processHandle"></param>
 /// <param name="address"></param>
 /// <param name="size"></param>
 /// <param name="newProtect"></param>
 /// <returns>Returns the previous memory access protection.</returns>
 public static MemoryProtect VirtualProtectEx(IntPtr processHandle, UIntPtr address,
     uint size, MemoryProtect newProtect)
 {
     MemoryProtect oldProtect = new MemoryProtect();
     if (!UnmanagedVirtualProtectEx(processHandle, address, size, newProtect, ref oldProtect))
     {
         throw new Win32Exception();
     }
     return oldProtect;
 }
Пример #6
0
 /// <summary>
 /// Reserves or commits a region of memory within the virtual address space of a specified process. 
 /// The function initializes the memory it allocates to zero, unless MEM_RESET is used.
 /// </summary>
 /// <param name="processHandle"></param>
 /// <param name="address"></param>
 /// <param name="size"></param>
 /// <param name="type"></param>
 /// <param name="protect"></param>
 /// <returns></returns>
 public static UIntPtr VirtualAllocEx(IntPtr processHandle, UIntPtr address, uint size, MemoryAllocationType type, MemoryProtect protect)
 {
     UIntPtr addr = UnmanagedVirtualAllocEx(processHandle, address, size, type, protect);
     if (addr == UIntPtr.Zero)
     {
         throw new Win32Exception();
     }
     return addr;
 }
Пример #7
0
        /// <summary>
        /// Reserves or commits a region of memory within the virtual address space of a specified process.
        /// The function initializes the memory it allocates to zero, unless MEM_RESET is used.
        /// </summary>
        /// <param name="processHandle"></param>
        /// <param name="address"></param>
        /// <param name="size"></param>
        /// <param name="type"></param>
        /// <param name="protect"></param>
        /// <returns></returns>
        public static UIntPtr VirtualAllocEx(IntPtr processHandle, UIntPtr address, uint size, MemoryAllocationType type, MemoryProtect protect)
        {
            UIntPtr addr = UnmanagedVirtualAllocEx(processHandle, address, size, type, protect);

            if (addr == UIntPtr.Zero)
            {
                throw new Win32Exception();
            }
            return(addr);
        }
Пример #8
0
 static extern UIntPtr UnmanagedVirtualAllocEx(IntPtr hProcess, UIntPtr lpAddress,
                                               uint dwSize, MemoryAllocationType flAllocationType, MemoryProtect flProtect);
Пример #9
0
 private static extern bool UnmanagedVirtualProtectEx(IntPtr hProcess, UIntPtr lpAddress,
                                                      uint dwSize, MemoryProtect flNewProtect, ref MemoryProtect lpflOldProtect);
Пример #10
0
 public static extern IntPtr VirtualAllocEx(
     IntPtr hProcess, IntPtr lpAddress, uint dwSize, MemoryState flAllocationType, MemoryProtect flProtect);