0

I know similar question have been asked before like here and a few other places. but I want to ask something about the basic concepts.

So, i have been assigned a project i have to make a "usb logger". The main function of the project is to capture data transmitted from PC to Usb printer on the logger software so raw data of each printout can be saved into a file for logging and analysis.

I was told that i can use a third party tool like usbpcap but I suggested why dont we get directly data from print spooler. as far as i know print spooler maintains a queue of the data to be printed.

before i start working on this project i want to ask a few basic questions

1) what is raw data in this scenario ?

2) can I achieve this by getting directly from spooler or is there another way.

3) which one will require more pc resources communicating with usb port or spooler?

I just need to understand the domain completely. (i will be developing this project using C#)

Thanks

Community
  • 1
  • 1
Aitizazk
  • 332
  • 1
  • 4
  • 16
  • You can capture this data from the spooler before it ever hits a USB port, but the question of how to proceed depends on what you plan to do with the data. If you capture it from USB, you'll be getting raw data intended to be understood by that printer. It could be Postscript, PCL, raw bitmap, or something entirely different and proprietary to the printer. This is almost certainly the hard way to do it. Capturing spool file data is probably simpler, but what is it you want to do with the data? – Carey Gregory Aug 20 '14 at 01:01
  • I just want to maintain a log of the data that is printed via the usb printer that's it. Is my approach correct ? – Aitizazk Aug 20 '14 at 18:49
  • When you say a log of the data that is printed, what do you mean? A capture of the entire actual output to the printer in raw form? Or just summary info such as who printed, when, where, etc? – Carey Gregory Aug 20 '14 at 23:37
  • Capture of the entire output in raw form. – Aitizazk Aug 22 '14 at 12:56

1 Answers1

0

If what you need to do is capture the entire output in raw form, the easiest way to do that is with a port monitor. A port monitor sits between the spooler and the physical output device and writes the raw data to that device, so it's the natural place to capture such data.

What you need to do is install the Windows WDK and take a look at the sample port monitor. You should be able to use that with very few modifications. Mainly, you just need to add code to write the data to a file somewhere in addition to writing it to the printer. You also need to change all the code dealing with the registry since the sample assumes it is the default port monitor and writes to registry keys reserved for Windows.

Just be aware the version 4 print drivers (ie, Win8) do not support custom port monitors. However, Win8 still supports v3 print drivers, which should cover any printer currently out there.

Carey Gregory
  • 6,836
  • 2
  • 26
  • 47