Author: gedmurphy
Date: Mon Aug 11 14:04:21 2008
New Revision: 35281
URL:
http://svn.reactos.org/svn/reactos?rev=35281&view=rev
Log:
Setup the named pipe server. Events aren't in place yet, so we don't read or
write.
Modified:
trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs
trunk/tools/reactosdbg/Pipe/namedpipe.cs
trunk/tools/reactosdbg/RosDBG/MainWindow.cs
trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.Designer.cs
trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.cs
Modified: trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/DebugProtocol/Deb…
==============================================================================
--- trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/DebugProtocol/DebugConnection.cs [iso-8859-1] Mon Aug 11
14:04:21 2008
@@ -69,7 +69,7 @@
public class DebugConnection
{
#region Primary State
- public enum Mode { ClosedMode, SocketMode, SerialMode }
+ public enum Mode { ClosedMode, SocketMode, SerialMode, PipeMode }
public Mode ConnectionMode
{
get { return mConnectionMode; }
@@ -109,6 +109,10 @@
#region Serial Mode Members
SerialPort mSerialPort;
+ #endregion
+
+ #region Named Pipe Members
+ NamedPipe mNamedPipe;
#endregion
public event DebugRegisterChangeEventHandler DebugRegisterChangeEvent;
@@ -159,6 +163,14 @@
mDnsAsyncResult = Dns.BeginGetHostEntry(host, mDnsLookup, this);
}
+ public void Start(string pipeName)
+ {
+ Close();
+ mNamedPipe = new NamedPipe();
+ mNamedPipe.Create(pipeName);
+ mNamedPipe.Listen();
+ }
+
public void Start(int baudrate, string port)
{
Close();
@@ -199,6 +211,11 @@
mSerialPort = null;
Running = false;
break;
+ case Mode.PipeMode:
+ mNamedPipe.Close();
+ mNamedPipe = null;
+ Running = false;
+ break;
}
mMedium = null;
Modified: trunk/tools/reactosdbg/Pipe/namedpipe.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/Pipe/namedpipe.cs…
==============================================================================
--- trunk/tools/reactosdbg/Pipe/namedpipe.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/Pipe/namedpipe.cs [iso-8859-1] Mon Aug 11 14:04:21 2008
@@ -23,7 +23,7 @@
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ConnectNamedPipe(
IntPtr hHandle,
- Overlapped lpOverlapped
+ IntPtr lpOverlapped
);
[DllImport("kernel32.dll", SetLastError = true)]
@@ -91,20 +91,15 @@
public class NamedPipe// : Pipe
{
- private const string pipeName = @"\\.\Pipe\RosDbg";
private const Int32 INVALID_HANDLE_VALUE = -1;
+ private const ulong ERROR_PIPE_CONNECTED = 535;
private IntPtr handle;
//FileAccess mode;
- protected NamedPipe()
+ public NamedPipe()
{
handle = IntPtr.Zero;
- }
-
- public IntPtr Create()
- {
- return Create(pipeName);
}
public IntPtr Create(string name)
@@ -141,6 +136,19 @@
if (handle == IntPtr.Zero)
throw new ObjectDisposedException("NamedPipeStream", "The
stream has already been closed");
Kernel32.FlushFileBuffers(handle);
+ }
+
+ public bool Listen()
+ {
+ Disconnect();
+ if (Kernel32.ConnectNamedPipe(handle, IntPtr.Zero) != true)
+ {
+ uint lastErr = (uint)Marshal.GetLastWin32Error();
+ if (lastErr == ERROR_PIPE_CONNECTED)
+ return true;
+ return false;
+ }
+ return true;
}
public int Read(byte[] buffer, int offset, int count)
Modified: trunk/tools/reactosdbg/RosDBG/MainWindow.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/MainWindow…
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/MainWindow.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/MainWindow.cs [iso-8859-1] Mon Aug 11 14:04:21 2008
@@ -327,7 +327,8 @@
PipeTargetSelect targetSelect = new PipeTargetSelect();
if (targetSelect.ShowDialog() == DialogResult.OK)
{
-
+ mConnection.Close();
+ mConnection.Start(targetSelect.PipeName);
}
}
}
Modified: trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.Designer.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/PipeTarget…
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.Designer.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.Designer.cs [iso-8859-1] Mon Aug 11
14:04:21 2008
@@ -101,7 +101,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "PipeTargetSelect";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "PipeTargetSelect";
+ this.Text = "Named Pipe";
this.ResumeLayout(false);
this.PerformLayout();
Modified: trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.cs
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/PipeTarget…
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/PipeTargetSelect.cs [iso-8859-1] Mon Aug 11 14:04:21
2008
@@ -1,20 +1,21 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
namespace RosDBG
{
public partial class PipeTargetSelect : Form
{
+ private const string defaultPipeName = @"\\.\Pipe\RosDbg";
+ private string pipeName;
+
public string PipeName
{
- get { return PipeNameTextBox.Text; }
- set { PipeNameTextBox.Text = value; }
+ get { return pipeName; }
+ }
+
+ public bool UseDefault
+ {
+ get { return DefaultRadioBtn.Checked; }
}
public PipeTargetSelect()
@@ -24,6 +25,15 @@
private void bOK_Click(object sender, EventArgs e)
{
+ if (DefaultRadioBtn.Checked)
+ {
+ pipeName = defaultPipeName;
+ }
+ else
+ {
+ pipeName = PipeNameTextBox.Text;
+ }
+
DialogResult = DialogResult.OK;
Close();
}