ReactOS 0.4.15-dev-5666-gc548b97
localmon.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winreg.h"
#include "winspool.h"
#include "ddk/winsplp.h"
#include "wine/test.h"
Include dependency graph for localmon.c:

Go to the source code of this file.

Macros

#define PORTNAME_PREFIX   3
 
#define PORTNAME_MINSIZE   5
 
#define PORTNAME_MAXSIZE   10
 
#define GET_MONITOR_FUNC(name)
 
#define GET_MONITOR_FUNC2(name)
 

Functions

static LPMONITOREX (WINAPI *pInitializePrintMonitor)(LPWSTR)
 
static LPMONITOR2 (WINAPI *pInitializePrintMonitor2)(PMONITORINIT
 
static BOOL (WINAPI *pEnumPorts)(LPWSTR
 
static DWORD (WINAPI *pXcvDataPort)(HANDLE
 
static LONG WINAPI CreateKey (HANDLE hcKey, LPCWSTR pszSubKey, DWORD dwOptions, REGSAM samDesired, PSECURITY_ATTRIBUTES pSecurityAttributes, PHANDLE phckResult, PDWORD pdwDisposition, HANDLE hSpooler)
 
static LONG WINAPI OpenKey (HANDLE hcKey, LPCWSTR pszSubKey, REGSAM samDesired, PHANDLE phkResult, HANDLE hSpooler)
 
static LONG WINAPI CloseKey (HANDLE hcKey, HANDLE hSpooler)
 
static LONG WINAPI DeleteKey (HANDLE hcKey, LPCWSTR pszSubKey, HANDLE hSpooler)
 
static LONG WINAPI EnumKey (HANDLE hcKey, DWORD dwIndex, LPWSTR pszName, PDWORD pcchName, PFILETIME pftLastWriteTime, HANDLE hSpooler)
 
static LONG WINAPI QueryInfoKey (HANDLE hcKey, PDWORD pcSubKeys, PDWORD pcbKey, PDWORD pcValues, PDWORD pcbValue, PDWORD pcbData, PDWORD pcbSecurityDescriptor, PFILETIME pftLastWriteTime, HANDLE hSpooler)
 
static LONG WINAPI SetValue (HANDLE hcKey, LPCWSTR pszValue, DWORD dwType, const BYTE *pData, DWORD cbData, HANDLE hSpooler)
 
static LONG WINAPI DeleteValue (HANDLE hcKey, LPCWSTR pszValue, HANDLE hSpooler)
 
static LONG WINAPI EnumValue (HANDLE hcKey, DWORD dwIndex, LPWSTR pszValue, PDWORD pcbValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
 
static LONG WINAPI QueryValue (HANDLE hcKey, LPCWSTR pszValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
 
static DWORD delete_port (LPWSTR portname)
 
static void find_installed_ports (void)
 
static void test_AddPort (void)
 
static void test_AddPortEx (void)
 
static void test_ClosePort (void)
 
static void test_ConfigurePort (void)
 
static void test_DeletePort (void)
 
static void test_EnumPorts (void)
 
static void test_InitializePrintMonitor (void)
 
static void test_InitializePrintMonitor2 (void)
 
static void test_OpenPort (void)
 
static void test_XcvClosePort (void)
 
static void test_XcvDataPort_AddPort (void)
 
static void test_XcvDataPort_ConfigureLPTPortCommandOK (void)
 
static void test_XcvDataPort_DeletePort (void)
 
static void test_XcvDataPort_GetTransmissionRetryTimeout (void)
 
static void test_XcvDataPort_MonitorUI (void)
 
static void test_XcvDataPort_PortIsValid (void)
 
static void test_XcvOpenPort (void)
 
 START_TEST (localmon)
 

Variables

static HMODULE hdll
 
static HMODULE hlocalmon
 
static HANDLE hmon
 
static LPHANDLE
 
static LPMONITOREX pm
 
static LPMONITOR2 pm2
 
static DWORD
 
static LPBYTE
 
static LPDWORD
 
static LPWSTR
 
static PHANDLE
 
static struct _MONITOR *static HANDLE
 
static HWND
 
static LPCOMMTIMEOUTS
 
static ACCESS_MASK
 
static LPCWSTR
 
static PBYTE
 
static PDWORD
 
static HANDLE hXcv
 
static HANDLE hXcv_noaccess
 
static const WCHAR cmd_AddPortW [] = {'A','d','d','P','o','r','t',0}
 
static const WCHAR cmd_ConfigureLPTPortCommandOKW []
 
static const WCHAR cmd_DeletePortW [] = {'D','e','l','e','t','e','P','o','r','t',0}
 
static const WCHAR cmd_GetTransmissionRetryTimeoutW []
 
static const WCHAR cmd_MonitorUIW [] = {'M','o','n','i','t','o','r','U','I',0}
 
static const WCHAR cmd_MonitorUI_lcaseW [] = {'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 does_not_existW [] = {'d','o','e','s','_','n','o','t','_','e','x','i','s','t',0}
 
static const CHAR emptyA [] = ""
 
static WCHAR emptyW [] = {0}
 
static WCHAR LocalPortW [] = {'L','o','c','a','l',' ','P','o','r','t',0}
 
static WCHAR Monitors_LocalPortW []
 
static const CHAR num_0A [] = "0"
 
static WCHAR num_0W [] = {'0',0}
 
static const CHAR num_1A [] = "1"
 
static WCHAR num_1W [] = {'1',0}
 
static const CHAR num_999999A [] = "999999"
 
static WCHAR num_999999W [] = {'9','9','9','9','9','9',0}
 
static const CHAR num_1000000A [] = "1000000"
 
static WCHAR num_1000000W [] = {'1','0','0','0','0','0','0',0}
 
static const WCHAR portname_comW [] = {'C','O','M',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 const WCHAR portname_lptW [] = {'L','P','T',0}
 
static WCHAR portname_lpt1W [] = {'L','P','T','1',':',0}
 
static WCHAR portname_lpt2W [] = {'L','P','T','2',':',0}
 
static WCHAR server_does_not_existW [] = {'\\','\\','d','o','e','s','_','n','o','t','_','e','x','i','s','t',0}
 
static const CHAR TransmissionRetryTimeoutA []
 
static const CHAR WinNT_CV_WindowsA []
 
static WCHAR wineW [] = {'W','i','n','e',0}
 
static WCHAR tempdirW [MAX_PATH]
 
static WCHAR tempfileW [MAX_PATH]
 
static WCHAR have_com [PORTNAME_MAXSIZE]
 
static WCHAR have_lpt [PORTNAME_MAXSIZE]
 
static WCHAR have_file [PORTNAME_MAXSIZE]
 
static MONITORREG monreg
 

Macro Definition Documentation

◆ GET_MONITOR_FUNC

#define GET_MONITOR_FUNC (   name)
Value:
if (pm) p##name = pm->Monitor.pfn##name; \
else if (pm2) p##name = pm2->pfn##name;
GLfloat GLfloat p
Definition: glext.h:8902
static LPMONITOR2 pm2
Definition: localmon.c:46
static LPMONITOREX pm
Definition: localmon.c:45
MONITOR Monitor
Definition: winsplp.h:864
Definition: name.c:39

Definition at line 1468 of file localmon.c.

◆ GET_MONITOR_FUNC2

#define GET_MONITOR_FUNC2 (   name)
Value:
if (pm) p##name = pm->Monitor.pfn##name; \
else if (pm2) p##name##2 = pm2->pfn##name;

Definition at line 1472 of file localmon.c.

◆ PORTNAME_MAXSIZE

#define PORTNAME_MAXSIZE   10

Definition at line 135 of file localmon.c.

◆ PORTNAME_MINSIZE

#define PORTNAME_MINSIZE   5

Definition at line 134 of file localmon.c.

◆ PORTNAME_PREFIX

#define PORTNAME_PREFIX   3

Definition at line 133 of file localmon.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pEnumPorts)
static

◆ CloseKey()

static LONG WINAPI CloseKey ( HANDLE  hcKey,
HANDLE  hSpooler 
)
static

Definition at line 157 of file localmon.c.

158{
159 ok(0, "should not be called\n");
161}
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ CreateKey()

static LONG WINAPI CreateKey ( HANDLE  hcKey,
LPCWSTR  pszSubKey,
DWORD  dwOptions,
REGSAM  samDesired,
PSECURITY_ATTRIBUTES  pSecurityAttributes,
PHANDLE  phckResult,
PDWORD  pdwDisposition,
HANDLE  hSpooler 
)
static

Definition at line 142 of file localmon.c.

145{
146 ok(0, "should not be called\n");
148}

◆ delete_port()

static DWORD delete_port ( LPWSTR  portname)
static

Definition at line 227 of file localmon.c.

228{
229 DWORD res;
230
231 if (pDeletePort) {
232 res = pDeletePort(NULL, 0, portname);
233 }
234 else
235 {
236 res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) portname, (lstrlenW(portname) + 1) * sizeof(WCHAR), NULL, 0, NULL);
237 }
238 return res;
239}
#define NULL
Definition: types.h:112
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
static HANDLE hXcv
Definition: localmon.c:73
static const WCHAR cmd_DeletePortW[]
Definition: localmon.c:82
BYTE * PBYTE
Definition: pedump.c:66
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_AddPortEx().

◆ DeleteKey()

static LONG WINAPI DeleteKey ( HANDLE  hcKey,
LPCWSTR  pszSubKey,
HANDLE  hSpooler 
)
static

Definition at line 163 of file localmon.c.

164{
165 ok(0, "should not be called\n");
167}

◆ DeleteValue()

static LONG WINAPI DeleteValue ( HANDLE  hcKey,
LPCWSTR  pszValue,
HANDLE  hSpooler 
)
static

Definition at line 192 of file localmon.c.

193{
194 ok(0, "should not be called\n");
196}

◆ DWORD()

static DWORD ( WINAPI pXcvDataPort)
static

◆ EnumKey()

static LONG WINAPI EnumKey ( HANDLE  hcKey,
DWORD  dwIndex,
LPWSTR  pszName,
PDWORD  pcchName,
PFILETIME  pftLastWriteTime,
HANDLE  hSpooler 
)
static

Definition at line 169 of file localmon.c.

171{
172 ok(0, "should not be called\n");
174}

Referenced by FindAdapterKey(), FindDeviceDescForAdapter(), and IopUpdateControlKeyWithResources().

◆ EnumValue()

static LONG WINAPI EnumValue ( HANDLE  hcKey,
DWORD  dwIndex,
LPWSTR  pszValue,
PDWORD  pcbValue,
PDWORD  pType,
PBYTE  pData,
PDWORD  pcbData,
HANDLE  hSpooler 
)
static

Definition at line 198 of file localmon.c.

201{
202 ok(0, "should not be called\n");
204}

◆ find_installed_ports()

static void find_installed_ports ( void  )
static

Definition at line 243 of file localmon.c.

244{
245 PORT_INFO_1W * pi = NULL;
247 DWORD needed;
248 DWORD returned;
249 DWORD res;
250 DWORD id;
251
252 have_com[0] = '\0';
253 have_lpt[0] = '\0';
254 have_file[0] = '\0';
255
256 if (!pEnumPorts) return;
257
258 res = pEnumPorts(NULL, 1, NULL, 0, &needed, &returned);
260 pi = HeapAlloc(GetProcessHeap(), 0, needed);
261 }
262 res = pEnumPorts(NULL, 1, (LPBYTE) pi, needed, &needed, &returned);
263
264 if (!res) {
265 skip("no ports found\n");
267 return;
268 }
269
270 id = 0;
271 while (id < returned) {
272 res = lstrlenW(pi[id].pName);
273 if ((res >= PORTNAME_MINSIZE) && (res < PORTNAME_MAXSIZE) &&
274 (pi[id].pName[res-1] == ':')) {
275 /* copy only the prefix ("LPT" or "COM") */
276 memcpy(&nameW, pi[id].pName, PORTNAME_PREFIX * sizeof(WCHAR));
277 nameW[PORTNAME_PREFIX] = '\0';
278
279 if (!have_com[0] && (lstrcmpiW(nameW, portname_comW) == 0)) {
280 memcpy(&have_com, pi[id].pName, (res+1) * sizeof(WCHAR));
281 }
282
283 if (!have_lpt[0] && (lstrcmpiW(nameW, portname_lptW) == 0)) {
284 memcpy(&have_lpt, pi[id].pName, (res+1) * sizeof(WCHAR));
285 }
286
287 if (!have_file[0] && (lstrcmpiW(pi[id].pName, portname_fileW) == 0)) {
288 memcpy(&have_file, pi[id].pName, (res+1) * sizeof(WCHAR));
289 }
290 }
291 id++;
292 }
293
295}
#define skip(...)
Definition: atltest.h:64
static const WCHAR nameW[]
Definition: main.c:46
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLuint id
Definition: glext.h:5910
#define PORTNAME_PREFIX
Definition: localmon.c:133
#define PORTNAME_MINSIZE
Definition: localmon.c:134
static WCHAR have_file[PORTNAME_MAXSIZE]
Definition: localmon.c:138
static WCHAR portname_fileW[]
Definition: localmon.c:114
#define PORTNAME_MAXSIZE
Definition: localmon.c:135
static const WCHAR portname_comW[]
Definition: localmon.c:111
static const WCHAR portname_lptW[]
Definition: localmon.c:115
static WCHAR have_lpt[PORTNAME_MAXSIZE]
Definition: localmon.c:137
static WCHAR have_com[PORTNAME_MAXSIZE]
Definition: localmon.c:136
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static LPSTR pName
Definition: security.c:75
static refpint_t pi[]
Definition: server.c:96
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1040

Referenced by START_TEST().

◆ LPMONITOR2()

static LPMONITOR2 ( WINAPI pInitializePrintMonitor2)
static

◆ LPMONITOREX()

static LPMONITOREX ( WINAPI pInitializePrintMonitor)
static

◆ OpenKey()

static LONG WINAPI OpenKey ( HANDLE  hcKey,
LPCWSTR  pszSubKey,
REGSAM  samDesired,
PHANDLE  phkResult,
HANDLE  hSpooler 
)
static

Definition at line 150 of file localmon.c.

152{
153 ok(0, "should not be called\n");
155}

◆ QueryInfoKey()

static LONG WINAPI QueryInfoKey ( HANDLE  hcKey,
PDWORD  pcSubKeys,
PDWORD  pcbKey,
PDWORD  pcValues,
PDWORD  pcbValue,
PDWORD  pcbData,
PDWORD  pcbSecurityDescriptor,
PFILETIME  pftLastWriteTime,
HANDLE  hSpooler 
)
static

Definition at line 176 of file localmon.c.

180{
181 ok(0, "should not be called\n");
183}

◆ QueryValue()

static LONG WINAPI QueryValue ( HANDLE  hcKey,
LPCWSTR  pszValue,
PDWORD  pType,
PBYTE  pData,
PDWORD  pcbData,
HANDLE  hSpooler 
)
static

Definition at line 206 of file localmon.c.

208{
210}

◆ SetValue()

static LONG WINAPI SetValue ( HANDLE  hcKey,
LPCWSTR  pszValue,
DWORD  dwType,
const BYTE pData,
DWORD  cbData,
HANDLE  hSpooler 
)
static

Definition at line 185 of file localmon.c.

187{
188 ok(0, "should not be called\n");
190}

◆ START_TEST()

START_TEST ( localmon  )

Definition at line 1476 of file localmon.c.

1477{
1478 DWORD numentries;
1479 DWORD res;
1480
1481 LoadLibraryA("winspool.drv");
1482 /* This DLL does not exist on Win9x */
1483 hdll = LoadLibraryA("localspl.dll");
1484 if (!hdll) {
1485 skip("localspl.dll cannot be loaded, most likely running on Win9x\n");
1486 return;
1487 }
1488
1489 tempdirW[0] = '\0';
1490 tempfileW[0] = '\0';
1492 ok(res != 0, "with %u\n", GetLastError());
1494 ok(res != 0, "with %u\n", GetLastError());
1495
1496 pInitializePrintMonitor = (void *) GetProcAddress(hdll, "InitializePrintMonitor");
1497 pInitializePrintMonitor2 = (void *) GetProcAddress(hdll, "InitializePrintMonitor2");
1498
1499 if (!pInitializePrintMonitor) {
1500 /* The Monitor for "Local Ports" was in a separate dll before w2k */
1501 hlocalmon = LoadLibraryA("localmon.dll");
1502 if (hlocalmon) {
1503 pInitializePrintMonitor = (void *) GetProcAddress(hlocalmon, "InitializePrintMonitor");
1504 }
1505 }
1506 if (!pInitializePrintMonitor && !pInitializePrintMonitor2) {
1507 skip("InitializePrintMonitor or InitializePrintMonitor2 not found\n");
1508 return;
1509 }
1510
1511 /* Native localmon.dll / localspl.dll need a valid Port-Entry in:
1512 a) since xp: HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports
1513 b) up to w2k: Section "Ports" in win.ini
1514 or InitializePrintMonitor fails. */
1515 if (pInitializePrintMonitor)
1516 pm = pInitializePrintMonitor(Monitors_LocalPortW);
1517 else if (pInitializePrintMonitor2) {
1519
1520 memset(&init, 0, sizeof(init));
1521 init.cbSize = sizeof(init);
1522 init.hckRegistryRoot = 0;
1523 init.pMonitorReg = &monreg;
1524 init.bLocal = TRUE;
1525
1526 pm2 = pInitializePrintMonitor2(&init, &hmon);
1527 ok(pm2 != NULL, "InitializePrintMonitor2 error %u\n", GetLastError());
1528 ok(pm2->cbSize >= FIELD_OFFSET(MONITOR2, pfnSendRecvBidiDataFromPort), "wrong cbSize %u\n", pm2->cbSize);
1529 }
1530
1531 if (pm || pm2) {
1532 if (pm) {
1533 ok(pm->dwMonitorSize == sizeof(MONITOR), "wrong dwMonitorSize %u\n", pm->dwMonitorSize);
1534 numentries = (pm->dwMonitorSize ) / sizeof(VOID *);
1535 /* NT4: 14, since w2k: 17 */
1536 ok( numentries == 14 || numentries == 17,
1537 "dwMonitorSize (%u) => %u Functions\n", pm->dwMonitorSize, numentries);
1538 }
1539 else if (pm2) {
1540 numentries = (pm2->cbSize ) / sizeof(VOID *);
1541 ok( numentries >= 20,
1542 "cbSize (%u) => %u Functions\n", pm2->cbSize, numentries);
1543 }
1544
1547 GET_MONITOR_FUNC2(OpenPortEx);
1548 GET_MONITOR_FUNC(StartDocPort);
1551 GET_MONITOR_FUNC(EndDocPort);
1554 GET_MONITOR_FUNC2(AddPortEx);
1557 GET_MONITOR_FUNC(GetPrinterDataFromPort);
1558 GET_MONITOR_FUNC(SetPortTimeOuts);
1562
1563 if ((pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
1564 SetLastError(0xdeadbeef);
1565 res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
1566 ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
1567
1568 SetLastError(0xdeadbeef);
1569 res = pXcvOpenPort(emptyW, 0, &hXcv_noaccess);
1570 ok(res, "hXcv_noaccess: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv_noaccess);
1571 }
1572 }
1573
1576
1578
1579 test_AddPort();
1585 test_OpenPort();
1586
1587 if ( !hXcv ) {
1588 skip("Xcv not supported\n");
1589 }
1590 else
1591 {
1600
1601 pXcvClosePort(hXcv);
1602 }
1603 if (hXcv_noaccess) pXcvClosePort(hXcv_noaccess);
1604
1605 /* Cleanup our temporary file */
1607}
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2080
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
#define GET_MONITOR_FUNC(name)
Definition: localmon.c:1468
static WCHAR wineW[]
Definition: localmon.c:128
static void test_XcvDataPort_GetTransmissionRetryTimeout(void)
Definition: localmon.c:1065
static WCHAR tempdirW[MAX_PATH]
Definition: localmon.c:130
static MONITORREG monreg
Definition: localmon.c:212
static WCHAR Monitors_LocalPortW[]
Definition: localmon.c:94
static HANDLE hXcv_noaccess
Definition: localmon.c:74
static HMODULE hdll
Definition: localmon.c:39
static void test_XcvDataPort_MonitorUI(void)
Definition: localmon.c:1185
static void test_OpenPort(void)
Definition: localmon.c:749
static void test_ConfigurePort(void)
Definition: localmon.c:536
static void test_XcvDataPort_AddPort(void)
Definition: localmon.c:893
static void test_XcvDataPort_PortIsValid(void)
Definition: localmon.c:1281
static void find_installed_ports(void)
Definition: localmon.c:243
static void test_XcvClosePort(void)
Definition: localmon.c:859
#define GET_MONITOR_FUNC2(name)
Definition: localmon.c:1472
static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
Definition: localmon.c:937
static void test_ClosePort(void)
Definition: localmon.c:439
static void test_InitializePrintMonitor2(void)
Definition: localmon.c:728
static void test_AddPort(void)
Definition: localmon.c:299
static void test_AddPortEx(void)
Definition: localmon.c:329
static WCHAR emptyW[]
Definition: localmon.c:92
static void test_InitializePrintMonitor(void)
Definition: localmon.c:701
static HMODULE hlocalmon
Definition: localmon.c:40
static void test_XcvDataPort_DeletePort(void)
Definition: localmon.c:1033
static WCHAR tempfileW[MAX_PATH]
Definition: localmon.c:131
static void test_DeletePort(void)
Definition: localmon.c:577
static void test_XcvOpenPort(void)
Definition: localmon.c:1421
static void test_EnumPorts(void)
Definition: localmon.c:610
static HANDLE hmon
Definition: localmon.c:41
BOOL WINAPI XcvOpenPort(_In_ LPCWSTR pszObject, _In_ ACCESS_MASK GrantedAccess, _Out_ PHANDLE phXcv)
DWORD WINAPI XcvDataPort(_In_ HANDLE hXcv, _In_ LPCWSTR pszDataName, _In_reads_bytes_(cbInputData) PBYTE pInputData, _In_ DWORD cbInputData, _Out_writes_bytes_(cbOutputData) PBYTE pOutputData, _In_ DWORD cbOutputData, _Out_ PDWORD pcbOutputNeeded)
BOOL WINAPI ReadPort(_In_ HANDLE hPort, _Out_writes_bytes_(cbBuffer) LPBYTE pBuffer, _In_ DWORD cbBuffer, _Out_ LPDWORD pcbRead)
BOOL WINAPI XcvClosePort(_In_ HANDLE hXcv)
BOOL WINAPI WritePort(_In_ HANDLE hPort, _In_reads_bytes_(cbBuf) LPBYTE pBuffer, _In_ DWORD cbBuf, _Out_ LPDWORD pcbWritten)
BOOL WINAPI OpenPort(_In_ LPWSTR pName, _Out_ PHANDLE pHandle)
BOOL WINAPI ClosePort(_In_ HANDLE hPort)
#define memset(x, y, z)
Definition: compat.h:39
DWORD cbSize
Definition: winsplp.h:868
DWORD dwMonitorSize
Definition: winsplp.h:863
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define EnumPorts
Definition: winspool.h:1241
#define SERVER_ACCESS_ADMINISTER
Definition: winspool.h:1366
#define AddPort
Definition: winspool.h:1242
#define DeletePort
Definition: winspool.h:1244
#define ConfigurePort
Definition: winspool.h:1243
static int init
Definition: wintirpc.c:33

◆ test_AddPort()

static void test_AddPort ( void  )
static

Definition at line 299 of file localmon.c.

300{
301 DWORD res;
302
303 /* moved to localui.dll since w2k */
304 if (!pAddPort) return;
305
306 if (0)
307 {
308 /* NT4 crash on this test */
309 pAddPort(NULL, 0, NULL);
310 }
311
312 /* Testing-Results (localmon.dll from NT4.0):
313 - The Servername is ignored
314 - Case of MonitorName is ignored
315 */
316
317 SetLastError(0xdeadbeef);
318 res = pAddPort(NULL, 0, emptyW);
319 ok(!res, "returned %d with %u (expected '0')\n", res, GetLastError());
320
321 SetLastError(0xdeadbeef);
322 res = pAddPort(NULL, 0, does_not_existW);
323 ok(!res, "returned %d with %u (expected '0')\n", res, GetLastError());
324
325}
static WCHAR does_not_existW[]
Definition: localmon.c:90

Referenced by START_TEST().

◆ test_AddPortEx()

static void test_AddPortEx ( void  )
static

Definition at line 329 of file localmon.c.

330{
332 DWORD res;
333
334 if (!pAddPortEx) {
335 skip("AddPortEx\n");
336 return;
337 }
338 if ((!pDeletePort) && (!hXcv)) {
339 skip("No API to delete a Port\n");
340 return;
341 }
342
343 /* start test with clean ports */
345
346 pi.pPortName = tempfileW;
347 if (0) {
348 /* tests crash with native localspl.dll in w2k,
349 but works with native localspl.dll in wine */
350 SetLastError(0xdeadbeef);
351 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
352 trace("returned %u with %u\n", res, GetLastError() );
353 ok( res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
354
355 /* port already exists: */
356 SetLastError(0xdeadbeef);
357 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
358 trace("returned %u with %u\n", res, GetLastError() );
360 "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
361 res, GetLastError());
363
364
365 /* NULL for pMonitorName is documented for Printmonitors, but
366 localspl.dll fails always with ERROR_INVALID_PARAMETER */
367 SetLastError(0xdeadbeef);
368 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, NULL);
369 trace("returned %u with %u\n", res, GetLastError() );
371 "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
372 res, GetLastError());
374
375
376 SetLastError(0xdeadbeef);
377 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, emptyW);
378 trace("returned %u with %u\n", res, GetLastError() );
380 "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
381 res, GetLastError());
383
384
385 SetLastError(0xdeadbeef);
386 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, does_not_existW);
387 trace("returned %u with %u\n", res, GetLastError() );
389 "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
390 res, GetLastError());
392 }
393
394 pi.pPortName = NULL;
395 SetLastError(0xdeadbeef);
396 res = pAddPortEx(NULL, 1, (LPBYTE) &pi, LocalPortW);
398 "got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
399 res, GetLastError());
400
401 /* level 2 is documented as supported for Printmonitors,
402 but localspl.dll fails always with ERROR_INVALID_LEVEL */
403
404 pi.pPortName = tempfileW;
405 pi.pMonitorName = LocalPortW;
406 pi.pDescription = wineW;
407 pi.fPortType = PORT_TYPE_WRITE;
408
409 SetLastError(0xdeadbeef);
410 res = pAddPortEx(NULL, 2, (LPBYTE) &pi, LocalPortW);
412 "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
413 res, GetLastError());
415
416
417 /* invalid levels */
418 SetLastError(0xdeadbeef);
419 res = pAddPortEx(NULL, 0, (LPBYTE) &pi, LocalPortW);
421 "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
422 res, GetLastError());
424
425
426 SetLastError(0xdeadbeef);
427 res = pAddPortEx(NULL, 3, (LPBYTE) &pi, LocalPortW);
429 "got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
430 res, GetLastError());
432
433 /* cleanup */
435}
#define trace
Definition: atltest.h:70
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static DWORD delete_port(LPWSTR portname)
Definition: localmon.c:227
static WCHAR LocalPortW[]
Definition: localmon.c:93
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define PORT_TYPE_WRITE
Definition: winspool.h:776

