ReactOS  0.4.15-dev-1377-ga59cecd
info.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winnls.h"
#include "winuser.h"
#include "winreg.h"
#include "winspool.h"
#include "commdlg.h"
#include "wine/test.h"
Include dependency graph for info.c:

Go to the source code of this file.

Classes

struct  monitor_entry
 

Macros

#define NONAMELESSSTRUCT
 
#define NONAMELESSUNION
 
#define MAGIC_DEAD   0xdeadbeef
 
#define DEFAULT_PRINTER_SIZE   1000
 
#define FORMTYPE_MAX   2
 

Functions

static BOOL (WINAPI *pAddPortExA)(LPSTR
 
static DWORD (WINAPI *pGetPrinterDataExA)(HANDLE
 
static BOOL is_spooler_deactivated (DWORD res, DWORD lasterror)
 
static BOOL is_access_denied (DWORD res, DWORD lasterror)
 
static void find_default_printer (VOID)
 
static struct monitor_entryfind_installed_monitor (void)
 
static void find_local_server (VOID)
 
static void find_tempfile (VOID)
 
static void test_AddMonitor (void)
 
static void test_AddPort (void)
 
static void test_AddPortEx (void)
 
static void test_ConfigurePort (void)
 
static void test_ClosePrinter (void)
 
static void test_DeleteMonitor (void)
 
static void test_DeletePort (void)
 
static void test_EnumForms (LPSTR pName)
 
static void test_EnumMonitors (void)
 
static void test_EnumPorts (void)
 
static void test_EnumPrinterDrivers (void)
 
static void test_EnumPrintProcessors (void)
 
static void test_GetDefaultPrinter (void)
 
static void test_GetPrinterDriverDirectory (void)
 
static void test_GetPrintProcessorDirectory (void)
 
static void test_OpenPrinter (void)
 
static void test_SetDefaultPrinter (void)
 
static void test_XcvDataW_MonitorUI (void)
 
static void test_XcvDataW_PortIsValid (void)
 
static void test_GetPrinter (void)
 
static void test_GetPrinterData (void)
 
static void test_GetPrinterDataEx (void)
 
static void test_GetPrinterDriver (void)
 
static void test_DEVMODEA (const DEVMODEA *dm, LONG dmSize, LPCSTR exp_prn_name)
 
static void test_DocumentProperties (void)
 
static void test_EnumPrinters (void)
 
static void test_DeviceCapabilities (void)
 
static void test_OpenPrinter_defaults (void)
 
static void test_IsValidDevmodeW (void)
 
 START_TEST (info)
 

Variables

static CHAR defaultspooldirectory [] = "DefaultSpoolDirectory"
 
static CHAR does_not_exist_dll [] = "does_not_exist.dll"
 
static CHAR does_not_exist [] = "does_not_exist"
 
static CHAR empty [] = ""
 
static CHAR env_x64 [] = "Windows x64"
 
static CHAR env_x86 [] = "Windows NT x86"
 
static CHAR env_win9x_case [] = "windowS 4.0"
 
static CHAR illegal_name [] = "illegal,name"
 
static CHAR invalid_env [] = "invalid_env"
 
static CHAR LocalPortA [] = "Local Port"
 
static CHAR portname_com1 [] = "COM1:"
 
static CHAR portname_file [] = "FILE:"
 
static CHAR portname_lpt1 [] = "LPT1:"
 
static CHAR server_does_not_exist [] = "\\\\does_not_exist"
 
static CHAR version_dll [] = "version.dll"
 
static CHAR winetest [] = "winetest"
 
static CHAR xcv_localport [] = ",XcvMonitor Local Port"
 
static const WCHAR cmd_MonitorUIW [] = {'M','o','n','i','t','o','r','U','I',0}
 
static const WCHAR cmd_PortIsValidW [] = {'P','o','r','t','I','s','V','a','l','i','d',0}
 
static WCHAR emptyW [] = {0}
 
static WCHAR portname_com1W [] = {'C','O','M','1',':',0}
 
static WCHAR portname_com2W [] = {'C','O','M','2',':',0}
 
static WCHAR portname_fileW [] = {'F','I','L','E',':',0}
 
static WCHAR portname_lpt1W [] = {'L','P','T','1',':',0}
 
static WCHAR portname_lpt2W [] = {'L','P','T','2',':',0}
 
static HANDLE hwinspool
 
static DWORD
 
static LPBYTE
 
static LPSTR
 
static LPWSTR
 
static LPDWORD
 
static LPCSTR
 
static LPCWSTR
 
static PBYTE
 
static PDWORD
 
static LPSTR default_printer = NULL
 
static LPSTR local_server = NULL
 
static LPSTR tempdirA = NULL
 
static LPSTR tempfileA = NULL
 
static LPWSTR tempdirW = NULL
 
static LPWSTR tempfileW = NULL
 

Macro Definition Documentation

◆ DEFAULT_PRINTER_SIZE

#define DEFAULT_PRINTER_SIZE   1000

Definition at line 39 of file info.c.

◆ FORMTYPE_MAX

#define FORMTYPE_MAX   2

◆ MAGIC_DEAD

#define MAGIC_DEAD   0xdeadbeef

Definition at line 38 of file info.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 24 of file info.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 25 of file info.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pAddPortExA)
static

◆ DWORD()

static DWORD ( WINAPI pGetPrinterDataExA)
static

◆ find_default_printer()

static void find_default_printer ( VOID  )
static

Definition at line 123 of file info.c.

124 {
125  static char buffer[DEFAULT_PRINTER_SIZE];
126  DWORD needed;
127  DWORD res;
128  LPSTR ptr;
129 
130  if ((default_printer == NULL) && (pGetDefaultPrinterA))
131  {
132  /* w2k and above */
133  needed = sizeof(buffer);
134  res = pGetDefaultPrinterA(buffer, &needed);
135  if(res) default_printer = buffer;
136  trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
137  }
138  if (default_printer == NULL)
139  {
140  HKEY hwindows;
141  DWORD type;
142  /* NT 3.x and above */
144  "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
145  0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
146 
147  needed = sizeof(buffer);
148  if (RegQueryValueExA(hwindows, "device", NULL, &type, (LPBYTE)buffer, &needed) == NO_ERROR) {
149  ptr = strchr(buffer, ',');
150  if (ptr) {
151  ptr[0] = '\0';
153  }
154  }
155  RegCloseKey(hwindows);
156  }
157  trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
158  }
159  if (default_printer == NULL)
160  {
161  /* win9x */
162  needed = sizeof(buffer);
163  res = GetProfileStringA("windows", "device", "*", buffer, needed);
164  if(res) {
165  ptr = strchr(buffer, ',');
166  if (ptr) {
167  ptr[0] = '\0';
169  }
170  }
171  trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
172  }
173 }
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
GLuint buffer
Definition: glext.h:5915
char * LPSTR
Definition: xmlstorage.h:182
#define NO_ERROR
Definition: dderror.h:5
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
static PVOID ptr
Definition: dispmode.c:27
INT WINAPI GetProfileStringA(LPCSTR section, LPCSTR entry, LPCSTR def_val, LPSTR buffer, UINT len)
Definition: profile.c:1252
#define trace
Definition: atltest.h:70
#define DEFAULT_PRINTER_SIZE
Definition: info.c:39
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPSTR default_printer
Definition: info.c:86
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
char * strchr(const char *String, int ch)
Definition: utclib.c:501
GLuint res
Definition: glext.h:9613
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by START_TEST().

◆ find_installed_monitor()

static struct monitor_entry* find_installed_monitor ( void  )
static

Definition at line 176 of file info.c.

177 {
178  MONITOR_INFO_2A mi2a;
179  static struct monitor_entry * entry = NULL;
181  DWORD i = 0;
182 
183  static struct monitor_entry monitor_table[] = {
184  {env_win9x_case, "localspl.dll"},
185  {env_x86, "localspl.dll"},
186  {env_x64, "localspl.dll"},
187  {env_win9x_case, "localmon.dll"},
188  {env_x86, "localmon.dll"},
189  {env_win9x_case, "tcpmon.dll"},
190  {env_x86, "tcpmon.dll"},
191  {env_win9x_case, "usbmon.dll"},
192  {env_x86, "usbmon.dll"},
193  {env_win9x_case, "mspp32.dll"},
194  {env_x86, "win32spl.dll"},
195  {env_x86, "redmonnt.dll"},
196  {env_x86, "redmon35.dll"},
197  {env_win9x_case, "redmon95.dll"},
198  {env_x86, "pdfcmnnt.dll"},
199  {env_win9x_case, "pdfcmn95.dll"},
200  };
201 
202  if (entry) return entry;
203 
204  num_tests = ARRAY_SIZE(monitor_table);
205 
206  /* cleanup */
210 
211  /* find a usable monitor from the table */
212  mi2a.pName = winetest;
213  while ((entry == NULL) && (i < num_tests)) {
214  entry = &monitor_table[i];
215  i++;
216  mi2a.pEnvironment = entry->env;
217  mi2a.pDLLName = entry->dllname;
218 
219  if (AddMonitorA(NULL, 2, (LPBYTE) &mi2a)) {
220  /* we got one */
221  trace("using '%s', '%s'\n", entry->env, entry->dllname);
223  }
224  else
225  {
226  entry = NULL;
227  }
228  }
229  return entry;
230 }
static CHAR env_win9x_case[]
Definition: info.c:47
WINBOOL WINAPI DeleteMonitorA(LPSTR pName, LPSTR pEnvironment, LPSTR pMonitorName)
unsigned char * LPBYTE
Definition: typedefs.h:53
static CHAR env_x86[]
Definition: info.c:46
WINBOOL WINAPI AddMonitorA(LPSTR pName, DWORD Level, LPBYTE pMonitorInfo)
static CHAR env_x64[]
Definition: info.c:45
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t entry
Definition: isohybrid.c:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
LPSTR pEnvironment
Definition: winspool.h:828
static CHAR winetest[]
Definition: info.c:56
Definition: info.c:81

Referenced by test_AddMonitor(), and test_DeleteMonitor().

◆ find_local_server()

static void find_local_server ( VOID  )
static

Definition at line 235 of file info.c.

236 {
237  static char buffer[MAX_PATH];
238  DWORD res;
239  DWORD size;
240 
241  size = sizeof(buffer) - 3 ;
242  buffer[0] = '\\';
243  buffer[1] = '\\';
244  buffer[2] = '\0';
245 
246  SetLastError(0xdeadbeef);
247  res = GetComputerNameA(&buffer[2], &size);
248  trace("returned %d with %d and %d: '%s'\n", res, GetLastError(), size, buffer);
249 
250  ok( res != 0, "returned %d with %d and %d: '%s' (expected '!= 0')\n",
251  res, GetLastError(), size, buffer);
252 
253  if (res) local_server = buffer;
254 }
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ find_tempfile()

static void find_tempfile ( VOID  )
static

Definition at line 258 of file info.c.

259 {
260  static CHAR buffer_dirA[MAX_PATH];
261  static CHAR buffer_fileA[MAX_PATH];
262  static WCHAR buffer_dirW[MAX_PATH];
263  static WCHAR buffer_fileW[MAX_PATH];
264  DWORD res;
265  int resint;
266 
267  memset(buffer_dirA, 0, MAX_PATH - 1);
268  buffer_dirA[MAX_PATH - 1] = '\0';
269  SetLastError(0xdeadbeef);
270  res = GetTempPathA(MAX_PATH, buffer_dirA);
271  ok(res, "returned %u with %u and '%s' (expected '!= 0')\n", res, GetLastError(), buffer_dirA);
272  if (res == 0) return;
273 
274  memset(buffer_fileA, 0, MAX_PATH - 1);
275  buffer_fileA[MAX_PATH - 1] = '\0';
276  SetLastError(0xdeadbeef);
277  res = GetTempFileNameA(buffer_dirA, winetest, 0, buffer_fileA);
278  ok(res, "returned %u with %u and '%s' (expected '!= 0')\n", res, GetLastError(), buffer_fileA);
279  if (res == 0) return;
280 
281  SetLastError(0xdeadbeef);
282  resint = MultiByteToWideChar(CP_ACP, 0, buffer_dirA, -1, buffer_dirW, MAX_PATH);
283  ok(res, "returned %u with %u (expected '!= 0')\n", resint, GetLastError());
284  if (resint == 0) return;
285 
286  SetLastError(0xdeadbeef);
287  resint = MultiByteToWideChar(CP_ACP, 0, buffer_fileA, -1, buffer_fileW, MAX_PATH);
288  ok(res, "returned %u with %u (expected '!= 0')\n", resint, GetLastError());
289  if (resint == 0) return;
290 
291  tempdirA = buffer_dirA;
292  tempfileA = buffer_fileA;
293  tempdirW = buffer_dirW;
294  tempfileW = buffer_fileW;
295  trace("tempfile: '%s'\n", tempfileA);
296 }
static LPSTR tempfileA
Definition: info.c:89
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static LPWSTR tempfileW
Definition: info.c:91
static LPWSTR tempdirW
Definition: info.c:90
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define ok(value,...)
Definition: atltest.h:57
#define MultiByteToWideChar
Definition: compat.h:110
static LPSTR tempdirA
Definition: info.c:88
GLuint res
Definition: glext.h:9613
static CHAR winetest[]
Definition: info.c:56
#define memset(x, y, z)
Definition: compat.h:39
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26

