public SectionView MapView( ProcessHandle processHandle, IntPtr baseAddress, IntPtr commitSize, long sectionOffset, IntPtr viewSize, SectionInherit inheritDisposition, MemoryFlags allocationType, MemoryProtection protection ) { NtStatus status; // sectionOffset requires 2 << 15 = 0x10000 = 65536 alignment. // viewSize will be rounded up to the page size. if ((status = Win32.NtMapViewOfSection( this, processHandle, ref baseAddress, IntPtr.Zero, commitSize, ref sectionOffset, ref viewSize, inheritDisposition, allocationType, protection )) >= NtStatus.Error) { Win32.Throw(status); } return(new SectionView(baseAddress, viewSize)); }
public static extern NtStatus NtMapViewOfSection( [In] IntPtr SectionHandle, [In] IntPtr ProcessHandle, ref IntPtr BaseAddress, [In] IntPtr ZeroBits, [In] IntPtr CommitSize, [Optional] ref long SectionOffset, ref IntPtr ViewSize, [In] SectionInherit InheritDisposition, [In] MemoryFlags AllocationType, [In] MemoryProtection Win32Protect);
public static extern NtStatus NtMapViewOfSection( SafeKernelObjectHandle SectionHandle, SafeKernelObjectHandle ProcessHandle, ref IntPtr BaseAddress, IntPtr ZeroBits, IntPtr CommitSize, [In, Out] LargeInteger SectionOffset, ref IntPtr ViewSize, SectionInherit InheritDisposition, AllocationType AllocationType, ProtectionType Win32Protect );
public static extern NtStatus NtMapViewOfSectionEx( SafeKernelObjectHandle SectionHandle, SafeKernelObjectHandle ProcessHandle, ref IntPtr BaseAddress, IntPtr ZeroBits, IntPtr CommitSize, [In, Out] LargeInteger SectionOffset, ref IntPtr ViewSize, SectionInherit InheritDisposition, AllocationType AllocationType, MemoryAllocationProtect Win32Protect, MemExtendedParameter[] ExtendedParameters, int ExtendedParameterCount );
/// <summary> /// Map section into a specific process /// </summary> /// <param name="process">The process to map into</param> /// <param name="type">The protection of the mapping</param> /// <param name="base_address">Optional base address</param> /// <param name="zero_bits">Number of zero bits.</param> /// <param name="commit_size">Size of pages to commit.</param> /// <param name="section_offset">Offset into the section.</param> /// <param name="view_size">Optional view size</param> /// <param name="allocation_type">Allocation type.</param> /// <param name="section_inherit">Section inheritance type.</param> /// <returns>The mapped section</returns> public NtMappedSection Map(NtProcess process, MemoryAllocationProtect type, IntPtr view_size, IntPtr base_address, IntPtr zero_bits, IntPtr commit_size, LargeInteger section_offset, SectionInherit section_inherit, AllocationType allocation_type) { return(Map(process, type, view_size, base_address, zero_bits, commit_size, section_offset, section_inherit, allocation_type, true).Result); }
/// <summary> /// Map section into a specific process /// </summary> /// <param name="process">The process to map into</param> /// <param name="type">The protection of the mapping</param> /// <param name="base_address">Optional base address</param> /// <param name="zero_bits">Number of zero bits.</param> /// <param name="commit_size">Size of pages to commit.</param> /// <param name="section_offset">Offset into the section.</param> /// <param name="view_size">Optional view size</param> /// <param name="allocation_type">Allocation type.</param> /// <param name="section_inherit">Section inheritance type.</param> /// <param name="throw_on_error">True to throw on error.</param> /// <returns>The mapped section</returns> public NtResult <NtMappedSection> Map(NtProcess process, MemoryAllocationProtect type, IntPtr view_size, IntPtr base_address, IntPtr zero_bits, IntPtr commit_size, LargeInteger section_offset, SectionInherit section_inherit, AllocationType allocation_type, bool throw_on_error) { return(NtSystemCalls.NtMapViewOfSection(Handle, process.Handle, ref base_address, zero_bits, commit_size, section_offset, ref view_size, section_inherit, allocation_type, type) .CreateResult(throw_on_error, () => new NtMappedSection(base_address, view_size.ToInt64(), process, true))); }