Referenced by START_TEST().

◆ test_ClosePort()

static void test_ClosePort ( void  )
static

Definition at line 439 of file localmon.c.

440{
441 HANDLE hPort;
442 HANDLE hPort2;
443 LPWSTR nameW = NULL;
444 DWORD res;
445 DWORD res2;
446
447
448 if (!pOpenPort || !pClosePort) return;
449
450 if (have_com[0]) {
451 nameW = have_com;
452
453 hPort = (HANDLE) 0xdeadbeef;
454 res = pOpenPort(nameW, &hPort);
455 hPort2 = (HANDLE) 0xdeadbeef;
456 res2 = pOpenPort(nameW, &hPort2);
457
458 if (res2 && (hPort2 != hPort)) {
459 SetLastError(0xdeadbeef);
460 res2 = pClosePort(hPort2);
461 ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
462 }
463
464 if (res) {
465 SetLastError(0xdeadbeef);
466 res = pClosePort(hPort);
467 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
468 }
469 }
470
471
472 if (have_lpt[0]) {
473 nameW = have_lpt;
474
475 hPort = (HANDLE) 0xdeadbeef;
476 res = pOpenPort(nameW, &hPort);
477 hPort2 = (HANDLE) 0xdeadbeef;
478 res2 = pOpenPort(nameW, &hPort2);
479
480 if (res2 && (hPort2 != hPort)) {
481 SetLastError(0xdeadbeef);
482 res2 = pClosePort(hPort2);
483 ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
484 }
485
486 if (res) {
487 SetLastError(0xdeadbeef);
488 res = pClosePort(hPort);
489 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
490 }
491 }
492
493
494 if (have_file[0]) {
496
497 hPort = (HANDLE) 0xdeadbeef;
498 res = pOpenPort(nameW, &hPort);
499 hPort2 = (HANDLE) 0xdeadbeef;
500 res2 = pOpenPort(nameW, &hPort2);
501
502 if (res2 && (hPort2 != hPort)) {
503 SetLastError(0xdeadbeef);
504 res2 = pClosePort(hPort2);
505 ok(res2, "got %u with %u (expected '!= 0')\n", res2, GetLastError());
506 }
507
508 if (res) {
509 SetLastError(0xdeadbeef);
510 res = pClosePort(hPort);
511 ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
512 }
513
514 }
515
516 if (0) {
517 /* an invalid HANDLE crash native localspl.dll */
518
519 SetLastError(0xdeadbeef);
520 res = pClosePort(NULL);
521 trace("got %u with %u\n", res, GetLastError());
522
523 SetLastError(0xdeadbeef);
524 res = pClosePort( (HANDLE) 0xdeadbeef);
525 trace("got %u with %u\n", res, GetLastError());
526
527 SetLastError(0xdeadbeef);
528 res = pClosePort(INVALID_HANDLE_VALUE);
529 trace("got %u with %u\n", res, GetLastError());
530 }
531
532}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static struct _MONITOR *static HANDLE
Definition: localmon.c:52
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_ConfigurePort()