Referenced by START_TEST().

◆ is_access_denied()

static BOOL is_access_denied ( DWORD  res,
DWORD  lasterror 
)
static

Definition at line 108 of file info.c.

109 {
110  if (!res && lasterror == ERROR_ACCESS_DENIED)
111  {
112  static int access_denied_reported = 0;
113  if (!access_denied_reported)
114  {
115  access_denied_reported = 1;
116  skip("More access rights are required for many tests\n");
117  }
118  return TRUE;
119  }
120  return FALSE;
121 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613

Referenced by test_AddMonitor(), test_AddPort(), test_ConfigurePort(), test_DeletePort(), test_XcvDataW_MonitorUI(), and test_XcvDataW_PortIsValid().

◆ is_spooler_deactivated()

static BOOL is_spooler_deactivated ( DWORD  res,
DWORD  lasterror 
)
static

Definition at line 93 of file info.c.

94 {
95  if (!res && lasterror == RPC_S_SERVER_UNAVAILABLE)
96  {
97  static int deactivated_spooler_reported = 0;
98  if (!deactivated_spooler_reported)
99  {
100  deactivated_spooler_reported = 1;
101  skip("The service 'Spooler' is required for many tests\n");
102  }
103  return TRUE;
104  }
105  return FALSE;
106 }
#define TRUE
Definition: types.h:120
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define FALSE
Definition: types.h:117
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613

Referenced by test_AddMonitor(), test_AddPort(), test_AddPortEx(), test_ClosePrinter(), test_ConfigurePort(), test_DeletePort(), test_EnumForms(), test_EnumMonitors(), test_EnumPorts(), test_EnumPrinterDrivers(), test_EnumPrinters(), test_EnumPrintProcessors(), test_GetPrinterDriverDirectory(), test_GetPrintProcessorDirectory(), test_OpenPrinter(), test_SetDefaultPrinter(), test_XcvDataW_MonitorUI(), and test_XcvDataW_PortIsValid().

◆ START_TEST()

START_TEST ( info  )

Definition at line 3049 of file info.c.

3050 {
3051  hwinspool = LoadLibraryA("winspool.drv");
3052  pAddPortExA = (void *) GetProcAddress(hwinspool, "AddPortExA");
3053  pEnumPrinterDriversW = (void *) GetProcAddress(hwinspool, "EnumPrinterDriversW");
3054  pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
3055  pGetPrinterDataExA = (void *) GetProcAddress(hwinspool, "GetPrinterDataExA");
3056  pGetPrinterDriverW = (void *) GetProcAddress(hwinspool, "GetPrinterDriverW");
3057  pGetPrinterW = (void *) GetProcAddress(hwinspool, "GetPrinterW");
3058  pSetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterA");
3059  pXcvDataW = (void *) GetProcAddress(hwinspool, "XcvDataW");
3060 
3063  find_tempfile();
3064 
3065  test_AddMonitor();
3066  test_AddPort();
3067  test_AddPortEx();
3071  test_DeletePort();
3077  test_EnumPorts();
3085  test_OpenPrinter();
3087  test_GetPrinter();
3094 
3095  /* Cleanup our temporary file */
3097 }
static void test_XcvDataW_PortIsValid(void)
Definition: info.c:2181
static void test_EnumPrintProcessors(void)
Definition: info.c:1305
static LPSTR tempfileA
Definition: info.c:89
static HANDLE hwinspool
Definition: info.c:69
static void test_ClosePrinter(void)
Definition: info.c:656
static void test_EnumMonitors(void)
Definition: info.c:949
static void test_GetPrinterData(void)
Definition: info.c:2376
static void find_default_printer(VOID)
Definition: info.c:123
static void test_GetPrinterDataEx(void)
Definition: info.c:2422
static void test_IsValidDevmodeW(void)
Definition: info.c:3002
static void test_GetPrintProcessorDirectory(void)
Definition: info.c:1656
static void test_XcvDataW_MonitorUI(void)
Definition: info.c:2061
static void test_EnumPorts(void)
Definition: info.c:1057
static void test_GetPrinterDriverDirectory(void)
Definition: info.c:1502
static void test_AddPortEx(void)
Definition: info.c:481
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_GetPrinterDriver(void)
Definition: info.c:2523
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static void test_SetDefaultPrinter(void)
Definition: info.c:1951
static void test_AddPort(void)
Definition: info.c:443
static void test_EnumForms(LPSTR pName)
Definition: info.c:816
static void test_DeletePort(void)
Definition: info.c:784
static void find_tempfile(VOID)
Definition: info.c:258
static void test_DocumentProperties(void)
Definition: info.c:2669
static void test_OpenPrinter(void)
Definition: info.c:1796
static void test_GetDefaultPrinter(void)
Definition: info.c:1425
static void test_GetPrinter(void)
Definition: info.c:2292
static LPSTR default_printer
Definition: info.c:86
static void test_OpenPrinter_defaults(void)
Definition: info.c:2883
static void find_local_server(VOID)
Definition: info.c:235
#define NULL
Definition: types.h:112
static void test_ConfigurePort(void)
Definition: info.c:594
static void test_DeleteMonitor(void)
Definition: info.c:700
static void test_EnumPrinters(void)
Definition: info.c:2712
static void test_AddMonitor(void)
Definition: info.c:300
#define GetProcAddress(x, y)
Definition: compat.h:612
static void test_DeviceCapabilities(void)
Definition: info.c:2764
static void test_EnumPrinterDrivers(void)
Definition: info.c:1155

◆ test_AddMonitor()

static void test_AddMonitor ( void  )
static

Definition at line 300 of file info.c.

301 {
302  MONITOR_INFO_2A mi2a;
303  struct monitor_entry * entry = NULL;
304  DWORD res;
305 
307 
309  res = AddMonitorA(NULL, 1, NULL);
311  "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
312  res, GetLastError());
313 
315  res = AddMonitorA(NULL, 3, NULL);
317  "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
318  res, GetLastError());
319 
320  /* This test crashes win9x on vmware (works with win9x on qemu 0.8.1) */
322  res = AddMonitorA(NULL, 2, NULL);
323  /* NT: unchanged, 9x: ERROR_PRIVILEGE_NOT_HELD */
324  ok(!res &&
325  ((GetLastError() == MAGIC_DEAD) ||
327  "returned %d with %d (expected '0' with: MAGIC_DEAD or "
328  "ERROR_PRIVILEGE_NOT_HELD)\n", res, GetLastError());
329 
330  ZeroMemory(&mi2a, sizeof(MONITOR_INFO_2A));
332  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
333  if (is_spooler_deactivated(res, GetLastError())) return;
334  if (is_access_denied(res, GetLastError())) return;
335 
336  /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_INVALID_ENVIRONMENT */
339  "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
340  "ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
341 
342  if (!entry) {
343  skip("No usable Monitor found\n");
344  return;
345  }
346 
347  if (0)
348  {
349  /* The test is deactivated, because when mi2a.pName is NULL, the subkey
350  HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
351  or HKLM\System\CurrentControlSet\Control\Print\Monitors\ì
352  is created on win9x and we do not want to hit this bug here. */
353 
354  mi2a.pEnvironment = entry->env;
356  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
357  ok(res, "AddMonitor error %d\n", GetLastError());
358  /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
359  }
360 
361  mi2a.pEnvironment = entry->env;
362  mi2a.pName = empty;
364  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
365  /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
366  ok( !res &&
369  "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
370  "ERROR_PRIVILEGE_NOT_HELD)\n",
371  res, GetLastError());
372 
373  mi2a.pName = winetest;
375  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
376  /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
377  ok( !res &&
380  "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
381  "ERROR_PRIVILEGE_NOT_HELD)\n",
382  res, GetLastError());
383 
384  mi2a.pDLLName = empty;
386  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
388  "returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
389  res, GetLastError());
390 
393  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
394  /* NT: ERROR_MOD_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
395  ok( !res &&
398  "returned %d with %d (expected '0' with: ERROR_MOD_NOT_FOUND or "
399  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
400 
401  mi2a.pDLLName = version_dll;
403  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
404  /* NT: ERROR_PROC_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
405  ok( !res &&
408  "returned %d with %d (expected '0' with: ERROR_PROC_NOT_FOUND or "
409  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
410  if (res) DeleteMonitorA(NULL, entry->env, winetest);
411 
412  /* Test AddMonitor with real options */
413  mi2a.pDLLName = entry->dllname;
415  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
416  /* Some apps depend on the result of GetLastError() also on success of AddMonitor */
417  ok(res && (GetLastError() == ERROR_SUCCESS),
418  "returned %d with %d (expected '!= 0' with ERROR_SUCCESS)\n", res, GetLastError());
419 
420  /* add a monitor twice */
422  res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
423  /* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006), 9x: ERROR_ALREADY_EXISTS (183) */
424  ok( !res &&
427  "returned %d with %d (expected '0' with: "
428  "ERROR_PRINT_MONITOR_ALREADY_INSTALLED or ERROR_ALREADY_EXISTS)\n",
429  res, GetLastError());
430 
433  res = AddMonitorA(empty, 2, (LPBYTE) &mi2a);
434  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
435 
436  /* cleanup */
438 
439 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static struct monitor_entry * find_installed_monitor(void)
Definition: info.c:176
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_PRIVILEGE_NOT_HELD
Definition: winerror.h:796
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ZeroMemory
Definition: winbase.h:1648
static CHAR empty[]
Definition: info.c:44
WINBOOL WINAPI DeleteMonitorA(LPSTR pName, LPSTR pEnvironment, LPSTR pMonitorName)
unsigned char * LPBYTE
Definition: typedefs.h:53
WINBOOL WINAPI AddMonitorA(LPSTR pName, DWORD Level, LPBYTE pMonitorInfo)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
uint32_t entry
Definition: isohybrid.c:63
static CHAR does_not_exist_dll[]
Definition: info.c:42
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED
Definition: winerror.h:1211
static CHAR version_dll[]
Definition: info.c:55
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
#define MAGIC_DEAD
Definition: info.c:38
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
static CHAR winetest[]
Definition: info.c:56
LPSTR pEnvironment
Definition: winspool.h:828
static BOOL is_access_denied(DWORD res, DWORD lasterror)
Definition: info.c:108
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
Definition: info.c:81

Referenced by START_TEST().

◆ test_AddPort()

static void test_AddPort ( void  )
static

Definition at line 443 of file info.c.

444 {
445  DWORD res;
446 
447  SetLastError(0xdeadbeef);
448  res = AddPortA(NULL, 0, NULL);
449  if (is_spooler_deactivated(res, GetLastError())) return;
450  /* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
451  ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
453  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
454  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
455 
456 
457  SetLastError(0xdeadbeef);
458  res = AddPortA(NULL, 0, empty);
459  /* Allowed only for (Printer-)Administrators */
460  if (is_access_denied(res, GetLastError())) return;
461 
462  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
463  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
465  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
466  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
467 
468 
469  SetLastError(0xdeadbeef);
471  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
472  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
474  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
475  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
476 
477 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
static CHAR does_not_exist[]
Definition: info.c:43
WINBOOL WINAPI AddPortA(LPSTR pName, HWND hWnd, LPSTR pMonitorName)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
static BOOL is_access_denied(DWORD res, DWORD lasterror)
Definition: info.c:108

Referenced by START_TEST().

◆ test_AddPortEx()

static void test_AddPortEx ( void  )
static

Definition at line 481 of file info.c.

482 {
484  DWORD res;
485 
486 
487  if (!pAddPortExA) {
488  win_skip("AddPortEx not supported\n");
489  return;
490  }
491 
492  /* start test with a clean system */
494 
495  pi.pPortName = tempfileA;
496  SetLastError(0xdeadbeef);
497  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
498  if (is_spooler_deactivated(res, GetLastError())) return;
499 
500  /* Allowed only for (Printer-)Administrators.
501  W2K+XP: ERROR_INVALID_PARAMETER */
502  if (!res && (GetLastError() == ERROR_INVALID_PARAMETER)) {
503  skip("ACCESS_DENIED (ERROR_INVALID_PARAMETER)\n");
504  return;
505  }
506  ok( res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
507 
508  /* add a port that already exists */
509  SetLastError(0xdeadbeef);
510  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
512  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
513  res, GetLastError());
515 
516 
517  /* the Monitorname must match */
518  SetLastError(0xdeadbeef);
519  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, NULL);
521  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
522  res, GetLastError());
523  if (res) DeletePortA(NULL, 0, tempfileA);
524 
525  SetLastError(0xdeadbeef);
526  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, empty);
528  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
529  res, GetLastError());
530  if (res) DeletePortA(NULL, 0, tempfileA);
531 
532  SetLastError(0xdeadbeef);
533  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, does_not_exist);
535  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
536  res, GetLastError());
537  if (res) DeletePortA(NULL, 0, tempfileA);
538 
539 
540  /* We need a Portname */
541  SetLastError(0xdeadbeef);
542  res = pAddPortExA(NULL, 1, NULL, LocalPortA);
544  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
545  res, GetLastError());
546 
547  pi.pPortName = NULL;
548  SetLastError(0xdeadbeef);
549  res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
551  "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
552  res, GetLastError());
553  if (res) DeletePortA(NULL, 0, tempfileA);
554 
555 
556  /* level 2 is documented as supported for Printmonitors,
557  but that is not supported for "Local Port" (localspl.dll) and
558  AddPortEx fails with ERROR_INVALID_LEVEL */
559 
560  pi.pPortName = tempfileA;
561  pi.pMonitorName = LocalPortA;
562  pi.pDescription = winetest;
563  pi.fPortType = PORT_TYPE_WRITE;
564 
565  SetLastError(0xdeadbeef);
566  res = pAddPortExA(NULL, 2, (LPBYTE) &pi, LocalPortA);
568  "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
569  res, GetLastError());
570  if (res) DeletePortA(NULL, 0, tempfileA);
571 
572 
573  /* invalid levels */
574  SetLastError(0xdeadbeef);
575  res = pAddPortExA(NULL, 0, (LPBYTE) &pi, LocalPortA);
577  "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
578  res, GetLastError());
579 
580  SetLastError(0xdeadbeef);
581  res = pAddPortExA(NULL, 3, (LPBYTE) &pi, LocalPortA);
583  "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
584  res, GetLastError());
585 
586 
587  /* cleanup */
589 
590 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static LPSTR tempfileA
Definition: info.c:89
#define PORT_TYPE_WRITE
Definition: winspool.h:776
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
static CHAR does_not_exist[]
Definition: info.c:43
unsigned char * LPBYTE
Definition: typedefs.h:53
static CHAR LocalPortA[]
Definition: info.c:50
WINBOOL WINAPI DeletePortA(LPSTR pName, HWND hWnd, LPSTR pPortName)
static refpint_t pi[]
Definition: server.c:96
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
static CHAR winetest[]
Definition: info.c:56
#define win_skip
Definition: test.h:149

Referenced by START_TEST().

◆ test_ClosePrinter()

static void test_ClosePrinter ( void  )
static

Definition at line 656 of file info.c.

657 {
658  HANDLE printer = 0;
659  BOOL res;
660 
661  /* NULL is handled */
662  SetLastError(0xdeadbeef);
663  res = ClosePrinter(NULL);
665  "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
666  res, GetLastError());
667 
668  /* A random value as HANDLE is handled */
669  SetLastError(0xdeadbeef);
670  res = ClosePrinter( (void *) -1);
671  if (is_spooler_deactivated(res, GetLastError())) return;
673  "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
674  res, GetLastError());
675 
676 
677  /* Normal use (The Spooler service is needed) */
678  SetLastError(0xdeadbeef);
679  res = OpenPrinterA(default_printer, &printer, NULL);
680  if (is_spooler_deactivated(res, GetLastError())) return;
681  if (res)
682  {
683  SetLastError(0xdeadbeef);
684  res = ClosePrinter(printer);
685  ok(res, "got %d with %d (expected TRUE)\n", res, GetLastError());
686 
687 
688  /* double free is handled */
689  SetLastError(0xdeadbeef);
690  res = ClosePrinter(printer);
692  "got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
693  res, GetLastError());
694 
695  }
696 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
static LPSTR default_printer
Definition: info.c:86
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ test_ConfigurePort()

static void test_ConfigurePort ( void  )
static

Definition at line 594 of file info.c.

595 {
596  DWORD res;
597 
598 
599  SetLastError(0xdeadbeef);
600  res = ConfigurePortA(NULL, 0, NULL);
601  if (is_spooler_deactivated(res, GetLastError())) return;
602  /* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
603  ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
605  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
606  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
607 
608  SetLastError(0xdeadbeef);
609  res = ConfigurePortA(NULL, 0, empty);
610  /* Allowed only for (Printer-)Administrators */
611  if (is_access_denied(res, GetLastError())) return;
612 
613  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
614  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
616  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
617  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
618 
619 
620  SetLastError(0xdeadbeef);
622  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
623  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
625  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
626  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
627 
628 
629  /* Testing-Results:
630  - Case of Portnames is ignored
631  - Portname without ":" => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
632  - Empty Servername (LPT1:) => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
633 
634  - Port not present => 9x: ERROR_INVALID_PARAMETER, NT:ERROR_NOT_SUPPORTED
635  - "FILE:" => 9x:Success, NT:ERROR_CANCELED
636  - Cancel ("Local Port") => ERROR_CANCELED
637  - Cancel ("Redirected Port") => Success
638  */
639  if (winetest_interactive > 0) {
640  SetLastError(0xdeadbeef);
642  trace("'%s' returned %d with %d\n", portname_com1, res, GetLastError());
643 
644  SetLastError(0xdeadbeef);
646  trace("'%s' returned %d with %d\n", portname_lpt1, res, GetLastError());
647 
648  SetLastError(0xdeadbeef);
650  trace("'%s' returned %d with %d\n", portname_file, res, GetLastError());
651  }
652 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
static CHAR does_not_exist[]
Definition: info.c:43
int winetest_interactive
static CHAR portname_lpt1[]
Definition: info.c:53
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static CHAR portname_file[]
Definition: info.c:52
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
static CHAR portname_com1[]
Definition: info.c:51
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
WINBOOL WINAPI ConfigurePortA(LPSTR pName, HWND hWnd, LPSTR pPortName)
GLuint res
Definition: glext.h:9613
static BOOL is_access_denied(DWORD res, DWORD lasterror)
Definition: info.c:108

Referenced by START_TEST().

◆ test_DeleteMonitor()

static void test_DeleteMonitor ( void  )
static

Definition at line 700 of file info.c.

701 {
702  MONITOR_INFO_2A mi2a;
703  struct monitor_entry * entry = NULL;
704  DWORD res;
705 
706 
708 
709  if (!entry) {
710  skip("No usable Monitor found\n");
711  return;
712  }
713 
714  mi2a.pName = winetest;
715  mi2a.pEnvironment = entry->env;
716  mi2a.pDLLName = entry->dllname;
717 
718  /* Testing DeleteMonitor with real options */
719  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
720 
723  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
724 
725  /* Delete the Monitor twice */
728  /* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
729  ok( !res &&
732  "returned %d with %d (expected '0' with: ERROR_UNKNOWN_PRINT_MONITOR"
733  " or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
734 
735  /* the environment */
736  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
739  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
740 
741  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
744  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
745 
746  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
749  ok( res || GetLastError() == ERROR_INVALID_ENVIRONMENT /* Vista/W2K8 */,
750  "returned %d with %d\n", res, GetLastError());
751 
752  /* the monitor-name */
753  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
755  res = DeleteMonitorA(NULL, entry->env, NULL);
756  /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
757  ok( !res &&
760  "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
761  "ERROR_INVALID_NAME)\n", res, GetLastError());
762 
763  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
765  res = DeleteMonitorA(NULL, entry->env, empty);
766  /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
767  ok( !res &&
770  "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
771  "ERROR_INVALID_NAME)\n", res, GetLastError());
772 
773  AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
776  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
777 
778  /* cleanup */
780 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static struct monitor_entry * find_installed_monitor(void)
Definition: info.c:176
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
WINBOOL WINAPI DeleteMonitorA(LPSTR pName, LPSTR pEnvironment, LPSTR pMonitorName)
unsigned char * LPBYTE
Definition: typedefs.h:53
#define ERROR_UNKNOWN_PRINT_MONITOR
Definition: winerror.h:1205
WINBOOL WINAPI AddMonitorA(LPSTR pName, DWORD Level, LPBYTE pMonitorInfo)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
uint32_t entry
Definition: isohybrid.c:63
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static CHAR invalid_env[]
Definition: info.c:49
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define MAGIC_DEAD
Definition: info.c:38
LPSTR pEnvironment
Definition: winspool.h:828
static CHAR winetest[]
Definition: info.c:56
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
Definition: info.c:81

Referenced by START_TEST().

◆ test_DeletePort()

static void test_DeletePort ( void  )
static

Definition at line 784 of file info.c.

785 {
786  DWORD res;
787 
788  SetLastError(0xdeadbeef);
789  res = DeletePortA(NULL, 0, NULL);
790  if (is_spooler_deactivated(res, GetLastError())) return;
791 
792  SetLastError(0xdeadbeef);
793  res = DeletePortA(NULL, 0, empty);
794  /* Allowed only for (Printer-)Administrators */
795  if (is_access_denied(res, GetLastError())) return;
796 
797  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
798  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
800  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
801  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
802 
803 
804  SetLastError(0xdeadbeef);
806  /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
807  ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
809  "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
810  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
811 
812 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
static CHAR does_not_exist[]
Definition: info.c:43
WINBOOL WINAPI DeletePortA(LPSTR pName, HWND hWnd, LPSTR pPortName)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
static BOOL is_access_denied(DWORD res, DWORD lasterror)
Definition: info.c:108

Referenced by START_TEST().

◆ test_DeviceCapabilities()

static void test_DeviceCapabilities ( void  )
static

Definition at line 2764 of file info.c.

2765 {
2766  HANDLE hComdlg32;
2767  BOOL (WINAPI *pPrintDlgA)(PRINTDLGA *);
2768  PRINTDLGA prn_dlg;
2769  DEVMODEA *dm;
2770  DEVNAMES *dn;
2771  const char *driver, *device, *port;
2772  WORD *papers;
2773  POINT *paper_size;
2774  POINTS ext;
2775  struct
2776  {
2777  char name[64];
2778  } *paper_name;
2779  INT n_papers, n_paper_size, n_paper_names, n_copies, ret;
2780  DWORD fields;
2781 
2782  hComdlg32 = LoadLibraryA("comdlg32.dll");
2783  assert(hComdlg32);
2784  pPrintDlgA = (void *)GetProcAddress(hComdlg32, "PrintDlgA");
2785  assert(pPrintDlgA);
2786 
2787  memset(&prn_dlg, 0, sizeof(prn_dlg));
2788  prn_dlg.lStructSize = sizeof(prn_dlg);
2789  prn_dlg.Flags = PD_RETURNDEFAULT;
2790  ret = pPrintDlgA(&prn_dlg);
2791  FreeLibrary(hComdlg32);
2792  if (!ret)
2793  {
2794  skip("PrintDlg returned no default printer\n");
2795  return;
2796  }
2797  ok(prn_dlg.hDevMode != 0, "PrintDlg returned hDevMode == NULL\n");
2798  ok(prn_dlg.hDevNames != 0, "PrintDlg returned hDevNames == NULL\n");
2799 
2800  dm = GlobalLock(prn_dlg.hDevMode);
2801  ok(dm != NULL, "GlobalLock(prn_dlg.hDevMode) failed\n");
2802  trace("dmDeviceName \"%s\"\n", dm->dmDeviceName);
2803 
2804  dn = GlobalLock(prn_dlg.hDevNames);
2805  ok(dn != NULL, "GlobalLock(prn_dlg.hDevNames) failed\n");
2806  ok(dn->wDriverOffset, "expected not 0 wDriverOffset\n");
2807  ok(dn->wDeviceOffset, "expected not 0 wDeviceOffset\n");
2808  ok(dn->wOutputOffset, "expected not 0 wOutputOffset\n");
2809  ok(dn->wDefault == DN_DEFAULTPRN, "expected DN_DEFAULTPRN got %x\n", dn->wDefault);
2810  driver = (const char *)dn + dn->wDriverOffset;
2811  device = (const char *)dn + dn->wDeviceOffset;
2812  port = (const char *)dn + dn->wOutputOffset;
2813  trace("driver \"%s\" device \"%s\" port \"%s\"\n", driver, device, port);
2814 
2815  test_DEVMODEA(dm, dm->dmSize + dm->dmDriverExtra, device);
2816 
2818  ok(n_papers > 0, "DeviceCapabilitiesA DC_PAPERS failed\n");
2819  papers = HeapAlloc(GetProcessHeap(), 0, sizeof(*papers) * n_papers);
2821  ok(ret == n_papers, "expected %d, got %d\n", n_papers, ret);
2822 #ifdef VERBOSE
2823  for (ret = 0; ret < n_papers; ret++)
2824  trace("papers[%d] = %d\n", ret, papers[ret]);
2825 #endif
2826  HeapFree(GetProcessHeap(), 0, papers);
2827 
2828  n_paper_size = DeviceCapabilitiesA(device, port, DC_PAPERSIZE, NULL, NULL);
2829  ok(n_paper_size > 0, "DeviceCapabilitiesA DC_PAPERSIZE failed\n");
2830  ok(n_paper_size == n_papers, "n_paper_size %d != n_papers %d\n", n_paper_size, n_papers);
2831  paper_size = HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_size) * n_paper_size);
2833  ok(ret == n_paper_size, "expected %d, got %d\n", n_paper_size, ret);
2834 #ifdef VERBOSE
2835  for (ret = 0; ret < n_paper_size; ret++)
2836  trace("paper_size[%d] = %d x %d\n", ret, paper_size[ret].x, paper_size[ret].y);
2837 #endif
2838  HeapFree(GetProcessHeap(), 0, paper_size);
2839 
2840  n_paper_names = DeviceCapabilitiesA(device, port, DC_PAPERNAMES, NULL, NULL);
2841  ok(n_paper_names > 0, "DeviceCapabilitiesA DC_PAPERNAMES failed\n");
2842  ok(n_paper_names == n_papers, "n_paper_names %d != n_papers %d\n", n_paper_names, n_papers);
2843  paper_name = HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_name) * n_paper_names);
2845  ok(ret == n_paper_names, "expected %d, got %d\n", n_paper_names, ret);
2846 #ifdef VERBOSE
2847  for (ret = 0; ret < n_paper_names; ret++)
2848  trace("paper_name[%u] = %s\n", ret, paper_name[ret].name);
2849 #endif
2850  HeapFree(GetProcessHeap(), 0, paper_name);
2851 
2852  n_copies = DeviceCapabilitiesA(device, port, DC_COPIES, NULL, dm);
2853  ok(n_copies > 0, "DeviceCapabilitiesA DC_COPIES failed\n");
2854  trace("n_copies = %d\n", n_copies);
2855 
2856  /* these capabilities are not available on all printer drivers */
2857  if (0)
2858  {
2860  ok(ret != -1, "DeviceCapabilitiesA DC_MAXEXTENT failed\n");
2861  ext = MAKEPOINTS(ret);
2862  trace("max ext = %d x %d\n", ext.x, ext.y);
2863 
2865  ok(ret != -1, "DeviceCapabilitiesA DC_MINEXTENT failed\n");
2866  ext = MAKEPOINTS(ret);
2867  trace("min ext = %d x %d\n", ext.x, ext.y);
2868  }
2869 
2871  ok(fields != (DWORD)-1, "DeviceCapabilitiesA DC_FIELDS failed\n");
2872  ok(fields == (dm->dmFields | DM_FORMNAME) ||
2873  fields == ((dm->dmFields | DM_FORMNAME | DM_PAPERSIZE) & ~(DM_PAPERLENGTH|DM_PAPERWIDTH)) ||
2874  broken(fields == dm->dmFields), /* Win9x/WinMe */
2875  "fields %x, dm->dmFields %x\n", fields, dm->dmFields);
2876 
2877  GlobalUnlock(prn_dlg.hDevMode);
2878  GlobalFree(prn_dlg.hDevMode);
2879  GlobalUnlock(prn_dlg.hDevNames);
2880  GlobalFree(prn_dlg.hDevNames);
2881 }
#define DC_PAPERS
Definition: windef.h:363
static void test_DEVMODEA(const DEVMODEA *dm, LONG dmSize, LPCSTR exp_prn_name)
Definition: info.c:2653
WORD dmSize
Definition: wingdi.h:1567
WORD wDefault
Definition: commdlg.h:300
#define DC_PAPERNAMES
Definition: windef.h:377
WORD dmDriverExtra
Definition: wingdi.h:1568
#define MAKEPOINTS(l)
Definition: wingdi.h:2944
#define assert(x)
Definition: debug.h:53
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
#define DC_MAXEXTENT
Definition: windef.h:366
#define DN_DEFAULTPRN
Definition: commdlg.h:199
#define DC_MINEXTENT
Definition: windef.h:365
FxDevice * device
Definition: devices.h:37
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
WORD wDeviceOffset
Definition: commdlg.h:298
#define DC_FIELDS
Definition: windef.h:362
char ext[3]
Definition: mkdosfs.c:358
#define DM_PAPERWIDTH
Definition: wingdi.h:1252
WORD wDriverOffset
Definition: commdlg.h:297
struct @1657::@1658 driver
#define DM_FORMNAME
Definition: wingdi.h:1265
#define DM_PAPERLENGTH
Definition: wingdi.h:1251
#define DC_COPIES
Definition: windef.h:379
#define FreeLibrary(x)
Definition: compat.h:607
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define DM_PAPERSIZE
Definition: wingdi.h:1250
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL hDevMode
Definition: commdlg.h:467
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
DWORD WINAPI DeviceCapabilitiesA(_In_ LPCSTR pDevice, _In_opt_ LPCSTR pPort, _In_ WORD fwCapability, _Out_writes_opt_(_Inexpressible_(1)) LPSTR pOutput, _In_opt_ const DEVMODEA *pDevMode)
DWORD dmFields
Definition: wingdi.h:1569
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
static BOOL(WINAPI *pAddPortExA)(LPSTR
#define broken(x)
Definition: _sntprintf.h:21
#define PD_RETURNDEFAULT
Definition: commdlg.h:157
#define DC_PAPERSIZE
Definition: windef.h:364
HGLOBAL hDevNames
Definition: commdlg.h:468
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1564
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
DWORD lStructSize
Definition: commdlg.h:465
#define skip(...)
Definition: atltest.h:64
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:612
DWORD Flags
Definition: commdlg.h:470
WORD wOutputOffset
Definition: commdlg.h:299
USHORT port
Definition: uri.c:228
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by START_TEST().

◆ test_DEVMODEA()

static void test_DEVMODEA ( const DEVMODEA dm,
LONG  dmSize,
LPCSTR  exp_prn_name 
)
static

Definition at line 2653 of file info.c.

2654 {
2655  /* On NT3.51, some fields in DEVMODEA are empty/zero
2656  (dmDeviceName, dmSpecVersion, dmDriverVersion and dmDriverExtra)
2657  We skip the Tests on this Platform */
2658  if (dm->dmSpecVersion || dm->dmDriverVersion || dm->dmDriverExtra) {
2659  /* The 0-terminated Printername can be larger (MAX_PATH) than CCHDEVICENAME */
2660  ok(!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -1) ||
2661  !strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -2), /* XP+ */
2662  "expected '%s', got '%s'\n", exp_prn_name, dm->dmDeviceName);
2663  ok(dm->dmSize + dm->dmDriverExtra == dmSize,
2664  "%u != %d\n", dm->dmSize + dm->dmDriverExtra, dmSize);
2665  }
2666  trace("dmFields %08x\n", dm->dmFields);
2667 }
WORD dmSize
Definition: wingdi.h:1567
WORD dmDriverExtra
Definition: wingdi.h:1568
WORD dmDriverVersion
Definition: wingdi.h:1566
WORD dmSpecVersion
Definition: wingdi.h:1565
const char * LPCSTR
Definition: xmlstorage.h:183
#define trace
Definition: atltest.h:70
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
DWORD dmFields
Definition: wingdi.h:1569
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define ok(value,...)
Definition: atltest.h:57
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1564

