This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
是的,这在技术上是可行的。您将需要一个过滤器驱动程序,这是一种在本机串行端口驱动程序之前注入自身的组件的设备驱动程序类型。在将驱动程序 IRP 发送给常规驱动程序之前,它会对驱动程序 IRP 进行破解。
这是 SysInternals 的 PortMon 实用程序使用的技术。但是,您无法用 C# 代码编写这样的驱动程序,CLR 无法加载到 Ring 0 中。至少在超级机密的 Midori 项目问世之前不能。
COM 过滤器驱动程序非常常见,例如,请查看这个。不过,您必须进行一些谷歌搜索才能找到具有 .NET 包装器的产品。
Yes, this is technically possible. You'll need a filter driver, a device driver type of a component that injects itself ahead of the native serial port driver. It gets a crack at the driver IRPs before sending them on to the regular driver.
This is the technique used by SysInternals' PortMon utility. However, you cannot write such a driver in C# code, the CLR cannot be loaded into ring 0. At least not until the super-secret Midori project sees the light of day.
COM filter drivers are pretty common, check out this one for example. You have to do some googling to find one that has a .NET wrapper though.
PortMon 是经典的 COM 端口监视器。它必须在程序打开 COM 端口之前运行,但可以启用/禁用监视部分。
PortMon is the classic COM port monitor. It has to be running before the program opens the COM port, but the monitoring part can be enabled/disabled.
您可以使用 Portmon for Windows 来监视活动。我执行此操作的另一种方法是使用一些硬件和笔记本电脑。我不确定如何使用 C# 应用程序自行监控它。一旦您连接到它并尝试再次连接,它将已在使用中。
另请检查一下,它有些相关,并附有有关 PortMon 如何工作的说明:
串行端口重定向或拆分 - Stack Overflow
如果您拥有或可以获得多个 COM端口,您可以使用分离器并从另一个端口进行监控。
You can use Portmon for Windows to monitor the activity. The other way I do this is with some hardware and a laptop. I'm not sure how you can monitor it yourself with a C# app. Once you are connected to it and attempt to connect again it will already be in use.
Also check this out, it's somewhat related, with a note on how PortMon works:
Serial Port Redirection or Splitting - Stack Overflow
If you have or can get more than one COM port, you could use a splitter and do the monitoring from the other port.
com0com 可能会满足您的需求。这对我有用。
com0com may satisfy your needs. It worked for me.