Installing drivers through PnP

REILLY,JOHN R (HP-Roseville,ex1) jreilly at hp.com
Mon Oct 22 08:14:10 GMT 2001


>JRA<
> Yep. This is because this entry is set when the driver binary is run
> as a Win32 program on the server which will be serving out the driver.

See DrvPrinterEvent(PRINTER_EVENT_INITIALIZE) in MSDN.

> Yes, that's right, the MS driver model DEPENDS ON DRIVER CODE BEING
EXECUTABLE
> ON THE SERVER !!!!!

Well... the server and the client are symmetric. MS actually just requires
the driver to initialize itself and bind to the printer object regardless
of whether its a client or a server.

> This was so braindamaged I found it hard to believe at first.

Agreed. 

> ...
> Absolutely. These are really driver bugs that are "permitted" on Windows
> x86 systems.

Given the architecture that MS defined, these are not actually 'bugs'
they are 'features' :-) As to "permitted", I'd say 'encouraged'. When the
config dll initialization entry point is called during printer installation
it is free to do *anything* it cares to do. There are some limitations
imposed by being called from the spooler service, but any determined
programmer can get around them; and they do!

>JF<
> a solution would be to maintain a drivers blacklist. For each of this
> drivers we maintain a list of fixup we do when such a driver is setup.

I tried that. If you eliminate the user mode drivers (SPLUserModeDriver),
you drop a huge number of drivers from the mix. If you black list all
drivers
that have ANY sort of problems because they have not been initialized, you
drop most drivers.

> Ugly isn't it ?  It's yet one more ugliness we could do thanks to some
> braindead driver writers.

Actually, I think this is a bit overstated. Those driver writers were doing
their job given the environment they planned to sell their products into.
They never expected Samba to come along, and not be able to do what MS told
them it would do for them. Lets not winge on about MS's clearly BAD design.
There is a work around. Its been in Samba for awhile. Yes it sucks that it
requires client side code, but at least you can get your drivers properly
setup.

There are several references in the Samba code related to printer
driver's needing to be initialized. This requires Win32 client code
that:

 1. Uses the driver's config DLL passing it the UNC printername and:
    a. Call DrvPrintEvent with PRINTER_EVENT_INITIALIZE
    b. Call DrvConvertDevMode with CDM_DRIVER_DEFAULT to get default
       DEVMODE
 2. Call SetPrinterData with the 'magic' key and the DEVMODE as data.

The last step triggers saving the "driver initialization" information
for this driver into the tdb. Later, new printers that use this
driver will have this initialization information bound to them. This
simulates the driver initialization, as if it had run on the Samba
server (as it would have on NT). Note: it would have been easier to use
SetPrinter because all the UNMARSHALLING of the DEVMODE is done there,
but 2K/XP clients do not set the DEVMODE (its an enhancement).

Reference the code:
  rpc_server.c: set_driver_init()              --> save_driver_init()
  rpc_server.c: spoolss_addprinterex_level_2() --> set_driver_init()

Until we can run "arbitrary" Win32 printer driver code on any Unix that
Samba runs on, we are stuck with client code. 

Cheers
JohnR

jreilly at hp.com | jreilly at samba.org  916-785-4532  fax:916-785-8880
iIPS - internet Imaging & Printing Systems, Hewlett-Packard Co.
8000 Foothills Blvd. Roseville, CA 95747-5659  M/S: 5659

Things are much more complicated than they appear.




More information about the samba-technical mailing list