Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitor a COM port already in use [closed]

Is it possible to read from a COM port already in use on Windows XP?

I would like to see the communication between some software and a device plugged into a serial device. I wrote a small program using C# to monitor the COM, but once it's in use by the other device it will not let you open it again. How can one monitor a COM port already in use?

I'm open to third-party software.

like image 561
rross Avatar asked Dec 03 '22 05:12

rross


1 Answers

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.

like image 59
Hans Passant Avatar answered Dec 18 '22 14:12

Hans Passant