2 * Unit test suite for the Spooler-Service helper DLL
4 * Copyright 2007 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
27 #include "wine/test.h"
33 static HMODULE hwinspool;
36 static BOOL (WINAPI * pBuildOtherNamesFromMachineName)(LPWSTR **, LPDWORD);
37 static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
39 #define WINSPOOL_TABLESIZE 16
41 static LPVOID fn_spl[WINSPOOL_TABLESIZE];
42 static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
43 static LPVOID fn_xp[WINSPOOL_TABLESIZE];
44 static LPVOID fn_v[WINSPOOL_TABLESIZE];
46 /* ########################### */
48 static LPCSTR load_functions(void)
53 hspl = LoadLibraryA(ptr);
54 if (!hspl) return ptr;
56 ptr = "BuildOtherNamesFromMachineName";
57 pBuildOtherNamesFromMachineName = (void *) GetProcAddress(hspl, ptr);
58 if (!pBuildOtherNamesFromMachineName) return ptr;
60 ptr = "SplInitializeWinSpoolDrv";
61 pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
62 if (!pSplInitializeWinSpoolDrv) return ptr;
66 hwinspool = LoadLibraryA(ptr);
67 if (!hwinspool) return ptr;
69 memset(fn_w2k, 0xff, sizeof(fn_w2k));
70 fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
71 fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
72 fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
73 fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
74 fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
75 fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
76 fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
77 fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
78 fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
79 fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
80 fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
82 memset(fn_xp, 0xff, sizeof(fn_xp));
83 fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
84 fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
85 fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
86 fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
87 fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
88 fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
89 fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
90 fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
91 fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
93 memset(fn_v, 0xff, sizeof(fn_v));
94 fn_v[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
95 fn_v[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
96 fn_v[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
97 fn_v[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
98 fn_v[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
99 fn_v[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
100 fn_v[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
101 fn_v[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
102 fn_v[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
103 fn_v[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 251); /* 0xfb */
109 /* ########################### */
111 static void test_BuildOtherNamesFromMachineName(void)
120 SetLastError(0xdeadbeef);
121 res = pBuildOtherNamesFromMachineName(&buffers, &numentries);
123 /* An array with 3 stringpointer is returned:
124 entry_#0: "" (empty String)
125 entry_#1: <hostname> (this is the same as the computername)
126 entry_#2: <ip-address> (string with the ip-address of <hostname>)
129 ok( res && (buffers != NULL) && (numentries == 3) && (buffers[0] != NULL) && (buffers[0][0] == '\0'),
130 "got %u with %u and %p,%u (%p:%d)\n", res, GetLastError(), buffers, numentries,
131 ((numentries > 0) && buffers) ? buffers[0] : NULL,
132 ((numentries > 0) && buffers && buffers[0]) ? lstrlenW(buffers[0]) : -1);
136 /* ########################### */
138 static void test_SplInitializeWinSpoolDrv(VOID)
140 LPVOID *fn_ref = fn_xp;
144 memset(fn_spl, 0xff, sizeof(fn_spl));
145 SetLastError(0xdeadbeef);
146 res = pSplInitializeWinSpoolDrv(fn_spl);
147 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
149 /* functions 0 to 5 are the same in "spoolss.dll" from w2k and above */
150 if (fn_spl[6] == fn_w2k[6]) {
153 if (fn_spl[9] == fn_v[9]) {
158 while (id < WINSPOOL_TABLESIZE) {
159 ok( fn_spl[id] == fn_ref[id],
160 "(#%02u) spoolss: %p (vista: %p, xp: %p, w2k: %p)\n",
161 id, fn_spl[id], fn_v[id], fn_xp[id], fn_w2k[id]);
166 /* ########################### */
172 /* spoolss.dll does not exist on win9x */
173 ptr = load_functions();
175 skip("%s not found\n", ptr);
179 test_BuildOtherNamesFromMachineName();
180 test_SplInitializeWinSpoolDrv();