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
30 #include "ddk/winsplp.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(spoolss
);
37 /* ################################ */
39 static HMODULE hwinspool
;
41 static const WCHAR winspooldrvW
[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
43 /******************************************************************************
46 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
48 TRACE("(%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
51 case DLL_WINE_PREATTACH
:
52 return FALSE
; /* prefer native version */
53 case DLL_PROCESS_ATTACH
: {
54 DisableThreadLibraryCalls(hinstDLL
);
57 case DLL_PROCESS_DETACH
:
58 if (lpvReserved
) break;
66 /******************************************************************
67 * AllocSplStr [SPOOLSS.@]
69 * Create a copy from the String on the Spooler-Heap
72 * pwstr [I] PTR to the String to copy
76 * Success: PTR to the copied String
79 LPWSTR WINAPI
AllocSplStr(LPCWSTR pwstr
)
84 TRACE("(%s)\n", debugstr_w(pwstr
));
85 if (!pwstr
) return NULL
;
87 len
= (lstrlenW(pwstr
) + 1) * sizeof(WCHAR
);
88 res
= HeapAlloc(GetProcessHeap(), 0, len
);
89 if (res
) lstrcpyW(res
, pwstr
);
91 TRACE("returning %p\n", res
);
95 /******************************************************************
96 * BuildOtherNamesFromMachineName [SPOOLSS.@]
98 BOOL WINAPI
BuildOtherNamesFromMachineName(LPVOID
* ptr1
, LPVOID
* ptr2
)
100 FIXME("(%p, %p) stub\n", ptr1
, ptr2
);
107 /******************************************************************
108 * DllAllocSplMem [SPOOLSS.@]
110 * Allocate cleared memory from the spooler heap
113 * size [I] Number of bytes to allocate
117 * Success: PTR to the allocated memory
120 * We use the process heap (Windows use a separate spooler heap)
123 LPVOID WINAPI
DllAllocSplMem(DWORD size
)
127 res
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
128 TRACE("(%d) => %p\n", size
, res
);
132 /******************************************************************
133 * DllFreeSplMem [SPOOLSS.@]
135 * Free the allocated spooler memory
138 * memory [I] PTR to the memory allocated by DllAllocSplMem
145 * We use the process heap (Windows use a separate spooler heap)
149 BOOL WINAPI
DllFreeSplMem(LPBYTE memory
)
151 TRACE("(%p)\n", memory
);
152 return HeapFree(GetProcessHeap(), 0, memory
);
155 /******************************************************************
156 * DllFreeSplStr [SPOOLSS.@]
158 * Free the allocated Spooler-String
161 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
169 BOOL WINAPI
DllFreeSplStr(LPWSTR pwstr
)
171 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr
), pwstr
);
172 return HeapFree(GetProcessHeap(), 0, pwstr
);
176 /******************************************************************
177 * ImpersonatePrinterClient [SPOOLSS.@]
179 BOOL WINAPI
ImpersonatePrinterClient(HANDLE hToken
)
181 FIXME("(%p) stub\n", hToken
);
185 /******************************************************************
186 * InitializeRouter [SPOOLSS.@]
188 BOOL WINAPI
InitializeRouter(void)
191 return backend_load_all();
194 /******************************************************************
195 * IsLocalCall [SPOOLSS.@]
197 BOOL WINAPI
IsLocalCall(void)
203 /******************************************************************
204 * RevertToPrinterSelf [SPOOLSS.@]
206 HANDLE WINAPI
RevertToPrinterSelf(void)
209 return (HANDLE
) 0xdead0947;
212 /******************************************************************
213 * SplInitializeWinSpoolDrv [SPOOLSS.@]
215 * Dynamic load "winspool.drv" and fill an array with some function-pointer
218 * table [I] array of function-pointer to fill
225 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
226 * We implement the XP-Version (The table has only 9 Pointer)
229 BOOL WINAPI
SplInitializeWinSpoolDrv(LPVOID
* table
)
233 TRACE("(%p)\n", table
);
235 hwinspool
= LoadLibraryW(winspooldrvW
);
236 if (!hwinspool
) return FALSE
;
238 table
[0] = (void *) GetProcAddress(hwinspool
, "OpenPrinterW");
239 table
[1] = (void *) GetProcAddress(hwinspool
, "ClosePrinter");
240 table
[2] = (void *) GetProcAddress(hwinspool
, "SpoolerDevQueryPrintW");
241 table
[3] = (void *) GetProcAddress(hwinspool
, "SpoolerPrinterEvent");
242 table
[4] = (void *) GetProcAddress(hwinspool
, "DocumentPropertiesW");
243 table
[5] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 212); /* LoadPrinterDriver */
244 table
[6] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 213); /* RefCntLoadDriver */
245 table
[7] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 214); /* RefCntUnloadDriver */
246 table
[8] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 215); /* ForceUnloadDriver */
248 for (res
= 0; res
< 9; res
++) {
249 if (table
[res
] == NULL
) return FALSE
;
256 /******************************************************************
257 * SplIsUpgrade [SPOOLSS.@]
259 BOOL WINAPI
SplIsUpgrade(void)
265 /******************************************************************
266 * SpoolerHasInitialized [SPOOLSS.@]
268 BOOL WINAPI
SpoolerHasInitialized(void)
274 /******************************************************************
275 * SpoolerInit [SPOOLSS.@]
277 BOOL WINAPI
SpoolerInit(void)
283 /******************************************************************
284 * WaitForSpoolerInitialization [SPOOLSS.@]
286 BOOL WINAPI
WaitForSpoolerInitialization(void)