2 * Implementation of the Spooler-Service helper DLL
4 * Copyright 2006 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
26 //#include "winbase.h"
27 //#include "winerror.h"
31 //#include "winspool.h"
32 //#include "ddk/winsplp.h"
35 #include <wine/debug.h>
37 WINE_DEFAULT_DEBUG_CHANNEL(spoolss
);
39 /* ################################ */
41 static HMODULE hwinspool
;
43 static const WCHAR winspooldrvW
[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
45 /******************************************************************************
48 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
50 TRACE("(%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
53 case DLL_WINE_PREATTACH
:
54 return FALSE
; /* prefer native version */
55 case DLL_PROCESS_ATTACH
: {
56 DisableThreadLibraryCalls(hinstDLL
);
59 case DLL_PROCESS_DETACH
:
60 if (lpvReserved
) break;
68 /******************************************************************
69 * AllocSplStr [SPOOLSS.@]
71 * Create a copy from the String on the Spooler-Heap
74 * pwstr [I] PTR to the String to copy
78 * Success: PTR to the copied String
81 LPWSTR WINAPI
AllocSplStr(LPCWSTR pwstr
)
86 TRACE("(%s)\n", debugstr_w(pwstr
));
87 if (!pwstr
) return NULL
;
89 len
= (lstrlenW(pwstr
) + 1) * sizeof(WCHAR
);
90 res
= HeapAlloc(GetProcessHeap(), 0, len
);
91 if (res
) lstrcpyW(res
, pwstr
);
93 TRACE("returning %p\n", res
);
97 /******************************************************************
98 * BuildOtherNamesFromMachineName [SPOOLSS.@]
100 BOOL WINAPI
BuildOtherNamesFromMachineName(LPVOID
* ptr1
, LPVOID
* ptr2
)
102 FIXME("(%p, %p) stub\n", ptr1
, ptr2
);
109 /******************************************************************
110 * DllAllocSplMem [SPOOLSS.@]
112 * Allocate cleared memory from the spooler heap
115 * size [I] Number of bytes to allocate
119 * Success: PTR to the allocated memory
122 * We use the process heap (Windows use a separate spooler heap)
125 LPVOID WINAPI
DllAllocSplMem(DWORD size
)
129 res
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
130 TRACE("(%d) => %p\n", size
, res
);
134 /******************************************************************
135 * DllFreeSplMem [SPOOLSS.@]
137 * Free the allocated spooler memory
140 * memory [I] PTR to the memory allocated by DllAllocSplMem
147 * We use the process heap (Windows use a separate spooler heap)
151 BOOL WINAPI
DllFreeSplMem(LPBYTE memory
)
153 TRACE("(%p)\n", memory
);
154 return HeapFree(GetProcessHeap(), 0, memory
);
157 /******************************************************************
158 * DllFreeSplStr [SPOOLSS.@]
160 * Free the allocated Spooler-String
163 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
171 BOOL WINAPI
DllFreeSplStr(LPWSTR pwstr
)
173 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr
), pwstr
);
174 return HeapFree(GetProcessHeap(), 0, pwstr
);
178 /******************************************************************
179 * ImpersonatePrinterClient [SPOOLSS.@]
181 BOOL WINAPI
ImpersonatePrinterClient(HANDLE hToken
)
183 FIXME("(%p) stub\n", hToken
);
187 /******************************************************************
188 * InitializeRouter [SPOOLSS.@]
190 BOOL WINAPI
InitializeRouter(void)
193 return backend_load_all();
196 /******************************************************************
197 * IsLocalCall [SPOOLSS.@]
199 BOOL WINAPI
IsLocalCall(void)
205 /******************************************************************
206 * RevertToPrinterSelf [SPOOLSS.@]
208 HANDLE WINAPI
RevertToPrinterSelf(void)
211 return (HANDLE
) 0xdead0947;
214 /******************************************************************
215 * SplInitializeWinSpoolDrv [SPOOLSS.@]
217 * Dynamic load "winspool.drv" and fill an array with some function-pointer
220 * table [I] array of function-pointer to fill
227 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
228 * We implement the XP-Version (The table has only 9 Pointer)
231 BOOL WINAPI
SplInitializeWinSpoolDrv(LPVOID
* table
)
235 TRACE("(%p)\n", table
);
237 hwinspool
= LoadLibraryW(winspooldrvW
);
238 if (!hwinspool
) return FALSE
;
240 table
[0] = (void *) GetProcAddress(hwinspool
, "OpenPrinterW");
241 table
[1] = (void *) GetProcAddress(hwinspool
, "ClosePrinter");
242 table
[2] = (void *) GetProcAddress(hwinspool
, "SpoolerDevQueryPrintW");
243 table
[3] = (void *) GetProcAddress(hwinspool
, "SpoolerPrinterEvent");
244 table
[4] = (void *) GetProcAddress(hwinspool
, "DocumentPropertiesW");
245 table
[5] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 212); /* LoadPrinterDriver */
246 table
[6] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 213); /* RefCntLoadDriver */
247 table
[7] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 214); /* RefCntUnloadDriver */
248 table
[8] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 215); /* ForceUnloadDriver */
250 for (res
= 0; res
< 9; res
++) {
251 if (table
[res
] == NULL
) return FALSE
;
258 /******************************************************************
259 * SplIsUpgrade [SPOOLSS.@]
261 BOOL WINAPI
SplIsUpgrade(void)
267 /******************************************************************
268 * SpoolerHasInitialized [SPOOLSS.@]
270 BOOL WINAPI
SpoolerHasInitialized(void)
276 /******************************************************************
277 * SpoolerInit [SPOOLSS.@]
279 BOOL WINAPI
SpoolerInit(void)
285 /******************************************************************
286 * WaitForSpoolerInitialization [SPOOLSS.@]
288 BOOL WINAPI
WaitForSpoolerInitialization(void)