Referenced by test_DeviceCapabilities(), and test_DocumentProperties().

◆ test_DocumentProperties()

static void test_DocumentProperties ( void  )
static

Definition at line 2669 of file info.c.

2670 {
2671  HANDLE hprn;
2672  LONG dm_size, ret;
2673  DEVMODEA *dm;
2674  char empty_str[] = "";
2675 
2676  if (!default_printer)
2677  {
2678  skip("There is no default printer installed\n");
2679  return;
2680  }
2681 
2682  hprn = 0;
2683  ret = OpenPrinterA(default_printer, &hprn, NULL);
2684  if (!ret)
2685  {
2686  skip("Unable to open the default printer (%s)\n", default_printer);
2687  return;
2688  }
2689  ok(hprn != 0, "wrong hprn %p\n", hprn);
2690 
2691  dm_size = DocumentPropertiesA(0, hprn, NULL, NULL, NULL, 0);
2692  trace("DEVMODEA required size %d\n", dm_size);
2693  ok(dm_size >= sizeof(DEVMODEA), "unexpected DocumentPropertiesA ret value %d\n", dm_size);
2694 
2695  dm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dm_size);
2696 
2697  ret = DocumentPropertiesA(0, hprn, NULL, dm, dm, DM_OUT_BUFFER);
2698  ok(ret == IDOK, "DocumentPropertiesA ret value %d != expected IDOK\n", ret);
2699 
2700  ret = DocumentPropertiesA(0, hprn, empty_str, dm, dm, DM_OUT_BUFFER);
2701  ok(ret == IDOK, "DocumentPropertiesA ret value %d != expected IDOK\n", ret);
2702 
2703  test_DEVMODEA(dm, dm_size, default_printer);
2704 
2705  HeapFree(GetProcessHeap(), 0, dm);
2706 
2707  SetLastError(0xdeadbeef);
2708  ret = ClosePrinter(hprn);
2709  ok(ret, "ClosePrinter error %d\n", GetLastError());
2710 }
static void test_DEVMODEA(const DEVMODEA *dm, LONG dmSize, LPCSTR exp_prn_name)
Definition: info.c:2653
#define IDOK
Definition: winuser.h:824
static const TCHAR empty_str[]
Definition: dialog.c:32
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
long LONG
Definition: pedump.c:60
#define DM_OUT_BUFFER
Definition: windef.h:359
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
LONG WINAPI DocumentPropertiesA(HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName, PDEVMODEA pDevModeOutput, PDEVMODEA pDevModeInput, DWORD fMode)
Definition: printers.c:666
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define SetLastError(x)
Definition: compat.h:611
int ret
static LPSTR default_printer
Definition: info.c:86
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define skip(...)
Definition: atltest.h:64
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by START_TEST().

◆ test_EnumForms()

static void test_EnumForms ( LPSTR  pName)
static

Definition at line 816 of file info.c.