static void test_ConfigurePort ( void  )
static

Definition at line 536 of file localmon.c.

537{
538 DWORD res;
539
540 /* moved to localui.dll since w2k */
541 if (!pConfigurePort) return;
542
543 if (0)
544 {
545 /* NT4 crash on this test */
546 pConfigurePort(NULL, 0, NULL);
547 }
548
549 /* Testing-Results (localmon.dll from NT4.0):
550 - Case of Portname is ignored
551 - "COM1:" and "COM01:" are the same (Compared by value)
552 - Portname without ":" => Dialog "Nothing to configure" comes up; Success
553 - "LPT1:", "LPT0:" and "LPT:" are the same (Numbers in "LPT:" are ignored)
554 - Empty Servername (LPT1:) => Dialog comes up (Servername is ignored)
555 - "FILE:" => Dialog "Nothing to configure" comes up; Success
556 - Empty Portname => => Dialog "Nothing to configure" comes up; Success
557 - Port "does_not_exist" => Dialog "Nothing to configure" comes up; Success
558 */
559 if (winetest_interactive > 0) {
560
561 SetLastError(0xdeadbeef);
562 res = pConfigurePort(NULL, 0, portname_com1W);
563 trace("returned %d with %u\n", res, GetLastError());
564
565 SetLastError(0xdeadbeef);
566 res = pConfigurePort(NULL, 0, portname_lpt1W);
567 trace("returned %d with %u\n", res, GetLastError());
568
569 SetLastError(0xdeadbeef);
570 res = pConfigurePort(NULL, 0, portname_fileW);
571 trace("returned %d with %u\n", res, GetLastError());
572 }
573}
static WCHAR portname_lpt1W[]
Definition: localmon.c:116
static WCHAR portname_com1W[]
Definition: localmon.c:112
int winetest_interactive

