ReactOS  0.4.15-dev-3456-g4a17d4b
ports.c File Reference
#include "precomp.h"
#include <marshalling/ports.h>
Include dependency graph for ports.c:

Go to the source code of this file.

Classes

struct  _MONITORUIDATA
 
struct  _PORTTHREADINFO
 

Typedefs

typedef struct _MONITORUIDATA MONITORUIDATA
 
typedef struct _MONITORUIDATAPMONITORUIDATA
 
typedef DWORD(* PPfpFunction) (LPWSTR, ULONG_PTR, LPWSTR)
 
typedef struct _PORTTHREADINFO PORTTHREADINFO
 
typedef struct _PORTTHREADINFOPPORTTHREADINFO
 

Functions

VOID WINAPI IntPortThread (PPORTTHREADINFO pPortThreadInfo)
 
BOOL WINAPI StartPortThread (LPWSTR pName, HWND hWnd, LPWSTR pPortName, PPfpFunction fpFunction)
 
BOOL WINAPI GetMonitorUIFullName (PWSTR pDeviceName, PWSTR *pModuleName)
 
BOOL WINAPI GetMonitorUIActivationContext (PWSTR pDeviceName, PMONITORUIDATA pmuid)
 
VOID FASTCALL FreeMonitorUI (PMONITORUIDATA pmuid)
 
BOOL FASTCALL StrNCatBuff (PWSTR ptr, size_t Size, PWSTR args,...)
 
PWSTR WINAPI ConstructXcvName (PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName)
 
DWORD WINAPI GetMonitorUI (PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName, PMONITORUI *pmui, PMONITORUIDATA *ppmuid)
 
BOOL WINAPI AddPortA (PSTR pName, HWND hWnd, PSTR pMonitorName)
 
BOOL WINAPI AddPortExW (PWSTR pName, DWORD Level, PBYTE lpBuffer, PWSTR lpMonitorName)
 
BOOL WINAPI AddPortExA (PSTR pName, DWORD Level, PBYTE lpBuffer, PSTR lpMonitorName)
 
BOOL WINAPI AddPortW (PWSTR pName, HWND hWnd, PWSTR pMonitorName)
 
BOOL WINAPI ConfigurePortA (PSTR pName, HWND hWnd, PSTR pPortName)
 
BOOL WINAPI ConfigurePortW (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI DeletePortA (PSTR pName, HWND hWnd, PSTR pPortName)
 
BOOL WINAPI DeletePortW (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI EnumPortsA (PSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI EnumPortsW (PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI SetPortA (PSTR pName, PSTR pPortName, DWORD dwLevel, PBYTE pPortInfo)
 
BOOL WINAPI SetPortW (PWSTR pName, PWSTR pPortName, DWORD dwLevel, PBYTE pPortInfo)
 

Typedef Documentation

◆ MONITORUIDATA

◆ PMONITORUIDATA

◆ PORTTHREADINFO

◆ PPfpFunction

typedef DWORD(* PPfpFunction) (LPWSTR, ULONG_PTR, LPWSTR)

Definition at line 20 of file ports.c.

◆ PPORTTHREADINFO

Function Documentation

◆ AddPortA()

BOOL WINAPI AddPortA ( PSTR  pName,
HWND  hWnd,
PSTR  pMonitorName 
)

Definition at line 420 of file ports.c.

421 {
422  LPWSTR nameW = NULL;
423  LPWSTR monitorW = NULL;
424  DWORD len;
425  BOOL res;
426 
427  TRACE("AddPortA(%s, %p, %s)\n",debugstr_a(pName), hWnd, debugstr_a(pMonitorName));
428 
429  if (pName)
430  {
431  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
432  nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
434  }
435 
436  if (pMonitorName)
437  {
438  len = MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, NULL, 0);
439  monitorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
440  MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, monitorW, len);
441  }
442 
444 
445  if (nameW) HeapFree(GetProcessHeap(), 0, nameW);
447 
448  return res;
449 }
#define CP_ACP
Definition: compat.h:109
HWND hWnd
Definition: settings.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR nameW[]
Definition: main.c:46
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI AddPortW(PWSTR pName, HWND hWnd, PWSTR pMonitorName)
Definition: ports.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR monitorW[]
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ AddPortExA()

BOOL WINAPI AddPortExA ( PSTR  pName,
DWORD  Level,
PBYTE  lpBuffer,
PSTR  lpMonitorName 
)

Definition at line 501 of file ports.c.

502 {
503  PORT_INFO_1W pi1W;
504  PORT_INFO_1A * pi1A;
505  LPWSTR nameW = NULL;
506  LPWSTR monitorW = NULL;
507  DWORD len;
508  BOOL res = FALSE;
509  WINSPOOL_PORT_INFO_FF *pPortInfoFF, PortInfoFF;
510 
511  pi1A = (PORT_INFO_1A *)lpBuffer;
512  pPortInfoFF = (WINSPOOL_PORT_INFO_FF*)lpBuffer;
513 
514  FIXME("AddPortExA(%s, %d, %p, %s): %s\n", debugstr_a(pName), Level, lpBuffer, debugstr_a(lpMonitorName), debugstr_a(pi1A ? pi1A->pName : NULL));
515 
516  if ( !lpBuffer || !lpMonitorName )
517  {
519  return FALSE;
520  }
521 
522  if (pName)
523  {
524  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
525  nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
527  }
528 
529  if (lpMonitorName)
530  {
531  len = MultiByteToWideChar(CP_ACP, 0, lpMonitorName, -1, NULL, 0);
532  monitorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
533  MultiByteToWideChar(CP_ACP, 0, lpMonitorName, -1, monitorW, len);
534  }
535 
536  pi1W.pName = NULL;
537  ZeroMemory( &PortInfoFF, sizeof(WINSPOOL_PORT_INFO_FF));
538 
539  switch ( Level )
540  {
541  case 1:
542  if ( pi1A->pName )
543  {
544  len = MultiByteToWideChar(CP_ACP, 0, pi1A->pName, -1, NULL, 0);
545  pi1W.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
546  MultiByteToWideChar(CP_ACP, 0, pi1A->pName, -1, pi1W.pName, len);
547  }
548  break;
549 
550  case 0xFFFFFFFF:
551  //
552  // Remember the calling parameter is Ansi.
553  //
554  if ( !pPortInfoFF->pPortName || !(PCHAR)pPortInfoFF->pPortName )
555  {
557  goto Cleanup;
558  }
559 
560  len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pPortInfoFF->pPortName, -1, NULL, 0);
561  PortInfoFF.pPortName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
562  MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pPortInfoFF->pPortName, -1, (LPWSTR)PortInfoFF.pPortName, len);
563 
564  PortInfoFF.cbMonitorData = pPortInfoFF->cbMonitorData;
565  PortInfoFF.pMonitorData = pPortInfoFF->pMonitorData;
566  break;
567 
568  default:
569  ERR("Level = %d, unsupported!\n", Level);
571  goto Cleanup;
572  }
573 
574  res = AddPortExW( nameW, Level, Level == 1 ? (PBYTE)&pi1W : (PBYTE)&PortInfoFF, monitorW );
575 
576 Cleanup:
577  if (nameW) HeapFree(GetProcessHeap(), 0, nameW);
579  if (pi1W.pName) HeapFree(GetProcessHeap(), 0, pi1W.pName);
580  if (PortInfoFF.pPortName) HeapFree(GetProcessHeap(), 0, PortInfoFF.pPortName);
581 
582  return res;
583 }
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define ZeroMemory
Definition: winbase.h:1664
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
BOOL WINAPI AddPortExW(PWSTR pName, DWORD Level, PBYTE lpBuffer, PWSTR lpMonitorName)
Definition: ports.c:11
const char * LPCSTR
Definition: xmlstorage.h:183
static const WCHAR nameW[]
Definition: main.c:46
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR monitorW[]
GLuint res
Definition: glext.h:9613
LPSTR pName
Definition: winspool.h:746
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:594
LPWSTR pName
Definition: winspool.h:749

