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
32 #include "ddk/winsplp.h"
33 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(winspool
);
39 /* ############################### */
41 static CRITICAL_SECTION backend_cs
;
42 static CRITICAL_SECTION_DEBUG backend_cs_debug
=
45 { &backend_cs_debug
.ProcessLocksList
, &backend_cs_debug
.ProcessLocksList
},
46 0, 0, { (DWORD_PTR
)(__FILE__
": backend_cs") }
48 static CRITICAL_SECTION backend_cs
= { &backend_cs_debug
, -1, 0, 0, 0, 0 };
50 /* ############################### */
52 HINSTANCE WINSPOOL_hInstance
= NULL
;
54 static HMODULE hlocalspl
= NULL
;
55 static BOOL (WINAPI
*pInitializePrintProvidor
)(LPPRINTPROVIDOR
, DWORD
, LPWSTR
);
57 PRINTPROVIDOR
* backend
= NULL
;
59 /******************************************************************************
60 * load_backend [internal]
62 * load and init our backend (the local printprovider: "localspl.dll")
68 * Failure: FALSE and RPC_S_SERVER_UNAVAILABLE
71 * In windows, winspool.drv use RPC to interact with the spooler service
72 * (spoolsv.exe with spoolss.dll) and the spooler router (spoolss.dll) interact
73 * with the correct printprovider (localspl.dll for the local system)
76 BOOL
load_backend(void)
78 static PRINTPROVIDOR mybackend
;
81 EnterCriticalSection(&backend_cs
);
82 hlocalspl
= LoadLibraryA("localspl.dll");
84 pInitializePrintProvidor
= (void *) GetProcAddress(hlocalspl
, "InitializePrintProvidor");
85 if (pInitializePrintProvidor
) {
87 /* native localspl does not clear unused entries */
88 memset(&mybackend
, 0, sizeof(mybackend
));
89 res
= pInitializePrintProvidor(&mybackend
, sizeof(mybackend
), NULL
);
92 LeaveCriticalSection(&backend_cs
);
93 TRACE("backend: %p (%p)\n", backend
, hlocalspl
);
97 FreeLibrary(hlocalspl
);
100 LeaveCriticalSection(&backend_cs
);
102 WARN("failed to load the backend: %u\n", GetLastError());
103 SetLastError(RPC_S_SERVER_UNAVAILABLE
);
107 /******************************************************************************
108 * unload_backend [internal]
111 static void unload_backend(void)
113 EnterCriticalSection(&backend_cs
);
115 FreeLibrary(hlocalspl
);
116 LeaveCriticalSection(&backend_cs
);
120 /******************************************************************************
123 * Winspool entry point.
126 BOOL WINAPI
DllMain(HINSTANCE hInstance
, DWORD reason
, LPVOID lpReserved
)
130 case DLL_PROCESS_ATTACH
: {
131 WINSPOOL_hInstance
= hInstance
;
132 DisableThreadLibraryCalls(hInstance
);
133 WINSPOOL_LoadSystemPrinters();
136 case DLL_PROCESS_DETACH
: