ReactOS 0.4.16-dev-250-g3ecd236
spoolss.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"
Include dependency graph for spoolss.c:

Go to the source code of this file.

Macros

#define WINSPOOL_TABLESIZE   16
 

Functions

static BOOL (WINAPI *pBuildOtherNamesFromMachineName)(LPWSTR **
 
static DWORD (WINAPI *pSplInitializeWinSpoolDrv)(LPVOID *)
 
static LPCSTR load_functions (void)
 
static void test_BuildOtherNamesFromMachineName (void)
 
static void test_SplInitializeWinSpoolDrv (VOID)
 
 START_TEST (spoolss)
 

Variables

static HMODULE hwinspool
 
static HMODULE hspl
 
static LPDWORD
 
static LPVOID fn_spl [WINSPOOL_TABLESIZE]
 
static LPVOID fn_w2k [WINSPOOL_TABLESIZE]
 
static LPVOID fn_xp [WINSPOOL_TABLESIZE]
 
static LPVOID fn_v [WINSPOOL_TABLESIZE]
 

Macro Definition Documentation

◆ WINSPOOL_TABLESIZE

#define WINSPOOL_TABLESIZE   16

Definition at line 39 of file spoolss.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pBuildOtherNamesFromMachineName)
static

◆ DWORD()

static DWORD ( WINAPI pSplInitializeWinSpoolDrv)
static

◆ load_functions()

static LPCSTR load_functions ( void  )
static

Definition at line 48 of file spoolss.c.

