1 /******************************************************************************
2 * Print Spooler Functions
5 * Copyright 1999 Thuy Nguyen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "ddk/winsplp.h"
30 #include "wine/debug.h"
31 #include "wine/unixlib.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(winspool
);
37 /* ############################### */
39 static CRITICAL_SECTION backend_cs
;
40 static CRITICAL_SECTION_DEBUG backend_cs_debug
=
43 { &backend_cs_debug
.ProcessLocksList
, &backend_cs_debug
.ProcessLocksList
},
44 0, 0, { (DWORD_PTR
)(__FILE__
": backend_cs") }
46 static CRITICAL_SECTION backend_cs
= { &backend_cs_debug
, -1, 0, 0, 0, 0 };
48 /* ############################### */
50 HINSTANCE WINSPOOL_hInstance
= NULL
;
52 static HMODULE hlocalspl
;
53 static BOOL (WINAPI
*pInitializePrintProvidor
)(LPPRINTPROVIDOR
, DWORD
, LPWSTR
);
54 PRINTPROVIDOR
*backend
= NULL
;
56 /******************************************************************************
57 * load_backend [internal]
59 * load and init our backend (the local printprovider: "localspl.dll")
65 * Failure: FALSE and RPC_S_SERVER_UNAVAILABLE
68 * In windows, winspool.drv use RPC to interact with the spooler service
69 * (spoolsv.exe with spoolss.dll) and the spooler router (spoolss.dll) interact
70 * with the correct printprovider (localspl.dll for the local system)
73 BOOL
load_backend(void)
75 static PRINTPROVIDOR mybackend
;
78 EnterCriticalSection(&backend_cs
);
79 hlocalspl
= LoadLibraryA("localspl.dll");
81 pInitializePrintProvidor
= (void *) GetProcAddress(hlocalspl
, "InitializePrintProvidor");
82 if (pInitializePrintProvidor
) {
84 /* native localspl does not clear unused entries */
85 memset(&mybackend
, 0, sizeof(mybackend
));
86 res
= pInitializePrintProvidor(&mybackend
, sizeof(mybackend
), NULL
);
89 LeaveCriticalSection(&backend_cs
);
90 TRACE("backend: %p (%p)\n", backend
, hlocalspl
);
94 FreeLibrary(hlocalspl
);
97 LeaveCriticalSection(&backend_cs
);
99 WARN("failed to load the backend: %lu\n", GetLastError());
100 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
104 /******************************************************************************
107 * Winspool entry point.
110 BOOL WINAPI
DllMain( HINSTANCE instance
, DWORD reason
, void *reserved
)
114 case DLL_PROCESS_ATTACH
:
115 WINSPOOL_hInstance
= instance
;
116 DisableThreadLibraryCalls( instance
);
117 if (!__wine_init_unix_call())
118 UNIX_CALL( process_attach
, NULL
);
119 WINSPOOL_LoadSystemPrinters();
122 case DLL_PROCESS_DETACH
:
124 DeleteCriticalSection(&backend_cs
);
125 FreeLibrary(hlocalspl
);