◆ AddPortExW()

BOOL WINAPI AddPortExW ( PWSTR  pName,
DWORD  Level,
PBYTE  lpBuffer,
PWSTR  lpMonitorName 
)

Definition at line 452 of file ports.c.

453 {
454  DWORD dwErrorCode;
455  WINSPOOL_PORT_CONTAINER PortInfoContainer;
456  WINSPOOL_PORT_VAR_CONTAINER PortVarContainer;
457  WINSPOOL_PORT_INFO_FF *pPortInfoFF;
458 
459  FIXME("AddPortExW(%S, %lu, %p, %S)\n", pName, Level, lpBuffer, lpMonitorName);
460 
461  switch (Level)
462  {
463  case 1:
464  // FIXME!!!! Only Level 1 is supported? See note in wine winspool test info.c : line 575. It's just not supported here.
465  PortInfoContainer.PortInfo.pPortInfo1 = (WINSPOOL_PORT_INFO_1*)lpBuffer;
466  PortInfoContainer.Level = Level;
467  PortVarContainer.cbMonitorData = 0;
468  PortVarContainer.pMonitorData = NULL;
469  break;
470 
471  case 0xFFFFFFFF:
472  pPortInfoFF = (WINSPOOL_PORT_INFO_FF*)lpBuffer;
473  PortInfoContainer.PortInfo.pPortInfoFF = pPortInfoFF;
474  PortInfoContainer.Level = Level;
475  PortVarContainer.cbMonitorData = pPortInfoFF->cbMonitorData;
476  PortVarContainer.pMonitorData = pPortInfoFF->pMonitorData;
477  break;
478 
479  default:
480  ERR("Level = %d, unsupported!\n", Level);
482  return FALSE;
483  }
484 
485  // Do the RPC call
487  {
488  dwErrorCode = _RpcAddPortEx(pName, &PortInfoContainer, &PortVarContainer, lpMonitorName);
489  }
491  {
492  dwErrorCode = RpcExceptionCode();
493  }
494  RpcEndExcept;
495 
496  SetLastError(dwErrorCode);
497  return (dwErrorCode == ERROR_SUCCESS);
498 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
WINSPOOL_PORT_INFO_1 * pPortInfo1
Definition: winspool.idl:670
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
DWORD _RpcAddPortEx(WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER *pPortContainer, WINSPOOL_PORT_VAR_CONTAINER *pPortVarContainer, WCHAR *pMonitorName)
Definition: ports.c:33
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExceptionCode()
Definition: rpc.h:132
static LPSTR pName
Definition: security.c:75
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
union _WINSPOOL_PORT_CONTAINER::@3356 PortInfo
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WINSPOOL_PORT_INFO_FF * pPortInfoFF
Definition: winspool.idl:676
#define RpcExcept(expr)
Definition: rpc.h:127

◆ AddPortW()

BOOL WINAPI AddPortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pMonitorName 
)

Definition at line 586 of file ports.c.

587 {
588  DWORD SessionId, dwErrorCode = 0;
589  PMONITORUIDATA pmuid;
590  PMONITORUI pmui = NULL;
591  BOOL Ret = FALSE;
592 
593  FIXME("AddPortW(%S, %p, %S)\n", pName, hWnd, pMonitorName);
594 
595  dwErrorCode = GetMonitorUI( pName, pMonitorName, L"XcvMonitor", &pmui, &pmuid );
596  FIXME("AddPortW Error %d\n",dwErrorCode);
597  if (dwErrorCode != ERROR_SUCCESS )
598  {
599  if ( dwErrorCode == ERROR_NOT_SUPPORTED ||
600  dwErrorCode == ERROR_MOD_NOT_FOUND ||
601  dwErrorCode == ERROR_INVALID_PRINT_MONITOR ||
602  dwErrorCode == ERROR_UNKNOWN_PORT ||
603  dwErrorCode == ERROR_INVALID_PRINTER_NAME )
604  {
605  if ( ProcessIdToSessionId( GetCurrentProcessId(), &SessionId ) && SessionId ) // Looking if this is remote.
606  {
607  dwErrorCode = ERROR_NOT_SUPPORTED;
608  }
609  else
610  {
611  Ret = StartPortThread( pName, hWnd, pMonitorName, (PPfpFunction)_RpcAddPort );
612  FIXME("AddPortW return StartPortThread\n");
613  dwErrorCode = GetLastError();
614  }
615  }
616  }
617  else
618  {
619  Ret = (*pmui->pfnAddPortUI)( pName, hWnd, pMonitorName, NULL );
620  }
621 
622  SetLastError(dwErrorCode);
623  FreeMonitorUI( pmuid );
624 
625  return Ret;
626 }
DWORD WINAPI GetMonitorUI(PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName, PMONITORUI *pmui, PMONITORUIDATA *ppmuid)
Definition: ports.c:288
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD _RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pMonitorName)
Definition: ports.c:12
ULONG SessionId
Definition: dllmain.c:28
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
DWORD(* PPfpFunction)(LPWSTR, ULONG_PTR, LPWSTR)
Definition: ports.c:20
#define ERROR_INVALID_PRINT_MONITOR
Definition: winerror.h:1212
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_UNKNOWN_PORT
Definition: winerror.h:1103
BOOL WINAPI ProcessIdToSessionId(IN DWORD dwProcessId, OUT PDWORD pSessionId)
Definition: proc.c:2176
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
VOID FASTCALL FreeMonitorUI(PMONITORUIDATA pmuid)
Definition: ports.c:183
#define ERROR_INVALID_PRINTER_NAME
Definition: winerror.h:1108
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
BOOL WINAPI StartPortThread(LPWSTR pName, HWND hWnd, LPWSTR pPortName, PPfpFunction fpFunction)
Definition: ports.c:55
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158

