public NtMappedSection OpenMappedFile(bool writable) { SectionAccessRights accessRights = SectionAccessRights.MapRead; if (writable) { accessRights |= SectionAccessRights.MapWrite; } using (NtSection section = NtSection.DuplicateFrom(_ent.ProcessId, new IntPtr(_ent.Handle), accessRights)) { return(section.Map(writable ? ProtectionType.ReadWrite : ProtectionType.ReadOnly)); } }
private void openNamedSectionToolStripMenuItem_Click(object sender, EventArgs e) { using (NamedObjectForm frm = new NamedObjectForm("Section")) { if (frm.ShowDialog(this) == DialogResult.OK) { using (NtSection handle = (NtSection)frm.ObjectHandle) { NtMappedSection mapped_file = handle.Map(frm.ReadOnly ? MemoryAllocationProtect.ReadOnly : MemoryAllocationProtect.ReadWrite); SectionEditorForm c = new SectionEditorForm(mapped_file, frm.ObjectName, frm.ReadOnly); c.Show(dockPanel, DockState.Document); } } } }