Referenced by START_TEST().

◆ test_DeletePort()

static void test_DeletePort ( void  )
static

Definition at line 577 of file localmon.c.

578{
579 DWORD res;
580
581 /* moved to localui.dll since w2k */
582 if (!pDeletePort) return;
583
584 if (0)
585 {
586 /* NT4 crash on this test */
587 pDeletePort(NULL, 0, NULL);
588 }
589
590 /* Testing-Results (localmon.dll from NT4.0):
591 - Case of Portname is ignored (returned '1' on Success)
592 - "COM1:" and "COM01:" are different (Compared as string)
593 - server_does_not_exist (LPT1:) => Port deleted, Success (Servername is ignored)
594 - Empty Portname => => FALSE (LastError not changed)
595 - Port "does_not_exist" => FALSE (LastError not changed)
596 */
597
598 SetLastError(0xdeadbeef);
599 res = pDeletePort(NULL, 0, emptyW);
600 ok(!res, "returned %d with %u (expected '0')\n", res, GetLastError());
601
602 SetLastError(0xdeadbeef);
603 res = pDeletePort(NULL, 0, does_not_existW);
604 ok(!res, "returned %d with %u (expected '0')\n", res, GetLastError());
605
606}

Referenced by START_TEST().

◆ test_EnumPorts()

static void test_EnumPorts ( void  )
static

Definition at line 610 of file localmon.c.