◆ ConfigurePortA()

BOOL WINAPI ConfigurePortA ( PSTR  pName,
HWND  hWnd,
PSTR  pPortName 
)

Definition at line 629 of file ports.c.

630 {
631  LPWSTR nameW = NULL;
632  LPWSTR portW = NULL;
633  INT len;
634  DWORD res;
635 
636  TRACE("ConfigurePortA(%s, %p, %s)\n", debugstr_a(pName), hWnd, debugstr_a(pPortName));
637 
638  /* convert servername to unicode */
639  if (pName)
640  {
641  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
642  nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
644  }
645 
646  /* convert portname to unicode */
647  if (pPortName)
648  {
649  len = MultiByteToWideChar(CP_ACP, 0, pPortName, -1, NULL, 0);
650  portW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
651  MultiByteToWideChar(CP_ACP, 0, pPortName, -1, portW, len);
652  }
653 
654  res = ConfigurePortW(nameW, hWnd, portW);
655 
656  if (nameW) HeapFree(GetProcessHeap(), 0, nameW);
657  if (portW) HeapFree(GetProcessHeap(), 0, portW);
658 
659  return res;
660 }
BOOL WINAPI ConfigurePortW(PWSTR pName, HWND hWnd, PWSTR pPortName)
Definition: ports.c:81
#define CP_ACP
Definition: compat.h:109
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:58
static const WCHAR nameW[]
Definition: main.c:46
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ ConfigurePortW()

BOOL WINAPI ConfigurePortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pPortName 
)

Definition at line 663 of file ports.c.

664 {
665  DWORD SessionId, dwErrorCode = 0;
666  PMONITORUIDATA pmuid;
667  PMONITORUI pmui = NULL;
668  BOOL Ret = FALSE;
669 
670  FIXME("ConfigurePortW(%S, %p, %S)\n", pName, hWnd, pPortName);
671 
672  dwErrorCode = GetMonitorUI( pName, pPortName, L"XcvPort", &pmui, &pmuid );
673 
674  if (dwErrorCode != ERROR_SUCCESS )
675  {
676  if ( dwErrorCode == ERROR_NOT_SUPPORTED ||
677  dwErrorCode == ERROR_MOD_NOT_FOUND ||
678  dwErrorCode == ERROR_INVALID_PRINT_MONITOR ||
679  dwErrorCode == ERROR_UNKNOWN_PORT ||
680  dwErrorCode == ERROR_INVALID_PRINTER_NAME )
681  {
682  if ( ProcessIdToSessionId( GetCurrentProcessId(), &SessionId ) && SessionId ) // Looking if this is remote.
683  {
684  dwErrorCode = ERROR_NOT_SUPPORTED;
685  }
686  else
687  {
689  dwErrorCode = GetLastError();
690  }
691  }
692  }
693  else
694  {
695  Ret = (*pmui->pfnConfigurePortUI)( pName, hWnd, pPortName );
696  }
697 
698  SetLastError(dwErrorCode);
699  FreeMonitorUI( pmuid );
700 
701  return Ret;
702 }
DWORD WINAPI GetMonitorUI(PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName, PMONITORUI *pmui, PMONITORUIDATA *ppmuid)
Definition: ports.c:288
#define ERROR_SUCCESS
Definition: deptool.c:10
ULONG SessionId
Definition: dllmain.c:28
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
DWORD(* PPfpFunction)(LPWSTR, ULONG_PTR, LPWSTR)
Definition: ports.c:20
#define ERROR_INVALID_PRINT_MONITOR
Definition: winerror.h:1212
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_UNKNOWN_PORT
Definition: winerror.h:1103
BOOL WINAPI ProcessIdToSessionId(IN DWORD dwProcessId, OUT PDWORD pSessionId)
Definition: proc.c:2176
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
VOID FASTCALL FreeMonitorUI(PMONITORUIDATA pmuid)
Definition: ports.c:183
#define ERROR_INVALID_PRINTER_NAME
Definition: winerror.h:1108
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
DWORD _RpcConfigurePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
Definition: ports.c:74
BOOL WINAPI StartPortThread(LPWSTR pName, HWND hWnd, LPWSTR pPortName, PPfpFunction fpFunction)
Definition: ports.c:55
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158

◆ ConstructXcvName()

PWSTR WINAPI ConstructXcvName ( PWSTR  pName,
PWSTR  pMonitorPortName,
PWSTR  pXcvName 
)

Definition at line 234 of file ports.c.

235 {
236  BOOL Ret = FALSE;
237  PWSTR pwstr = NULL;
238  size_t sXcv, smpn = 0, Size = 0;
239 
240  if ( pName )
241  {
242  Size = wcslen( pName ) + 1;
243  }
244 
245  sXcv = wcslen( pXcvName ) + Size;
246 
247  if ( pMonitorPortName )
248  {
249  smpn = wcslen( pMonitorPortName );
250  }
251 
252  Size = sXcv + smpn + 3;
253 
254  pwstr = DllAllocSplMem( Size * sizeof(WCHAR) );
255 
256  memset( pwstr, 0, Size );
257 
258  if ( pwstr )
259  {
260  // The caller wants an Xcv handle and provided a string like:
261  // ", XcvMonitor Local Port"
262  // "\\COMPUTERNAME\, XcvMonitor Local Port"
263  // ", XcvPort LPT1:"
264  // "\\COMPUTERNAME\, XcvPort LPT1:"
265  //
266  // This produces; !pName ",XcvMonitor " or pName "\\COMPUTERNAME\XcvMonitor "
267  //
268  Ret = StrNCatBuff( pwstr,
269  Size,
270  pName ? pName : L"",
271  pName ? L"\\" : L",",
272  pXcvName,
273  L" ",
274  pMonitorPortName ? pMonitorPortName : L"",
275  NULL );
276  }
277 
278  if ( !Ret )
279  {
280  DllFreeSplMem( pwstr );
281  pwstr = NULL;
282  }
283 
284  return pwstr;
285 }
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL FASTCALL StrNCatBuff(PWSTR ptr, size_t Size, PWSTR args,...)
Definition: ports.c:208
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
#define memset(x, y, z)
Definition: compat.h:39

Referenced by GetMonitorUI().

◆ DeletePortA()

BOOL WINAPI DeletePortA ( PSTR  pName,
HWND  hWnd,
PSTR  pPortName 
)

Definition at line 705 of file ports.c.

