Example #1
0
 private Win32DebugConsole(int session_id, NtEvent buffer_ready, NtEvent data_ready,
                           NtSection buffer, NtMappedSection mapped_buffer)
 {
     _session_id      = session_id;
     _buffer_ready    = buffer_ready;
     _data_ready      = data_ready;
     _buffer          = buffer;
     _mapped_buffer   = mapped_buffer;
     _data_ready_wait = data_ready.DuplicateAsWaitHandle();
     _symlinks        = new Dictionary <int, DisposableList <NtSymbolicLink> >();
 }
Example #2
0
        public static bool ChangeLogPathInSection(string path, out string previousPath)
        {
            previousPath = null;

            // open and map section RW
            NtSection section = null;

            foreach (string name in PulseSharedSectionNames)
            {
                if (section != null)
                {
                    break;
                }
                try {
                    section = NtSection.Open(name, null, SectionAccessRights.MapRead | SectionAccessRights.MapWrite);
                } catch {}
            }
            if (section == null)
            {
                return(false);
            }
            NtMappedSection map = null;

            try {
                map = section.MapReadWrite();
            } catch {
                return(false);
            }
            if (map == null)
            {
                return(false);
            }

            // read the old path and write the new one
            try {
                byte[] buf = new byte[LogPathMaxLength];
                map.ReadArray(LogPathOffset, buf, 0, LogPathMaxLength);
                previousPath = BytesToString(buf);
                buf          = StringToBytes(path + '\0');
                if (buf.Length > LogPathMaxLength)
                {
                    return(false);
                }
                map.WriteArray(LogPathOffset, buf, 0, buf.Length);
            } catch {
                return(false);
            }
            return(true);
        }
 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);
             }
         }
     }
 }
Example #4
0
        private SectionEditorForm(NtMappedSection map, bool readOnly)
        {
            _random   = new Random();
            _map      = map;
            _readOnly = readOnly;
            _prov     = new NativeMappedFileByteProvider(_map, _readOnly);

            InitializeComponent();
            if (_readOnly)
            {
                corruptToolStripMenuItem.Visible      = false;
                loadFromFileToolStripMenuItem.Visible = false;
            }

            hexBox.ByteProvider = _prov;

            Disposed += SectionEditorForm_Disposed;
        }
        private SectionEditorForm(NtMappedSection map, bool readOnly)
        {
            _random = new Random();
            _map = map;
            _readOnly = readOnly;
            _prov = new NativeMappedFileByteProvider(_map, _readOnly);            

            InitializeComponent();
            if (_readOnly)
            {
                corruptToolStripMenuItem.Visible = false;
                loadFromFileToolStripMenuItem.Visible = false;
            }

            hexBox.ByteProvider = _prov;

            Disposed += SectionEditorForm_Disposed;
        }
        static string GetName(NtSection section, NtMappedSection map)
        {
            string name = String.Empty;

            try
            {
                name = map.FullPath;
                if (string.IsNullOrEmpty(name))
                {
                    name = section.FullPath;
                }
            }
            catch (NtException)
            {
            }

            return(string.IsNullOrEmpty(name) ?
                   $"Handle {section.Handle.DangerousGetHandle()} - 0x{map.DangerousGetHandle().ToInt64():X}" : name);
        }
        private SectionEditorForm(NtMappedSection map, bool readOnly, long length)
        {
            _random            = new Random();
            _map               = map;
            _readOnly          = readOnly;
            _prov              = new NativeMappedFileByteProvider(_map, _readOnly, length);
            _prov.ByteWritten += _prov_ByteWritten;

            InitializeComponent();
            if (_readOnly)
            {
                corruptToolStripMenuItem.Visible      = false;
                loadFromFileToolStripMenuItem.Visible = false;
            }

            loadFromFileToolStripMenuItem.Enabled = !_readOnly;
            toolStripButtonLoad.Enabled           = !_readOnly;
            hexBox.ByteProvider = _prov;
            InitDataInspectors();
            UpdateDataInspectors();

            Disposed += SectionEditorForm_Disposed;
        }
 public SectionEditorForm(NtMappedSection map, string name, bool readOnly, long length)
     : this(map, readOnly, length)
 {
     TabText = $"{name} {GetReadOnlyString()}";
     Text    = TabText;
 }
 public SectionEditorForm(NtMappedSection map, NtHandle handle, bool readOnly)
     : this(map, handle, readOnly, map.Length)
 {
 }
 public SectionEditorForm(NtMappedSection map, NtHandle handle, bool readOnly, long length)
     : this(map, readOnly, length)
 {
     TabText = $"Process {handle.ProcessId} - Handle {handle.Handle} {GetReadOnlyString()}";
 }
Example #11
0
 public SectionEditorForm(NtMappedSection map, string name, bool readOnly)
     : this(map, readOnly)
 {
     TabText = String.Format("{0} {1}", name, _readOnly ? "(RO)" : "");
     Text    = TabText;
 }
 public NativeMappedFileByteProvider(NtMappedSection map, bool readOnly, long length)
 {
     _readOnly = readOnly;
     _map      = map;
     Length    = Math.Min(length, map.ValidLength);
 }
Example #13
0
 public NativeMappedFileByteProvider(NtMappedSection map, bool readOnly)
 {
     _readOnly = readOnly;
     _map      = map;
 }
 public SectionEditorForm(NtMappedSection map, string name, bool readOnly)
     : this(map, readOnly)
 {            
     TabText = String.Format("{0} {1}", name, _readOnly ? "(RO)" : "");
 }
 public SectionEditorForm(NtMappedSection map, NtHandle handle, bool readOnly) 
     : this(map, readOnly)        
 {                           
     TabText = String.Format("Process {0} - Handle {1} {2}", handle.ProcessId, handle.Handle, _readOnly ? "(RO)" : "");            
 }
 public SectionEditorForm(NtMappedSection map, string name, bool readOnly)
     : this(map, name, readOnly, map.Length)
 {
 }
Example #17
0
 public SectionEditorForm(NtMappedSection map, NtHandle handle, bool readOnly)
     : this(map, readOnly)
 {
     TabText = String.Format("Process {0} - Handle {1} {2}", handle.ProcessId, handle.Handle, _readOnly ? "(RO)" : "");
 }
Example #18
0
 public NativeMappedFileByteProvider(NtMappedSection map, bool readOnly, long length)
 {
     _readOnly = readOnly;
     _map      = map;
     Length    = length;
 }