611{
612 DWORD res;
613 DWORD level;
615 DWORD cbBuf;
617 DWORD pcReturned;
618
619 if (!pEnumPorts) return;
620
621 /* valid levels are 1 and 2 */
622 for(level = 0; level < 4; level++) {
623
624 cbBuf = 0xdeadbeef;
625 pcReturned = 0xdeadbeef;
626 SetLastError(0xdeadbeef);
627 res = pEnumPorts(NULL, level, NULL, 0, &cbBuf, &pcReturned);
628
629 /* use only a short test, when we test with an invalid level */
630 if(!level || (level > 2)) {
631 /* NT4 fails with ERROR_INVALID_LEVEL (as expected)
632 XP succeeds with ERROR_SUCCESS () */
633 ok( (cbBuf == 0) && (pcReturned == 0),
634 "(%d) returned %d with %u and %d, %d (expected 0, 0)\n",
635 level, res, GetLastError(), cbBuf, pcReturned);
636 continue;
637 }
638
640 "(%d) returned %d with %u and %d, %d (expected '0' with "
641 "ERROR_INSUFFICIENT_BUFFER)\n",
642 level, res, GetLastError(), cbBuf, pcReturned);
643
644 buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf * 2);
645 if (buffer == NULL) continue;
646
647 pcbNeeded = 0xdeadbeef;
648 pcReturned = 0xdeadbeef;
649 SetLastError(0xdeadbeef);
650 res = pEnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
651 ok( res, "(%d) returned %d with %u and %d, %d (expected '!= 0')\n",
652 level, res, GetLastError(), pcbNeeded, pcReturned);
653 /* We can compare the returned Data with the Registry / "win.ini",[Ports] here */
654
655 pcbNeeded = 0xdeadbeef;
656 pcReturned = 0xdeadbeef;
657 SetLastError(0xdeadbeef);
658 res = pEnumPorts(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
659 ok( res, "(%d) returned %d with %u and %d, %d (expected '!= 0')\n",
660 level, res, GetLastError(), pcbNeeded, pcReturned);
661
662 pcbNeeded = 0xdeadbeef;
663 pcReturned = 0xdeadbeef;
664 SetLastError(0xdeadbeef);
665 res = pEnumPorts(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
667 "(%d) returned %d with %u and %d, %d (expected '0' with "
668 "ERROR_INSUFFICIENT_BUFFER)\n",
669 level, res, GetLastError(), pcbNeeded, pcReturned);
670
671 if (0)
672 {
673 /* The following tests crash this app with native localmon/localspl */
674 pEnumPorts(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
675 pEnumPorts(NULL, level, buffer, cbBuf, NULL, &pcReturned);
676 pEnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
677 }
678
679 /* The Servername is ignored */
680 pcbNeeded = 0xdeadbeef;
681 pcReturned = 0xdeadbeef;
682 SetLastError(0xdeadbeef);
683 res = pEnumPorts(emptyW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
684 ok( res, "(%d) returned %d with %u and %d, %d (expected '!= 0')\n",
685 level, res, GetLastError(), pcbNeeded, pcReturned);
686
687 pcbNeeded = 0xdeadbeef;
688 pcReturned = 0xdeadbeef;
689 SetLastError(0xdeadbeef);
690 res = pEnumPorts(server_does_not_existW, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
691 ok( res, "(%d) returned %d with %u and %d, %d (expected '!= 0')\n",
692 level, res, GetLastError(), pcbNeeded, pcReturned);
693
695 }
696}
GLint level
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
static WCHAR server_does_not_existW[]
Definition: localmon.c:118
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828

Referenced by START_TEST().

◆ test_InitializePrintMonitor()

static void test_InitializePrintMonitor ( void  )
static

Definition at line 701 of file localmon.c.

702{
704
705 if (!pInitializePrintMonitor) return;
706
707 SetLastError(0xdeadbeef);
708 res = pInitializePrintMonitor(NULL);
709 /* The Parameter was unchecked before w2k */
711 "returned %p with %u\n (expected '!= NULL' or: NULL with "
712 "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
713
714 SetLastError(0xdeadbeef);
715 res = pInitializePrintMonitor(emptyW);
717 "returned %p with %u\n (expected '!= NULL' or: NULL with "
718 "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
719
720 /* Every call with a non-empty string returns the same Pointer */
721 SetLastError(0xdeadbeef);
722 res = pInitializePrintMonitor(Monitors_LocalPortW);
723 ok( res == pm,
724 "returned %p with %u (expected %p)\n", res, GetLastError(), pm);
725 ok(res->dwMonitorSize == sizeof(MONITOR), "wrong dwMonitorSize %u\n", res->dwMonitorSize);
726}

Referenced by START_TEST().

◆ test_InitializePrintMonitor2()

static void test_InitializePrintMonitor2 ( void  )
static

Definition at line 728 of file localmon.c.

729{
731 MONITOR2 *monitor2;
732 HANDLE hmon;
733
734 if (!pInitializePrintMonitor2) return;
735
736 memset(&init, 0, sizeof(init));
737 init.cbSize = sizeof(init);
738 init.hckRegistryRoot = 0;
739 init.pMonitorReg = &monreg;
740 init.bLocal = TRUE;
741
742 monitor2 = pInitializePrintMonitor2(&init, &hmon);
743 ok(monitor2 != NULL, "InitializePrintMonitor2 error %u\n", GetLastError());
744 ok(monitor2->cbSize >= FIELD_OFFSET(MONITOR2, pfnSendRecvBidiDataFromPort), "wrong cbSize %u\n", monitor2->cbSize);
745}

Referenced by START_TEST().

◆ test_OpenPort()

static void test_OpenPort ( void  )
static

Definition at line 749 of file localmon.c.

750{
751 HANDLE hPort;
752 HANDLE hPort2;
753 LPWSTR nameW = NULL;
754 DWORD res;
755 DWORD res2;
756
757 if (!pOpenPort || !pClosePort) return;
758
759 if (have_com[0]) {
760 nameW = have_com;
761
762 hPort = (HANDLE) 0xdeadbeef;
763 SetLastError(0xdeadbeef);
764 res = pOpenPort(nameW, &hPort);
765 ok( res, "got %u with %u and %p (expected '!= 0')\n",
766 res, GetLastError(), hPort);
767
768 /* the same HANDLE is returned for a second OpenPort in native localspl */
769 hPort2 = (HANDLE) 0xdeadbeef;
770 SetLastError(0xdeadbeef);
771 res2 = pOpenPort(nameW, &hPort2);
772 ok( res2, "got %u with %u and %p (expected '!= 0')\n",
773 res2, GetLastError(), hPort2);
774
775 if (res) pClosePort(hPort);
776 if (res2 && (hPort2 != hPort)) pClosePort(hPort2);
777 }
778
779 if (have_lpt[0]) {
780 nameW = have_lpt;
781
782 hPort = (HANDLE) 0xdeadbeef;
783 SetLastError(0xdeadbeef);
784 res = pOpenPort(nameW, &hPort);
786 "got %u with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
787 res, GetLastError(), hPort);
788
789 /* the same HANDLE is returned for a second OpenPort in native localspl */
790 hPort2 = (HANDLE) 0xdeadbeef;
791 SetLastError(0xdeadbeef);
792 res2 = pOpenPort(nameW, &hPort2);
793 ok( res2 || (GetLastError() == ERROR_ACCESS_DENIED),
794 "got %u with %u and %p (expected '!= 0' or '0' with ERROR_ACCESS_DENIED)\n",
795 res2, GetLastError(), hPort2);
796
797 if (res) pClosePort(hPort);
798 if (res2 && (hPort2 != hPort)) pClosePort(hPort2);
799 }
800
801 if (have_file[0]) {
803
804 hPort = (HANDLE) 0xdeadbeef;
805 SetLastError(0xdeadbeef);
806 res = pOpenPort(nameW, &hPort);
807 ok( res, "got %u with %u and %p (expected '!= 0')\n",
808 res, GetLastError(), hPort);
809
810 /* a different HANDLE is returned for a second OpenPort */
811 hPort2 = (HANDLE) 0xdeadbeef;
812 SetLastError(0xdeadbeef);
813 res2 = pOpenPort(nameW, &hPort2);
814 ok( res2 && (hPort2 != hPort),
815 "got %u with %u and %p (expected '!= 0' and '!= %p')\n",
816 res2, GetLastError(), hPort2, hPort);
817
818 if (res) pClosePort(hPort);
819 if (res2 && (hPort2 != hPort)) pClosePort(hPort2);
820 }
821
822 if (0) {
823 /* this test crash native localspl (w2k+xp) */
824 if (nameW) {
825 hPort = (HANDLE) 0xdeadbeef;
826 SetLastError(0xdeadbeef);
827 res = pOpenPort(nameW, NULL);
828 trace("got %u with %u and %p\n", res, GetLastError(), hPort);
829 }
830 }
831
832 hPort = (HANDLE) 0xdeadbeef;
833 SetLastError(0xdeadbeef);
834 res = pOpenPort(does_not_existW, &hPort);
835 ok (!res && (hPort == (HANDLE) 0xdeadbeef),
836 "got %u with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
837 if (res) pClosePort(hPort);
838
839 hPort = (HANDLE) 0xdeadbeef;
840 SetLastError(0xdeadbeef);
841 res = pOpenPort(emptyW, &hPort);
842 ok (!res && (hPort == (HANDLE) 0xdeadbeef),
843 "got %u with 0x%x and %p (expected '0' and 0xdeadbeef)\n", res, GetLastError(), hPort);
844 if (res) pClosePort(hPort);
845
846
847 /* NULL as name crash native localspl (w2k+xp) */
848 if (0) {
849 hPort = (HANDLE) 0xdeadbeef;
850 SetLastError(0xdeadbeef);
851 res = pOpenPort(NULL, &hPort);
852 trace("got %u with %u and %p\n", res, GetLastError(), hPort);
853 }
854
855}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97

Referenced by START_TEST().

◆ test_XcvClosePort()

static void test_XcvClosePort ( void  )
static

Definition at line 859 of file localmon.c.

860{
861 DWORD res;
862 HANDLE hXcv2;
863
864
865 if (0)
866 {
867 /* crash with native localspl.dll (w2k+xp) */
868 pXcvClosePort(NULL);
869 pXcvClosePort(INVALID_HANDLE_VALUE);
870 }
871
872
873 SetLastError(0xdeadbeef);
874 hXcv2 = (HANDLE) 0xdeadbeef;
875 res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv2);
876 ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
877
878 if (res) {
879 SetLastError(0xdeadbeef);
880 res = pXcvClosePort(hXcv2);
881 ok(res, "returned %d with %u (expected '!= 0')\n", res, GetLastError());
882
883 if (0)
884 {
885 /* test for "Double Free": crash with native localspl.dll (w2k+xp) */
886 pXcvClosePort(hXcv2);
887 }
888 }
889}

Referenced by START_TEST().

◆ test_XcvDataPort_AddPort()

static void test_XcvDataPort_AddPort ( void  )
static

Definition at line 893 of file localmon.c.

894{
895 DWORD res;
896
897 /*
898 * The following tests crash with native localspl.dll on w2k and xp,
899 * but it works, when the native dll (w2k and xp) is used in wine.
900 * also tested (same crash): replacing emptyW with portname_lpt1W
901 * and replacing "NULL, 0, NULL" with "buffer, MAX_PATH, &needed"
902 *
903 * We need to use a different API (AddPortEx) instead
904 */
905 if (0)
906 {
907 /* create a Port for a normal, writable file */
908 SetLastError(0xdeadbeef);
909 res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
910 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
911
912 /* add our testport again */
913 SetLastError(0xdeadbeef);
914 res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
915 ok( res == ERROR_ALREADY_EXISTS, "returned %d with %u (expected ERROR_ALREADY_EXISTS)\n", res, GetLastError());
916
917 /* create a well-known Port */
918 SetLastError(0xdeadbeef);
919 res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
920 ok( res == ERROR_ALREADY_EXISTS, "returned %d with %u (expected ERROR_ALREADY_EXISTS)\n", res, GetLastError());
921
922 /* ERROR_ALREADY_EXISTS is also returned from native localspl.dll on wine,
923 when "RPT1:" was already installed for redmonnt.dll:
924 res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_rpt1W, ...
925 */
926
927 /* cleanup */
928 SetLastError(0xdeadbeef);
929 res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
930 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
931 }
932
933}
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR cmd_AddPortW[]
Definition: localmon.c:78
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80

Referenced by START_TEST().

◆ test_XcvDataPort_ConfigureLPTPortCommandOK()

static void test_XcvDataPort_ConfigureLPTPortCommandOK ( void  )
static

Definition at line 937 of file localmon.c.

938{
939 CHAR org_value[16];
940 CHAR buffer[16];
941 HKEY hroot = NULL;
942 DWORD res;
943 DWORD needed;
944
945
946 /* Read the original value from the registry */
948 if (res == ERROR_ACCESS_DENIED) {
949 skip("ACCESS_DENIED\n");
950 return;
951 }
952
953 if (res != ERROR_SUCCESS) {
954 /* unable to open the registry: skip the test */
955 skip("got %d\n", res);
956 return;
957 }
958 org_value[0] = '\0';
959 needed = sizeof(org_value)-1 ;
960 res = RegQueryValueExA(hroot, TransmissionRetryTimeoutA, NULL, NULL, (PBYTE) org_value, &needed);
962 "returned %u and %u for \"%s\" (expected ERROR_SUCCESS or "
963 "ERROR_FILE_NOT_FOUND)\n", res, needed, org_value);
964
966
967 /* set to "0" */
968 needed = (DWORD) 0xdeadbeef;
969 SetLastError(0xdeadbeef);
970 res = pXcvDataPort(hXcv, cmd_ConfigureLPTPortCommandOKW, (PBYTE) num_0W, sizeof(num_0W), NULL, 0, &needed);
972 skip("'ConfigureLPTPortCommandOK' not supported\n");
973 return;
974 }
975 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
976 needed = sizeof(buffer)-1 ;
978 ok( (res == ERROR_SUCCESS) && (lstrcmpA(buffer, num_0A) == 0),
979 "returned %d and '%s' (expected ERROR_SUCCESS and '%s')\n",
980 res, buffer, num_0A);
981
982
983 /* set to "1" */
984 needed = (DWORD) 0xdeadbeef;
985 SetLastError(0xdeadbeef);
986 res = pXcvDataPort(hXcv, cmd_ConfigureLPTPortCommandOKW, (PBYTE) num_1W, sizeof(num_1W), NULL, 0, &needed);
987 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
988 needed = sizeof(buffer)-1 ;
990 ok( (res == ERROR_SUCCESS) && (lstrcmpA(buffer, num_1A) == 0),
991 "returned %d and '%s' (expected ERROR_SUCCESS and '%s')\n",
992 res, buffer, num_1A);
993
994 /* set to "999999" */
995 needed = (DWORD) 0xdeadbeef;
996 SetLastError(0xdeadbeef);
997 res = pXcvDataPort(hXcv, cmd_ConfigureLPTPortCommandOKW, (PBYTE) num_999999W, sizeof(num_999999W), NULL, 0, &needed);
998 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
999 needed = sizeof(buffer)-1 ;
1001 ok( (res == ERROR_SUCCESS) && (lstrcmpA(buffer, num_999999A) == 0),
1002 "returned %d and '%s' (expected ERROR_SUCCESS and '%s')\n",
1004
1005 /* set to "1000000" */
1006 needed = (DWORD) 0xdeadbeef;
1007 SetLastError(0xdeadbeef);
1008 res = pXcvDataPort(hXcv, cmd_ConfigureLPTPortCommandOKW, (PBYTE) num_1000000W, sizeof(num_1000000W), NULL, 0, &needed);
1009 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
1010 needed = sizeof(buffer)-1 ;
1012 ok( (res == ERROR_SUCCESS) && (lstrcmpA(buffer, num_1000000A) == 0),
1013 "returned %d and '%s' (expected ERROR_SUCCESS and '%s')\n",
1015
1016 /* using cmd_ConfigureLPTPortCommandOKW with does_not_existW:
1017 the string "does_not_exist" is written to the registry */
1018
1019
1020 /* restore the original value */
1022 if (org_value[0]) {
1023 res = RegSetValueExA(hroot, TransmissionRetryTimeoutA, 0, REG_SZ, (PBYTE)org_value, lstrlenA(org_value)+1);
1024 ok(res == ERROR_SUCCESS, "unable to restore original value (got %u): %s\n", res, org_value);
1025 }
1026
1027 RegCloseKey(hroot);
1028
1029}
#define RegCloseKey(hKey)
Definition: registry.h:47
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4817
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3321
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
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:4027
#define REG_SZ
Definition: layer.c:22
static const CHAR TransmissionRetryTimeoutA[]
Definition: localmon.c:120
static WCHAR num_1W[]
Definition: localmon.c:105
static WCHAR num_999999W[]
Definition: localmon.c:107
static const CHAR num_1A[]
Definition: localmon.c:104
static DWORD
Definition: localmon.c:47
static const CHAR WinNT_CV_WindowsA[]
Definition: localmon.c:123
static WCHAR num_1000000W[]
Definition: localmon.c:109
static const CHAR num_999999A[]
Definition: localmon.c:106
static const WCHAR cmd_ConfigureLPTPortCommandOKW[]
Definition: localmon.c:79
static WCHAR num_0W[]
Definition: localmon.c:103
static const CHAR num_0A[]
Definition: localmon.c:102
static const CHAR num_1000000A[]
Definition: localmon.c:108
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_XcvDataPort_DeletePort()

static void test_XcvDataPort_DeletePort ( void  )
static

Definition at line 1033 of file localmon.c.

1034{
1035 DWORD res;
1036 DWORD needed;
1037
1038
1039 /* cleanup: just to make sure */
1040 needed = (DWORD) 0xdeadbeef;
1041 SetLastError(0xdeadbeef);
1042 res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, &needed);
1043 ok( !res || (res == ERROR_FILE_NOT_FOUND),
1044 "returned %d with %u (expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND)\n",
1045 res, GetLastError());
1046
1047
1048 /* ToDo: cmd_AddPortW for tempfileW, then cmd_DeletePortW for the existing Port */
1049
1050
1051 /* try to delete a nonexistent Port */
1052 needed = (DWORD) 0xdeadbeef;
1053 SetLastError(0xdeadbeef);
1054 res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, &needed);
1056 "returned %d with %u (expected ERROR_FILE_NOT_FOUND)\n", res, GetLastError());
1057
1058 /* emptyW as Portname: ERROR_FILE_NOT_FOUND is returned */
1059 /* NULL as Portname: Native localspl.dll crashed */
1060
1061}

