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 /******************************************************************************
44 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
46 TRACE("(%p, %ld, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
49 case DLL_PROCESS_ATTACH
: {
50 DisableThreadLibraryCalls(hinstDLL
);
53 case DLL_PROCESS_DETACH
:
54 if (lpvReserved
) break;
62 /******************************************************************
63 * AllocSplStr [SPOOLSS.@]
65 * Create a copy from the String on the Spooler-Heap
68 * pwstr [I] PTR to the String to copy
72 * Success: PTR to the copied String
75 LPWSTR WINAPI
AllocSplStr(LPCWSTR pwstr
)
80 TRACE("(%s)\n", debugstr_w(pwstr
));
81 if (!pwstr
) return NULL
;
83 len
= (lstrlenW(pwstr
) + 1) * sizeof(WCHAR
);
84 res
= HeapAlloc(GetProcessHeap(), 0, len
);
85 if (res
) lstrcpyW(res
, pwstr
);
87 TRACE("returning %p\n", res
);
91 /******************************************************************
92 * BuildOtherNamesFromMachineName [SPOOLSS.@]
94 BOOL WINAPI
BuildOtherNamesFromMachineName(LPVOID
* ptr1
, LPVOID
* ptr2
)
96 FIXME("(%p, %p) stub\n", ptr1
, ptr2
);
103 /******************************************************************
104 * DllAllocSplMem [SPOOLSS.@]
106 * Allocate cleared memory from the spooler heap
109 * size [I] Number of bytes to allocate
113 * Success: PTR to the allocated memory
116 * We use the process heap (Windows use a separate spooler heap)
119 LPVOID WINAPI
DllAllocSplMem(DWORD size
)
123 res
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
124 TRACE("(%ld) => %p\n", size
, res
);
128 /******************************************************************
129 * DllFreeSplMem [SPOOLSS.@]
131 * Free the allocated spooler memory
134 * memory [I] PTR to the memory allocated by DllAllocSplMem
141 * We use the process heap (Windows use a separate spooler heap)
145 BOOL WINAPI
DllFreeSplMem(LPBYTE memory
)
147 TRACE("(%p)\n", memory
);
148 return HeapFree(GetProcessHeap(), 0, memory
);
151 /******************************************************************
152 * DllFreeSplStr [SPOOLSS.@]
154 * Free the allocated Spooler-String
157 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
165 BOOL WINAPI
DllFreeSplStr(LPWSTR pwstr
)
167 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr
), pwstr
);
168 return HeapFree(GetProcessHeap(), 0, pwstr
);
172 /******************************************************************
173 * ImpersonatePrinterClient [SPOOLSS.@]
175 BOOL WINAPI
ImpersonatePrinterClient(HANDLE hToken
)
177 FIXME("(%p) stub\n", hToken
);
181 /******************************************************************
182 * InitializeRouter [SPOOLSS.@]
184 BOOL WINAPI
InitializeRouter(void)
187 return backend_load_all();
190 /******************************************************************
191 * IsLocalCall [SPOOLSS.@]
193 BOOL WINAPI
IsLocalCall(void)
199 /******************************************************************
200 * RevertToPrinterSelf [SPOOLSS.@]
202 HANDLE WINAPI
RevertToPrinterSelf(void)
205 return (HANDLE
) 0xdead0947;
208 /******************************************************************
209 * SplInitializeWinSpoolDrv [SPOOLSS.@]
211 * Dynamic load "winspool.drv" and fill an array with some function-pointer
214 * table [I] array of function-pointer to fill
221 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
222 * We implement the XP-Version (The table has only 9 Pointer)
225 BOOL WINAPI
SplInitializeWinSpoolDrv(LPVOID
* table
)
229 TRACE("(%p)\n", table
);
231 hwinspool
= LoadLibraryW(L
"winspool.drv");
232 if (!hwinspool
) return FALSE
;
234 table
[0] = (void *) GetProcAddress(hwinspool
, "OpenPrinterW");
235 table
[1] = (void *) GetProcAddress(hwinspool
, "ClosePrinter");
236 table
[2] = (void *) GetProcAddress(hwinspool
, "SpoolerDevQueryPrintW");
237 table
[3] = (void *) GetProcAddress(hwinspool
, "SpoolerPrinterEvent");
238 table
[4] = (void *) GetProcAddress(hwinspool
, "DocumentPropertiesW");
239 table
[5] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 212); /* LoadPrinterDriver */
240 table
[6] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 213); /* RefCntLoadDriver */
241 table
[7] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 214); /* RefCntUnloadDriver */
242 table
[8] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 215); /* ForceUnloadDriver */
244 for (res
= 0; res
< 9; res
++) {
245 if (table
[res
] == NULL
) return FALSE
;
252 /******************************************************************
253 * SplIsUpgrade [SPOOLSS.@]
255 BOOL WINAPI
SplIsUpgrade(void)
261 /******************************************************************
262 * SpoolerHasInitialized [SPOOLSS.@]
264 BOOL WINAPI
SpoolerHasInitialized(void)
270 /******************************************************************
271 * SpoolerInit [SPOOLSS.@]
273 BOOL WINAPI
SpoolerInit(void)
279 /******************************************************************
280 * WaitForSpoolerInitialization [SPOOLSS.@]
282 BOOL WINAPI
WaitForSpoolerInitialization(void)