2

Working with the Windows Driver Development Kit sample package (v 8.1), I found a sample print processor implementation that I tried to use as a starting point for my own custom print processor ("GenPrint Print Processor Sample"). I managed to successfully build it in Visual Studio 2017 Community (changing PlatformToolset to "v141"), and I'm apparently able to successfully install it (by creating the registry item, "HKLM:\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Print Processors\genprint" with item property "Driver" and value "genprint.dll", and copying the freshly built dll to %WinDir%/System32/spool/prtprocs/x64/). I can then set up a test printer and select my "genprint" print processor using Printer Properties > Advanced > Print Processor..., and I can even attach to the spooler process, spoolsv, from my debugger in Visual Studio and set a breakpoint in EnumPrintProcessorDatatypesW(...), and see it get hit when I reopen the Print Processor dialog for my test printer. So far, so good!

The problem comes when I set a breakpoint anywhere else, and queue up an actual job to the printer queue. Say at the beginning of OpenPrintProcessor(...). Or PrintDocumentOnPrintProcessor(...), or, you name it. Nothing, nada, zilch. It seems these functions are just never called at all, at least not the implementations exported by my DLL. I even resorted to inserting event logs ala Event Tracing for Windows (ETW) at the beginning of every function exported by the DLL, but the only logs ever generated are the ones for EnumPrintProcessorDatatypesW(...).

What on Earth might be going on?? Is it possible that, for some odd reason, the spooler is using a different print processor than mine, even though I explicitly associated mine with the print queue in question? And if so, why?

[Update: it looks like the behavior I'm seeing is down to "print driver isolation"; when I change the isolation mode for the driver associated with the queue to "None", then I can attach to the spoolsv process. Otherwise, my print processor is running in a separate process communicating with spoolsv via DCOM, as described at: https://blogs.technet.microsoft.com/askperf/2009/10/08/windows-7-windows-server-2008-r2-print-driver-isolation/ -- I'm guessing the system-wide default has been changed to use print driver isolation since post-Windows 7, unless you explicitly configure the driver to "None" (or it configures itself that way)]

  • Does the printer have a V3 (not V4) driver? – Nick Westgate Oct 10 '17 at 00:21
  • Either way, i get the same problem (at least on Windows Server 2012 R2). I seem to be narrowing the problem down to a some kind of either OS and/or buiid environment dependency, though. When I rebuild the thing in VS 2015 and run it on a spooler in Windows 7 Professional, I have no trouble hitting breakpoints in the DLL's other exported functions. – user6436780 Oct 10 '17 at 03:26
  • Make sure spooling is enabled in the printer. If spooling is disabled, the print processor is bypassed. In the printer properties window, select "Advanced" and make sure "Spool print documents so program finishes printing faster" is enabled. – Craig Lebakken Oct 10 '17 at 14:48
  • You should put your update up as an answer and mark it accepted, if it's what solved your problem. – João Mendes Feb 27 '18 at 11:34

0 Answers0