Referenced by START_TEST().

◆ test_XcvDataPort_GetTransmissionRetryTimeout()

static void test_XcvDataPort_GetTransmissionRetryTimeout ( void  )
static

Definition at line 1065 of file localmon.c.

1066{
1067 CHAR org_value[16];
1068 HKEY hroot = NULL;
1069 DWORD buffer[2];
1070 DWORD res;
1071 DWORD needed;
1072 DWORD len;
1073
1074
1075 /* ask for needed size */
1076 needed = (DWORD) 0xdeadbeef;
1077 SetLastError(0xdeadbeef);
1078 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, NULL, 0, &needed);
1080 skip("'GetTransmissionRetryTimeout' not supported\n");
1081 return;
1082 }
1083 len = sizeof(DWORD);
1084 ok( (res == ERROR_INSUFFICIENT_BUFFER) && (needed == len),
1085 "returned %d with %u and %u (expected ERROR_INSUFFICIENT_BUFFER "
1086 "and '%u')\n", res, GetLastError(), needed, len);
1087 len = needed;
1088
1089 /* Read the original value from the registry */
1091 if (res == ERROR_ACCESS_DENIED) {
1092 skip("ACCESS_DENIED\n");
1093 return;
1094 }
1095
1096 if (res != ERROR_SUCCESS) {
1097 /* unable to open the registry: skip the test */
1098 skip("got %d\n", res);
1099 return;
1100 }
1101
1102 org_value[0] = '\0';
1103 needed = sizeof(org_value)-1 ;
1104 res = RegQueryValueExA(hroot, TransmissionRetryTimeoutA, NULL, NULL, (PBYTE) org_value, &needed);
1106 "returned %u and %u for \"%s\" (expected ERROR_SUCCESS or "
1107 "ERROR_FILE_NOT_FOUND)\n", res, needed, org_value);
1108
1109 /* Get default value (documented as 90 in the w2k reskit, but that is wrong) */
1111 needed = (DWORD) 0xdeadbeef;
1112 buffer[0] = 0xdeadbeef;
1113 SetLastError(0xdeadbeef);
1114 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1115 ok( (res == ERROR_SUCCESS) && (buffer[0] == 45),
1116 "returned %d with %u and %u for %d\n (expected ERROR_SUCCESS "
1117 "for '45')\n", res, GetLastError(), needed, buffer[0]);
1118
1119 /* the default timeout is returned, when the value is empty */
1121 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", GetLastError());
1122 needed = (DWORD) 0xdeadbeef;
1123 buffer[0] = 0xdeadbeef;
1124 SetLastError(0xdeadbeef);
1125 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1126 ok( (res == ERROR_SUCCESS) && (buffer[0] == 45),
1127 "returned %d with %u and %u for %d\n (expected ERROR_SUCCESS "
1128 "for '45')\n", res, GetLastError(), needed, buffer[0]);
1129
1130 /* the dialog is limited (1 - 999999), but that is done somewhere else */
1132 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", GetLastError());
1133 needed = (DWORD) 0xdeadbeef;
1134 buffer[0] = 0xdeadbeef;
1135 SetLastError(0xdeadbeef);
1136 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1137 ok( (res == ERROR_SUCCESS) && (buffer[0] == 0),
1138 "returned %d with %u and %u for %d\n (expected ERROR_SUCCESS "
1139 "for '0')\n", res, GetLastError(), needed, buffer[0]);
1140
1141
1143 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", GetLastError());
1144 needed = (DWORD) 0xdeadbeef;
1145 buffer[0] = 0xdeadbeef;
1146 SetLastError(0xdeadbeef);
1147 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1148 ok( (res == ERROR_SUCCESS) && (buffer[0] == 1),
1149 "returned %d with %u and %u for %d\n (expected 'ERROR_SUCCESS' "
1150 "for '1')\n", res, GetLastError(), needed, buffer[0]);
1151
1153 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", GetLastError());
1154 needed = (DWORD) 0xdeadbeef;
1155 buffer[0] = 0xdeadbeef;
1156 SetLastError(0xdeadbeef);
1157 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1158 ok( (res == ERROR_SUCCESS) && (buffer[0] == 999999),
1159 "returned %d with %u and %u for %d\n (expected ERROR_SUCCESS "
1160 "for '999999')\n", res, GetLastError(), needed, buffer[0]);
1161
1162
1164 ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", GetLastError());
1165 needed = (DWORD) 0xdeadbeef;
1166 buffer[0] = 0xdeadbeef;
1167 SetLastError(0xdeadbeef);
1168 res = pXcvDataPort(hXcv, cmd_GetTransmissionRetryTimeoutW, NULL, 0, (PBYTE) buffer, len, &needed);
1169 ok( (res == ERROR_SUCCESS) && (buffer[0] == 1000000),
1170 "returned %d with %u and %u for %d\n (expected ERROR_SUCCESS "
1171 "for '1000000')\n", res, GetLastError(), needed, buffer[0]);
1172
1173 /* restore the original value */
1175 if (org_value[0]) {
1176 res = RegSetValueExA(hroot, TransmissionRetryTimeoutA, 0, REG_SZ, (PBYTE)org_value, lstrlenA(org_value)+1);
1177 ok(res == ERROR_SUCCESS, "unable to restore original value (got %u): %s\n", res, org_value);
1178 }
1179
1180 RegCloseKey(hroot);
1181}
GLenum GLsizei len
Definition: glext.h:6722
static const CHAR emptyA[]
Definition: localmon.c:91
static const WCHAR cmd_GetTransmissionRetryTimeoutW[]
Definition: localmon.c:83

Referenced by START_TEST().

◆ test_XcvDataPort_MonitorUI()

static void test_XcvDataPort_MonitorUI ( void  )
static

Definition at line 1185 of file localmon.c.