706 {
707  LPWSTR nameW = NULL;
708  LPWSTR portW = NULL;
709  INT len;
710  DWORD res;
711 
712  FIXME("DeletePortA(%s, %p, %s)\n", debugstr_a(pName), hWnd, debugstr_a(pPortName));
713 
714  /* convert servername to unicode */
715  if (pName)
716  {
717  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
718  nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
720  }
721 
722  /* convert portname to unicode */
723  if (pPortName)
724  {
725  len = MultiByteToWideChar(CP_ACP, 0, pPortName, -1, NULL, 0);
726  portW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
727  MultiByteToWideChar(CP_ACP, 0, pPortName, -1, portW, len);
728  }
729 
730  res = DeletePortW(nameW, hWnd, portW);
731 
732  if (nameW) HeapFree(GetProcessHeap(), 0, nameW);
733  if (portW) HeapFree(GetProcessHeap(), 0, portW);
734 
735  return res;
736 }
#define CP_ACP
Definition: compat.h:109
HWND hWnd
Definition: settings.c:17
int32_t INT
Definition: typedefs.h:58
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR nameW[]
Definition: main.c:46
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI DeletePortW(PWSTR pName, HWND hWnd, PWSTR pPortName)
Definition: ports.c:114
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLuint res
Definition: glext.h:9613
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ DeletePortW()

BOOL WINAPI DeletePortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pPortName 
)

Definition at line 739 of file ports.c.

740 {
741  DWORD dwErrorCode = 0;
742  PMONITORUIDATA pmuid;
743  PMONITORUI pmui = NULL;
744  BOOL Ret = FALSE;
745 
746  FIXME("DeletePortW(%S, %p, %S)\n", pName, hWnd, pPortName);
747 
748  dwErrorCode = GetMonitorUI( pName, pPortName, L"XcvPort", &pmui, &pmuid );
749  FIXME("DeletePortW Error %d\n",dwErrorCode);
750  if (dwErrorCode != ERROR_SUCCESS )
751  {
752  if ( dwErrorCode == ERROR_NOT_SUPPORTED ||
753  dwErrorCode == ERROR_MOD_NOT_FOUND ||
754  dwErrorCode == ERROR_INVALID_PRINT_MONITOR ||
755  dwErrorCode == ERROR_UNKNOWN_PORT ||
756  dwErrorCode == ERROR_INVALID_PRINTER_NAME )
757  {
758  Ret = StartPortThread(pName, hWnd, pPortName, (PPfpFunction)_RpcDeletePort );
759  dwErrorCode = GetLastError();
760  }
761  }
762  else
763  {
764  Ret = (*pmui->pfnDeletePortUI)( pName, hWnd, pPortName );
765  }
766 
767  SetLastError(dwErrorCode);
768  FreeMonitorUI( pmuid );
769 
770  return Ret;
771 }
DWORD WINAPI GetMonitorUI(PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName, PMONITORUI *pmui, PMONITORUIDATA *ppmuid)
Definition: ports.c:288
#define ERROR_SUCCESS
Definition: deptool.c:10
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
DWORD(* PPfpFunction)(LPWSTR, ULONG_PTR, LPWSTR)
Definition: ports.c:20
#define ERROR_INVALID_PRINT_MONITOR
Definition: winerror.h:1212
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_UNKNOWN_PORT
Definition: winerror.h:1103
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
VOID FASTCALL FreeMonitorUI(PMONITORUIDATA pmuid)
Definition: ports.c:183
#define ERROR_INVALID_PRINTER_NAME
Definition: winerror.h:1108
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
DWORD _RpcDeletePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
Definition: ports.c:93
BOOL WINAPI StartPortThread(LPWSTR pName, HWND hWnd, LPWSTR pPortName, PPfpFunction fpFunction)
Definition: ports.c:55

◆ EnumPortsA()

