VirtualAllocEx() private method

private VirtualAllocEx ( IntPtr hProcess, IntPtr lpAddress, uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect ) : IntPtr
hProcess System.IntPtr
lpAddress System.IntPtr
dwSize uint
flAllocationType AllocationType
flProtect MemoryProtection
return System.IntPtr
コード例 #1
0
        public static RemoteMemoryRegion Allocate(Process process, SafeProcessHandle handle, UInt32 size)
        {
            var result = new RemoteMemoryRegion {
                Process = process,
                Size    = size
            };

            result.Address = Win32.VirtualAllocEx(
                handle.DangerousGetHandle(), IntPtr.Zero,
                size, AllocationType.Commit | AllocationType.Reserve,
                MemoryProtection.ReadWrite
                );
            if (result.Address == IntPtr.Zero)
            {
                var error = Win32.GetLastError();
                throw new Exception(String.Format("Allocation failed: Error {0:x8}", error));
            }
            return(result);
        }