817 {
818  DWORD res;
819  HANDLE hprinter = 0;
820  LPBYTE buffer;
821  DWORD cbBuf;
823  DWORD pcReturned;
824  DWORD level;
825  UINT i;
826  const char *formtype;
827  static const char * const formtypes[] = { "FORM_USER", "FORM_BUILTIN", "FORM_PRINTER", "FORM_flag_unknown" };
828 #define FORMTYPE_MAX 2
829  PFORM_INFO_1A pFI_1a;
830  PFORM_INFO_2A pFI_2a;
831 
832  res = OpenPrinterA(pName, &hprinter, NULL);
833  if (is_spooler_deactivated(res, GetLastError())) return;
834  if (!res || !hprinter)
835  {
836  /* opening the local Printserver is not supported on win9x */
837  if (pName) skip("Failed to open '%s' (not supported on win9x)\n", pName);
838  return;
839  }
840 
841  /* valid levels are 1 and 2 */
842  for(level = 0; level < 4; level++) {
843  cbBuf = 0xdeadbeef;
844  pcReturned = 0xdeadbeef;
845  SetLastError(0xdeadbeef);
846  res = EnumFormsA(hprinter, level, NULL, 0, &cbBuf, &pcReturned);
847 
848  /* EnumForms is not implemented on win9x */
849  if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
850 
851  /* EnumForms for the server is not implemented on all NT-versions */
852  if (!res && (GetLastError() == ERROR_INVALID_HANDLE) && !pName) continue;
853 
854  /* Level 2 for EnumForms is not supported on all systems */
855  if (!res && (GetLastError() == ERROR_INVALID_LEVEL) && (level == 2)) continue;
856 
857  /* use only a short test when testing an invalid level */
858  if(!level || (level > 2)) {
859  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
860  (res && (pcReturned == 0)),
861  "(%d) returned %d with %d and 0x%08x (expected '0' with "
862  "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
863  level, res, GetLastError(), pcReturned);
864  continue;
865  }
866 
868  "(%d) returned %d with %d (expected '0' with "
869  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
870 
871  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
872  if (buffer == NULL) continue;
873 
874  SetLastError(0xdeadbeef);
875  res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
876  ok(res, "(%d) returned %d with %d (expected '!=0')\n",
877  level, res, GetLastError());
878 
879  if (winetest_debug > 1) {
880  trace("dumping %d forms level %d\n", pcReturned, level);
881  pFI_1a = (PFORM_INFO_1A)buffer;
882  pFI_2a = (PFORM_INFO_2A)buffer;
883  for (i = 0; i < pcReturned; i++)
884  {
885  /* first part is same in FORM_INFO_1 and FORM_INFO_2 */
886  formtype = (pFI_1a->Flags <= FORMTYPE_MAX) ? formtypes[pFI_1a->Flags] : formtypes[3];
887  trace("%u (%s): %.03fmm x %.03fmm, %s\n", i, pFI_1a->pName,
888  (float)pFI_1a->Size.cx/1000, (float)pFI_1a->Size.cy/1000, formtype);
889 
890  if (level == 1) pFI_1a ++;
891  else {
892  /* output additional FORM_INFO_2 fields */
893  trace("\tkeyword=%s strtype=%u muidll=%s resid=%u dispname=%s langid=%u\n",
894  pFI_2a->pKeyword, pFI_2a->StringType, pFI_2a->pMuiDll,
895  pFI_2a->dwResourceId, pFI_2a->pDisplayName, pFI_2a->wLangId);
896 
897  /* offset pointer pFI_1a by 1*sizeof(FORM_INFO_2A) Bytes */
898  pFI_2a ++;
899  pFI_1a = (PFORM_INFO_1A)pFI_2a;
900  }
901  }
902  }
903 
904  SetLastError(0xdeadbeef);
905  res = EnumFormsA(hprinter, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
906  ok( res, "(%d) returned %d with %d (expected '!=0')\n",
907  level, res, GetLastError());
908 
909  SetLastError(0xdeadbeef);
910  res = EnumFormsA(hprinter, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
912  "(%d) returned %d with %d (expected '0' with "
913  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
914 
915 
916  SetLastError(0xdeadbeef);
917  res = EnumFormsA(hprinter, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
919  "(%d) returned %d with %d (expected '0' with "
920  "ERROR_INVALID_USER_BUFFER)\n", level, res, GetLastError());
921 
922 
923  SetLastError(0xdeadbeef);
924  res = EnumFormsA(hprinter, level, buffer, cbBuf, NULL, &pcReturned);
926  "(%d) returned %d with %d (expected '0' with "
927  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
928 
929  SetLastError(0xdeadbeef);
930  res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, NULL);
932  "(%d) returned %d with %d (expected '0' with "
933  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
934 
935  SetLastError(0xdeadbeef);
936  res = EnumFormsA(0, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
938  "(%d) returned %d with %d (expected '0' with "
939  "ERROR_INVALID_HANDLE)\n", level, res, GetLastError());
940 
942  } /* for(level ... */
943 
944  ClosePrinter(hprinter);
945 }
DWORD dwResourceId
Definition: winspool.h:651
GLint level
Definition: gl.h:1546
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD StringType
Definition: winspool.h:649
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
struct _FORM_INFO_2A * PFORM_INFO_2A
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
int winetest_debug
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
unsigned char * LPBYTE
Definition: typedefs.h:53
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
LONG cx
Definition: windef.h:334
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
LANGID wLangId
Definition: winspool.h:653
#define SetLastError(x)
Definition: compat.h:611
struct _FORM_INFO_1A * PFORM_INFO_1A
WINBOOL WINAPI EnumFormsA(HANDLE hPrinter, DWORD Level, LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
LPCSTR pDisplayName
Definition: winspool.h:652
static float(__cdecl *square_half_float)(float x
#define ok(value,...)
Definition: atltest.h:57
DWORD Flags
Definition: winspool.h:626
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LPCSTR pMuiDll
Definition: winspool.h:650
LPSTR pName
Definition: winspool.h:627
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
SIZEL Size
Definition: winspool.h:628
LONG cy
Definition: windef.h:335
LPCSTR pKeyword
Definition: winspool.h:648
#define HeapFree(x, y, z)
Definition: compat.h:594
#define FORMTYPE_MAX
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_EnumMonitors()

static void test_EnumMonitors ( void  )
static

Definition at line 949 of file info.c.

950 {
951  DWORD res;
952  LPBYTE buffer;
953  DWORD cbBuf;
955  DWORD pcReturned;
956  DWORD level;
957 
958  /* valid levels are 1 and 2 */
959  for(level = 0; level < 4; level++) {
960  cbBuf = MAGIC_DEAD;
961  pcReturned = MAGIC_DEAD;
963  res = EnumMonitorsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
964  if (is_spooler_deactivated(res, GetLastError())) return;
965  /* not implemented yet in wine */
966  if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
967 
968 
969  /* use only a short test when testing an invalid level */
970  if(!level || (level > 2)) {
971  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
972  (res && (pcReturned == 0)),
973  "(%d) returned %d with %d and 0x%08x (expected '0' with "
974  "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
975  level, res, GetLastError(), pcReturned);
976  continue;
977  }
978 
979  /* Level 2 is not supported on win9x */
980  if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
981  skip("Level %d not supported\n", level);
982  continue;
983  }
984 
986  "(%d) returned %d with %d (expected '0' with "
987  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
988 
989  if (!cbBuf) {
990  skip("no valid buffer size returned\n");
991  continue;
992  }
993 
994  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
995  if (buffer == NULL) continue;
996 
999  res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
1000  ok(res, "(%d) returned %d with %d (expected '!=0')\n",
1001  level, res, GetLastError());
1002  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n",
1003  level, pcbNeeded, cbBuf);
1004  /* We can validate the returned Data with the Registry here */
1005 
1006 
1008  pcReturned = MAGIC_DEAD;
1010  res = EnumMonitorsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
1011  ok(res, "(%d) returned %d with %d (expected '!=0')\n", level,
1012  res, GetLastError());
1013  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level,
1014  pcbNeeded, cbBuf);
1015 
1018  res = EnumMonitorsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
1020  "(%d) returned %d with %d (expected '0' with "
1021  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
1022 
1023  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level,
1024  pcbNeeded, cbBuf);
1025 
1026 /*
1027  Do not add the next test:
1028  w2k+: RPC_X_NULL_REF_POINTER
1029  NT3.5: ERROR_INVALID_USER_BUFFER
1030  win9x: crash in winspool.drv
1031 
1032  res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
1033 */
1034 
1037  pcReturned = MAGIC_DEAD;
1038  res = EnumMonitorsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
1040  "(%d) returned %d with %d (expected '!=0' or '0' with "
1041  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
1042 
1044  pcReturned = MAGIC_DEAD;
1046  res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
1048  "(%d) returned %d with %d (expected '!=0' or '0' with "
1049  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
1050 
1052  } /* for(level ... */
1053 }
WINBOOL WINAPI EnumMonitorsA(LPSTR pName, DWORD Level, LPBYTE pMonitor, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
GLint level
Definition: gl.h:1546
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define MAGIC_DEAD
Definition: info.c:38
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_EnumPorts()

static void test_EnumPorts ( void  )
static

Definition at line 1057 of file info.c.

1058 {
1059  DWORD res;
1060  DWORD level;
1061  LPBYTE buffer;
1062  DWORD cbBuf;
1063  DWORD pcbNeeded;
1064  DWORD pcReturned;
1065 
1066  /* valid levels are 1 and 2 */
1067  for(level = 0; level < 4; level++) {
1068 
1069  cbBuf = 0xdeadbeef;
1070  pcReturned = 0xdeadbeef;
1071  SetLastError(0xdeadbeef);
1072  res = EnumPortsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
1073  if (is_spooler_deactivated(res, GetLastError())) return;
1074 
1075  /* use only a short test when testing an invalid level */
1076  if(!level || (level > 2)) {
1077  /* NT: ERROR_INVALID_LEVEL, 9x: success */
1078  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
1079  (res && (pcReturned == 0)),
1080  "(%d) returned %d with %d and 0x%08x (expected '0' with "
1081  "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
1082  level, res, GetLastError(), pcReturned);
1083  continue;
1084  }
1085 
1086 
1087  /* Level 2 is not supported on NT 3.x */
1088  if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
1089  skip("Level %d not supported\n", level);
1090  continue;
1091  }
1092 
1094  "(%d) returned %d with %d (expected '0' with "
1095  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
1096 
1097  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
1098  if (buffer == NULL) continue;
1099 
1100  pcbNeeded = 0xdeadbeef;
1101  SetLastError(0xdeadbeef);
1102  res = EnumPortsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
1103  ok(res, "(%d) returned %d with %d (expected '!=0')\n", level, res, GetLastError());
1104  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
1105  /* ToDo: Compare the returned Data with the Registry / "win.ini",[Ports] here */
1106 
1107  pcbNeeded = 0xdeadbeef;
1108  pcReturned = 0xdeadbeef;
1109  SetLastError(0xdeadbeef);
1110  res = EnumPortsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
1111  ok(res, "(%d) returned %d with %d (expected '!=0')\n", level, res, GetLastError());
1112  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
1113 
1114  pcbNeeded = 0xdeadbeef;
1115  SetLastError(0xdeadbeef);
1116  res = EnumPortsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
1118  "(%d) returned %d with %d (expected '0' with "
1119  "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
1120  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
1121 
1122  /*
1123  Do not add this test:
1124  res = EnumPortsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
1125  w2k+: RPC_X_NULL_REF_POINTER
1126  NT3.5: ERROR_INVALID_USER_BUFFER
1127  win9x: crash in winspool.drv
1128  */
1129 
1130  SetLastError(0xdeadbeef);
1131  res = EnumPortsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
1132  /* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
1133  ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER) ) ||
1134  ( res && (GetLastError() == ERROR_SUCCESS) ),
1135  "(%d) returned %d with %d (expected '0' with "
1136  "RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
1137  level, res, GetLastError());
1138 
1139 
1140  SetLastError(0xdeadbeef);
1141  res = EnumPortsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
1142  /* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
1143  ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER) ) ||
1144  ( res && (GetLastError() == ERROR_SUCCESS) ),
1145  "(%d) returned %d with %d (expected '0' with "
1146  "RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
1147  level, res, GetLastError());
1148 
1150  }
1151 }
GLint level
Definition: gl.h:1546
#define ERROR_SUCCESS
Definition: deptool.c:10
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
WINBOOL WINAPI EnumPortsA(LPSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_EnumPrinterDrivers()

static void test_EnumPrinterDrivers ( void  )
static

Definition at line 1155 of file info.c.

1156 {
1157  static char env_all[] = "all";
1158 
1159  DWORD res;
1160  LPBYTE buffer;
1161  DWORD cbBuf;
1162  DWORD pcbNeeded;
1163  DWORD pcReturned;
1164  DWORD level;
1165 
1166  /* 1-3 for w95/w98/NT4; 1-3+6 for me; 1-6 for w2k/xp/2003; 1-6+8 for vista */
1167  for(level = 0; level < 10; level++) {
1168  cbBuf = 0xdeadbeef;
1169  pcReturned = 0xdeadbeef;
1170  SetLastError(0xdeadbeef);
1171  res = EnumPrinterDriversA(NULL, NULL, level, NULL, 0, &cbBuf, &pcReturned);
1172  if (is_spooler_deactivated(res, GetLastError())) return;
1173 
1174  /* use only a short test when testing an invalid level */
1175  if(!level || (level == 7) || (level > 8)) {
1176 
1177  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
1178  (res && (pcReturned == 0)),
1179  "(%d) got %u with %u and 0x%x "
1180  "(expected '0' with ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
1181  level, res, GetLastError(), pcReturned);
1182  continue;
1183  }
1184 
1185  /* some levels are not supported on all windows versions */
1186  if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
1187  skip("Level %d not supported\n", level);
1188  continue;
1189  }
1190 
1191  ok( ((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) ||
1192  (res && (default_printer == NULL)),
1193  "(%u) got %u with %u for %s (expected '0' with "
1194  "ERROR_INSUFFICIENT_BUFFER or '!= 0' without a printer)\n",
1196 
1197  if (!cbBuf) {
1198  skip("no valid buffer size returned\n");
1199  continue;
1200  }
1201 
1202  /* EnumPrinterDriversA returns the same number of bytes as EnumPrinterDriversW */
1203  if (pEnumPrinterDriversW)
1204  {
1205  DWORD double_needed;
1206  DWORD double_returned;
1207  pEnumPrinterDriversW(NULL, NULL, level, NULL, 0, &double_needed, &double_returned);
1208  ok(double_needed == cbBuf, "level %d: EnumPrinterDriversA returned different size %d than EnumPrinterDriversW (%d)\n", level, cbBuf, double_needed);
1209  }
1210 
1211  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf + 4);
1212  if (buffer == NULL) continue;
1213 
1214  SetLastError(0xdeadbeef);
1215  pcbNeeded = 0xdeadbeef;
1216  res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
1217  ok(res, "(%u) got %u with %u (expected '!=0')\n", level, res, GetLastError());
1218  ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
1219 
1220  /* validate the returned data here */
1221  if (level > 1) {
1223 
1224  ok( strrchr(di->pDriverPath, '\\') != NULL,
1225  "(%u) got %s for %s (expected a full path)\n",
1226  level, di->pDriverPath, di->pName);
1227 
1228  }
1229 
1230  SetLastError(0xdeadbeef);
1231  pcReturned = 0xdeadbeef;
1232  pcbNeeded = 0xdeadbeef;
1233  res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
1234  ok(res, "(%u) got %u with %u (expected '!=0')\n", level, res, GetLastError());
1235  ok(pcbNeeded == cbBuf, "(%u) returned %u (expected %u)\n", level, pcbNeeded, cbBuf);
1236 
1237  SetLastError(0xdeadbeef);
1238  pcbNeeded = 0xdeadbeef;
1239  res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
1241  "(%u) got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1242  level, res, GetLastError());
1243  ok(pcbNeeded == cbBuf, "(%u) returned %u (expected %u)\n", level, pcbNeeded, cbBuf);
1244 
1245 /*
1246  Do not add the next test:
1247  NT: ERROR_INVALID_USER_BUFFER
1248  win9x: crash or 100% CPU
1249 
1250  res = EnumPrinterDriversA(NULL, NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
1251 */
1252 
1253  SetLastError(0xdeadbeef);
1254  pcbNeeded = 0xdeadbeef;
1255  pcReturned = 0xdeadbeef;
1256  res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf, NULL, &pcReturned);
1258  "(%u) got %u with %u (expected '!=0' or '0' with "
1259  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
1260 
1261  pcbNeeded = 0xdeadbeef;
1262  pcReturned = 0xdeadbeef;
1263  SetLastError(0xdeadbeef);
1266  "(%u) got %u with %u (expected '!=0' or '0' with "
1267  "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
1268 
1270  } /* for(level ... */
1271 
1272  pcbNeeded = 0;
1273  pcReturned = 0;
1274  SetLastError(0xdeadbeef);
1275  res = EnumPrinterDriversA(NULL, env_all, 1, NULL, 0, &pcbNeeded, &pcReturned);
1276  if (res)
1277  {
1278  skip("no printer drivers found\n");
1279  return;
1280  }
1282  {
1283  win_skip("NT4 and below don't support the 'all' environment value\n");
1284  return;
1285  }
1286  ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "unexpected error %u\n", GetLastError());
1287 
1289  res = EnumPrinterDriversA(NULL, env_all, 1, buffer, pcbNeeded, &pcbNeeded, &pcReturned);
1290  ok(res, "EnumPrinterDriversA failed %u\n", GetLastError());
1291  if (res && pcReturned > 0)
1292  {
1294  ok((LPBYTE) di_1->pName == NULL || (LPBYTE) di_1->pName < buffer ||
1295  (LPBYTE) di_1->pName >= (LPBYTE)(di_1 + pcReturned),
1296  "Driver Information not in sequence; pName %p, top of data %p\n",
1297  di_1->pName, di_1 + pcReturned);
1298  }
1299 
1301 }
GLint level
Definition: gl.h:1546
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
WINBOOL WINAPI EnumPrinterDriversA(LPSTR pName, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
unsigned char * LPBYTE
Definition: typedefs.h:53
LPSTR pDriverPath
Definition: winspool.h:384
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _DRIVER_INFO_2A * LPDRIVER_INFO_2A
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
static LPSTR default_printer
Definition: info.c:86
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define win_skip
Definition: test.h:149
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_EnumPrinters()

static void test_EnumPrinters ( void  )
static

Definition at line 2712 of file info.c.

2713 {
2714  DWORD neededA, neededW, num;
2715  DWORD ret;
2716 
2717  SetLastError(0xdeadbeef);
2718  neededA = -1;
2719  ret = EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &neededA, &num);
2720  if (is_spooler_deactivated(ret, GetLastError())) return;
2721  if (!ret)
2722  {
2723  /* We have 1 or more printers */
2725  ok(neededA > 0, "Expected neededA to show the number of needed bytes\n");
2726  }
2727  else
2728  {
2729  /* We don't have any printers defined */
2730  ok(GetLastError() == S_OK, "gle %d\n", GetLastError());
2731  ok(neededA == 0, "Expected neededA to be zero\n");
2732  }
2733  ok(num == 0, "num %d\n", num);
2734 
2735  SetLastError(0xdeadbeef);
2736  neededW = -1;
2737  ret = EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &neededW, &num);
2738  /* EnumPrintersW is not supported on all platforms */
2740  {
2741  win_skip("EnumPrintersW is not implemented\n");
2742  return;
2743  }
2744 
2745  if (!ret)
2746  {
2747  /* We have 1 or more printers */
2749  ok(neededW > 0, "Expected neededW to show the number of needed bytes\n");
2750  }
2751  else
2752  {
2753  /* We don't have any printers defined */
2754  ok(GetLastError() == S_OK, "gle %d\n", GetLastError());
2755  ok(neededW == 0, "Expected neededW to be zero\n");
2756  }
2757  ok(num == 0, "num %d\n", num);
2758 
2759  /* Outlook2003 relies on the buffer size returned by EnumPrintersA being big enough
2760  to hold the buffer returned by EnumPrintersW */
2761  ok(neededA == neededW, "neededA %d neededW %d\n", neededA, neededW);
2762 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define PRINTER_ENUM_LOCAL
Definition: winspool.h:896
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
#define SetLastError(x)
Definition: compat.h:611
WINBOOL WINAPI EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
int ret
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
WINBOOL WINAPI EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
#define win_skip
Definition: test.h:149
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_EnumPrintProcessors()

