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
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(spoolss
);
30 /* ################################ */
32 static HMODULE hwinspool
;
33 static const WCHAR winspooldrvW
[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
35 /******************************************************************
38 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
40 TRACE("(%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
43 case DLL_WINE_PREATTACH
:
44 return FALSE
; /* prefer native version */
45 case DLL_PROCESS_ATTACH
: {
46 DisableThreadLibraryCalls(hinstDLL
);
53 /******************************************************************
54 * AllocSplStr [SPOOLSS.@]
56 * Create a copy from the String on the Spooler-Heap
59 * pwstr [I] PTR to the String to copy
63 * Success: PTR to the copied String
66 LPWSTR WINAPI
AllocSplStr(LPCWSTR pwstr
)
71 TRACE("(%s)\n", debugstr_w(pwstr
));
72 if (!pwstr
) return NULL
;
74 len
= (lstrlenW(pwstr
) + 1) * sizeof(WCHAR
);
75 res
= HeapAlloc(GetProcessHeap(), 0, len
);
76 if (res
) lstrcpyW(res
, pwstr
);
78 TRACE("returning %p\n", res
);
82 /******************************************************************
83 * BuildOtherNamesFromMachineName [SPOOLSS.@]
85 BOOL WINAPI
BuildOtherNamesFromMachineName(LPVOID
* ptr1
, LPVOID
* ptr2
)
87 FIXME("(%p, %p) stub\n", ptr1
, ptr2
);
94 /******************************************************************
95 * DllAllocSplMem [SPOOLSS.@]
97 * Allocate cleared memory from the spooler heap
100 * size [I] Number of bytes to allocate
104 * Success: PTR to the allocated memory
107 * We use the process heap (Windows use a separate spooler heap)
110 LPVOID WINAPI
DllAllocSplMem(DWORD size
)
114 res
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
115 TRACE("(%d) => %p\n", size
, res
);
119 /******************************************************************
120 * DllFreeSplMem [SPOOLSS.@]
122 * Free the allocated spooler memory
125 * memory [I] PTR to the memory allocated by DllAllocSplMem
132 * We use the process heap (Windows use a separate spooler heap)
136 BOOL WINAPI
DllFreeSplMem(LPBYTE memory
)
138 TRACE("(%p)\n", memory
);
139 return HeapFree(GetProcessHeap(), 0, memory
);
142 /******************************************************************
143 * DllFreeSplStr [SPOOLSS.@]
145 * Free the allocated Spooler-String
148 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
156 BOOL WINAPI
DllFreeSplStr(LPWSTR pwstr
)
158 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr
), pwstr
);
159 return HeapFree(GetProcessHeap(), 0, pwstr
);
163 /******************************************************************
164 * ImpersonatePrinterClient [SPOOLSS.@]
166 BOOL WINAPI
ImpersonatePrinterClient(HANDLE hToken
)
168 FIXME("(%p) stub\n", hToken
);
172 /******************************************************************
173 * RevertToPrinterSelf [SPOOLSS.@]
175 HANDLE WINAPI
RevertToPrinterSelf(void)
178 return (HANDLE
) 0xdead0947;
181 /******************************************************************
182 * SplInitializeWinSpoolDrv [SPOOLSS.@]
184 * Dynamic load "winspool.drv" and fill an array with some function-pointer
187 * table [I] array of function-pointer to fill
194 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
195 * We implement the XP-Version (The table has only 9 Pointer)
198 BOOL WINAPI
SplInitializeWinSpoolDrv(LPVOID
* table
)
202 TRACE("(%p)\n", table
);
204 hwinspool
= LoadLibraryW(winspooldrvW
);
205 if (!hwinspool
) return FALSE
;
207 table
[0] = (void *) GetProcAddress(hwinspool
, "OpenPrinterW");
208 table
[1] = (void *) GetProcAddress(hwinspool
, "ClosePrinter");
209 table
[2] = (void *) GetProcAddress(hwinspool
, "SpoolerDevQueryPrintW");
210 table
[3] = (void *) GetProcAddress(hwinspool
, "SpoolerPrinterEvent");
211 table
[4] = (void *) GetProcAddress(hwinspool
, "DocumentPropertiesW");
212 table
[5] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 212); /* LoadPrinterDriver */
213 table
[6] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 213); /* RefCntLoadDriver */
214 table
[7] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 214); /* RefCntUnloadDriver */
215 table
[8] = (void *) GetProcAddress(hwinspool
, (LPSTR
) 215); /* ForceUnloadDriver */
217 for (res
= 0; res
< 9; res
++) {
218 if (table
[res
] == NULL
) return FALSE
;
225 /******************************************************************
226 * SplIsUpgrade [SPOOLSS.@]
228 BOOL WINAPI
SplIsUpgrade(void)
234 /******************************************************************
235 * SpoolerHasInitialized [SPOOLSS.@]
237 BOOL WINAPI
SpoolerHasInitialized(void)
243 /******************************************************************
244 * SpoolerInit [SPOOLSS.@]
246 BOOL WINAPI
SpoolerInit(void)