I need to programmatically sniff data that is being passed through the parallel port (LPT) to printer in Windows XP.
This is what I have tried in the past 3-4 days:
Firstly, I tried to read data using windows CreateFile(), WaitCommEvent() and ReadFile() functions. But they seem to block the port, so that the port access is denied to other applications.
Secondly, I have used com0com to create virtual COM port to get the printer data and then send it to LPT. This requires me to make the source user space application send the data to COM port first and then I write my code to tunnel that data to printer through LPT port. So, I basically redirect the print stream through COM port rather than sniffing it over the LPT port. So, it requires changing the settings in the application whose print data I need to capture. Hence, this is more of a hack but not something I need.
Finally, I have used PortMon and PrintFil as mentioned in this question. They work fine but I need to include PortMon's sniff functionality in my application.
So, is there any open source library or code sample which could be used to sniff the parallel port data similar to what portmon or printfil do ?