static void test_EnumPrintProcessors ( void  )
static

Definition at line 1305 of file info.c.

1306 {
1307  DWORD res;
1308  LPBYTE buffer;
1309  DWORD cbBuf;
1310  DWORD pcbNeeded;
1311  DWORD pcReturned;
1312 
1313 
1314  cbBuf = 0xdeadbeef;
1315  pcReturned = 0xdeadbeef;
1316  SetLastError(0xdeadbeef);
1317  res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, 0, &cbBuf, &pcReturned);
1318  if (is_spooler_deactivated(res, GetLastError())) return;
1319 
1320  if (res && !cbBuf) {
1321  skip("No Printprocessor installed\n");
1322  return;
1323  }
1324 
1326  "got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1327  res, GetLastError());
1328 
1329  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf + 4);
1330  if (buffer == NULL)
1331  return;
1332 
1333  SetLastError(0xdeadbeef);
1334  pcbNeeded = 0xdeadbeef;
1335  res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
1336  ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
1337  /* validate the returned data here. */
1338 
1339 
1340  SetLastError(0xdeadbeef);
1341  pcReturned = 0xdeadbeef;
1342  pcbNeeded = 0xdeadbeef;
1343  res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
1344  ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
1345 
1346  SetLastError(0xdeadbeef);
1347  pcbNeeded = 0xdeadbeef;
1348  res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
1350  "got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1351  res, GetLastError());
1352 
1353  /* only level 1 is valid */
1354  if (0) {
1355  /* both tests crash on win98se */
1356  SetLastError(0xdeadbeef);
1357  pcbNeeded = 0xdeadbeef;
1358  pcReturned = 0xdeadbeef;
1359  res = EnumPrintProcessorsA(NULL, NULL, 0, buffer, cbBuf, &pcbNeeded, &pcReturned);
1360  ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
1361  "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
1362  res, GetLastError());
1363 
1364  SetLastError(0xdeadbeef);
1365  pcbNeeded = 0xdeadbeef;
1366  res = EnumPrintProcessorsA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded, &pcReturned);
1367  ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
1368  "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
1369  res, GetLastError());
1370  }
1371 
1372  /* an empty environment is ignored */
1373  SetLastError(0xdeadbeef);
1374  pcbNeeded = 0xdeadbeef;
1375  res = EnumPrintProcessorsA(NULL, empty, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
1376  ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
1377 
1378  /* the environment is checked */
1379  SetLastError(0xdeadbeef);
1380  pcbNeeded = 0xdeadbeef;
1381  res = EnumPrintProcessorsA(NULL, invalid_env, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
1382  /* NT5: ERROR_INVALID_ENVIRONMENT, NT4: res != 0, 9x: ERROR_INVALID_PARAMETER */
1383  ok( broken(res) || /* NT4 */
1386  "got %u with %u (expected '0' with ERROR_INVALID_ENVIRONMENT or "
1387  "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
1388 
1389 
1390  /* failure-Codes for NULL */
1391  SetLastError(0xdeadbeef);
1392  pcbNeeded = 0xdeadbeef;
1393  pcReturned = 0xdeadbeef;
1394  res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, cbBuf, &pcbNeeded, &pcReturned);
1395  todo_wine {
1397  "got %u with %u (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
1398  res, GetLastError());
1399  }
1400 
1401  SetLastError(0xdeadbeef);
1402  pcbNeeded = 0xdeadbeef;
1403  pcReturned = 0xdeadbeef;
1404  res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, NULL, &pcReturned);
1405  /* the NULL is ignored on win9x */
1406  ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
1407  "got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
1408  res, GetLastError());
1409 
1410  pcbNeeded = 0xdeadbeef;
1411  pcReturned = 0xdeadbeef;
1412  SetLastError(0xdeadbeef);
1414  /* the NULL is ignored on win9x */
1415  ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
1416  "got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
1417  res, GetLastError());
1418 
1420 
1421 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
GLuint buffer
Definition: glext.h:5915
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
unsigned char * LPBYTE
Definition: typedefs.h:53
WINBOOL WINAPI EnumPrintProcessorsA(LPSTR pName, LPSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define todo_wine
Definition: test.h:162
#define broken(x)
Definition: _sntprintf.h:21
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static CHAR invalid_env[]
Definition: info.c:49
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_GetDefaultPrinter()

static void test_GetDefaultPrinter ( void  )
static

Definition at line 1425 of file info.c.

1426 {
1427  BOOL retval;
1428  DWORD exact = DEFAULT_PRINTER_SIZE;
1429  DWORD size;
1431 
1432  if (!pGetDefaultPrinterA) return;
1433  /* only supported on NT like OSes starting with win2k */
1434 
1436  retval = pGetDefaultPrinterA(buffer, &exact);
1437  if (!retval || !exact || !*buffer ||
1438  (ERROR_SUCCESS != GetLastError())) {
1439  if ((ERROR_FILE_NOT_FOUND == GetLastError()) ||
1441  trace("this test requires a default printer to be set\n");
1442  else {
1443  ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
1444  "function returned %s\n"
1445  "last error 0x%08x\n"
1446  "returned buffer size 0x%08x\n"
1447  "returned buffer content %s\n",
1448  retval ? "true" : "false", GetLastError(), exact, buffer);
1449  }
1450  return;
1451  }
1453  retval = pGetDefaultPrinterA(NULL, NULL);
1454  ok( !retval, "function result wrong! False expected\n");
1456  "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
1457  GetLastError());
1458 
1460  retval = pGetDefaultPrinterA(buffer, NULL);
1461  ok( !retval, "function result wrong! False expected\n");
1463  "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
1464  GetLastError());
1465 
1467  size = 0;
1468  retval = pGetDefaultPrinterA(NULL, &size);
1469  ok( !retval, "function result wrong! False expected\n");
1471  "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1472  GetLastError());
1473  ok( size == exact, "Parameter size wrong! %d expected got %d\n",
1474  exact, size);
1475 
1478  retval = pGetDefaultPrinterA(NULL, &size);
1479  ok( !retval, "function result wrong! False expected\n");
1481  "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1482  GetLastError());
1483  ok( size == exact, "Parameter size wrong! %d expected got %d\n",
1484  exact, size);
1485 
1486  size = 0;
1487  retval = pGetDefaultPrinterA(buffer, &size);
1488  ok( !retval, "function result wrong! False expected\n");
1490  "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1491  GetLastError());
1492  ok( size == exact, "Parameter size wrong! %d expected got %d\n",
1493  exact, size);
1494 
1495  size = exact;
1496  retval = pGetDefaultPrinterA(buffer, &size);
1497  ok( retval, "function result wrong! True expected\n");
1498  ok( size == exact, "Parameter size wrong! %d expected got %d\n",
1499  exact, size);
1500 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
#define DEFAULT_PRINTER_SIZE
Definition: info.c:39
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_GetPrinter()

static void test_GetPrinter ( void  )
static

Definition at line 2292 of file info.c.

2293 {
2294  HANDLE hprn;
2295  BOOL ret;
2296  BYTE *buf;
2297  INT level;
2298  DWORD needed, filled;
2299 
2300  if (!default_printer)
2301  {
2302  skip("There is no default printer installed\n");
2303  return;
2304  }
2305 
2306  hprn = 0;
2307  ret = OpenPrinterA(default_printer, &hprn, NULL);
2308  if (!ret)
2309  {
2310  skip("Unable to open the default printer (%s)\n", default_printer);
2311  return;
2312  }
2313  ok(hprn != 0, "wrong hprn %p\n", hprn);
2314 
2315  for (level = 1; level <= 9; level++)
2316  {
2317  SetLastError(0xdeadbeef);
2318  needed = (DWORD)-1;
2319  ret = GetPrinterA(hprn, level, NULL, 0, &needed);
2320  if (ret)
2321  {
2322  win_skip("Level %d is not supported on Win9x/WinMe\n", level);
2323  ok(GetLastError() == ERROR_SUCCESS, "wrong error %d\n", GetLastError());
2324  ok(needed == 0,"Expected 0, got %d\n", needed);
2325  continue;
2326  }
2327  ok(!ret, "level %d: GetPrinter should fail\n", level);
2328  /* Not all levels are supported on all Windows-Versions */
2329  if (GetLastError() == ERROR_INVALID_LEVEL ||
2330  GetLastError() == ERROR_NOT_SUPPORTED /* Win9x/WinMe */)
2331  {
2332  skip("Level %d not supported\n", level);
2333  continue;
2334  }
2335  ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %d\n", GetLastError());
2336  ok(needed > 0,"not expected needed buffer size %d\n", needed);
2337 
2338  /* GetPrinterA returns the same number of bytes as GetPrinterW */
2339  if (!ret && pGetPrinterW && level != 6 && level != 7)
2340  {
2341  DWORD double_needed;
2342  ret = pGetPrinterW(hprn, level, NULL, 0, &double_needed);
2343  ok(!ret, "level %d: GetPrinter error %d\n", level, GetLastError());
2344  ok(double_needed == needed, "level %d: GetPrinterA returned different size %d than GetPrinterW (%d)\n", level, needed, double_needed);
2345  }
2346 
2347  buf = HeapAlloc(GetProcessHeap(), 0, needed);
2348 
2349  SetLastError(0xdeadbeef);
2350  filled = -1;
2351  ret = GetPrinterA(hprn, level, buf, needed, &filled);
2352  ok(ret, "level %d: GetPrinter error %d\n", level, GetLastError());
2353  ok(needed == filled, "needed %d != filled %d\n", needed, filled);
2354 
2355  if (level == 2)
2356  {
2357  PRINTER_INFO_2A *pi_2 = (PRINTER_INFO_2A *)buf;
2358 
2359  ok(pi_2->pPrinterName!= NULL, "not expected NULL ptr\n");
2360  ok(pi_2->pDriverName!= NULL, "not expected NULL ptr\n");
2361 
2362  trace("pPrinterName %s\n", pi_2->pPrinterName);
2363  trace("pDriverName %s\n", pi_2->pDriverName);
2364  }
2365 
2366  HeapFree(GetProcessHeap(), 0, buf);
2367  }
2368 
2369  SetLastError(0xdeadbeef);
2370  ret = ClosePrinter(hprn);
2371  ok(ret, "ClosePrinter error %d\n", GetLastError());
2372 }
static DWORD
Definition: info.c:70
GLint level
Definition: gl.h:1546
#define ERROR_SUCCESS
Definition: deptool.c:10
WINBOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:2033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int32_t INT
Definition: typedefs.h:58
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int BOOL
Definition: ntddk_ex.h:94
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
LPSTR pDriverName
Definition: winspool.h:42
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
LPSTR pPrinterName
Definition: winspool.h:39
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
int ret
unsigned char BYTE
Definition: xxhash.c:193
static LPSTR default_printer
Definition: info.c:86
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define win_skip
Definition: test.h:149
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_GetPrinterData()