1186{
1187 DWORD res;
1188 BYTE buffer[MAX_PATH + 2];
1189 DWORD needed;
1190 DWORD len;
1191
1192
1193 /* ask for needed size */
1194 needed = (DWORD) 0xdeadbeef;
1195 SetLastError(0xdeadbeef);
1196 res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, NULL, 0, &needed);
1198 skip("'MonitorUI' nor supported\n");
1199 return;
1200 }
1201 ok( (res == ERROR_INSUFFICIENT_BUFFER) && (needed <= MAX_PATH),
1202 "returned %d with %u and 0x%x (expected 'ERROR_INSUFFICIENT_BUFFER' "
1203 " and '<= MAX_PATH')\n", res, GetLastError(), needed);
1204
1205 if (needed > MAX_PATH) {
1206 skip("buffer overflow (%u)\n", needed);
1207 return;
1208 }
1209 len = needed;
1210
1211 /* the command is required */
1212 needed = (DWORD) 0xdeadbeef;
1213 SetLastError(0xdeadbeef);
1214 res = pXcvDataPort(hXcv, emptyW, NULL, 0, NULL, 0, &needed);
1215 ok( res == ERROR_INVALID_PARAMETER, "returned %d with %u and 0x%x "
1216 "(expected 'ERROR_INVALID_PARAMETER')\n", res, GetLastError(), needed);
1217
1218 if (0) {
1219 /* crash with native localspl.dll (w2k+xp) */
1220 pXcvDataPort(hXcv, NULL, NULL, 0, buffer, MAX_PATH, &needed);
1221 pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, NULL, len, &needed);
1222 pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len, NULL);
1223 }
1224
1225
1226 /* hXcv is ignored for the command "MonitorUI" */
1227 needed = (DWORD) 0xdeadbeef;
1228 SetLastError(0xdeadbeef);
1229 res = pXcvDataPort(NULL, cmd_MonitorUIW, NULL, 0, buffer, len, &needed);
1230 ok( res == ERROR_SUCCESS, "returned %d with %u and 0x%x "
1231 "(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
1232
1233
1234 /* pszDataName is case-sensitive */
1235 memset(buffer, 0, len);
1236 needed = (DWORD) 0xdeadbeef;
1237 SetLastError(0xdeadbeef);
1238 res = pXcvDataPort(hXcv, cmd_MonitorUI_lcaseW, NULL, 0, buffer, len, &needed);
1239 ok( res == ERROR_INVALID_PARAMETER, "returned %d with %u and 0x%x "
1240 "(expected 'ERROR_INVALID_PARAMETER')\n", res, GetLastError(), needed);
1241
1242 /* off by one: larger */
1243 needed = (DWORD) 0xdeadbeef;
1244 SetLastError(0xdeadbeef);
1245 res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len+1, &needed);
1246 ok( res == ERROR_SUCCESS, "returned %d with %u and 0x%x "
1247 "(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
1248
1249
1250 /* off by one: smaller */
1251 /* the buffer is not modified for NT4, w2k, XP */
1252 needed = (DWORD) 0xdeadbeef;
1253 SetLastError(0xdeadbeef);
1254 res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len-1, &needed);
1255 ok( res == ERROR_INSUFFICIENT_BUFFER, "returned %d with %u and 0x%x "
1256 "(expected 'ERROR_INSUFFICIENT_BUFFER')\n", res, GetLastError(), needed);
1257
1258 /* Normal use. The DLL-Name without a Path is returned */
1259 memset(buffer, 0, len);
1260 needed = (DWORD) 0xdeadbeef;
1261 SetLastError(0xdeadbeef);
1262 res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len, &needed);
1263 ok( res == ERROR_SUCCESS, "returned %d with %u and 0x%x "
1264 "(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
1265
1266
1267 /* small check without access-rights: */
1268 if (!hXcv_noaccess) return;
1269
1270 /* The ACCESS_MASK is ignored for "MonitorUI" */
1271 memset(buffer, 0, len);
1272 needed = (DWORD) 0xdeadbeef;
1273 SetLastError(0xdeadbeef);
1274 res = pXcvDataPort(hXcv_noaccess, cmd_MonitorUIW, NULL, 0, buffer, sizeof(buffer), &needed);
1275 ok( res == ERROR_SUCCESS, "returned %d with %u and 0x%x "
1276 "(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
1277}
static const WCHAR cmd_MonitorUIW[]
Definition: localmon.c:87
static const WCHAR cmd_MonitorUI_lcaseW[]
Definition: localmon.c:88
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_XcvDataPort_PortIsValid()

static void test_XcvDataPort_PortIsValid ( void  )
static

Definition at line 1281 of file localmon.c.

1282{
1283 DWORD res;
1284 DWORD needed;
1285
1286 /* normal use: "LPT1:" */
1287 needed = (DWORD) 0xdeadbeef;
1288 SetLastError(0xdeadbeef);
1289 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed);
1291 skip("'PostIsValid' not supported\n");
1292 return;
1293 }
1294 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
1295
1296
1297 if (0) {
1298 /* crash with native localspl.dll (w2k+xp) */
1299 pXcvDataPort(hXcv, cmd_PortIsValidW, NULL, 0, NULL, 0, &needed);
1300 }
1301
1302
1303 /* hXcv is ignored for the command "PortIsValid" */
1304 needed = (DWORD) 0xdeadbeef;
1305 SetLastError(0xdeadbeef);
1306 res = pXcvDataPort(NULL, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, NULL);
1307 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
1308
1309 /* needed is ignored */
1310 needed = (DWORD) 0xdeadbeef;
1311 SetLastError(0xdeadbeef);
1312 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, NULL);
1313 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
1314
1315
1316 /* cbInputData is ignored */
1317 needed = (DWORD) 0xdeadbeef;
1318 SetLastError(0xdeadbeef);
1319 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, 0, NULL, 0, &needed);
1320 ok( res == ERROR_SUCCESS,
1321 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1322 res, GetLastError(), needed);
1323
1324 needed = (DWORD) 0xdeadbeef;
1325 SetLastError(0xdeadbeef);
1326 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, 1, NULL, 0, &needed);
1327 ok( res == ERROR_SUCCESS,
1328 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1329 res, GetLastError(), needed);
1330
1331 needed = (DWORD) 0xdeadbeef;
1332 SetLastError(0xdeadbeef);
1333 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W) -1, NULL, 0, &needed);
1334 ok( res == ERROR_SUCCESS,
1335 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1336 res, GetLastError(), needed);
1337
1338 needed = (DWORD) 0xdeadbeef;
1339 SetLastError(0xdeadbeef);
1340 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W) -2, NULL, 0, &needed);
1341 ok( res == ERROR_SUCCESS,
1342 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1343 res, GetLastError(), needed);
1344
1345
1346 /* an empty name is not allowed */
1347 needed = (DWORD) 0xdeadbeef;
1348 SetLastError(0xdeadbeef);
1349 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) emptyW, sizeof(emptyW), NULL, 0, &needed);
1351 "returned %d with %u and 0x%x (expected ERROR_PATH_NOT_FOUND)\n",
1352 res, GetLastError(), needed);
1353
1354
1355 /* a directory is not allowed */
1356 needed = (DWORD) 0xdeadbeef;
1357 SetLastError(0xdeadbeef);
1358 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) tempdirW, (lstrlenW(tempdirW) + 1) * sizeof(WCHAR), NULL, 0, &needed);
1359 /* XP(admin): ERROR_INVALID_NAME, XP(user): ERROR_PATH_NOT_FOUND, w2k ERROR_ACCESS_DENIED */
1361 (res == ERROR_ACCESS_DENIED), "returned %d with %u and 0x%x "
1362 "(expected ERROR_INVALID_NAME, ERROR_PATH_NOT_FOUND or ERROR_ACCESS_DENIED)\n",
1363 res, GetLastError(), needed);
1364
1365
1366 /* test more valid well known Ports: */
1367 needed = (DWORD) 0xdeadbeef;
1368 SetLastError(0xdeadbeef);
1369 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt2W, sizeof(portname_lpt2W), NULL, 0, &needed);
1370 ok( res == ERROR_SUCCESS,
1371 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1372 res, GetLastError(), needed);
1373
1374
1375 needed = (DWORD) 0xdeadbeef;
1376 SetLastError(0xdeadbeef);
1377 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_com1W, sizeof(portname_com1W), NULL, 0, &needed);
1378 ok( res == ERROR_SUCCESS,
1379 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1380 res, GetLastError(), needed);
1381
1382
1383 needed = (DWORD) 0xdeadbeef;
1384 SetLastError(0xdeadbeef);
1385 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_com2W, sizeof(portname_com2W), NULL, 0, &needed);
1386 ok( res == ERROR_SUCCESS,
1387 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1388 res, GetLastError(), needed);
1389
1390
1391 needed = (DWORD) 0xdeadbeef;
1392 SetLastError(0xdeadbeef);
1393 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_fileW, sizeof(portname_fileW), NULL, 0, &needed);
1394 ok( res == ERROR_SUCCESS,
1395 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1396 res, GetLastError(), needed);
1397
1398
1399 /* a normal, writable file is allowed */
1400 needed = (DWORD) 0xdeadbeef;
1401 SetLastError(0xdeadbeef);
1402 res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, &needed);
1403 ok( res == ERROR_SUCCESS,
1404 "returned %d with %u and 0x%x (expected ERROR_SUCCESS)\n",
1405 res, GetLastError(), needed);
1406
1407
1408 /* small check without access-rights: */
1409 if (!hXcv_noaccess) return;
1410
1411 /* The ACCESS_MASK from XcvOpenPort is ignored in "PortIsValid" */
1412 needed = (DWORD) 0xdeadbeef;
1413 SetLastError(0xdeadbeef);
1414 res = pXcvDataPort(hXcv_noaccess, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed);
1415 ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
1416
1417}
#define ERROR_INVALID_NAME
Definition: compat.h:103
static const WCHAR cmd_PortIsValidW[]
Definition: localmon.c:89
static WCHAR portname_com2W[]
Definition: localmon.c:113
static WCHAR portname_lpt2W[]
Definition: localmon.c:117
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by START_TEST().

◆ test_XcvOpenPort()

static void test_XcvOpenPort ( void  )
static

Definition at line 1421 of file localmon.c.

1422{
1423 DWORD res;
1424 HANDLE hXcv2;
1425
1426
1427 if (0)
1428 {
1429 /* crash with native localspl.dll (w2k+xp) */
1430 pXcvOpenPort(NULL, SERVER_ACCESS_ADMINISTER, &hXcv2);
1431 pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, NULL);
1432 }
1433
1434
1435 /* The returned handle is the result from a previous "spoolss.dll,DllAllocSplMem" */
1436 SetLastError(0xdeadbeef);
1437 hXcv2 = (HANDLE) 0xdeadbeef;
1438 res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv2);
1439 ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
1440 if (res) pXcvClosePort(hXcv2);
1441
1442
1443 /* The ACCESS_MASK is not checked in XcvOpenPort */
1444 SetLastError(0xdeadbeef);
1445 hXcv2 = (HANDLE) 0xdeadbeef;
1446 res = pXcvOpenPort(emptyW, 0, &hXcv2);
1447 ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
1448 if (res) pXcvClosePort(hXcv2);
1449
1450
1451 /* A copy of pszObject is saved in the Memory-Block */
1452 SetLastError(0xdeadbeef);
1453 hXcv2 = (HANDLE) 0xdeadbeef;
1454 res = pXcvOpenPort(portname_lpt1W, SERVER_ALL_ACCESS, &hXcv2);
1455 ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
1456 if (res) pXcvClosePort(hXcv2);
1457
1458 SetLastError(0xdeadbeef);
1459 hXcv2 = (HANDLE) 0xdeadbeef;
1460 res = pXcvOpenPort(portname_fileW, SERVER_ALL_ACCESS, &hXcv2);
1461 ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
1462 if (res) pXcvClosePort(hXcv2);
1463
1464}
#define SERVER_ALL_ACCESS
Definition: winspool.h:1375

Referenced by START_TEST().

Variable Documentation

◆ ACCESS_MASK

Definition at line 68 of file localmon.c.

◆ cmd_AddPortW

const WCHAR cmd_AddPortW[] = {'A','d','d','P','o','r','t',0}
static

Definition at line 78 of file localmon.c.

Referenced by test_XcvDataPort_AddPort().

◆ cmd_ConfigureLPTPortCommandOKW