BOOL WINAPI EnumPortsA ( PSTR  pName,
DWORD  Level,
PBYTE  pPorts,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 774 of file ports.c.

775 {
776  BOOL res;
777  LPBYTE bufferW = NULL;
778  LPWSTR nameW = NULL;
779  DWORD needed = 0;
780  DWORD numentries = 0;
781  INT len;
782 
783  TRACE("EnumPortsA(%s, %d, %p, %d, %p, %p)\n", debugstr_a(pName), Level, pPorts, cbBuf, pcbNeeded, pcReturned);
784 
785  if ((Level < 1) || (Level > 2))
786  {
787  ERR("Level = %d, unsupported!\n", Level);
789  return FALSE;
790  }
791 
792  /* convert servername to unicode */
793  if (pName)
794  {
795  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
796  nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
798  }
799  /* alloc (userbuffersize*sizeof(WCHAR) and try to enum the Ports */
800  needed = cbBuf * sizeof(WCHAR);
801  if (needed) bufferW = HeapAlloc(GetProcessHeap(), 0, needed);
802  res = EnumPortsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
803 
805  {
806  if (pcbNeeded) needed = *pcbNeeded;
807  /* HeapReAlloc return NULL, when bufferW was NULL */
808  bufferW = (bufferW) ? HeapReAlloc(GetProcessHeap(), 0, bufferW, needed) :
809  HeapAlloc(GetProcessHeap(), 0, needed);
810 
811  /* Try again with the large Buffer */
812  res = EnumPortsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
813  }
814  needed = pcbNeeded ? *pcbNeeded : 0;
815  numentries = pcReturned ? *pcReturned : 0;
816 
817  /*
818  W2k require the buffersize from EnumPortsW also for EnumPortsA.
819  We use the smaller Ansi-Size to avoid conflicts with fixed Buffers of old Apps.
820  */
821  if (res)
822  {
823  /* EnumPortsW collected all Data. Parse them to calculate ANSI-Size */
824  DWORD entrysize = 0;
825  DWORD index;
826  LPSTR ptr;
827  LPPORT_INFO_2W pi2w;
828  LPPORT_INFO_2A pi2a;
829 
830  needed = 0;
831  entrysize = (Level == 1) ? sizeof(PORT_INFO_1A) : sizeof(PORT_INFO_2A);
832 
833  /* First pass: calculate the size for all Entries */
834  pi2w = (LPPORT_INFO_2W) bufferW;
835  pi2a = (LPPORT_INFO_2A) pPorts;
836  index = 0;
837  while (index < numentries)
838  {
839  index++;
840  needed += entrysize; /* PORT_INFO_?A */
841  TRACE("%p: parsing #%d (%s)\n", pi2w, index, debugstr_w(pi2w->pPortName));
842 
843  needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pPortName, -1,
844  NULL, 0, NULL, NULL);
845  if (Level > 1)
846  {
847  needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pMonitorName, -1,
848  NULL, 0, NULL, NULL);
849  needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pDescription, -1,
850  NULL, 0, NULL, NULL);
851  }
852  /* use LPBYTE with entrysize to avoid double code (PORT_INFO_1 + PORT_INFO_2) */
853  pi2w = (LPPORT_INFO_2W) (((LPBYTE)pi2w) + entrysize);
854  pi2a = (LPPORT_INFO_2A) (((LPBYTE)pi2a) + entrysize);
855  }
856 
857  /* check for errors and quit on failure */
858  if (cbBuf < needed)
859  {
861  res = FALSE;
862  goto cleanup;
863  }
864  len = entrysize * numentries; /* room for all PORT_INFO_?A */
865  ptr = (LPSTR) &pPorts[len]; /* room for strings */
866  cbBuf -= len ; /* free Bytes in the user-Buffer */
867  pi2w = (LPPORT_INFO_2W) bufferW;
868  pi2a = (LPPORT_INFO_2A) pPorts;
869  index = 0;
870  /* Second Pass: Fill the User Buffer (if we have one) */
871  while ((index < numentries) && pPorts)
872  {
873  index++;
874  TRACE("%p: writing PORT_INFO_%dA #%d\n", pi2a, Level, index);
875  pi2a->pPortName = ptr;
876  len = WideCharToMultiByte(CP_ACP, 0, pi2w->pPortName, -1,
877  ptr, cbBuf , NULL, NULL);
878  ptr += len;
879  cbBuf -= len;
880  if (Level > 1)
881  {
882  pi2a->pMonitorName = ptr;
883  len = WideCharToMultiByte(CP_ACP, 0, pi2w->pMonitorName, -1,
884  ptr, cbBuf, NULL, NULL);
885  ptr += len;
886  cbBuf -= len;
887 
888  pi2a->pDescription = ptr;
889  len = WideCharToMultiByte(CP_ACP, 0, pi2w->pDescription, -1,
890  ptr, cbBuf, NULL, NULL);
891  ptr += len;
892  cbBuf -= len;
893 
894  pi2a->fPortType = pi2w->fPortType;
895  pi2a->Reserved = 0; /* documented: "must be zero" */
896 
897  }
898  /* use LPBYTE with entrysize to avoid double code (PORT_INFO_1 + PORT_INFO_2) */
899  pi2w = (LPPORT_INFO_2W) (((LPBYTE)pi2w) + entrysize);
900  pi2a = (LPPORT_INFO_2A) (((LPBYTE)pi2a) + entrysize);
901  }
902  }
903 
904 cleanup:
905  if (pcbNeeded) *pcbNeeded = needed;
906  if (pcReturned) *pcReturned = (res) ? numentries : 0;
907 
908  if (nameW) HeapFree(GetProcessHeap(), 0, nameW);
909  if (bufferW) HeapFree(GetProcessHeap(), 0, bufferW);
910 
911  TRACE("returning %d with %d (%d byte for %d of %d entries)\n",
912  (res), GetLastError(), needed, (res)? numentries : 0, numentries);
913 
914  return (res);
915 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
BOOL WINAPI EnumPortsW(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: ports.c:147
LPWSTR pPortName
Definition: winspool.h:765
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
struct _PORT_INFO_2W * LPPORT_INFO_2W
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
char * LPSTR
Definition: xmlstorage.h:182
DWORD Reserved
Definition: winspool.h:761
int32_t INT
Definition: typedefs.h:58
DWORD fPortType
Definition: winspool.h:760
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
struct _PORT_INFO_2A * LPPORT_INFO_2A
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
LPSTR pDescription
Definition: winspool.h:759
GLuint index
Definition: glext.h:6031
static const WCHAR nameW[]
Definition: main.c:46
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
struct _PORT_INFO_2A PORT_INFO_2A
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
LPWSTR pMonitorName
Definition: winspool.h:766
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define HeapReAlloc
Definition: compat.h:593
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
LPSTR pPortName
Definition: winspool.h:757
GLuint res
Definition: glext.h:9613
char * cleanup(char *str)
Definition: wpickclick.c:99
LPSTR pMonitorName
Definition: winspool.h:758
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
LPWSTR pDescription
Definition: winspool.h:767
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ EnumPortsW()

BOOL WINAPI EnumPortsW ( PWSTR  pName,
DWORD  Level,
PBYTE  pPorts,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 918 of file ports.c.

919 {
920  DWORD dwErrorCode;
921 
922  TRACE("EnumPortsW(%S, %lu, %p, %lu, %p, %p)\n", pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
923 
924  if ((Level < 1) || (Level > 2))
925  {
926  ERR("Level = %d, unsupported!\n", Level);
928  return FALSE;
929  }
930 
931  // Do the RPC call
933  {
934  dwErrorCode = _RpcEnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
935  }
937  {
938  dwErrorCode = RpcExceptionCode();
939  ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode);
940  }
941  RpcEndExcept;
942 
943  if (dwErrorCode == ERROR_SUCCESS)
944  {
945  // Replace relative offset addresses in the output by absolute pointers.
946  ASSERT(Level >= 1 && Level <= 2);
947  MarshallUpStructuresArray(cbBuf, pPorts, *pcReturned, pPortInfoMarshalling[Level]->pInfo, pPortInfoMarshalling[Level]->cbStructureSize, TRUE);
948  }
949 
950  SetLastError(dwErrorCode);
951  return (dwErrorCode == ERROR_SUCCESS);
952 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static const MARSHALLING * pPortInfoMarshalling[]
Definition: ports.h:28
#define FALSE
Definition: types.h:117
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define ASSERT(a)
Definition: mode.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define ERR(fmt,...)
Definition: debug.h:110
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
DWORD _RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE *pPort, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
Definition: ports.c:112
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define RpcExcept(expr)
Definition: rpc.h:127
BOOL WINAPI MarshallUpStructuresArray(DWORD cbSize, PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:202

◆ FreeMonitorUI()

VOID FASTCALL FreeMonitorUI ( PMONITORUIDATA  pmuid)

Definition at line 183 of file ports.c.

184 {
185  if ( pmuid )
186  {
187  if ( pmuid->hLibrary )
188  {
189  FreeLibrary( pmuid->hLibrary );
190  }
191  if ( pmuid->Activeated )
192  {
193  DeactivateActCtx( 0, pmuid->ulpCookie );
194  }
195  if ( pmuid->hActCtx != INVALID_HANDLE_VALUE )
196  {
197  ReleaseActCtx( pmuid->hActCtx );
198  }
199  if ( pmuid->pModuleName )
200  {
201  DllFreeSplMem( pmuid->pModuleName );
202  }
203  DllFreeSplMem( pmuid );
204  }
205 }
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
HANDLE hActCtx
Definition: ports.c:14
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL Activeated
Definition: ports.c:17
HMODULE hLibrary
Definition: ports.c:13
ULONG_PTR ulpCookie
Definition: ports.c:15
#define FreeLibrary(x)
Definition: compat.h:607
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
PWSTR pModuleName
Definition: ports.c:16

Referenced by AddPortW(), ConfigurePortW(), DeletePortW(), and GetMonitorUI().

◆ GetMonitorUI()

DWORD WINAPI GetMonitorUI ( PWSTR  pName,
PWSTR  pMonitorPortName,
PWSTR  pXcvName,
PMONITORUI pmui,
PMONITORUIDATA ppmuid 
)

Definition at line 288 of file ports.c.

289 {
290  DWORD dwErrorCode = ERROR_SUCCESS, cbOutputNeeded, dwStatus;
291  HANDLE hPrinter = NULL;
293  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
294  PWSTR pDevice = NULL, pOutputString = NULL;
295  PMONITORUIDATA pmuid = NULL;
296  PRINTER_DEFAULTSW wDefault = { 0, 0, PRINTER_ATTRIBUTE_QUEUED };
297  BYTE OutputData[1024], InputData[4];
298 
299  *pmui = NULL;
300  *ppmuid = NULL;
301 
302  pDevice = ConstructXcvName( pName, pMonitorPortName, pXcvName );
303 
304  if ( !pDevice )
305  {
306  return GetLastError();
307  }
308 
309  FIXME("GMUI : XcvName : %S\n",pDevice);
310 
311  if ( OpenPrinterW( (LPWSTR)pDevice, &hPrinter, &wDefault ) )
312  {
313  pHandle = (PSPOOLER_HANDLE)hPrinter;
314 
315  // Do the RPC call
317  {
318  dwErrorCode = _RpcXcvData( pHandle->hPrinter,
319  L"MonitorUI",
320  (PBYTE)&InputData,
321  0,
322  (PBYTE)&OutputData,
323  1024,
324  &cbOutputNeeded,
325  &dwStatus );
326  }
328  {
329  dwErrorCode = RpcExceptionCode();
330  ERR("GMUI : _RpcXcvData failed with exception code %lu!\n", dwErrorCode);
331  }
332  RpcEndExcept;
333 
334  if ( dwErrorCode == ERROR_INSUFFICIENT_BUFFER )
335  {
336  pOutputString = DllAllocSplMem( cbOutputNeeded );
337 
338  // Do the RPC call
340  {
341  dwErrorCode = _RpcXcvData( pHandle->hPrinter,
342  L"MonitorUI",
343  (PBYTE)&InputData,
344  0,
345  (PBYTE)pOutputString,
346  cbOutputNeeded,
347  &cbOutputNeeded,
348  &dwStatus );
349  }
351  {
352  dwErrorCode = RpcExceptionCode();
353  ERR("GMUI : _RpcXcvData failed with exception code %lu!\n", dwErrorCode);
354  }
355  RpcEndExcept;
356  }
357 
358  if ( dwErrorCode != ERROR_SUCCESS || dwStatus != ERROR_SUCCESS )
359  {
360  goto Cleanup;
361  }
362 
363  pmuid = DllAllocSplMem( sizeof(MONITORUIDATA) );
364  if ( pmuid )
365  {
366  memset( pmuid, 0, sizeof(MONITORUIDATA) );
367  pmuid->hActCtx = INVALID_HANDLE_VALUE;
368  }
369  else
370  {
371  ERR("GMUI : Memory error\n");
372  dwErrorCode = GetLastError();
373  goto Cleanup;
374  }
375 
376  if ( GetMonitorUIActivationContext( pOutputString ? pOutputString : (PWSTR)&OutputData, pmuid ) )
377  {
378  FIXME("GMUI : MonitorUI Path : %S\n",pmuid->pModuleName);
379 
380  hModule = LoadLibraryW( pmuid->pModuleName );
381  if ( hModule )
382  {
383  FARPROC fpInitializePrintMonitorUI = (PVOID) GetProcAddress( hModule, "InitializePrintMonitorUI" );
384  if ( fpInitializePrintMonitorUI )
385  {
386  pmuid->hLibrary = hModule;
387  *pmui = (PMONITORUI)(*fpInitializePrintMonitorUI)();
388  *ppmuid = pmuid;
389  }
390  else
391  {
392  ERR("GMUI : Failed to get MUI %S\n",pmuid->pModuleName);
393  FreeMonitorUI( pmuid );
394  }
395  }
396  else
397  {
398  ERR("GMUI : Failed to load library %S\n",pmuid->pModuleName);
399  }
400  }
401  }
402  else
403  {
404  ERR("GMUI : Failed to open printer handle\n");
405  }
406 
407  dwErrorCode = GetLastError();
408 
409 Cleanup:
410  if ( hPrinter ) ClosePrinter( hPrinter );
411  if ( pOutputString ) DllFreeSplMem( pOutputString );
412  if ( pDevice ) DllFreeSplMem( pDevice );
413 
414  FIXME("GMUI : Error Code Exit %d\n",dwErrorCode);
415 
416  return dwErrorCode;
417 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define PRINTER_ATTRIBUTE_QUEUED
Definition: winspool.h:208
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
HANDLE hActCtx
Definition: ports.c:14
#define L(x)
Definition: ntvdm.h:50
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
DWORD _RpcXcvData(WINSPOOL_PRINTER_HANDLE hXcv, const WCHAR *pszDataName, BYTE *pInputData, DWORD cbInputData, BYTE *pOutputData, DWORD cbOutputData, DWORD *pcbOutputNeeded, DWORD *pdwStatus)
Definition: xcv.c:11
#define LoadLibraryW(x)
Definition: compat.h:606
void * PVOID
Definition: retypes.h:9
HMODULE hLibrary
Definition: ports.c:13
FxDevice * pDevice
#define RpcExceptionCode()
Definition: rpc.h:132
static LPSTR pName
Definition: security.c:75
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID FASTCALL FreeMonitorUI(PMONITORUIDATA pmuid)
Definition: ports.c:183
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:2624
BOOL WINAPI GetMonitorUIActivationContext(PWSTR pDeviceName, PMONITORUIDATA pmuid)
Definition: ports.c:138
DWORD dwStatus
Definition: mediaobj.idl:95
#define NULL
Definition: types.h:112
struct _MONITORUI * PMONITORUI
#define GetProcAddress(x, y)
Definition: compat.h:612
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
BYTE * PBYTE
Definition: pedump.c:66
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
PWSTR pModuleName
Definition: ports.c:16
int(* FARPROC)()
Definition: compat.h:36
#define RpcExcept(expr)
Definition: rpc.h:127
PWSTR WINAPI ConstructXcvName(PWSTR pName, PWSTR pMonitorPortName, PWSTR pXcvName)
Definition: ports.c:234
HMODULE hModule
Definition: animate.c:44
HANDLE hPrinter
Definition: precomp.h:50
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AddPortW(), ConfigurePortW(), and DeletePortW().

◆ GetMonitorUIActivationContext()

BOOL WINAPI GetMonitorUIActivationContext ( PWSTR  pDeviceName,
PMONITORUIDATA  pmuid 
)

Definition at line 138 of file ports.c.

139 {
140  // ACTCTXW actctx;
141  // HANDLE handle;
142  BOOL Ret = FALSE;
143 
144  FIXME("GMUIAC : Module pDeviceName %S\n",pDeviceName);
145 
146  if ( !GetMonitorUIFullName( pDeviceName, &pmuid->pModuleName ) )
147  {
148  ERR("GetMonitorUIFullName Failed\n");
149  return Ret;
150  }
151 /* OMG! SxS again?
152  memset(&actctx, 0, sizeof(ACTCTXW));
153  actctx.cbSize = sizeof(ACTCTXW);
154  actctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
155  actctx.lpResourceName = MAKEINTRESOURCEW(123); This might be the reason....
156  actctx.lpSource = pmuid->pModuleName;
157 
158  handle = CreateActCtxW(&actctx);
159 
160  if ( handle != INVALID_HANDLE_VALUE )
161  {
162  pmuid->hActCtx = handle;
163  if ( ActivateActCtx( handle, &pmuid->ulpCookie ) )
164  {
165  pmuid->Activeated = TRUE;
166  Ret = TRUE;
167  }
168  else
169  {
170  pmuid->Activeated = FALSE;
171  }
172  }
173  else
174  {
175  ERR("GetMonitorUIActivationContext Failed %S\n",pmuid->pModuleName);
176  }*/
177  pmuid->hActCtx = INVALID_HANDLE_VALUE;
178  Ret = TRUE;
179  return Ret;
180 }
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
HANDLE hActCtx
Definition: ports.c:14
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL WINAPI GetMonitorUIFullName(PWSTR pDeviceName, PWSTR *pModuleName)
Definition: ports.c:103
#define ERR(fmt,...)
Definition: debug.h:110
PWSTR pModuleName
Definition: ports.c:16

Referenced by GetMonitorUI().

◆ GetMonitorUIFullName()

BOOL WINAPI GetMonitorUIFullName ( PWSTR  pDeviceName,
PWSTR pModuleName 
)

Definition at line 103 of file ports.c.

104 {
105  STRSAFE_LPWSTR SysDir;
106  UINT length;
107  HRESULT hr;
108 
109  *pModuleName = NULL;
110 
111  SysDir = HeapAlloc(hProcessHeap, 0, MAX_PATH*sizeof(WCHAR));
112 
113  if ( SysDir )
114  {
115  memset( SysDir, 0, MAX_PATH*sizeof(WCHAR) );
116 
117  length = GetSystemDirectoryW( SysDir, MAX_PATH*sizeof(WCHAR) );
118 
119  if ( length > 0 )
120  {
121  StringCbCatW(SysDir, MAX_PATH*sizeof(WCHAR), L"\\");
122 
123  hr = StringCchCatW( SysDir, MAX_PATH*sizeof(WCHAR), pDeviceName );
124  if ( !FAILED(hr) )
125  {
126  *pModuleName = SysDir;
127  return TRUE;
128  }
130  }
131 
132  HeapFree(hProcessHeap, 0, SysDir);
133  }
134  return FALSE;
135 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
wchar_t * STRSAFE_LPWSTR
Definition: ntstrsafe.h:53
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
#define SetLastError(x)
Definition: compat.h:611
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HRESULT_CODE(hr)
Definition: winerror.h:76
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:594
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by GetMonitorUIActivationContext().

◆ IntPortThread()

VOID WINAPI IntPortThread ( PPORTTHREADINFO  pPortThreadInfo)

Definition at line 33 of file ports.c.

34 {
35  FIXME("IPT : %s\n",debugstr_w( pPortThreadInfo->pPortName ));
36  // Do the RPC call
38  {
39  pPortThreadInfo->dwErrorCode = pPortThreadInfo->fpFunction( pPortThreadInfo->pName, pPortThreadInfo->hWnd, pPortThreadInfo->pPortName );
40  }
42  {
43  pPortThreadInfo->dwErrorCode = RpcExceptionCode();
44  ERR("IPT : _RpcXyzPort failed with exception code %lu!\n", pPortThreadInfo->dwErrorCode);
45  }
47 
48  SetEvent( pPortThreadInfo->hEvent );
49 }
LPWSTR pPortName
Definition: ports.c:26
#define RpcEndExcept
Definition: rpc.h:128
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD dwErrorCode
Definition: ports.c:28
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
ULONG_PTR hWnd
Definition: ports.c:25
#define RpcExceptionCode()
Definition: rpc.h:132
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE hEvent
Definition: ports.c:29
LPWSTR pName
Definition: ports.c:24
#define ERR(fmt,...)
Definition: debug.h:110
PPfpFunction fpFunction
Definition: ports.c:27
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by StartPortThread().

◆ SetPortA()

BOOL WINAPI SetPortA ( PSTR  pName,
PSTR  pPortName,
DWORD  dwLevel,
PBYTE  pPortInfo 
)

Definition at line 955 of file ports.c.

956 {
957  LPWSTR NameW = NULL;
958  LPWSTR PortNameW = NULL;
959  PORT_INFO_3W pi3W;
960  PORT_INFO_3A *pi3A;
961  DWORD len;
962  BOOL res;
963 
964  pi3A = (PORT_INFO_3A*)pPortInfo;
965 
966  TRACE("SetPortA(%s, %s, %lu, %p)\n", pName, pPortName, dwLevel, pPortInfo);
967 
968  if ( dwLevel != 3 )
969  {
970  ERR("Level = %d, unsupported!\n", dwLevel);
972  return FALSE;
973  }
974 
975  if (pName)
976  {
977  len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
978  NameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
979  MultiByteToWideChar(CP_ACP, 0, pName, -1, NameW, len);
980  }
981 
982  if (pPortName)
983  {
984  len = MultiByteToWideChar(CP_ACP, 0, pPortName, -1, NULL, 0);
985  PortNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
986  MultiByteToWideChar(CP_ACP, 0, pPortName, -1, PortNameW, len);
987  }
988 
989  if (pi3A->pszStatus)
990  {
991  len = MultiByteToWideChar(CP_ACP, 0, pi3A->pszStatus, -1, NULL, 0);
992  pi3W.pszStatus = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
993  MultiByteToWideChar(CP_ACP, 0, pi3A->pszStatus, -1, pi3W.pszStatus, len);
994  }
995 
996  pi3W.dwStatus = pi3A->dwStatus;
997  pi3W.dwSeverity = pi3A->dwSeverity;
998 
999  res = SetPortW( NameW, PortNameW, dwLevel, (PBYTE)&pi3W );
1000 
1001  if (NameW) HeapFree(GetProcessHeap(), 0, NameW);
1002  if (PortNameW) HeapFree(GetProcessHeap(), 0, PortNameW);
1003  if (pi3W.pszStatus) HeapFree(GetProcessHeap(), 0, pi3W.pszStatus);
1004 
1005  return res;
1006 }
BOOL WINAPI SetPortW(PWSTR pName, PWSTR pPortName, DWORD dwLevel, PBYTE pPortInfo)
Definition: ports.c:216
DWORD dwStatus
Definition: winspool.h:782
#define CP_ACP
Definition: compat.h:109
LPSTR pszStatus
Definition: winspool.h:783
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwStatus
Definition: winspool.h:788
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define GetProcessHeap()
Definition: compat.h:595
DWORD dwSeverity
Definition: winspool.h:784
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD dwSeverity
Definition: winspool.h:790
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
LPWSTR pszStatus
Definition: winspool.h:789
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
GLuint res
Definition: glext.h:9613
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ SetPortW()

BOOL WINAPI SetPortW ( PWSTR  pName,
PWSTR  pPortName,
DWORD  dwLevel,
PBYTE  pPortInfo 
)

Definition at line 1009 of file ports.c.

1010 {
1011  DWORD dwErrorCode;
1012  WINSPOOL_PORT_CONTAINER PortInfoContainer;
1013 
1014  TRACE("SetPortW(%S, %S, %lu, %p)\n", pName, pPortName, dwLevel, pPortInfo);
1015 
1016  if ( dwLevel != 3 )
1017  {
1018  ERR("Level = %d, unsupported!\n", dwLevel);
1020  return FALSE;
1021  }
1022 
1023  PortInfoContainer.PortInfo.pPortInfo3 = (WINSPOOL_PORT_INFO_3*)pPortInfo;
1024  PortInfoContainer.Level = dwLevel;
1025 
1026  // Do the RPC call
1027  RpcTryExcept
1028  {
1029  dwErrorCode = _RpcSetPort(pName, pPortName, &PortInfoContainer);
1030  }
1032  {
1033  dwErrorCode = RpcExceptionCode();
1034  }
1035  RpcEndExcept;
1036 
1037  SetLastError(dwErrorCode);
1038  return (dwErrorCode == ERROR_SUCCESS);
1039 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define RpcTryExcept
Definition: rpc.h:126
DWORD _RpcSetPort(WINSPOOL_HANDLE pName, WCHAR *pPortName, WINSPOOL_PORT_CONTAINER *pPortContainer)
Definition: ports.c:144
WINSPOOL_PORT_INFO_3 * pPortInfo3
Definition: winspool.idl:674
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
union _WINSPOOL_PORT_CONTAINER::@3356 PortInfo
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define RpcExcept(expr)
Definition: rpc.h:127

◆ StartPortThread()

BOOL WINAPI StartPortThread ( LPWSTR  pName,
HWND  hWnd,
LPWSTR  pPortName,
PPfpFunction  fpFunction 
)

Definition at line 55 of file ports.c.

56 {
57  PORTTHREADINFO PortThreadInfo;
58  HANDLE htHandle;
59  MSG Msg;
60  DWORD tid;
61 
62  if ( hWnd ) EnableWindow( hWnd, FALSE );
63 
64  PortThreadInfo.pName = pName;
65  PortThreadInfo.hWnd = (ULONG_PTR)hWnd;
66  PortThreadInfo.pPortName = pPortName;
67  PortThreadInfo.fpFunction = fpFunction;
68  PortThreadInfo.dwErrorCode = ERROR_SUCCESS;
69  PortThreadInfo.hEvent = CreateEventW( NULL, TRUE, FALSE, NULL );
70 
71  htHandle = CreateThread( NULL,
72  32*1024,
74  &PortThreadInfo,
75  0,
76  &tid );
77 
78  CloseHandle( htHandle );
79 
80  while ( MsgWaitForMultipleObjects( 1, &PortThreadInfo.hEvent, FALSE, INFINITE, QS_ALLINPUT ) == 1 )
81  {
82  while ( PeekMessageW( &Msg, NULL, 0, 0, PM_REMOVE ) )
83  {
86  }
87  }
88 
89  CloseHandle( PortThreadInfo.hEvent );
90 
91  if ( hWnd )
92  {
95  SetFocus(hWnd);
96  }
97 
98  SetLastError(PortThreadInfo.dwErrorCode);
99  return (PortThreadInfo.dwErrorCode == ERROR_SUCCESS);
100 }
LPWSTR pPortName
Definition: ports.c:26
BOOL WINAPI TranslateMessage(_In_ const MSG *)
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:723
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
HWND WINAPI SetFocus(_In_opt_ HWND)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
DWORD dwErrorCode
Definition: ports.c:28
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
ULONG_PTR hWnd
Definition: ports.c:25
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
VOID WINAPI IntPortThread(PPORTTHREADINFO pPortThreadInfo)
Definition: ports.c:33
HANDLE hEvent
Definition: ports.c:29
LPWSTR pName
Definition: ports.c:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define QS_ALLINPUT
Definition: winuser.h:897
#define NULL
Definition: types.h:112
struct @1587 Msg[]
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define ULONG_PTR
Definition: config.h:101
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1186
#define INFINITE
Definition: serial.h:102
PPfpFunction fpFunction
Definition: ports.c:27
static TfClientId tid

Referenced by AddPortW(), ConfigurePortW(), and DeletePortW().

◆ StrNCatBuff()

BOOL FASTCALL StrNCatBuff ( PWSTR  ptr,
size_t  Size,
PWSTR  args,
  ... 
)

Definition at line 208 of file ports.c.

209 {
210  va_list Args;
211  PWSTR pwstr;
212  HRESULT hr;
213  BOOL Ret = TRUE;
214 
215  va_start(Args, args );
216 
217  for ( pwstr = args ; pwstr ; pwstr = va_arg( Args, PWSTR ) )
218  {
219  hr = StringCchCatNW( ptr, Size, pwstr, wcslen(pwstr) );
220  if ( FAILED(hr) )
221  {
223  Ret = FALSE;
224  break;
225  }
226  }
227 
228  va_end(Args);
229 
230  return Ret;
231 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
char * va_list
Definition: acmsvcex.h:78
char ** Args
Definition: acdebug.h:353
LONG HRESULT
Definition: typedefs.h:79
va_start(ap, x)
#define SetLastError(x)
Definition: compat.h:611
STRSAFEAPI StringCchCatNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToAppend)
Definition: strsafe.h:407
#define va_arg(ap, T)
Definition: acmsvcex.h:89
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HRESULT_CODE(hr)
Definition: winerror.h:76

Referenced by ConstructXcvName().