static void test_GetPrinterData ( void  )
static

Definition at line 2376 of file info.c.

2377 {
2378  HANDLE hprn = 0;
2379  DWORD res;
2380  DWORD type;
2381  CHAR buffer[MAX_PATH + 1];
2382  DWORD needed;
2383  DWORD len;
2384 
2385  /* ToDo: test parameter validation, test with the default printer */
2386 
2387  SetLastError(0xdeadbeef);
2388  res = OpenPrinterA(NULL, &hprn, NULL);
2389  if (!res)
2390  {
2391  return;
2392  }
2393 
2394  memset(buffer, '#', sizeof(buffer));
2395  buffer[MAX_PATH] = 0;
2396  type = 0xdeadbeef;
2397  needed = 0xdeadbeef;
2398  SetLastError(0xdeadbeef);
2399  res = GetPrinterDataA(hprn, defaultspooldirectory, &type, (LPBYTE) buffer, sizeof(buffer), &needed);
2400 
2401  len = lstrlenA(buffer) + sizeof(CHAR);
2402  /* NT4 and w2k require a buffer to save the UNICODE result also for the ANSI function */
2403  ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2404  "got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
2405  res, type, needed, buffer, len);
2406 
2407  needed = 0xdeadbeef;
2408  SetLastError(0xdeadbeef);
2409  res = GetPrinterDataA(hprn, defaultspooldirectory, NULL, NULL, 0, &needed);
2410  ok( (res == ERROR_MORE_DATA) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2411  "got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
2412 
2413  /* ToDo: test SPLREG_* */
2414 
2415  SetLastError(0xdeadbeef);
2416  res = ClosePrinter(hprn);
2417  ok(res, "ClosePrinter error %d\n", GetLastError());
2418 }
DWORD WINAPI GetPrinterDataA(HANDLE hPrinter, LPSTR pValueName, LPDWORD pType, LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
Definition: printerdata.c:326
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
static CHAR defaultspooldirectory[]
Definition: info.c:41
unsigned char * LPBYTE
Definition: typedefs.h:53
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
GLenum GLsizei len
Definition: glext.h:6722
#define ERROR_MORE_DATA
Definition: dderror.h:13
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39
#define CHAR(Char)
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_GetPrinterDataEx()

static void test_GetPrinterDataEx ( void  )
static

Definition at line 2422 of file info.c.

2423 {
2424  HANDLE hprn = 0;
2425  DWORD res;
2426  DWORD type;
2427  CHAR buffer[MAX_PATH + 1];
2428  DWORD needed;
2429  DWORD len;
2430 
2431  /* not present before w2k */
2432  if (!pGetPrinterDataExA) {
2433  win_skip("GetPrinterDataEx not found\n");
2434  return;
2435  }
2436 
2437  /* ToDo: test parameter validation, test with the default printer */
2438 
2439  SetLastError(0xdeadbeef);
2440  res = OpenPrinterA(NULL, &hprn, NULL);
2441  if (!res)
2442  {
2443  win_skip("Unable to open the printserver: %d\n", GetLastError());
2444  return;
2445  }
2446 
2447  /* keyname is ignored, when hprn is a HANDLE for a printserver */
2448  memset(buffer, '#', sizeof(buffer));
2449  buffer[MAX_PATH] = 0;
2450  type = 0xdeadbeef;
2451  needed = 0xdeadbeef;
2452  SetLastError(0xdeadbeef);
2453  res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, &type,
2454  (LPBYTE) buffer, sizeof(buffer), &needed);
2455 
2456  len = lstrlenA(buffer) + sizeof(CHAR);
2457  /* NT4 and w2k require a buffer to save the UNICODE result also for the ANSI function */
2458  ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2459  "got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
2460  res, type, needed, buffer, len);
2461 
2462  memset(buffer, '#', sizeof(buffer));
2463  buffer[MAX_PATH] = 0;
2464  type = 0xdeadbeef;
2465  needed = 0xdeadbeef;
2466  SetLastError(0xdeadbeef);
2467  res = pGetPrinterDataExA(hprn, "", defaultspooldirectory, &type,
2468  (LPBYTE) buffer, sizeof(buffer), &needed);
2469  len = lstrlenA(buffer) + sizeof(CHAR);
2470  ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2471  "got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
2472  res, type, needed, buffer, len);
2473 
2474  memset(buffer, '#', sizeof(buffer));
2475  buffer[MAX_PATH] = 0;
2476  type = 0xdeadbeef;
2477  needed = 0xdeadbeef;
2478  SetLastError(0xdeadbeef);
2479  /* Wine uses GetPrinterDataEx with "PrinterDriverData" to implement GetPrinterData */
2480  res = pGetPrinterDataExA(hprn, "PrinterDriverData", defaultspooldirectory,
2481  &type, (LPBYTE) buffer, sizeof(buffer), &needed);
2482  len = lstrlenA(buffer) + sizeof(CHAR);
2483  ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2484  "got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
2485  res, type, needed, buffer, len);
2486 
2487 
2488  memset(buffer, '#', sizeof(buffer));
2489  buffer[MAX_PATH] = 0;
2490  type = 0xdeadbeef;
2491  needed = 0xdeadbeef;
2492  SetLastError(0xdeadbeef);
2493  res = pGetPrinterDataExA(hprn, does_not_exist, defaultspooldirectory, &type,
2494  (LPBYTE) buffer, sizeof(buffer), &needed);
2495  len = lstrlenA(buffer) + sizeof(CHAR);
2496  ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2497  "got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
2498  res, type, needed, buffer, len);
2499 
2500  needed = 0xdeadbeef;
2501  SetLastError(0xdeadbeef);
2502  /* vista and w2k8 have a bug in GetPrinterDataEx:
2503  the current LastError value is returned as result */
2504  res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, NULL, NULL, 0, &needed);
2505  ok( ((res == ERROR_MORE_DATA) || broken(res == 0xdeadbeef)) &&
2506  ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2507  "got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
2508 
2509  needed = 0xdeadbeef;
2510  SetLastError(0xdeaddead);
2511  res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, NULL, NULL, 0, &needed);
2512  ok( ((res == ERROR_MORE_DATA) || broken(res == 0xdeaddead)) &&
2513  ((needed == len) || (needed == (len * sizeof(WCHAR)))),
2514  "got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
2515 
2516  SetLastError(0xdeadbeef);
2517  res = ClosePrinter(hprn);
2518  ok(res, "ClosePrinter error %d\n", GetLastError());
2519 }
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
static CHAR does_not_exist[]
Definition: info.c:43
static CHAR defaultspooldirectory[]
Definition: info.c:41
unsigned char * LPBYTE
Definition: typedefs.h:53
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
GLenum GLsizei len
Definition: glext.h:6722
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39
#define CHAR(Char)
#define win_skip
Definition: test.h:149
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_GetPrinterDriver()

static void test_GetPrinterDriver ( void  )
static

Definition at line 2523 of file info.c.

2524 {
2525  HANDLE hprn;
2526  BOOL ret;
2527  BYTE *buf;
2528  INT level;
2529  DWORD needed, filled;
2530 
2531  if (!default_printer)
2532  {
2533  skip("There is no default printer installed\n");
2534  return;
2535  }
2536 
2537  hprn = 0;
2538  ret = OpenPrinterA(default_printer, &hprn, NULL);
2539  if (!ret)
2540  {
2541  skip("Unable to open the default printer (%s)\n", default_printer);
2542  return;
2543  }
2544  ok(hprn != 0, "wrong hprn %p\n", hprn);
2545 
2546  for (level = -1; level <= 7; level++)
2547  {
2548  SetLastError(0xdeadbeef);
2549  needed = (DWORD)-1;
2550  ret = GetPrinterDriverA(hprn, NULL, level, NULL, 0, &needed);
2551  ok(!ret, "level %d: GetPrinterDriver should fail\n", level);
2552  if (level >= 1 && level <= 6)
2553  {
2554  /* Not all levels are supported on all Windows-Versions */
2555  if(GetLastError() == ERROR_INVALID_LEVEL) continue;
2556  ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %d\n", GetLastError());
2557  ok(needed > 0,"not expected needed buffer size %d\n", needed);
2558  }
2559  else
2560  {
2561  /* ERROR_OUTOFMEMORY found on win9x */
2562  ok( ((GetLastError() == ERROR_INVALID_LEVEL) ||
2564  "%d: returned %d with %d (expected '0' with: "
2565  "ERROR_INVALID_LEVEL or ERROR_OUTOFMEMORY)\n",
2566  level, ret, GetLastError());
2567  /* needed is modified in win9x. The modified Value depends on the
2568  default Printer. testing for "needed == (DWORD)-1" will fail */
2569  continue;
2570  }
2571 
2572  /* GetPrinterDriverA returns the same number of bytes as GetPrinterDriverW */
2573  if (!ret && pGetPrinterDriverW)
2574  {
2575  DWORD double_needed;
2576  ret = pGetPrinterDriverW(hprn, NULL, level, NULL, 0, &double_needed);
2577  ok(!ret, "level %d: GetPrinterDriver error %d\n", level, GetLastError());
2578  ok(double_needed == needed, "GetPrinterDriverA returned different size %d than GetPrinterDriverW (%d)\n", needed, double_needed);
2579  }
2580 
2581  buf = HeapAlloc(GetProcessHeap(), 0, needed);
2582 
2583  SetLastError(0xdeadbeef);
2584  filled = -1;
2585  ret = GetPrinterDriverA(hprn, NULL, level, buf, needed, &filled);
2586  ok(ret, "level %d: GetPrinterDriver error %d\n", level, GetLastError());
2587  ok(needed == filled, "needed %d != filled %d\n", needed, filled);
2588 
2589  if (level == 2)
2590  {
2591  DRIVER_INFO_2A *di_2 = (DRIVER_INFO_2A *)buf;
2592  DWORD calculated = sizeof(*di_2);
2593  HANDLE hf;
2594 
2595  /* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
2596  NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k-win7(Usermode): 3, win8 and above(Usermode): 4 */
2597  ok( (di_2->cVersion <= 4) ||
2598  (di_2->cVersion == 0x0400), "di_2->cVersion = %d\n", di_2->cVersion);
2599  ok(di_2->pName != NULL, "not expected NULL ptr\n");
2600  ok(di_2->pEnvironment != NULL, "not expected NULL ptr\n");
2601  ok(di_2->pDriverPath != NULL, "not expected NULL ptr\n");
2602  ok(di_2->pDataFile != NULL, "not expected NULL ptr\n");
2603  ok(di_2->pConfigFile != NULL, "not expected NULL ptr\n");
2604 
2605  trace("cVersion %d\n", di_2->cVersion);
2606  trace("pName %s\n", di_2->pName);
2607  calculated += strlen(di_2->pName) + 1;
2608  trace("pEnvironment %s\n", di_2->pEnvironment);
2609  calculated += strlen(di_2->pEnvironment) + 1;
2610  trace("pDriverPath %s\n", di_2->pDriverPath);
2611  calculated += strlen(di_2->pDriverPath) + 1;
2612  trace("pDataFile %s\n", di_2->pDataFile);
2613  calculated += strlen(di_2->pDataFile) + 1;
2614  trace("pConfigFile %s\n", di_2->pConfigFile);
2615  calculated += strlen(di_2->pConfigFile) + 1;
2616 
2618  if(hf != INVALID_HANDLE_VALUE)
2619  CloseHandle(hf);
2620  todo_wine
2621  ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pDriverPath);
2622 
2624  if(hf != INVALID_HANDLE_VALUE)
2625  CloseHandle(hf);
2626  ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pDataFile);
2627 
2629  if(hf != INVALID_HANDLE_VALUE)
2630  CloseHandle(hf);
2631  todo_wine
2632  ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pConfigFile);
2633 
2634  /* XP allocates memory for both ANSI and unicode names */
2635  ok(filled >= calculated,"calculated %d != filled %d\n", calculated, filled);
2636 
2637  /* Obscure test - demonstrate that Windows zero fills the buffer, even on failure */
2638  ret = GetPrinterDriverA(hprn, NULL, level, buf, needed - 2, &filled);
2639  ok(!ret, "level %d: GetPrinterDriver succeeded with less buffer than it should\n", level);
2640  ok(di_2->pDataFile == NULL ||
2641  broken(di_2->pDataFile != NULL), /* Win9x/WinMe */
2642  "Even on failure, GetPrinterDriver clears the buffer to zeros\n");
2643  }
2644 
2645  HeapFree(GetProcessHeap(), 0, buf);
2646  }
2647 
2648  SetLastError(0xdeadbeef);
2649  ret = ClosePrinter(hprn);
2650  ok(ret, "ClosePrinter error %d\n", GetLastError());
2651 }
static DWORD
Definition: info.c:70
WINBOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
GLint level
Definition: gl.h:1546
#define CloseHandle
Definition: compat.h:598
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
int32_t INT
Definition: typedefs.h:58
#define FILE_SHARE_READ
Definition: compat.h:136
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int BOOL
Definition: ntddk_ex.h:94
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
LPSTR pConfigFile
Definition: winspool.h:386
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:2553
#define OPEN_EXISTING
Definition: compat.h:634
LPSTR pEnvironment
Definition: winspool.h:383
DWORD cVersion
Definition: winspool.h:381
LPSTR pDriverPath
Definition: winspool.h:384
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define todo_wine
Definition: test.h:162
#define GENERIC_READ
Definition: compat.h:135
unsigned char BYTE
Definition: xxhash.c:193
#define broken(x)
Definition: _sntprintf.h:21
static LPSTR default_printer
Definition: info.c:86
#define ok(value,...)
Definition: atltest.h:57
LPSTR pDataFile
Definition: winspool.h:385
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_GetPrinterDriverDirectory()