49{
50 LPCSTR ptr;
51
52 ptr = "spoolss.dll";
54 if (!hspl) return ptr;
55
56 ptr = "BuildOtherNamesFromMachineName";
57 pBuildOtherNamesFromMachineName = (void *) GetProcAddress(hspl, ptr);
58 if (!pBuildOtherNamesFromMachineName) return ptr;
59
60 ptr = "SplInitializeWinSpoolDrv";
61 pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
62 if (!pSplInitializeWinSpoolDrv) return ptr;
63
64
65 /* Calling BuildOtherNamesFromMachineName or SplInitializeWinSpoolDrv on
66 * Win7 results in a breakpoint exception. If you continue after hitting
67 * the breakpoint, the functions fail with ERROR_NOT_SUPPORTED. So we
68 * just skip the tests on Win7, since they won't provide any useful info.
69 * To detect Win7, we check whether UnloadDriver exists (it doesn't on
70 * Win7, but does exist on earlier Windows versions) */
71 ptr = "UnloadDriver";
72 if (GetProcAddress(hspl, ptr) == NULL) return ptr;
73
74
75 ptr = "winspool.drv";
77 if (!hwinspool) return ptr;
78
79 memset(fn_w2k, 0xff, sizeof(fn_w2k));
80 fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
81 fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
82 fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
83 fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
84 fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
85 fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
86 fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW");
87 fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW");
88 fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
89 fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
90 fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
91
92 memset(fn_xp, 0xff, sizeof(fn_xp));
93 fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
94 fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
95 fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
96 fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
97 fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
98 fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
99 fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
100 fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
101 fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
102
103 memset(fn_v, 0xff, sizeof(fn_v));
104 fn_v[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
105 fn_v[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
106 fn_v[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
107 fn_v[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
108 fn_v[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
109 fn_v[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
110 fn_v[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
111 fn_v[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
112 fn_v[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
113 fn_v[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 251); /* 0xfb */
114
115 return NULL;
116
117}
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static PVOID ptr
Definition: dispmode.c:27
#define memset(x, y, z)
Definition: compat.h:39
static LPVOID fn_w2k[WINSPOOL_TABLESIZE]
Definition: spoolss.c:42
static LPVOID fn_xp[WINSPOOL_TABLESIZE]
Definition: spoolss.c:43
static HMODULE hwinspool
Definition: spoolss.c:33
static HMODULE hspl
Definition: spoolss.c:35
static LPVOID fn_v[WINSPOOL_TABLESIZE]
Definition: spoolss.c:44
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( spoolss  )

Definition at line 207 of file spoolss.c.

208{
209 LPCSTR ptr;
210
211 /* The tests fail on Win7 (see comments in load_function() */
213 if (ptr) {
214 win_skip("%s not found\n", ptr);
215 return;
216 }
217
220
221}
#define win_skip
Definition: test.h:163
static void test_SplInitializeWinSpoolDrv(VOID)
Definition: spoolss.c:177
static void test_BuildOtherNamesFromMachineName(void)
Definition: spoolss.c:121
static LPCSTR load_functions(void)
Definition: spoolss.c:48

◆ test_BuildOtherNamesFromMachineName()

static void test_BuildOtherNamesFromMachineName ( void  )
static

Definition at line 121 of file spoolss.c.

122{
124 DWORD numentries;
125 DWORD res;
126
127 buffers = NULL;
128 numentries = 0;
129
130 SetLastError(0xdeadbeef);
131 res = pBuildOtherNamesFromMachineName(&buffers, &numentries);
132
133 /* An array with a number of stringpointers is returned (minimum of 3):
134 entry_#0: "" (empty String)
135 entry_#1: <hostname> (this is the same as the computername)
136 1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
137
138 As of Vista:
139
140 IPv6 fully disabled (lan interfaces, connections, tunnel interfaces and loopback interfaces)
141 entry_#0: "" (empty String)
142 entry_#1: <hostname> (this is the same as the computername)
143 1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
144 entry_#x: "::1"
145
146 IPv6 partly disabled (lan interfaces, connections):
147 entry_#0: "" (empty String)
148 entry_#1: <hostname> (this is the same as the computername)
149 entry_#2: "::1"
150 1 entry per Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
151
152 IPv6 fully enabled but not on all lan interfaces:
153 entry_#0: "" (empty String)
154 entry_#1: <hostname> (this is the same as the computername)
155 1 entry per IPv6 enabled Ethernet adapter : <ip-address> (string with a Link-local IPv6 ip-address)
156 1 entry per IPv4 enabled Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
157
158 IPv6 fully enabled on all lan interfaces:
159 entry_#0: "" (empty String)
160 entry_#1: <hostname> (this is the same as the computername)
161 1 entry per IPv6 enabled Ethernet adapter : <ip-address> (string with a Link-local IPv6 ip-address)
162 entry_#x: <ip-address> Tunnel adapter (string with a Link-local IPv6 ip-address)
163 1 entry per IPv4 enabled Ethernet adapter : <ip-address> (string with a IPv4 ip-address)
164 entry_#y: <ip-address> Tunnel adapter (string with a IPv6 ip-address)
165 */
166
168 ok( res && (buffers != NULL) && (numentries >= 3) && (buffers[0] != NULL) && (buffers[0][0] == '\0'),
169 "got %u with %u and %p,%u (%p:%d)\n", res, GetLastError(), buffers, numentries,
170 ((numentries > 0) && buffers) ? buffers[0] : NULL,
171 ((numentries > 0) && buffers && buffers[0]) ? lstrlenW(buffers[0]) : -1);
172
173}
#define ok(value,...)
Definition: atltest.h:57
#define SetLastError(x)
Definition: compat.h:752
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
const GLuint * buffers
Definition: glext.h:5916
#define todo_wine
Definition: custom.c:89
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_SplInitializeWinSpoolDrv()

static void test_SplInitializeWinSpoolDrv ( VOID  )
static

Definition at line 177 of file spoolss.c.

178{
179 LPVOID *fn_ref = fn_xp;
180 DWORD res;
181 LONG id;
182
183 memset(fn_spl, 0xff, sizeof(fn_spl));
184 SetLastError(0xdeadbeef);
185 res = pSplInitializeWinSpoolDrv(fn_spl);
186 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
187
188 /* functions 0 to 5 are the same in "spoolss.dll" from w2k and above */
189 if (fn_spl[6] == fn_w2k[6]) {
190 fn_ref = fn_w2k;
191 }
192 if (fn_spl[9] == fn_v[9]) {
193 fn_ref = fn_v;
194 }
195
196 id = 0;
197 while (id < WINSPOOL_TABLESIZE) {
198 ok( fn_spl[id] == fn_ref[id],
199 "(#%02u) spoolss: %p (vista: %p, xp: %p, w2k: %p)\n",
200 id, fn_spl[id], fn_v[id], fn_xp[id], fn_w2k[id]);
201 id++;
202 }
203}
GLuint id
Definition: glext.h:5910
long LONG
Definition: pedump.c:60
static LPVOID fn_spl[WINSPOOL_TABLESIZE]
Definition: spoolss.c:41
#define WINSPOOL_TABLESIZE
Definition: spoolss.c:39

Referenced by START_TEST().

Variable Documentation

◆ fn_spl

LPVOID fn_spl[WINSPOOL_TABLESIZE]
static

Definition at line 41 of file spoolss.c.

Referenced by test_SplInitializeWinSpoolDrv().

◆ fn_v

LPVOID fn_v[WINSPOOL_TABLESIZE]
static

Definition at line 44 of file spoolss.c.

Referenced by load_functions(), and test_SplInitializeWinSpoolDrv().

◆ fn_w2k

LPVOID fn_w2k[WINSPOOL_TABLESIZE]
static

Definition at line 42 of file spoolss.c.

Referenced by load_functions(), and test_SplInitializeWinSpoolDrv().

◆ fn_xp

LPVOID fn_xp[WINSPOOL_TABLESIZE]
static

Definition at line 43 of file spoolss.c.

Referenced by load_functions(), and test_SplInitializeWinSpoolDrv().

◆ hspl

HMODULE hspl
static

Definition at line 35 of file spoolss.c.

Referenced by load_functions().

◆ hwinspool

HMODULE hwinspool
static

Definition at line 33 of file spoolss.c.

Referenced by load_functions().

◆ LPDWORD

Definition at line 36 of file spoolss.c.