const WCHAR cmd_ConfigureLPTPortCommandOKW[]
static
Initial value:
= {'C','o','n','f','i','g','u','r','e',
'L','P','T','P','o','r','t',
'C','o','m','m','a','n','d','O','K',0}

Definition at line 79 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK().

◆ cmd_DeletePortW

const WCHAR cmd_DeletePortW[] = {'D','e','l','e','t','e','P','o','r','t',0}
static

Definition at line 82 of file localmon.c.

Referenced by delete_port(), test_XcvDataPort_AddPort(), and test_XcvDataPort_DeletePort().

◆ cmd_GetTransmissionRetryTimeoutW

const WCHAR cmd_GetTransmissionRetryTimeoutW[]
static
Initial value:
= {'G','e','t',
'T','r','a','n','s','m','i','s','s','i','o','n',
'R','e','t','r','y','T','i','m','e','o','u','t',0}

Definition at line 83 of file localmon.c.

Referenced by test_XcvDataPort_GetTransmissionRetryTimeout().

◆ cmd_MonitorUI_lcaseW

const WCHAR cmd_MonitorUI_lcaseW[] = {'m','o','n','i','t','o','r','u','i',0}
static

Definition at line 88 of file localmon.c.

Referenced by test_XcvDataPort_MonitorUI().

◆ cmd_MonitorUIW

const WCHAR cmd_MonitorUIW[] = {'M','o','n','i','t','o','r','U','I',0}
static

Definition at line 87 of file localmon.c.

Referenced by test_XcvDataPort_MonitorUI().

◆ cmd_PortIsValidW

const WCHAR cmd_PortIsValidW[] = {'P','o','r','t','I','s','V','a','l','i','d',0}
static

Definition at line 89 of file localmon.c.

Referenced by test_XcvDataPort_PortIsValid().

◆ does_not_existW

WCHAR does_not_existW[] = {'d','o','e','s','_','n','o','t','_','e','x','i','s','t',0}
static

◆ DWORD

◆ emptyA

const CHAR emptyA[] = ""
static

Definition at line 91 of file localmon.c.

Referenced by test_XcvDataPort_GetTransmissionRetryTimeout().

◆ emptyW

◆ HANDLE

Definition at line 52 of file localmon.c.

Referenced by test_ClosePort(), test_OpenPort(), test_XcvClosePort(), and test_XcvOpenPort().

◆ have_com

WCHAR have_com[PORTNAME_MAXSIZE]
static

Definition at line 136 of file localmon.c.

Referenced by find_installed_ports(), test_ClosePort(), and test_OpenPort().

◆ have_file

WCHAR have_file[PORTNAME_MAXSIZE]
static

◆ have_lpt

WCHAR have_lpt[PORTNAME_MAXSIZE]
static

Definition at line 137 of file localmon.c.

Referenced by find_installed_ports(), test_ClosePort(), and test_OpenPort().

◆ hdll

HMODULE hdll
static

Definition at line 39 of file localmon.c.

Referenced by START_TEST().

◆ hlocalmon

HMODULE hlocalmon
static

Definition at line 40 of file localmon.c.

Referenced by START_TEST().

◆ hmon

◆ HWND

Definition at line 58 of file localmon.c.

◆ hXcv

◆ hXcv_noaccess

HANDLE hXcv_noaccess
static

Definition at line 74 of file localmon.c.

Referenced by START_TEST(), test_XcvDataPort_MonitorUI(), and test_XcvDataPort_PortIsValid().

◆ LocalPortW

WCHAR LocalPortW[] = {'L','o','c','a','l',' ','P','o','r','t',0}
static

Definition at line 93 of file localmon.c.

Referenced by test_AddPortEx().

◆ LPBYTE

Definition at line 47 of file localmon.c.

◆ LPCOMMTIMEOUTS

Definition at line 67 of file localmon.c.

◆ LPCWSTR

Definition at line 69 of file localmon.c.

◆ LPDWORD

Definition at line 47 of file localmon.c.

◆ LPHANDLE

Definition at line 43 of file localmon.c.

◆ LPWSTR

Definition at line 48 of file localmon.c.

◆ Monitors_LocalPortW

WCHAR Monitors_LocalPortW[]
static
Initial value:
= {
'S','y','s','t','e','m','\\',
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
'C','o','n','t','r','o','l','\\',
'P','r','i','n','t','\\',
'M','o','n','i','t','o','r','s','\\',
'L','o','c','a','l',' ','P','o','r','t',0}

Definition at line 94 of file localmon.c.

Referenced by START_TEST(), and test_InitializePrintMonitor().

◆ monreg

MONITORREG monreg
static
Initial value:
=
{
sizeof(MONITORREG),
}
static LONG WINAPI CloseKey(HANDLE hcKey, HANDLE hSpooler)
Definition: localmon.c:157
static LONG WINAPI CreateKey(HANDLE hcKey, LPCWSTR pszSubKey, DWORD dwOptions, REGSAM samDesired, PSECURITY_ATTRIBUTES pSecurityAttributes, PHANDLE phckResult, PDWORD pdwDisposition, HANDLE hSpooler)
Definition: localmon.c:142
static LONG WINAPI QueryValue(HANDLE hcKey, LPCWSTR pszValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
Definition: localmon.c:206
static LONG WINAPI OpenKey(HANDLE hcKey, LPCWSTR pszSubKey, REGSAM samDesired, PHANDLE phkResult, HANDLE hSpooler)
Definition: localmon.c:150
static LONG WINAPI QueryInfoKey(HANDLE hcKey, PDWORD pcSubKeys, PDWORD pcbKey, PDWORD pcValues, PDWORD pcbValue, PDWORD pcbData, PDWORD pcbSecurityDescriptor, PFILETIME pftLastWriteTime, HANDLE hSpooler)
Definition: localmon.c:176
static LONG WINAPI EnumValue(HANDLE hcKey, DWORD dwIndex, LPWSTR pszValue, PDWORD pcbValue, PDWORD pType, PBYTE pData, PDWORD pcbData, HANDLE hSpooler)
Definition: localmon.c:198
static LONG WINAPI EnumKey(HANDLE hcKey, DWORD dwIndex, LPWSTR pszName, PDWORD pcchName, PFILETIME pftLastWriteTime, HANDLE hSpooler)
Definition: localmon.c:169
static LONG WINAPI DeleteKey(HANDLE hcKey, LPCWSTR pszSubKey, HANDLE hSpooler)
Definition: localmon.c:163
@ SetValue
Definition: shader.c:1968
int DeleteValue()
Definition: movefile.cpp:60
struct _MONITORREG MONITORREG

Definition at line 212 of file localmon.c.

Referenced by START_TEST(), and test_InitializePrintMonitor2().

◆ num_0A

const CHAR num_0A[] = "0"
static

◆ num_0W

WCHAR num_0W[] = {'0',0}
static

Definition at line 103 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK().

◆ num_1000000A

const CHAR num_1000000A[] = "1000000"
static

◆ num_1000000W

WCHAR num_1000000W[] = {'1','0','0','0','0','0','0',0}
static

Definition at line 109 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK().

◆ num_1A

const CHAR num_1A[] = "1"
static

◆ num_1W

WCHAR num_1W[] = {'1',0}
static

Definition at line 105 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK().

◆ num_999999A

const CHAR num_999999A[] = "999999"
static

◆ num_999999W

WCHAR num_999999W[] = {'9','9','9','9','9','9',0}
static

Definition at line 107 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK().

◆ PBYTE

Definition at line 70 of file localmon.c.

◆ PDWORD

Definition at line 70 of file localmon.c.

◆ PHANDLE

Definition at line 49 of file localmon.c.

◆ pm

◆ pm2

LPMONITOR2 pm2
static

◆ portname_com1W

WCHAR portname_com1W[] = {'C','O','M','1',':',0}
static

Definition at line 112 of file localmon.c.

Referenced by test_ConfigurePort(), and test_XcvDataPort_PortIsValid().

◆ portname_com2W

WCHAR portname_com2W[] = {'C','O','M','2',':',0}
static

Definition at line 113 of file localmon.c.

Referenced by test_XcvDataPort_PortIsValid().

◆ portname_comW

const WCHAR portname_comW[] = {'C','O','M',0}
static

Definition at line 111 of file localmon.c.

Referenced by find_installed_ports().

◆ portname_fileW

WCHAR portname_fileW[] = {'F','I','L','E',':',0}
static

◆ portname_lpt1W

WCHAR portname_lpt1W[] = {'L','P','T','1',':',0}
static

◆ portname_lpt2W

WCHAR portname_lpt2W[] = {'L','P','T','2',':',0}
static

Definition at line 117 of file localmon.c.

Referenced by test_XcvDataPort_PortIsValid().

◆ portname_lptW

const WCHAR portname_lptW[] = {'L','P','T',0}
static

Definition at line 115 of file localmon.c.

Referenced by find_installed_ports().

◆ server_does_not_existW

WCHAR server_does_not_existW[] = {'\\','\\','d','o','e','s','_','n','o','t','_','e','x','i','s','t',0}
static

Definition at line 118 of file localmon.c.

Referenced by test_EnumPorts().

◆ tempdirW

WCHAR tempdirW[MAX_PATH]
static

Definition at line 130 of file localmon.c.

Referenced by START_TEST(), and test_XcvDataPort_PortIsValid().

◆ tempfileW

◆ TransmissionRetryTimeoutA

const CHAR TransmissionRetryTimeoutA[]
static
Initial value:
= {'T','r','a','n','s','m','i','s','s','i','o','n',
'R','e','t','r','y','T','i','m','e','o','u','t',0}

Definition at line 120 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK(), and test_XcvDataPort_GetTransmissionRetryTimeout().

◆ wineW

WCHAR wineW[] = {'W','i','n','e',0}
static

◆ WinNT_CV_WindowsA

const CHAR WinNT_CV_WindowsA[]
static
Initial value:
= {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'W','i','n','d','o','w','s',0}

Definition at line 123 of file localmon.c.

Referenced by test_XcvDataPort_ConfigureLPTPortCommandOK(), and test_XcvDataPort_GetTransmissionRetryTimeout().