static void test_GetPrinterDriverDirectory ( void  )
static

Definition at line 1502 of file info.c.

1503 {
1504  LPBYTE buffer = NULL;
1505  DWORD cbBuf = 0, pcbNeeded = 0;
1506  BOOL res;
1507 
1508 
1510  res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, 0, &cbBuf);
1511  if (is_spooler_deactivated(res, GetLastError())) return;
1512 
1513  trace("first call returned 0x%04x, with %d: buffer size 0x%08x\n",
1514  res, GetLastError(), cbBuf);
1515 
1516  ok((res == 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
1517  "returned %d with lasterror=%d (expected '0' with "
1518  "ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError());
1519 
1520  if (!cbBuf) {
1521  skip("no valid buffer size returned\n");
1522  return;
1523  }
1524 
1525  buffer = HeapAlloc( GetProcessHeap(), 0, cbBuf*2);
1526  if (buffer == NULL) return ;
1527 
1529  ok( res, "expected result != 0, got %d\n", res);
1530  ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
1531  pcbNeeded, cbBuf);
1532 
1534  ok( res, "expected result != 0, got %d\n", res);
1535  ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
1536  pcbNeeded, cbBuf);
1537 
1540  ok( !res , "expected result == 0, got %d\n", res);
1541  ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
1542  pcbNeeded, cbBuf);
1543 
1545  "last error set to %d instead of ERROR_INSUFFICIENT_BUFFER\n",
1546  GetLastError());
1547 
1548 /*
1549  Do not add the next test:
1550  XPsp2: crash in this app, when the spooler is not running
1551  NT3.5: ERROR_INVALID_USER_BUFFER
1552  win9x: ERROR_INVALID_PARAMETER
1553 
1554  pcbNeeded = MAGIC_DEAD;
1555  SetLastError(MAGIC_DEAD);
1556  res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
1557 */
1558 
1561  /* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
1562  NT: RPC_X_NULL_REF_POINTER */
1565  "returned %d with %d (expected '!=0' or '0' with RPC_X_NULL_REF_POINTER "
1566  "or '0' with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
1567 
1569  res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
1570  /* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
1571  NT: RPC_X_NULL_REF_POINTER */
1574  "returned %d with %d (expected '!=0' or '0' with RPC_X_NULL_REF_POINTER "
1575  "or '0' with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
1576 
1577  /* with a valid buffer, but level is too large */
1578  buffer[0] = '\0';
1581 
1582  /* Level not checked in win9x and wine:*/
1583  if((res != FALSE) && buffer[0])
1584  {
1585  trace("Level '2' not checked '%s'\n", buffer);
1586  }
1587  else
1588  {
1589  ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
1590  "returned %d with lasterror=%d (expected '0' with "
1591  "ERROR_INVALID_LEVEL)\n", res, GetLastError());
1592  }
1593 
1594  /* printing environments are case insensitive */
1595  /* "Windows 4.0" is valid for win9x and NT */
1596  buffer[0] = '\0';
1599  buffer, cbBuf*2, &pcbNeeded);
1600 
1601  if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
1602  cbBuf = pcbNeeded;
1603  buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
1604  if (buffer == NULL) return ;
1605 
1608  buffer, cbBuf*2, &pcbNeeded);
1609  }
1610 
1611  ok(res && buffer[0], "returned %d with "
1612  "lasterror=%d and len=%d (expected '1' with 'len > 0')\n",
1613  res, GetLastError(), lstrlenA((char *)buffer));
1614 
1615  buffer[0] = '\0';
1618  buffer, cbBuf*2, &pcbNeeded);
1619 
1620  if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
1621  cbBuf = pcbNeeded;
1622  buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
1623  if (buffer == NULL) return ;
1624 
1625  buffer[0] = '\0';
1628  buffer, cbBuf*2, &pcbNeeded);
1629  }
1630 
1631  /* "Windows NT x86" is invalid for win9x */
1632  ok( (res && buffer[0]) ||
1634  "returned %d with lasterror=%d and len=%d (expected '!= 0' with "
1635  "'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
1636  res, GetLastError(), lstrlenA((char *)buffer));
1637 
1638  /* A setup program (PDFCreator_0.8.0) use empty strings */
1641  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
1642 
1645  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
1646 
1649  ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
1650 
1651  HeapFree( GetProcessHeap(), 0, buffer);
1652 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
return
Definition: dirsup.c:529
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
static CHAR env_win9x_case[]
Definition: info.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
GLuint buffer
Definition: glext.h:5915
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static CHAR env_x86[]
Definition: info.c:46
#define GetProcessHeap()
Definition: compat.h:595
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
WINBOOL WINAPI GetPrinterDriverDirectoryA(LPSTR pName, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverDirectory, DWORD cbBuf, LPDWORD pcbNeeded)
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define HeapReAlloc
Definition: compat.h:593
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
#define MAGIC_DEAD
Definition: info.c:38
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_GetPrintProcessorDirectory()

static void test_GetPrintProcessorDirectory ( void  )
static

Definition at line 1656 of file info.c.

1657 {
1658  LPBYTE buffer = NULL;
1659  DWORD cbBuf = 0;
1660  DWORD pcbNeeded = 0;
1661  BOOL res;
1662 
1663 
1664  SetLastError(0xdeadbeef);
1665  res = GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, 0, &cbBuf);
1666  if (is_spooler_deactivated(res, GetLastError())) return;
1667 
1669  "returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1670  res, GetLastError());
1671 
1672  buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf*2);
1673  if(buffer == NULL) return;
1674 
1675  buffer[0] = '\0';
1676  SetLastError(0xdeadbeef);
1678  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
1679 
1680  SetLastError(0xdeadbeef);
1681  buffer[0] = '\0';
1683  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
1684 
1685  /* Buffer too small */
1686  buffer[0] = '\0';
1687  SetLastError(0xdeadbeef);
1690  "returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1691  res, GetLastError());
1692 
1693  if (0)
1694  {
1695  /* XPsp2: the program will crash here, when the spooler is not running */
1696  /* GetPrinterDriverDirectory has the same bug */
1697  pcbNeeded = 0;
1698  SetLastError(0xdeadbeef);
1700  /* NT: ERROR_INVALID_USER_BUFFER, 9x: res != 0 */
1701  ok( (!res && (GetLastError() == ERROR_INVALID_USER_BUFFER)) ||
1702  broken(res),
1703  "returned %d with %d (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
1704  res, GetLastError());
1705  }
1706 
1707  buffer[0] = '\0';
1708  SetLastError(0xdeadbeef);
1710  /* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
1711  NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
1712  ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
1714  "returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER "
1715  "or with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
1716 
1717  buffer[0] = '\0';
1718  SetLastError(0xdeadbeef);
1719  res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
1720  /* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
1721  NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
1722  ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
1724  "returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER "
1725  "or with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
1726 
1727  /* with a valid buffer, but level is invalid */
1728  buffer[0] = '\0';
1729  SetLastError(0xdeadbeef);
1731  /* Level is ignored in win9x*/
1732  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
1733  broken(res && buffer[0]),
1734  "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
1735  res, GetLastError());
1736 
1737  buffer[0] = '\0';
1738  SetLastError(0xdeadbeef);
1740  /* Level is ignored on win9x*/
1741  ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
1742  broken(res && buffer[0]),
1743  "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
1744  res, GetLastError());
1745 
1746  /* Empty environment is the same as the default environment */
1747  buffer[0] = '\0';
1748  SetLastError(0xdeadbeef);
1750  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
1751 
1752  /* "Windows 4.0" is valid for win9x and NT */
1753  buffer[0] = '\0';
1754  SetLastError(0xdeadbeef);
1756  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
1757 
1758 
1759  /* "Windows NT x86" is invalid for win9x */
1760  buffer[0] = '\0';
1761  SetLastError(0xdeadbeef);
1764  "returned %d with %d (expected '!= 0' or '0' with "
1765  "ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
1766 
1767  /* invalid on all systems */
1768  buffer[0] = '\0';
1769  SetLastError(0xdeadbeef);
1772  "returned %d with %d (expected '0' with ERROR_INVALID_ENVIRONMENT)\n",
1773  res, GetLastError());
1774 
1775  /* Empty servername is the same as the local computer */
1776  buffer[0] = '\0';
1777  SetLastError(0xdeadbeef);
1779  ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
1780 
1781  /* invalid on all systems */
1782  buffer[0] = '\0';
1783  SetLastError(0xdeadbeef);
1785  ok( !res, "expected failure\n");
1786  ok( GetLastError() == RPC_S_SERVER_UNAVAILABLE || /* NT */
1787  GetLastError() == ERROR_INVALID_PARAMETER || /* 9x */
1788  GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista */
1789  "unexpected last error %d\n", GetLastError());
1790 
1792 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
WINBOOL WINAPI GetPrintProcessorDirectoryA(LPSTR pName, LPSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded)
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1087
#define RPC_S_INVALID_NET_ADDR
Definition: winerror.h:1018
static CHAR env_win9x_case[]
Definition: info.c:47
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
static CHAR empty[]
Definition: info.c:44
GLuint buffer
Definition: glext.h:5915
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
static CHAR env_x86[]
Definition: info.c:46
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define broken(x)
Definition: _sntprintf.h:21
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
Definition: info.c:93
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static CHAR invalid_env[]
Definition: info.c:49
static CHAR server_does_not_exist[]
Definition: info.c:54
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INVALID_ENVIRONMENT
Definition: winerror.h:1112
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_IsValidDevmodeW()

static void test_IsValidDevmodeW ( void  )
static

Definition at line 3002 of file info.c.

3003 {
3004  static const struct
3005  {
3006  DWORD dmFields;
3007  WORD dmSize;
3008  BOOL ret;
3009  } test[] =
3010  {
3011  { 0, FIELD_OFFSET(DEVMODEW, dmFields) + 0, FALSE },
3012  { 0, FIELD_OFFSET(DEVMODEW, dmFields) + 1, FALSE },
3013  { 0, FIELD_OFFSET(DEVMODEW, dmFields) + 2, FALSE },
3014  { 0, FIELD_OFFSET(DEVMODEW, dmFields) + 3, FALSE },
3015  { 0, FIELD_OFFSET(DEVMODEW, dmFields) + 4, TRUE },
3016 
3020 
3021  { DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 0, FALSE },
3022  { DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 1, FALSE },
3023  { DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 2, FALSE },
3024  { DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 3, FALSE },
3025  { DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 4, TRUE },
3026 
3027  };
3028  DEVMODEW dm;
3029  int i;
3030  BOOL ret;
3031 
3032  ret = IsValidDevmodeW(NULL, 0);
3033  ok(!ret, "got %d\n", ret</