ReactOS  0.4.15-dev-3175-g222acf5
precomp.h File Reference
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
#include <lmcons.h>
#include <rpc.h>
#include <strsafe.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winreg.h>
#include <winspool.h>
#include <winsplp.h>
#include <winddiui.h>
#include <dsrole.h>
#include <secext.h>
#include <ndk/rtlfuncs.h>
#include <skiplist.h>
#include <spoolss.h>
#include <wine/debug.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _LOCAL_PRINT_MONITOR
 
struct  _LOCAL_PORT
 
struct  _LOCAL_PRINT_PROCESSOR
 
struct  _LOCAL_PRINTER
 
struct  _LOCAL_JOB
 
struct  _LOCAL_PRINTER_HANDLE
 
struct  _LOCAL_PORT_HANDLE
 
struct  _LOCAL_XCV_HANDLE
 
struct  _LOCAL_HANDLE
 
struct  _SHD_HEADER
 
struct  _PRINTENV_T
 

Macros

#define WIN32_NO_STATUS
 
#define SKIPLIST_LEVELS   16
 
#define IS_VALID_JOB_ID(ID)   (ID >= 1 && ID <= 99999)
 
#define IS_VALID_PRIORITY(P)   (P >= MIN_PRIORITY && P <= MAX_PRIORITY)
 
#define SHD_WIN2003_SIGNATURE   0x4968
 

Typedefs

typedef BOOL(WINAPIPClosePrintProcessor) (HANDLE)
 
typedef BOOL(WINAPIPControlPrintProcessor) (HANDLE, DWORD)
 
typedef BOOL(WINAPIPEnumPrintProcessorDatatypesW) (LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD)
 
typedef DWORD(WINAPIPGetPrintProcessorCapabilities) (LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD)
 
typedef HANDLE(WINAPIPOpenPrintProcessor) (LPWSTR, PPRINTPROCESSOROPENDATA)
 
typedef BOOL(WINAPIPPrintDocumentOnPrintProcessor) (HANDLE, LPWSTR)
 
typedef LPMONITOREX(WINAPIPInitializePrintMonitor) (PWSTR)
 
typedef LPMONITOR2(WINAPIPInitializePrintMonitor2) (PMONITORINIT, PHANDLE)
 
typedef PMONITORUI(WINAPIPInitializePrintMonitorUI) (VOID)
 
typedef struct _LOCAL_HANDLE LOCAL_HANDLE
 
typedef struct _LOCAL_HANDLEPLOCAL_HANDLE
 
typedef struct _LOCAL_JOB LOCAL_JOB
 
typedef struct _LOCAL_JOBPLOCAL_JOB
 
typedef struct _LOCAL_PORT LOCAL_PORT
 
typedef struct _LOCAL_PORTPLOCAL_PORT
 
typedef struct _LOCAL_PORT_HANDLE LOCAL_PORT_HANDLE
 
typedef struct _LOCAL_PORT_HANDLEPLOCAL_PORT_HANDLE
 
typedef struct _LOCAL_PRINT_MONITOR LOCAL_PRINT_MONITOR
 
typedef struct _LOCAL_PRINT_MONITORPLOCAL_PRINT_MONITOR
 
typedef struct _LOCAL_PRINT_PROCESSOR LOCAL_PRINT_PROCESSOR
 
typedef struct _LOCAL_PRINT_PROCESSORPLOCAL_PRINT_PROCESSOR
 
typedef struct _LOCAL_PRINTER LOCAL_PRINTER
 
typedef struct _LOCAL_PRINTERPLOCAL_PRINTER
 
typedef struct _LOCAL_PRINTER_HANDLE LOCAL_PRINTER_HANDLE
 
typedef struct _LOCAL_PRINTER_HANDLEPLOCAL_PRINTER_HANDLE
 
typedef struct _LOCAL_XCV_HANDLE LOCAL_XCV_HANDLE
 
typedef struct _LOCAL_XCV_HANDLEPLOCAL_XCV_HANDLE
 
typedef struct _SHD_HEADER SHD_HEADER
 
typedef struct _SHD_HEADERPSHD_HEADER
 
typedef struct _PRINTENV_T PRINTENV_T
 
typedef struct _PRINTENV_TPPRINTENV_T
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (localspl)
 
BOOL InitializeFormList (VOID)
 
BOOL WINAPI LocalAddForm (HANDLE hPrinter, DWORD Level, PBYTE pForm)
 
BOOL WINAPI LocalDeleteForm (HANDLE hPrinter, PWSTR pFormName)
 
BOOL WINAPI LocalEnumForms (HANDLE hPrinter, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI LocalGetForm (HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI LocalSetForm (HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm)
 
DWORD WINAPI CreateJob (PLOCAL_PRINTER_HANDLE pPrinterHandle)
 
void FreeJob (PLOCAL_JOB pJob)
 
DWORD GetJobFilePath (PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
 
BOOL InitializeGlobalJobList (VOID)
 
void InitializePrinterJobList (PLOCAL_PRINTER pPrinter)
 
BOOL WINAPI LocalAddJob (HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI LocalEnumJobs (HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, PBYTE pStart, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
 
BOOL WINAPI LocalGetJob (HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pStart, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI LocalScheduleJob (HANDLE hPrinter, DWORD dwJobID)
 
BOOL WINAPI LocalSetJob (HANDLE hPrinter, DWORD JobId, DWORD Level, PBYTE pJobInfo, DWORD Command)
 
PLOCAL_JOB ReadJobShadowFile (PCWSTR pwszFilePath)
 
BOOL WriteJobShadowFile (PWSTR pwszFilePath, const PLOCAL_JOB pJob)
 
PLOCAL_PRINT_MONITOR FindPrintMonitor (PCWSTR pwszName)
 
BOOL InitializePrintMonitorList (void)
 
BOOL WINAPI LocalEnumMonitors (PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI LocalAddMonitor (PWSTR pName, DWORD Level, PBYTE pMonitors)
 
BOOL WINAPI LocalDeleteMonitor (PWSTR pName, PWSTR pEnvironment, PWSTR pMonitorName)
 
PLOCAL_PORT FindPort (PCWSTR pwszName)
 
BOOL InitializePortList (void)
 
BOOL WINAPI LocalEnumPorts (PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI LocalAddPortEx (PWSTR pName, DWORD Level, PBYTE lpBuffer, PWSTR lpMonitorName)
 
BOOL WINAPI LocalAddPort (LPWSTR pName, HWND hWnd, LPWSTR pMonitorName)
 
BOOL WINAPI LocalConfigurePort (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI LocalDeletePort (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI LocalSetPort (PWSTR pName, PWSTR pPortName, DWORD dwLevel, PBYTE pPortInfo)
 
BOOL CreatePortEntry (PCWSTR pwszName, PLOCAL_PRINT_MONITOR pPrintMonitor)
 
DWORD WINAPI LocalGetPrinterData (HANDLE hPrinter, PWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
 
DWORD WINAPI LocalGetPrinterDataEx (HANDLE hPrinter, PCWSTR pKeyName, PCWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
 
DWORD WINAPI LocalSetPrinterData (HANDLE hPrinter, PWSTR pValueName, DWORD Type, PBYTE pData, DWORD cbData)
 
DWORD WINAPI LocalSetPrinterDataEx (HANDLE hPrinter, LPCWSTR pKeyName, LPCWSTR pValueName, DWORD Type, LPBYTE pData, DWORD cbData)
 
BOOL InitializePrinterDrivers (VOID)
 
BOOL WINAPI LocalAddPrinterDriver (LPWSTR pName, DWORD level, LPBYTE pDriverInfo)
 
BOOL WINAPI LocalAddPrinterDriverEx (LPWSTR pName, DWORD level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags)
 
BOOL WINAPI LocalGetPrinterDriver (HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI LocalGetPrinterDriverDirectory (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverDirectory, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI LocalGetPrinterDriverEx (HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, PDWORD pdwServerMajorVersion, PDWORD pdwServerMinorVersion)
 
BOOL WINAPI LocalEnumPrinterDrivers (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
PPRINTENV_T validate_envW (LPCWSTR env)
 
BOOL InitializePrinterList (void)
 
BOOL WINAPI LocalEnumPrinters (DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
 
BOOL WINAPI LocalGetPrinter (HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI LocalOpenPrinter (PWSTR lpPrinterName, HANDLE *phPrinter, PPRINTER_DEFAULTSW pDefault)
 
DWORD WINAPI LocalPrinterMessageBox (HANDLE hPrinter, DWORD Error, HWND hWnd, LPWSTR pText, LPWSTR pCaption, DWORD dwType)
 
BOOL WINAPI LocalReadPrinter (HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pNoBytesRead)
 
DWORD WINAPI LocalStartDocPrinter (HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo)
 
BOOL WINAPI LocalStartPagePrinter (HANDLE hPrinter)
 
BOOL WINAPI LocalWritePrinter (HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten)
 
BOOL WINAPI LocalEndPagePrinter (HANDLE hPrinter)
 
BOOL WINAPI LocalEndDocPrinter (HANDLE hPrinter)
 
BOOL WINAPI LocalClosePrinter (HANDLE hPrinter)
 
VOID BroadcastChange (PLOCAL_HANDLE pHandle)
 
DWORD WINAPI PrintingThreadProc (PLOCAL_JOB pJob)
 
BOOL FindDatatype (const PLOCAL_PRINT_PROCESSOR pPrintProcessor, PCWSTR pwszDatatype)
 
PLOCAL_PRINT_PROCESSOR FindPrintProcessor (PCWSTR pwszName)
 
BOOL InitializePrintProcessorList (void)
 
BOOL WINAPI LocalEnumPrintProcessorDatatypes (LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
 
BOOL WINAPI LocalEnumPrintProcessors (LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
 
BOOL WINAPI LocalGetPrintProcessorDirectory (LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI LocalGetSpoolFileInfo (HANDLE hPrinter, LPWSTR *pSpoolDir, LPHANDLE phFile, HANDLE hSpoolerProcess, HANDLE hAppProcess)
 
BOOL WINAPI LocalCommitSpoolData (HANDLE hPrinter, DWORD cbCommit)
 
BOOL WINAPI LocalCloseSpoolFileHandle (HANDLE hPrinter)
 
PWSTR AllocAndRegQueryWSZ (HKEY hKey, PCWSTR pwszValueName)
 
PDEVMODEW DuplicateDevMode (PDEVMODEW pInput)
 
LONG copy_servername_from_name (LPCWSTR name, LPWSTR target)
 
BOOL WINAPI LocalXcvData (HANDLE hXcv, const WCHAR *pszDataName, BYTE *pInputData, DWORD cbInputData, BYTE *pOutputData, DWORD cbOutputData, DWORD *pcbOutputNeeded, DWORD *pdwStatus)
 

Variables

SKIPLIST GlobalJobList
 
const WCHAR wszCurrentEnvironment []
 
const DWORD cbCurrentEnvironment
 
const DWORD dwSpoolerMajorVersion
 
const DWORD dwSpoolerMinorVersion
 
const WCHAR wszDefaultDocumentName []
 
HKEY hPrintKey
 
HKEY hPrintersKey
 
PCWSTR wszPrintProviderInfo [3]
 
WCHAR wszJobDirectory [MAX_PATH]
 
DWORD cchJobDirectory
 
WCHAR wszSpoolDirectory [MAX_PATH]
 
DWORD cchSpoolDirectory
 
LIST_ENTRY PrintMonitorList
 
SKIPLIST PrinterList
 

Macro Definition Documentation

◆ IS_VALID_JOB_ID

#define IS_VALID_JOB_ID (   ID)    (ID >= 1 && ID <= 99999)

Definition at line 38 of file precomp.h.

◆ IS_VALID_PRIORITY

#define IS_VALID_PRIORITY (   P)    (P >= MIN_PRIORITY && P <= MAX_PRIORITY)

Definition at line 39 of file precomp.h.

◆ SHD_WIN2003_SIGNATURE

#define SHD_WIN2003_SIGNATURE   0x4968

Definition at line 42 of file precomp.h.

◆ SKIPLIST_LEVELS

#define SKIPLIST_LEVELS   16

Definition at line 30 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file precomp.h.

Typedef Documentation

◆ LOCAL_HANDLE

Definition at line 56 of file precomp.h.

◆ LOCAL_JOB

Definition at line 57 of file precomp.h.

◆ LOCAL_PORT

Definition at line 58 of file precomp.h.

◆ LOCAL_PORT_HANDLE

Definition at line 59 of file precomp.h.

◆ LOCAL_PRINT_MONITOR

Definition at line 60 of file precomp.h.

◆ LOCAL_PRINT_PROCESSOR

Definition at line 61 of file precomp.h.

◆ LOCAL_PRINTER

Definition at line 62 of file precomp.h.

◆ LOCAL_PRINTER_HANDLE

Definition at line 63 of file precomp.h.

◆ LOCAL_XCV_HANDLE

Definition at line 64 of file precomp.h.

◆ PClosePrintProcessor

typedef BOOL(WINAPI * PClosePrintProcessor) (HANDLE)

Definition at line 45 of file precomp.h.

◆ PControlPrintProcessor

typedef BOOL(WINAPI * PControlPrintProcessor) (HANDLE, DWORD)

Definition at line 46 of file precomp.h.

◆ PEnumPrintProcessorDatatypesW

typedef BOOL(WINAPI * PEnumPrintProcessorDatatypesW) (LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD)

Definition at line 47 of file precomp.h.

◆ PGetPrintProcessorCapabilities

typedef DWORD(WINAPI * PGetPrintProcessorCapabilities) (LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD)

Definition at line 48 of file precomp.h.

◆ PInitializePrintMonitor

typedef LPMONITOREX(WINAPI * PInitializePrintMonitor) (PWSTR)

Definition at line 51 of file precomp.h.

◆ PInitializePrintMonitor2

typedef LPMONITOR2(WINAPI * PInitializePrintMonitor2) (PMONITORINIT, PHANDLE)

Definition at line 52 of file precomp.h.

◆ PInitializePrintMonitorUI

typedef PMONITORUI(WINAPI * PInitializePrintMonitorUI) (VOID)

Definition at line 53 of file precomp.h.

◆ PLOCAL_HANDLE

Definition at line 56 of file precomp.h.

◆ PLOCAL_JOB

Definition at line 57 of file precomp.h.

◆ PLOCAL_PORT

Definition at line 58 of file precomp.h.

◆ PLOCAL_PORT_HANDLE

Definition at line 59 of file precomp.h.

◆ PLOCAL_PRINT_MONITOR

Definition at line 60 of file precomp.h.

◆ PLOCAL_PRINT_PROCESSOR

Definition at line 61 of file precomp.h.

◆ PLOCAL_PRINTER

Definition at line 62 of file precomp.h.

◆ PLOCAL_PRINTER_HANDLE

Definition at line 63 of file precomp.h.

◆ PLOCAL_XCV_HANDLE

Definition at line 64 of file precomp.h.

◆ POpenPrintProcessor

typedef HANDLE(WINAPI * POpenPrintProcessor) (LPWSTR, PPRINTPROCESSOROPENDATA)

Definition at line 49 of file precomp.h.

◆ PPrintDocumentOnPrintProcessor

typedef BOOL(WINAPI * PPrintDocumentOnPrintProcessor) (HANDLE, LPWSTR)

Definition at line 50 of file precomp.h.

◆ PPRINTENV_T

◆ PRINTENV_T

◆ PSHD_HEADER

Definition at line 65 of file precomp.h.

◆ SHD_HEADER

Definition at line 65 of file precomp.h.

Function Documentation

◆ AllocAndRegQueryWSZ()

PWSTR AllocAndRegQueryWSZ ( HKEY  hKey,
PCWSTR  pwszValueName 
)

Definition at line 26 of file tools.c.

27 {
28  DWORD cbNeeded;
29  LONG lStatus;
30  PWSTR pwszValue;
31 
32  // Determine the size of the required buffer.
33  lStatus = RegQueryValueExW(hKey, pwszValueName, NULL, NULL, NULL, &cbNeeded);
34  if (lStatus != ERROR_SUCCESS)
35  {
36  ERR("RegQueryValueExW failed with status %ld!\n", lStatus);
37  return NULL;
38  }
39 
40  // Allocate it.
41  pwszValue = DllAllocSplMem(cbNeeded);
42  if (!pwszValue)
43  {
44  ERR("DllAllocSplMem failed!\n");
45  return NULL;
46  }
47 
48  // Now get the actual value.
49  lStatus = RegQueryValueExW(hKey, pwszValueName, NULL, NULL, (PBYTE)pwszValue, &cbNeeded);
50  if (lStatus != ERROR_SUCCESS)
51  {
52  ERR("RegQueryValueExW failed with status %ld!\n", lStatus);
53  DllFreeSplMem(pwszValue);
54  return NULL;
55  }
56 
57  return pwszValue;
58 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
long LONG
Definition: pedump.c:60
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
_In_z_ PCWSTR pwszValueName
Definition: ntuser.h:37
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
BYTE * PBYTE
Definition: pedump.c:66

Referenced by InitializePrinterList(), and InitializePrintMonitorList().

◆ BroadcastChange()

VOID BroadcastChange ( PLOCAL_HANDLE  pHandle)

Definition at line 350 of file printers.c.

351 {
352  PLOCAL_PRINTER pPrinter;
353  PSKIPLIST_NODE pNode;
354  DWORD cchMachineName = 0;
355  WCHAR wszMachineName[MAX_PATH] = {0}; // if not local, use Machine Name then Printer Name... pPrinter->pJob->pwszMachineName?
356 
357  for (pNode = PrinterList.Head.Next[0]; pNode; pNode = pNode->Next[0])
358  {
359  pPrinter = (PLOCAL_PRINTER)pNode->Element;
360 
361  StringCchCopyW( &wszMachineName[cchMachineName], sizeof(wszMachineName), pPrinter->pwszPrinterName );
362 
363  PostMessageW( HWND_BROADCAST, WM_DEVMODECHANGE, 0, (LPARAM)&wszMachineName );
364  }
365 }
SKIPLIST_NODE Head
Definition: skiplist.h:37
#define WM_DEVMODECHANGE
Definition: winuser.h:1614
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LONG_PTR LPARAM
Definition: windef.h:208
SKIPLIST PrinterList
Definition: printers.c:11
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
struct _SKIPLIST_NODE * Next[SKIPLIST_LEVELS]
Definition: skiplist.h:30
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _LOCAL_PRINTER * PLOCAL_PRINTER
Definition: precomp.h:62
PVOID Element
Definition: skiplist.h:31
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HWND_BROADCAST
Definition: winuser.h:1190
PWSTR pwszPrinterName
Definition: precomp.h:119

Referenced by LocalAddForm(), LocalDeleteForm(), and LocalSetForm().

◆ copy_servername_from_name()

LONG copy_servername_from_name ( LPCWSTR  name,
LPWSTR  target 
)

Definition at line 89 of file tools.c.

90 {
92  LPWSTR ptr;
94  DWORD len;
95  DWORD serverlen;
96 
97  if (target) *target = '\0';
98 
99  if (name == NULL) return 0;
100  if ((name[0] != '\\') || (name[1] != '\\')) return 0;
101 
102  server = &name[2];
103  /* skip over both backslash, find separator '\' */
104  ptr = wcschr(server, '\\');
105  serverlen = (ptr) ? ptr - server : lstrlenW(server);
106 
107  /* servername is empty */
108  if (serverlen == 0) return 0;
109 
110  FIXME("found %s\n", debugstr_wn(server, serverlen));
111 
112  if (serverlen > MAX_COMPUTERNAME_LENGTH) return -(LONG)serverlen;
113 
114  if (target)
115  {
116  memcpy(target, server, serverlen * sizeof(WCHAR));
117  target[serverlen] = '\0';
118  }
119 
120  len = ARRAYSIZE(buffer);
121  if (GetComputerNameW(buffer, &len))
122  {
123  if ((serverlen == len) && (_wcsnicmp(server, buffer, len) == 0))
124  {
125  /* The requested Servername is our computername */
126  return 0;
127  }
128  }
129  return serverlen;
130 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define lstrlenW
Definition: compat.h:609
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:111
static PVOID ptr
Definition: dispmode.c:27
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_wn
Definition: kernel32.h:33
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
#define NULL
Definition: types.h:112
Definition: name.c:38
GLenum target
Definition: glext.h:7315
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LocalAddMonitor(), LocalAddPort(), LocalAddPortEx(), LocalAddPrinterDriver(), LocalAddPrinterDriverEx(), LocalConfigurePort(), LocalDeleteMonitor(), LocalDeletePort(), and LocalSetPort().

◆ CreateJob()

DWORD WINAPI CreateJob ( PLOCAL_PRINTER_HANDLE  pPrinterHandle)

Definition at line 257 of file jobs.c.

258 {
259  const WCHAR wszDoubleBackslash[] = L"\\";
260  const DWORD cchDoubleBackslash = _countof(wszDoubleBackslash) - 1;
261 
262  DWORD cchMachineName;
263  DWORD cchUserName;
264  DWORD dwErrorCode;
265  PLOCAL_JOB pJob;
266  RPC_BINDING_HANDLE hServerBinding = NULL;
267  RPC_WSTR pwszBinding = NULL;
268  RPC_WSTR pwszMachineName = NULL;
269 
270  TRACE("CreateJob(%p)\n", pPrinterHandle);
271 
272  // Create a new job.
273  pJob = DllAllocSplMem(sizeof(LOCAL_JOB));
274  if (!pJob)
275  {
276  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
277  ERR("DllAllocSplMem failed!\n");
278  goto Cleanup;
279  }
280 
281  // Reserve an ID for this job.
282  if (!_GetNextJobID(&pJob->dwJobID))
283  {
284  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
285  goto Cleanup;
286  }
287 
288  // Copy over defaults to the LOCAL_JOB structure.
289  pJob->pPrinter = pPrinterHandle->pPrinter;
290  pJob->pPrintProcessor = pPrinterHandle->pPrinter->pPrintProcessor;
291  pJob->dwPriority = DEF_PRIORITY;
293  pJob->pwszDatatype = AllocSplStr(pPrinterHandle->pwszDatatype);
295  pJob->pDevMode = DuplicateDevMode(pPrinterHandle->pDevMode);
296  GetSystemTime(&pJob->stSubmitted);
297 
298  // Get the user name for the Job.
299  cchUserName = UNLEN + 1;
300  pJob->pwszUserName = DllAllocSplMem(cchUserName * sizeof(WCHAR));
301  if (!GetUserNameW(pJob->pwszUserName, &cchUserName))
302  {
303  dwErrorCode = GetLastError();
304  ERR("GetUserNameW failed with error %lu!\n", dwErrorCode);
305  goto Cleanup;
306  }
307 
308  // FIXME: For now, pwszNotifyName equals pwszUserName.
309  pJob->pwszNotifyName = AllocSplStr(pJob->pwszUserName);
310 
311  // Get the name of the machine that submitted the Job over RPC.
312  dwErrorCode = RpcBindingServerFromClient(NULL, &hServerBinding);
313  if (dwErrorCode != RPC_S_OK)
314  {
315  ERR("RpcBindingServerFromClient failed with status %lu!\n", dwErrorCode);
316  goto Cleanup;
317  }
318 
319  dwErrorCode = RpcBindingToStringBindingW(hServerBinding, &pwszBinding);
320  if (dwErrorCode != RPC_S_OK)
321  {
322  ERR("RpcBindingToStringBindingW failed with status %lu!\n", dwErrorCode);
323  goto Cleanup;
324  }
325 
326  dwErrorCode = RpcStringBindingParseW(pwszBinding, NULL, NULL, &pwszMachineName, NULL, NULL);
327  if (dwErrorCode != RPC_S_OK)
328  {
329  ERR("RpcStringBindingParseW failed with status %lu!\n", dwErrorCode);
330  goto Cleanup;
331  }
332 
333  cchMachineName = wcslen(pwszMachineName);
334  pJob->pwszMachineName = DllAllocSplMem((cchMachineName + cchDoubleBackslash + 1) * sizeof(WCHAR));
335  CopyMemory(pJob->pwszMachineName, wszDoubleBackslash, cchDoubleBackslash * sizeof(WCHAR));
336  CopyMemory(&pJob->pwszMachineName[cchDoubleBackslash], pwszMachineName, (cchMachineName + 1) * sizeof(WCHAR));
337 
338  // Add the job to the Global Job List.
340  {
341  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
342  ERR("InsertElementSkiplist failed for job %lu for the GlobalJobList!\n", pJob->dwJobID);
343  goto Cleanup;
344  }
345 
346  // Add the job at the end of the Printer's Job List.
347  // As all new jobs are created with default priority, we can be sure that it would always be inserted at the end.
348  if (!InsertTailElementSkiplist(&pJob->pPrinter->JobList, pJob))
349  {
350  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
351  ERR("InsertTailElementSkiplist failed for job %lu for the Printer's Job List!\n", pJob->dwJobID);
352  goto Cleanup;
353  }
354 
355  // We were successful!
356  pPrinterHandle->bStartedDoc = TRUE;
357  pPrinterHandle->pJob = pJob;
358  dwErrorCode = ERROR_SUCCESS;
359 
360  // Don't let the cleanup routine free this.
361  pJob = NULL;
362 
363 Cleanup:
364  if (pJob)
365  DllFreeSplMem(pJob);
366 
367  if (pwszMachineName)
368  RpcStringFreeW(&pwszMachineName);
369 
370  if (pwszBinding)
371  RpcStringFreeW(&pwszBinding);
372 
373  if (hServerBinding)
374  RpcBindingFree(&hServerBinding);
375 
376  return dwErrorCode;
377 }
SYSTEMTIME stSubmitted
Definition: precomp.h:147
PDEVMODEW pDevMode
Definition: precomp.h:174
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:783
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL InsertTailElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:308
RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR *String)
Definition: rpcrt4_main.c:174
#define TRUE
Definition: types.h:120
static BOOL _GetNextJobID(PDWORD dwJobID)
Definition: jobs.c:73
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PWSTR pwszMachineName
Definition: precomp.h:160
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
SKIPLIST JobList
Definition: precomp.h:130
#define DEF_PRIORITY
Definition: winspool.h:230
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
DWORD dwPriority
Definition: precomp.h:146
PDEVMODEW pDevMode
Definition: precomp.h:161
#define JOB_STATUS_SPOOLING
Definition: winspool.h:341
DWORD dwJobID
Definition: precomp.h:140
BOOL InsertElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:250
PWSTR pwszDatatype
Definition: precomp.h:151
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:128
RPCRTAPI RPC_STATUS RPC_ENTRY RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE *ServerBinding)
Definition: rpc_binding.c:1642
DWORD dwStatus
Definition: precomp.h:159
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
RPC_STATUS WINAPI RpcStringBindingParseW(RPC_WSTR StringBinding, RPC_WSTR *ObjUuid, RPC_WSTR *Protseq, RPC_WSTR *NetworkAddr, RPC_WSTR *Endpoint, RPC_WSTR *Options)
Definition: rpc_binding.c:674
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define TRACE(s)
Definition: solgame.cpp:4
RPC_STATUS WINAPI RpcBindingToStringBindingW(RPC_BINDING_HANDLE Binding, RPC_WSTR *StringBinding)
Definition: rpc_binding.c:943
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
PLOCAL_PRINTER pPrinter
Definition: precomp.h:144
#define CopyMemory
Definition: winbase.h:1662
unsigned long DWORD
Definition: ntddk_ex.h:95
PWSTR pwszNotifyName
Definition: precomp.h:149
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
PWSTR pwszDocumentName
Definition: precomp.h:150
#define UNLEN
Definition: sspi.c:28
PDEVMODEW DuplicateDevMode(PDEVMODEW pInput)
Definition: tools.c:61
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PLOCAL_JOB pJob
Definition: precomp.h:172
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:145
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PLOCAL_PRINTER pPrinter
Definition: precomp.h:171
const WCHAR wszDefaultDocumentName[]
Definition: main.c:25
SKIPLIST GlobalJobList
Definition: jobs.c:11
PWSTR pwszUserName
Definition: precomp.h:148
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by LocalAddJob(), and LocalStartDocPrinter().

◆ CreatePortEntry()

BOOL CreatePortEntry ( PCWSTR  pwszName,
PLOCAL_PRINT_MONITOR  pPrintMonitor 
)

Definition at line 37 of file ports.c.

38 {
39  PLOCAL_PORT pPort;
40  DWORD cbPortName = (wcslen( pwszName ) + 1) * sizeof(WCHAR);
41 
42  // Create a new LOCAL_PORT structure for it.
43  pPort = DllAllocSplMem(sizeof(LOCAL_PORT) + cbPortName);
44  if (!pPort)
45  {
47  return FALSE;
48  }
49 
50  pPort->pPrintMonitor = pPrintMonitor;
51  pPort->pwszName = wcscpy( (PWSTR)(pPort+1), pwszName );
52 
53  // Insert it into the list and advance to the next port.
54  InsertTailList(&_PortList, &pPort->Entry);
55 
56  return TRUE;
57 }
LIST_ENTRY Entry
Definition: precomp.h:89
PWSTR pwszName
Definition: precomp.h:90
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:91
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define InsertTailList(ListHead, Entry)
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static LIST_ENTRY _PortList
Definition: ports.c:11
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95

Referenced by _HandleAddPort(), LocalAddPort(), and LocalAddPortEx().

◆ DuplicateDevMode()

PDEVMODEW DuplicateDevMode ( PDEVMODEW  pInput)

Definition at line 61 of file tools.c.

62 {
63  PDEVMODEW pOutput;
64 
65  // Allocate a buffer for this DevMode.
66  pOutput = DllAllocSplMem(pInput->dmSize + pInput->dmDriverExtra);
67  if (!pOutput)
68  {
69  ERR("DllAllocSplMem failed!\n");
70  return NULL;
71  }
72 
73  // Copy it.
74  CopyMemory(pOutput, pInput, pInput->dmSize + pInput->dmDriverExtra);
75 
76  return pOutput;
77 }
WORD dmDriverExtra
Definition: wingdi.h:1620
WORD dmSize
Definition: wingdi.h:1619
#define CopyMemory
Definition: winbase.h:1662
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95

Referenced by _LocalOpenPrinterHandle(), CreateJob(), and ReadJobShadowFile().

◆ FindDatatype()

BOOL FindDatatype ( const PLOCAL_PRINT_PROCESSOR  pPrintProcessor,
PCWSTR  pwszDatatype 
)

Definition at line 80 of file printprocessors.c.

81 {
82  DWORD i;
83  PDATATYPES_INFO_1W pCurrentDatatype = pPrintProcessor->pDatatypesInfo1;
84 
85  TRACE("FindDatatype(%p, %S)\n", pPrintProcessor, pwszDatatype);
86 
87  if (!pwszDatatype)
88  return FALSE;
89 
90  for (i = 0; i < pPrintProcessor->dwDatatypeCount; i++)
91  {
92  if (wcsicmp(pCurrentDatatype->pName, pwszDatatype) == 0)
93  return TRUE;
94 
95  ++pCurrentDatatype;
96  }
97 
98  return FALSE;
99 }
PDATATYPES_INFO_1W pDatatypesInfo1
Definition: precomp.h:102
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wcsicmp
Definition: compat.h:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by _LocalOpenPrinterHandle(), _LocalSetJobLevel1(), _LocalSetJobLevel2(), InitializePrinterList(), and LocalStartDocPrinter().

◆ FindPort()

PLOCAL_PORT FindPort ( PCWSTR  pwszName)

Definition at line 15 of file ports.c.

16 {
18  PLOCAL_PORT pPort;
19 
20  TRACE("FindPort(%S)\n", pwszName);
21 
22  if (!pwszName)
23  return NULL;
24 
26  {
28 
29  if (_wcsicmp(pPort->pwszName, pwszName) == 0)
30  return pPort;
31  }
32 
33  return NULL;
34 }
PWSTR pwszName
Definition: precomp.h:90
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:119
static LIST_ENTRY _PortList
Definition: ports.c:11
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by _HandleDeletePort(), _LocalOpenPortHandle(), _LocalOpenXcvHandle(), InitializePrinterList(), LocalAddPort(), LocalAddPortEx(), LocalConfigurePort(), LocalDeletePort(), and LocalSetPort().

◆ FindPrintMonitor()

PLOCAL_PRINT_MONITOR FindPrintMonitor ( PCWSTR  pwszName)

Definition at line 28 of file monitors.c.

29 {
31  PLOCAL_PRINT_MONITOR pPrintMonitor;
32 
33  TRACE("FindPrintMonitor(%S)\n", pwszName);
34 
35  if (!pwszName)
36  return NULL;
37 
39  {
41 
42  if (_wcsicmp(pPrintMonitor->pwszName, pwszName) == 0)
43  return pPrintMonitor;
44  }
45 
46  return NULL;
47 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by _LocalOpenXcvHandle(), LocalAddPort(), LocalAddPortEx(), and LocalDeleteMonitor().

◆ FindPrintProcessor()

PLOCAL_PRINT_PROCESSOR FindPrintProcessor ( PCWSTR  pwszName)

Definition at line 102 of file printprocessors.c.

103 {
105  PLOCAL_PRINT_PROCESSOR pPrintProcessor;
106 
107  TRACE("FindPrintProcessor(%S)\n", pwszName);
108 
109  if (!pwszName)
110  return NULL;
111 
113  {
115 
116  if (wcsicmp(pPrintProcessor->pwszName, pwszName) == 0)
117  return pPrintProcessor;
118  }
119 
120  return NULL;
121 }
static LIST_ENTRY _PrintProcessorList
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
#define wcsicmp
Definition: compat.h:15
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
base of all file and directory entries
Definition: entries.h:82

Referenced by _LocalSetJobLevel2(), InitializePrinterList(), LocalEnumPrintProcessorDatatypes(), and ReadJobShadowFile().

◆ FreeJob()

void FreeJob ( PLOCAL_JOB  pJob)

Definition at line 1452 of file jobs.c.

1453 {
1454  PWSTR pwszSHDFile;
1455 
1456  TRACE("FreeJob(%p)\n", pJob);
1457 
1458  // Remove the Job from both Job Lists.
1459  DeleteElementSkiplist(&pJob->pPrinter->JobList, pJob);
1461 
1462  // Try to delete the corresponding .SHD file.
1463  pwszSHDFile = DllAllocSplMem(GetJobFilePath(L"SHD", 0, NULL));
1464  if (pwszSHDFile && GetJobFilePath(L"SHD", pJob->dwJobID, pwszSHDFile))
1465  DeleteFileW(pwszSHDFile);
1466 
1467  // Free memory for the mandatory fields.
1468  DllFreeSplMem(pJob->pDevMode);
1469  DllFreeSplStr(pJob->pwszDatatype);
1473  DllFreeSplStr(pJob->pwszUserName);
1474 
1475  // Free memory for the optional fields if they are present.
1476  if (pJob->pwszOutputFile)
1478 
1479  if (pJob->pwszPrintProcessorParameters)
1481 
1482  if (pJob->pwszStatus)
1483  DllFreeSplStr(pJob->pwszStatus);
1484 
1485  // Finally free the job structure itself.
1486  DllFreeSplMem(pJob);
1487 }
PWSTR pwszOutputFile
Definition: precomp.h:152
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PWSTR pwszMachineName
Definition: precomp.h:160
SKIPLIST JobList
Definition: precomp.h:130
PDEVMODEW pDevMode
Definition: precomp.h:161
DWORD dwJobID
Definition: precomp.h:140
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
PWSTR pwszDatatype
Definition: precomp.h:151
DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
Definition: jobs.c:146
PWSTR pwszPrintProcessorParameters
Definition: precomp.h:153
#define TRACE(s)
Definition: solgame.cpp:4
PLOCAL_PRINTER pPrinter
Definition: precomp.h:144
PWSTR pwszNotifyName
Definition: precomp.h:149
static const WCHAR L[]
Definition: oid.c:1250
PWSTR pwszDocumentName
Definition: precomp.h:150
#define NULL
Definition: types.h:112
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:130
PVOID DeleteElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:146
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PWSTR pwszStatus
Definition: precomp.h:154
SKIPLIST GlobalJobList
Definition: jobs.c:11
PWSTR pwszUserName
Definition: precomp.h:148

Referenced by _LocalClosePrinterHandle(), and LocalSetJob().

◆ GetJobFilePath()

DWORD GetJobFilePath ( PCWSTR  pwszExtension,
DWORD  dwJobID,
PWSTR  pwszOutput 
)

Definition at line 146 of file jobs.c.

147 {
148  TRACE("GetJobFilePath(%S, %lu, %p)\n", pwszExtension, dwJobID, pwszOutput);
149 
150  if (pwszOutput)
151  {
152  CopyMemory(pwszOutput, wszJobDirectory, cchJobDirectory * sizeof(WCHAR));
153  swprintf(&pwszOutput[cchJobDirectory], L"\\%05lu.%s", dwJobID, pwszExtension);
154  }
155 
156  // pwszExtension may be L"SPL" or L"SHD", same length for both!
157  return (cchJobDirectory + sizeof("\\?????.SPL")) * sizeof(WCHAR);
158 }
#define swprintf
Definition: precomp.h:40
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CopyMemory
Definition: winbase.h:1662
DWORD cchJobDirectory
Definition: main.c:14
static const WCHAR L[]
Definition: oid.c:1250
WCHAR wszJobDirectory[MAX_PATH]
Definition: main.c:13

Referenced by _LocalOpenPrinterHandle(), FreeJob(), InitializeGlobalJobList(), LocalAddJob(), LocalScheduleJob(), LocalSetJob(), and PrintingThreadProc().

◆ InitializeFormList()

BOOL InitializeFormList ( VOID  )

Definition at line 228 of file forms.c.

229 {
230  DWORD dwErrorCode;
231  PFORM_INFO_LIST pfil;
232  REGISTRYFORMINFO rfi;
233 
234  FIXME("InitializeFormList\n");
235 
236  dwErrorCode = (DWORD)RegCreateKeyExW( HKEY_LOCAL_MACHINE,
237  L"SYSTEM\\CurrentControlSet\\Control\\Print\\Forms",
238  0,
239  NULL,
242  NULL,
243  &hFormCKey,
244  NULL ); // KEY_OPENED_EXISTING_KEY );
245 
246  if ( dwErrorCode != ERROR_SUCCESS && dwErrorCode != ERROR_ALREADY_EXISTS )
247  {
248  ERR("RegCreateKeyExW failed for the Forms with error %lu!\n", dwErrorCode);
249  goto Cleanup;
250  }
251 
252  // Open some registry keys and leave them open. We need them multiple times throughout the Local Spooler.
253  dwErrorCode = (DWORD)RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Print\\Forms", 0, KEY_ALL_ACCESS, &hFormsKey);
254  if (dwErrorCode != ERROR_SUCCESS)
255  {
256  ERR("RegOpenKeyExW failed for \"Forms\" with error %lu!\n", dwErrorCode);
257  goto Cleanup;
258  }
259 
260  _dwLastForm = 1;
261 
263 
264  {
265  int i = 0, Size;
266  while ( BuiltInForms[ i ].pName != NULL )
267  {
268  TRACE("InitializeFormList L s %S\n",BuiltInForms[ i ].pName );
269 
270  Size = sizeof(FORM_INFO_LIST) + ((wcslen(BuiltInForms[ i ].pName) + 1) * sizeof(WCHAR));
271 
272  pfil = DllAllocSplMem( Size );
273 
274  pfil->pName = wcscpy( (PWSTR)(pfil+1), BuiltInForms[ i ].pName );
275  pfil->Flags = BuiltInForms[ i ].Flags;
276  pfil->Size = BuiltInForms[ i ].Size;
277  pfil->ImageableArea = BuiltInForms[ i ].ImageableArea;
278  pfil->Sig = FORMINFOSIG;
279  pfil->Index = _dwLastForm++;
280  pfil->pKeyword = NULL;
281  pfil->StringType = STRING_NONE;
282  pfil->pMuiDll = NULL;
283  pfil->dwResourceId = 0;
284  pfil->pDisplayName = NULL;
285  pfil->wLangId = 0;
286 
287  InsertTailList( &FormList, &pfil->List );
288 
289  rfi.Size = pfil->Size;
290  rfi.ImageableArea = pfil->ImageableArea;
291  rfi.Index = pfil->Index;
292  rfi.Flags = pfil->Flags;
293 
294  dwErrorCode = RegSetValueExW( hFormsKey, pfil->pName, 0, REG_BINARY, (PBYTE)&rfi, sizeof( rfi ) );
295  if ( dwErrorCode == ERROR_SUCCESS )
296  {
297  TRACE("Init : RQVEW : %S added\n",pfil->pName);
298  }
299 
300  i++;
301  }
302  }
303 
304 Cleanup:
305  return TRUE;
306 }
static DWORD _dwLastForm
Definition: forms.c:22
#define STRING_NONE
Definition: winspool.h:672
HKEY hFormsKey
Definition: forms.c:225
#define ERROR_SUCCESS
Definition: deptool.c:10
RECTL ImageableArea
Definition: forms.c:219
#define REG_BINARY
Definition: nt_native.h:1496
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
FORM_INFO_1W BuiltInForms[]
Definition: forms.c:160
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
LIST_ENTRY List
Definition: forms.c:15
#define InsertTailList(ListHead, Entry)
#define DWORD
Definition: nt_native.h:44
DWORD Flags
Definition: winspool.h:633
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LIST_ENTRY FormList
Definition: forms.c:21
#define FIXME(fmt,...)
Definition: debug.h:111
RECTL ImageableArea
Definition: winspool.h:636
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
DWORD Sig
Definition: forms.c:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _FORM_INFO_LIST FORM_INFO_LIST
HKEY hFormCKey
Definition: forms.c:224
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
DWORD Index
Definition: forms.c:17
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FORMINFOSIG
Definition: forms.c:10
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
BYTE * PBYTE
Definition: pedump.c:66
SIZEL Size
Definition: winspool.h:635
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _InitializeLocalSpooler().

◆ InitializeGlobalJobList()

BOOL InitializeGlobalJobList ( VOID  )

Definition at line 161 of file jobs.c.

162 {
163  const WCHAR wszPath[] = L"\\?????.SHD";
164  const DWORD cchPath = _countof(wszPath) - 1;
165 
166  DWORD dwErrorCode;
167  DWORD dwJobID;
168  HANDLE hFind;
169  PLOCAL_JOB pJob = NULL;
170  PWSTR p;
171  WCHAR wszFullPath[MAX_PATH];
172  WIN32_FIND_DATAW FindData;
173 
174  TRACE("InitializeGlobalJobList()\n");
175 
176  // This one is incremented in _GetNextJobID.
177  _dwLastJobID = 0;
178 
179  // Initialize an empty list for all jobs of all local printers.
180  // We will search it by Job ID (supply a pointer to a DWORD in LookupElementSkiplist).
182 
183  // Construct the full path search pattern.
184  CopyMemory(wszFullPath, wszJobDirectory, cchJobDirectory * sizeof(WCHAR));
185  CopyMemory(&wszFullPath[cchJobDirectory], wszPath, (cchPath + 1) * sizeof(WCHAR));
186 
187  // Use the search pattern to look for unfinished jobs serialized in shadow files (.SHD)
188  hFind = FindFirstFileW(wszFullPath, &FindData);
189  if (hFind == INVALID_HANDLE_VALUE)
190  {
191  // No unfinished jobs found.
192  dwErrorCode = ERROR_SUCCESS;
193  goto Cleanup;
194  }
195 
196  do
197  {
198  // Skip possible subdirectories.
199  if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
200  continue;
201 
202  // Extract the Job ID and verify the file name format at the same time.
203  // This includes all valid names (like "00005.SHD") and excludes invalid ones (like "10ABC.SHD").
204  dwJobID = wcstoul(FindData.cFileName, &p, 10);
205  if (!IS_VALID_JOB_ID(dwJobID))
206  continue;
207 
208  if (wcsicmp(p, L".SHD") != 0)
209  continue;
210 
211  // This shadow file has a valid name. Construct the full path and try to load it.
212  GetJobFilePath(L"SHD", dwJobID, wszFullPath);
213  pJob = ReadJobShadowFile(wszFullPath);
214  if (!pJob)
215  continue;
216 
217  // Add it to the Global Job List.
219  {
220  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
221  ERR("InsertElementSkiplist failed for job %lu for the GlobalJobList!\n", pJob->dwJobID);
222  goto Cleanup;
223  }
224 
225  // Add it to the Printer's Job List.
226  if (!InsertElementSkiplist(&pJob->pPrinter->JobList, pJob))
227  {
228  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
229  ERR("InsertElementSkiplist failed for job %lu for the Printer's Job List!\n", pJob->dwJobID);
230  goto Cleanup;
231  }
232  }
233  while (FindNextFileW(hFind, &FindData));
234 
235  dwErrorCode = ERROR_SUCCESS;
236 
237 Cleanup:
238  // Outside the loop
239  if (hFind)
240  FindClose(hFind);
241 
242  SetLastError(dwErrorCode);
243  return (dwErrorCode == ERROR_SUCCESS);
244 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
SKIPLIST JobList
Definition: precomp.h:130
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
void InitializeSkiplist(PSKIPLIST Skiplist, PSKIPLIST_ALLOCATE_ROUTINE AllocateRoutine, PSKIPLIST_COMPARE_ROUTINE CompareRoutine, PSKIPLIST_FREE_ROUTINE FreeRoutine)
Definition: skiplist.c:220
static DWORD _dwLastJobID
Definition: jobs.c:14
DWORD dwJobID
Definition: precomp.h:140
PLOCAL_JOB ReadJobShadowFile(PCWSTR pwszFilePath)
Definition: jobs.c:1187
BOOL InsertElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:250
DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
Definition: jobs.c:146
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
PLOCAL_PRINTER pPrinter
Definition: precomp.h:144
#define MAX_PATH
Definition: compat.h:34
#define CopyMemory
Definition: winbase.h:1662
DWORD cchJobDirectory
Definition: main.c:14
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define wcsicmp
Definition: compat.h:15
void(WINAPI * PSKIPLIST_FREE_ROUTINE)(PVOID)
Definition: skiplist.h:24
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
#define IS_VALID_JOB_ID(ID)
Definition: precomp.h:38
WCHAR wszJobDirectory[MAX_PATH]
Definition: main.c:13
#define NULL
Definition: types.h:112
static int WINAPI _GlobalJobListCompareRoutine(PVOID FirstStruct, PVOID SecondStruct)
Definition: jobs.c:100
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
GLfloat GLfloat p
Definition: glext.h:8902
SKIPLIST GlobalJobList
Definition: jobs.c:11
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by _InitializeLocalSpooler().

◆ InitializePortList()

BOOL InitializePortList ( void  )

Definition at line 60 of file ports.c.

61 {
62  BOOL bReturnValue;
63  DWORD cbNeeded;
64  DWORD cbPortName;
65  DWORD dwErrorCode;
66  DWORD dwReturned;
67  DWORD i;
68  PLOCAL_PORT pPort;
69  PLOCAL_PRINT_MONITOR pPrintMonitor;
72  PPORT_INFO_1W pPortInfo1 = NULL;
73 
74  TRACE("InitializePortList()\n");
75 
76  // Initialize an empty list for our Ports.
78 
79  // Loop through all Print Monitors.
81  {
82  // Cleanup from the previous run.
83  if (pPortInfo1)
84  {
85  DllFreeSplMem(pPortInfo1);
86  pPortInfo1 = NULL;
87  }
88 
90 
91  // Determine the required buffer size for EnumPorts.
92  if (pPrintMonitor->bIsLevel2)
93  bReturnValue = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnEnumPorts(pPrintMonitor->hMonitor, NULL, 1, NULL, 0, &cbNeeded, &dwReturned);
94  else
95  bReturnValue = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnEnumPorts(NULL, 1, NULL, 0, &cbNeeded, &dwReturned);
96 
97  // Check the returned error code.
99  {
100  ERR("Print Monitor \"%S\" failed with error %lu on EnumPorts!\n", pPrintMonitor->pwszName, GetLastError());
101  continue;
102  }
103 
104  // Allocate a buffer large enough.
105  pPortInfo1 = DllAllocSplMem(cbNeeded);
106  if (!pPortInfo1)
107  {
108  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
109  ERR("DllAllocSplMem failed!\n");
110  goto Cleanup;
111  }
112 
113  // Get the ports handled by this monitor.
114  if (pPrintMonitor->bIsLevel2)
115  bReturnValue = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnEnumPorts(pPrintMonitor->hMonitor, NULL, 1, (PBYTE)pPortInfo1, cbNeeded, &cbNeeded, &dwReturned);
116  else
117  bReturnValue = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnEnumPorts(NULL, 1, (PBYTE)pPortInfo1, cbNeeded, &cbNeeded, &dwReturned);
118 
119  // Check the return value.
120  if (!bReturnValue)
121  {
122  ERR("Print Monitor \"%S\" failed with error %lu on EnumPorts!\n", pPrintMonitor->pwszName, GetLastError());
123  continue;
124  }
125 
126  // Loop through all returned ports.
127  p = pPortInfo1;
128 
129  for (i = 0; i < dwReturned; i++)
130  {
131  cbPortName = (wcslen(p->pName) + 1) * sizeof(WCHAR);
132 
133  // Create a new LOCAL_PORT structure for it.
134  pPort = DllAllocSplMem(sizeof(LOCAL_PORT) + cbPortName);
135  if (!pPort)
136  {
137  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
138  ERR("DllAllocSplMem failed!\n");
139  goto Cleanup;
140  }
141 
142  pPort->pPrintMonitor = pPrintMonitor;
143  pPort->pwszName = (PWSTR)((PBYTE)pPort + sizeof(LOCAL_PORT));
144  CopyMemory(pPort->pwszName, p->pName, cbPortName);
145 
146  // Insert it into the list and advance to the next port.
147  InsertTailList(&_PortList, &pPort->Entry);
148  p++;
149  }
150  }
151 
152  dwErrorCode = ERROR_SUCCESS;
153 
154 Cleanup:
155  // Inside the loop
156  if (pPortInfo1)
157  DllFreeSplMem(pPortInfo1);
158 
159  SetLastError(dwErrorCode);
160  return (dwErrorCode == ERROR_SUCCESS);
161 }
LIST_ENTRY Entry
Definition: precomp.h:89
PWSTR pwszName
Definition: precomp.h:90
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:91
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define InsertTailList(ListHead, Entry)
struct _LOCAL_PORT LOCAL_PORT
Definition: precomp.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CopyMemory
Definition: winbase.h:1662
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
Definition: typedefs.h:119
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static LIST_ENTRY _PortList
Definition: ports.c:11
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
struct _MONITOR2 * PMONITOR2
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
GLfloat GLfloat p
Definition: glext.h:8902
struct _MONITOREX * LPMONITOREX
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
BYTE * PBYTE
Definition: pedump.c:66
base of all file and directory entries
Definition: entries.h:82
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by _InitializeLocalSpooler().

◆ InitializePrinterDrivers()

BOOL InitializePrinterDrivers ( VOID  )

Definition at line 77 of file printerdrivers.c.

78 {
79  WCHAR szSysDir[MAX_PATH];
80  DWORD cbBuf;
81 
82  if (wszLocalSplFile[0] && wszPrintUiFile[0])
83  return TRUE;
84 
85  if (!GetSystemDirectoryW(szSysDir, _countof(szSysDir)))
86  {
87  ERR("GetSystemDirectoryW failed\n");
88  return FALSE;
89  }
90 
91  StringCbCopyW(wszLocalSplFile, sizeof(wszLocalSplFile), szSysDir);
92  StringCbCatW(wszLocalSplFile, sizeof(wszLocalSplFile), L"\\localspl.dll");
93 
94  StringCbCopyW(wszPrintUiFile, sizeof(wszPrintUiFile), szSysDir);
95  StringCbCatW(wszPrintUiFile, sizeof(wszPrintUiFile), L"\\printui.dll");
96 
97  if (!LocalGetPrinterDriverDirectory(NULL, (PWSTR)wszCurrentEnvironment, 1, (PBYTE)szSysDir, (DWORD)sizeof(szSysDir), &cbBuf))
98  {
99  ERR("LocalGetPrinterDriverDirectory failed\n");
100  return FALSE;
101  }
102 
103  StringCbCopyW(wszDriverPath, sizeof(wszDriverPath), szSysDir);
106 
107  // HAX! need to get it from the Reg Key L"Driver"!
108  StringCbCatW(wszDriverPath, sizeof(wszDriverPath), L"UniDrv.dll");
109 
110  FIXME("DriverPath : %S\n",wszDriverPath);
111 
112  return TRUE;
113 }
static WCHAR wszPrintUiFile[MAX_PATH]
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI LocalGetPrinterDriverDirectory(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverDirectory, DWORD cbBuf, PDWORD pcbNeeded)
static WCHAR wszDriverPath[MAX_PATH]
static const WCHAR backslashW[]
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
const WCHAR wszCurrentEnvironment[]
Definition: prtprocenv.h:11
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR version3_subdirW[]
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
static WCHAR wszLocalSplFile[MAX_PATH]
#define ERR(fmt,...)
Definition: debug.h:110
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
#define NULL
Definition: types.h:112
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
BYTE * PBYTE
Definition: pedump.c:66

Referenced by _InitializeLocalSpooler().

◆ InitializePrinterJobList()

void InitializePrinterJobList ( PLOCAL_PRINTER  pPrinter)

Definition at line 247 of file jobs.c.

248 {
249  TRACE("InitializePrinterJobList(%p)\n", pPrinter);
250 
251  // Initialize an empty list for this printer's jobs.
252  // This one is only for sorting the jobs. If you need to lookup a job, search the GlobalJobList by Job ID.
254 }
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
SKIPLIST JobList
Definition: precomp.h:130
void InitializeSkiplist(PSKIPLIST Skiplist, PSKIPLIST_ALLOCATE_ROUTINE AllocateRoutine, PSKIPLIST_COMPARE_ROUTINE CompareRoutine, PSKIPLIST_FREE_ROUTINE FreeRoutine)
Definition: skiplist.c:220
#define TRACE(s)
Definition: solgame.cpp:4
static int WINAPI _PrinterJobListCompareRoutine(PVOID FirstStruct, PVOID SecondStruct)
Definition: jobs.c:115
void(WINAPI * PSKIPLIST_FREE_ROUTINE)(PVOID)
Definition: skiplist.h:24
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95

Referenced by InitializePrinterList().

◆ InitializePrinterList()

BOOL InitializePrinterList ( void  )

Definition at line 107 of file printers.c.

108 {
109  DWORD cbData;
110  DWORD cchPrinterName;
111  DWORD dwErrorCode;
112  DWORD dwSubKeys;
113  DWORD i;
114  HKEY hSubKey = NULL;
115  PLOCAL_PORT pPort;
116  PLOCAL_PRINTER pPrinter = NULL;
117  PLOCAL_PRINT_PROCESSOR pPrintProcessor;
118  PWSTR pwszPort = NULL;
119  PWSTR pwszPrintProcessor = NULL;
120  WCHAR wszPrinterName[MAX_PRINTER_NAME + 1];
121 
122  TRACE("InitializePrinterList()\n");
123 
124  // Initialize an empty list for our printers.
126 
127  // Get the number of subkeys of the printers registry key. Each subkey is a local printer there.
128  dwErrorCode = (DWORD)RegQueryInfoKeyW(hPrintersKey, NULL, NULL, NULL, &dwSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
129  if (dwErrorCode != ERROR_SUCCESS)
130  {
131  ERR("RegQueryInfoKeyW failed with status %lu!\n", dwErrorCode);
132  goto Cleanup;
133  }
134 
135  // Loop through all available local printers.
136  for (i = 0; i < dwSubKeys; i++)
137  {
138  // Cleanup tasks from the previous run
139  if (hSubKey)
140  {
141  RegCloseKey(hSubKey);
142  hSubKey = NULL;
143  }
144 
145  if (pPrinter)
146  {
147  if (pPrinter->pDefaultDevMode)
148  DllFreeSplMem(pPrinter->pDefaultDevMode);
149 
150  if (pPrinter->pwszDefaultDatatype)
152 
153  if (pPrinter->pwszDescription)
154  DllFreeSplStr(pPrinter->pwszDescription);
155 
156  if (pPrinter->pwszPrinterDriver)
157  DllFreeSplStr(pPrinter->pwszPrinterDriver);
158 
159  if (pPrinter->pwszPrinterName)
160  DllFreeSplStr(pPrinter->pwszPrinterName);
161 
162  DllFreeSplMem(pPrinter);
163  pPrinter = NULL;
164  }
165 
166  if (pwszPrintProcessor)
167  {
168  DllFreeSplStr(pwszPrintProcessor);
169  pwszPrintProcessor = NULL;
170  }
171 
172  // Get the name of this printer.
173  cchPrinterName = _countof(wszPrinterName);
174  dwErrorCode = (DWORD)RegEnumKeyExW(hPrintersKey, i, wszPrinterName, &cchPrinterName, NULL, NULL, NULL, NULL);
175  if (dwErrorCode == ERROR_MORE_DATA)
176  {
177  // This printer name exceeds the maximum length and is invalid.
178  continue;
179  }
180  else if (dwErrorCode != ERROR_SUCCESS)
181  {
182  ERR("RegEnumKeyExW failed for iteration %lu with status %lu!\n", i, dwErrorCode);
183  continue;
184  }
185 
186  // Open this Printer's registry key.
187  dwErrorCode = (DWORD)RegOpenKeyExW(hPrintersKey, wszPrinterName, 0, KEY_READ, &hSubKey);
188  if (dwErrorCode != ERROR_SUCCESS)
189  {
190  ERR("RegOpenKeyExW failed for Printer \"%S\" with status %lu!\n", wszPrinterName, dwErrorCode);
191  continue;
192  }
193 
194  // Get the Print Processor.
195  pwszPrintProcessor = AllocAndRegQueryWSZ(hSubKey, L"Print Processor");
196  if (!pwszPrintProcessor)
197  continue;
198 
199  // Try to find it in the Print Processor List.
200  pPrintProcessor = FindPrintProcessor(pwszPrintProcessor);
201  if (!pPrintProcessor)
202  {
203  ERR("Invalid Print Processor \"%S\" for Printer \"%S\"!\n", pwszPrintProcessor, wszPrinterName);
204  continue;
205  }
206 
207  // Get the Port.
208  pwszPort = AllocAndRegQueryWSZ(hSubKey, L"Port");
209  if (!pwszPort)
210  continue;
211 
212  // Try to find it in the Port List.
213  pPort = FindPort(pwszPort);
214  if (!pPort)
215  {
216  ERR("Invalid Port \"%S\" for Printer \"%S\"!\n", pwszPort, wszPrinterName);
217  continue;
218  }
219 
220  // Create a new LOCAL_PRINTER structure for it.
221  pPrinter = DllAllocSplMem(sizeof(LOCAL_PRINTER));
222  if (!pPrinter)
223  {
224  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
225  ERR("DllAllocSplMem failed!\n");
226  goto Cleanup;
227  }
228 
229  pPrinter->pwszPrinterName = AllocSplStr(wszPrinterName);
230  pPrinter->pPrintProcessor = pPrintProcessor;
231  pPrinter->pPort = pPort;
232  InitializePrinterJobList(pPrinter);
233 
234  // Get the location.
235  pPrinter->pwszLocation = AllocAndRegQueryWSZ(hSubKey, L"Location");
236  if (!pPrinter->pwszLocation)
237  continue;
238 
239  // Get the printer driver.
240  pPrinter->pwszPrinterDriver = AllocAndRegQueryWSZ(hSubKey, L"Printer Driver");
241  if (!pPrinter->pwszPrinterDriver)
242  continue;
243 
244  // Get the description.
245  pPrinter->pwszDescription = AllocAndRegQueryWSZ(hSubKey, L"Description");
246  if (!pPrinter->pwszDescription)
247  continue;
248 
249  // Get the default datatype.
250  pPrinter->pwszDefaultDatatype = AllocAndRegQueryWSZ(hSubKey, L"Datatype");
251  if (!pPrinter->pwszDefaultDatatype)
252  continue;
253 
254  // Verify that it's valid.
255  if (!FindDatatype(pPrintProcessor, pPrinter->pwszDefaultDatatype))
256  {
257  ERR("Invalid default datatype \"%S\" for Printer \"%S\"!\n", pPrinter->pwszDefaultDatatype, wszPrinterName);
258  continue;
259  }
260 
261  // Determine the size of the DevMode.
262  dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, NULL, &cbData);
263  if (dwErrorCode != ERROR_SUCCESS)
264  {
265  ERR("Couldn't query the size of the DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
266  continue;
267  }
268 
269  // Allocate enough memory for the DevMode.
270  pPrinter->pDefaultDevMode = DllAllocSplMem(cbData);
271  if (!pPrinter->pDefaultDevMode)
272  {
273  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
274  ERR("DllAllocSplMem failed!\n");
275  goto Cleanup;
276  }
277 
278  // Get the default DevMode.
279  dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Default DevMode", NULL, NULL, (PBYTE)pPrinter->pDefaultDevMode, &cbData);
280  if (dwErrorCode != ERROR_SUCCESS)
281  {
282  ERR("Couldn't query a DevMode for Printer \"%S\", status is %lu, cbData is %lu!\n", wszPrinterName, dwErrorCode, cbData);
283  continue;
284  }
285 
286  // Get the Attributes.
287  cbData = sizeof(DWORD);
288  dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Attributes", NULL, NULL, (PBYTE)&pPrinter->dwAttributes, &cbData);
289  if (dwErrorCode != ERROR_SUCCESS)
290  {
291  ERR("Couldn't query Attributes for Printer \"%S\", status is %lu!\n", wszPrinterName, dwErrorCode);
292  continue;
293  }
294 
295  // Get the Status.
296  cbData = sizeof(DWORD);
297  dwErrorCode = (DWORD)RegQueryValueExW(hSubKey, L"Status", NULL, NULL, (PBYTE)&pPrinter->dwStatus, &cbData);
298  if (dwErrorCode != ERROR_SUCCESS)
299  {
300  ERR("Couldn't query Status for Printer \"%S\", status is %lu!\n", wszPrinterName, dwErrorCode);
301  continue;
302  }
303 
304  // Add this printer to the printer list.
305  if (!InsertElementSkiplist(&PrinterList, pPrinter))
306  {
307  ERR("InsertElementSkiplist failed for Printer \"%S\"!\n", pPrinter->pwszPrinterName);
308  goto Cleanup;
309  }
310 
311  // Don't let the cleanup routines free this.
312  pPrinter = NULL;
313  }
314 
315  dwErrorCode = ERROR_SUCCESS;
316 
317 Cleanup:
318  // Inside the loop
319  if (hSubKey)
320  RegCloseKey(hSubKey);
321 
322  if (pPrinter)
323  {
324  if (pPrinter->pDefaultDevMode)
325  DllFreeSplMem(pPrinter->pDefaultDevMode);
326 
327  if (pPrinter->pwszDefaultDatatype)
329 
330  if (pPrinter->pwszDescription)
331  DllFreeSplStr(pPrinter->pwszDescription);
332 
333  if (pPrinter->pwszPrinterDriver)
334  DllFreeSplStr(pPrinter->pwszPrinterDriver);
335 
336  if (pPrinter->pwszPrinterName)
337  DllFreeSplStr(pPrinter->pwszPrinterName);
338 
339  DllFreeSplMem(pPrinter);
340  }
341 
342  if (pwszPrintProcessor)
343  DllFreeSplStr(pwszPrintProcessor);
344 
345  SetLastError(dwErrorCode);
346  return (dwErrorCode == ERROR_SUCCESS);
347 }
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD dwAttributes
Definition: precomp.h:121
PWSTR pwszPrinterDriver
Definition: precomp.h:124
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
HKEY hPrintersKey
Definition: main.c:12
PWSTR pwszLocation
Definition: precomp.h:123
#define DWORD
Definition: nt_native.h:44
void InitializeSkiplist(PSKIPLIST Skiplist, PSKIPLIST_ALLOCATE_ROUTINE AllocateRoutine, PSKIPLIST_COMPARE_ROUTINE CompareRoutine, PSKIPLIST_FREE_ROUTINE FreeRoutine)
Definition: skiplist.c:220
void InitializePrinterJobList(PLOCAL_PRINTER pPrinter)
Definition: jobs.c:247
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
BOOL InsertElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:250
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:128
PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName)
Definition: tools.c:26
static int WINAPI _PrinterListCompareRoutine(PVOID FirstStruct, PVOID SecondStruct)
Definition: printers.c:91
SKIPLIST PrinterList
Definition: printers.c:11
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
BOOL FindDatatype(const PLOCAL_PRINT_PROCESSOR pPrintProcessor, PCWSTR pwszDatatype)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define MAX_PRINTER_NAME
Definition: fpSetJob.c:25
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
void(WINAPI * PSKIPLIST_FREE_ROUTINE)(PVOID)
Definition: skiplist.h:24
static const WCHAR L[]
Definition: oid.c:1250
PWSTR pwszDefaultDatatype
Definition: precomp.h:126
PLOCAL_PORT FindPort(PCWSTR pwszName)
Definition: ports.c:15
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERROR_MORE_DATA
Definition: dderror.h:13
PWSTR pwszDescription
Definition: precomp.h:125
PDEVMODEW pDefaultDevMode
Definition: precomp.h:127
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD dwStatus
Definition: precomp.h:122
#define NULL
Definition: types.h:112
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:130
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PLOCAL_PRINT_PROCESSOR FindPrintProcessor(PCWSTR pwszName)
PLOCAL_PORT pPort
Definition: precomp.h:129
BYTE * PBYTE
Definition: pedump.c:66
PWSTR pwszPrinterName
Definition: precomp.h:119

Referenced by _InitializeLocalSpooler().

◆ InitializePrintMonitorList()

BOOL InitializePrintMonitorList ( void  )

Definition at line 126 of file monitors.c.

127 {
128  const WCHAR wszMonitorsPath[] = L"SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors";
129  const DWORD cchMonitorsPath = _countof(wszMonitorsPath) - 1;
130 
131  DWORD cchMaxSubKey;
132  DWORD cchPrintMonitorName;
133  DWORD dwErrorCode;
134  DWORD dwSubKeys;
135  DWORD i;
136  HINSTANCE hinstPrintMonitor = NULL;
137  HKEY hKey = NULL;
138  HKEY hSubKey = NULL;
139  MONITORINIT MonitorInit;
140  PInitializePrintMonitor pfnInitializePrintMonitor;
141  PInitializePrintMonitor2 pfnInitializePrintMonitor2;
142  PLOCAL_PRINT_MONITOR pPrintMonitor = NULL;
143  PWSTR pwszRegistryPath = NULL;
144 
145  TRACE("InitializePrintMonitorList()\n");
146 
147  // Initialize an empty list for our Print Monitors.
149 
150  // Open the key containing Print Monitors.
151  dwErrorCode = (DWORD)RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszMonitorsPath, 0, KEY_READ, &hKey);
152  if (dwErrorCode != ERROR_SUCCESS)
153  {
154  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
155  goto Cleanup;
156  }
157 
158  // Get the number of Print Providers and maximum sub key length.
159  dwErrorCode = (DWORD)RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwSubKeys, &cchMaxSubKey, NULL, NULL, NULL, NULL, NULL, NULL);
160  if (dwErrorCode != ERROR_SUCCESS)
161  {
162  ERR("RegQueryInfoKeyW failed with status %lu!\n", dwErrorCode);
163  goto Cleanup;
164  }
165 
166  // Loop through all available Print Providers.
167  for (i = 0; i < dwSubKeys; i++)
168  {
169  // Cleanup tasks from the previous run
170  if (hSubKey)
171  {
172  RegCloseKey(hSubKey);
173  hSubKey = NULL;
174  }
175 
176  if (pwszRegistryPath)
177  {
178  DllFreeSplMem(pwszRegistryPath);
179  pwszRegistryPath = NULL;
180  }
181 
182  if (pPrintMonitor)
183  {
184  if (pPrintMonitor->pwszFileName)
185  DllFreeSplMem(pPrintMonitor->pwszFileName);
186 
187  if (pPrintMonitor->pwszName)
188  DllFreeSplMem(pPrintMonitor->pwszName);
189 
190  DllFreeSplMem(pPrintMonitor);
191  pPrintMonitor = NULL;
192  }
193 
194  // Create a new LOCAL_PRINT_MONITOR structure for it.
195  pPrintMonitor = DllAllocSplMem(sizeof(LOCAL_PRINT_MONITOR));
196  if (!pPrintMonitor)
197  {
198  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
199  ERR("DllAllocSplMem failed!\n");
200  goto Cleanup;
201  }
202 
203  memset( pPrintMonitor, 0, sizeof(LOCAL_PRINT_MONITOR));
204 
205  // Allocate memory for the Print Monitor Name.
206  pPrintMonitor->pwszName = DllAllocSplMem((cchMaxSubKey + 1) * sizeof(WCHAR));
207  if (!pPrintMonitor->pwszName)
208  {
209  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
210  ERR("DllAllocSplMem failed!\n");
211  goto Cleanup;
212  }
213 
214  // Get the name of this Print Monitor.
215  cchPrintMonitorName = cchMaxSubKey + 1;
216  dwErrorCode = (DWORD)RegEnumKeyExW(hKey, i, pPrintMonitor->pwszName, &cchPrintMonitorName, NULL, NULL, NULL, NULL);
217  if (dwErrorCode != ERROR_SUCCESS)
218  {
219  ERR("RegEnumKeyExW failed for iteration %lu with status %lu!\n", i, dwErrorCode);
220  continue;
221  }
222 
223  // Open this Print Monitor's registry key.
224  dwErrorCode = (DWORD)RegOpenKeyExW(hKey, pPrintMonitor->pwszName, 0, KEY_READ, &hSubKey);
225  if (dwErrorCode != ERROR_SUCCESS)
226  {
227  ERR("RegOpenKeyExW failed for Print Provider \"%S\" with status %lu!\n", pPrintMonitor->pwszName, dwErrorCode);
228  continue;
229  }
230 
231  // Get the file name of the Print Monitor.
232  pPrintMonitor->pwszFileName = AllocAndRegQueryWSZ(hSubKey, L"Driver");
233  if (!pPrintMonitor->pwszFileName)
234  continue;
235 
236  // Try to load it.
237  hinstPrintMonitor = LoadLibraryW(pPrintMonitor->pwszFileName);
238  if (!hinstPrintMonitor)
239  {
240  ERR("LoadLibraryW failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
241  continue;
242  }
243 
244  pPrintMonitor->hModule = hinstPrintMonitor;
245 
246  // Try to find a Level 2 initialization routine first.
247  pfnInitializePrintMonitor2 = (PInitializePrintMonitor2)GetProcAddress(hinstPrintMonitor, "InitializePrintMonitor2");
248  if (pfnInitializePrintMonitor2)
249  {
250  // Prepare a MONITORINIT structure.
251  MonitorInit.cbSize = sizeof(MONITORINIT);
252  MonitorInit.bLocal = TRUE;
253 
254  // TODO: Fill the other fields.
255  MonitorInit.hckRegistryRoot = hKey;
256  MonitorInit.pMonitorReg = &MonReg;
257 
258  // Call the Level 2 initialization routine.
259  pPrintMonitor->pMonitor = (PMONITOR2)pfnInitializePrintMonitor2(&MonitorInit, &pPrintMonitor->hMonitor);
260  if (!pPrintMonitor->pMonitor)
261  {
262  ERR("InitializePrintMonitor2 failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
263  continue;
264  }
265  FIXME("InitializePrintMonitor2 loaded.\n");
266  pPrintMonitor->bIsLevel2 = TRUE;
267  }
268  else
269  {
270  // Try to find a Level 1 initialization routine then.
271  pfnInitializePrintMonitor = (PInitializePrintMonitor)GetProcAddress(hinstPrintMonitor, "InitializePrintMonitor");
272  if (pfnInitializePrintMonitor)
273  {
274  // Construct the registry path.
275  pwszRegistryPath = DllAllocSplMem((cchMonitorsPath + 1 + cchPrintMonitorName + 1) * sizeof(WCHAR));
276  if (!pwszRegistryPath)
277  {
278  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
279  ERR("DllAllocSplMem failed!\n");
280  goto Cleanup;
281  }
282 
283  CopyMemory(pwszRegistryPath, wszMonitorsPath, cchMonitorsPath * sizeof(WCHAR));
284  pwszRegistryPath[cchMonitorsPath] = L'\\';
285  CopyMemory(&pwszRegistryPath[cchMonitorsPath + 1], pPrintMonitor->pwszName, (cchPrintMonitorName + 1) * sizeof(WCHAR));
286 
287  // Call the Level 1 initialization routine.
288  pPrintMonitor->pMonitor = (LPMONITOREX)pfnInitializePrintMonitor(pwszRegistryPath);
289  if (!pPrintMonitor->pMonitor)
290  {
291  ERR("InitializePrintMonitor failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
292  continue;
293  }
294  }
295  else
296  {
297  ERR("No initialization routine found for \"%S\"!\n", pPrintMonitor->pwszFileName);
298  continue;
299  }
300  }
301 
302  // Add this Print Monitor to the list.
303  InsertTailList(&PrintMonitorList, &pPrintMonitor->Entry);
304  FIXME("InitializePrintMonitorList Handle %p\n",pPrintMonitor->hMonitor);
305  pPrintMonitor->refcount++;
306 
307  // Don't let the cleanup routine free this.
308  pPrintMonitor = NULL;
309  }
310 
311  dwErrorCode = ERROR_SUCCESS;
312 
313 Cleanup:
314  // Inside the loop
315  if (hSubKey)
316  RegCloseKey(hSubKey);
317 
318  if (pwszRegistryPath)
319  DllFreeSplMem(pwszRegistryPath);
320 
321  if (pPrintMonitor)
322  {
323  if (pPrintMonitor->pwszFileName)
324  DllFreeSplMem(pPrintMonitor->pwszFileName);
325 
326  if (pPrintMonitor->pwszName)
327  DllFreeSplMem(pPrintMonitor->pwszName);
328 
329  DllFreeSplMem(pPrintMonitor);
330  }
331 
332  // Outside the loop
333  if (hKey)
334  RegCloseKey(hKey);
335 
336  SetLastError(dwErrorCode);
337  return (dwErrorCode == ERROR_SUCCESS);
338 }
LPMONITOR2(WINAPI * PInitializePrintMonitor2)(PMONITORINIT, PHANDLE)
Definition: precomp.h:52
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
HKEYMONITOR hckRegistryRoot
Definition: winsplp.h:748
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define InsertTailList(ListHead, Entry)
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FIXME(fmt,...)
Definition: debug.h:111
PMONITORREG pMonitorReg
Definition: winsplp.h:749
#define LoadLibraryW(x)
Definition: compat.h:606
PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName)
Definition: tools.c:26
struct _MONITORINIT MONITORINIT
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define CopyMemory
Definition: winbase.h:1662
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
LIST_ENTRY Entry
Definition: precomp.h:73
static const WCHAR L[]
Definition: oid.c:1250
static MONITORREG MonReg
Definition: monitors.c:110
static const WCHAR Cleanup[]
Definition: register.c:80
DWORD cbSize
Definition: winsplp.h:746
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
LPMONITOREX(WINAPI * PInitializePrintMonitor)(PWSTR)
Definition: precomp.h:51
BOOL bLocal
Definition: winsplp.h:750
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
struct _MONITOR2 * PMONITOR2
#define GetProcAddress(x, y)
Definition: compat.h:612
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
struct _MONITOREX * LPMONITOREX
#define memset(x, y, z)
Definition: compat.h:39
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _InitializeLocalSpooler().

◆ InitializePrintProcessorList()

BOOL InitializePrintProcessorList ( void  )

Definition at line 129 of file printprocessors.c.

130 {
131  DWORD cbDatatypes;
132  DWORD cbFileName;
133  DWORD cchPrintProcessorPath;
134  DWORD cchMaxSubKey;
135  DWORD cchPrintProcessorName;
136  DWORD dwErrorCode;
137  DWORD dwSubKeys;
138  DWORD i;
139  HINSTANCE hinstPrintProcessor;
140  HKEY hKey = NULL;
141  HKEY hSubKey = NULL;
142  HKEY hSubSubKey = NULL;
143  PLOCAL_PRINT_PROCESSOR pPrintProcessor = NULL;
145  WCHAR wszPrintProcessorPath[MAX_PATH];
146 
147  TRACE("InitializePrintProcessorList()\n");
148 
149  // Initialize an empty list for our Print Processors.
151 
152  // Prepare the path to the Print Processor directory.
153  if (!LocalGetPrintProcessorDirectory(NULL, (PWSTR)wszCurrentEnvironment, 1, (PBYTE)wszPrintProcessorPath, sizeof(wszPrintProcessorPath), &cchPrintProcessorPath))
154  {
155  dwErrorCode = GetLastError();
156  goto Cleanup;
157  }
158 
159  // LocalGetPrintProcessorDirectory returns the number of copied bytes. Convert this into a number of characters without the terminating null-character.
160  cchPrintProcessorPath /= sizeof(WCHAR);
161  --cchPrintProcessorPath;
162 
163  // Append a trailing backslash.
164  wszPrintProcessorPath[cchPrintProcessorPath] = L'\\';
165  ++cchPrintProcessorPath;
166 
167  // Open the environment registry key.
169  if (dwErrorCode != ERROR_SUCCESS)
170  goto Cleanup;
171 
172  // Open the "Print Processors" subkey.
173  dwErrorCode = (DWORD)RegOpenKeyExW(hKey, L"Print Processors", 0, KEY_READ, &hSubKey);
174  if (dwErrorCode != ERROR_SUCCESS)
175  {
176  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
177  goto Cleanup;
178  }
179 
180  // Get the number of Print Processors and maximum sub key length.
181  dwErrorCode = (DWORD)RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &dwSubKeys, &cchMaxSubKey, NULL, NULL, NULL, NULL, NULL, NULL);
182  if (dwErrorCode != ERROR_SUCCESS)
183  {
184  ERR("RegQueryInfoKeyW failed with status %lu!\n", dwErrorCode);
185  goto Cleanup;
186  }
187 
188  // Loop through all available local Print Processors.
189  for (i = 0; i < dwSubKeys; i++)
190  {
191  // Cleanup tasks from the previous run
192  if (hSubSubKey)
193  {
194  RegCloseKey(hSubSubKey);
195  hSubSubKey = NULL;
196  }
197 
198  if (pPrintProcessor)
199  {
200  if (pPrintProcessor->pwszName)
201  DllFreeSplStr(pPrintProcessor->pwszName);
202 
203  if (pPrintProcessor->pDatatypesInfo1)
204  DllFreeSplMem(pPrintProcessor->pDatatypesInfo1);
205 
206  DllFreeSplMem(pPrintProcessor);
207  pPrintProcessor = NULL;
208  }
209 
210  // Create a new LOCAL_PRINT_PROCESSOR structure for it.
211  pPrintProcessor = DllAllocSplMem(sizeof(LOCAL_PRINT_PROCESSOR));
212  if (!pPrintProcessor)
213  {
214  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
215  ERR("DllAllocSplMem failed!\n");
216  goto Cleanup;
217  }
218 
219  // Allocate memory for the Print Monitor Name.
220  pPrintProcessor->pwszName = DllAllocSplMem((cchMaxSubKey + 1) * sizeof(WCHAR));
221  if (!pPrintProcessor->pwszName)
222  {
223  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
224  ERR("DllAllocSplMem failed!\n");
225  goto Cleanup;
226  }
227 
228  // Get the name of this Print Processor.
229  cchPrintProcessorName = cchMaxSubKey + 1;
230  dwErrorCode = (DWORD)RegEnumKeyExW(hSubKey, i, pPrintProcessor->pwszName, &cchPrintProcessorName, NULL, NULL, NULL, NULL);
231  if (dwErrorCode != ERROR_SUCCESS)
232  {
233  ERR("RegEnumKeyExW failed with status %ld!\n", dwErrorCode);
234  continue;
235  }
236 
237  // Open this Print Processor's registry key.
238  dwErrorCode = (DWORD)RegOpenKeyExW(hSubKey, pPrintProcessor->pwszName, 0, KEY_READ, &hSubSubKey);
239  if (dwErrorCode != ERROR_SUCCESS)
240  {
241  ERR("RegOpenKeyExW failed for Print Processor \"%S\" with status %lu!\n", pPrintProcessor->pwszName, dwErrorCode);
242  continue;
243  }
244 
245  // Get the file name of the Print Processor.
246  cbFileName = sizeof(wszFileName);
247  dwErrorCode = (DWORD)RegQueryValueExW(hSubSubKey, L"Driver", NULL, NULL, (PBYTE)wszFileName, &cbFileName);
248  if (dwErrorCode != ERROR_SUCCESS)
249  {
250  ERR("RegQueryValueExW failed for Print Processor \"%S\" with status %lu!\n", pPrintProcessor->pwszName, dwErrorCode);
251  continue;
252  }
253 
254  // Verify that our buffer is large enough.
255  if (cchPrintProcessorPath + cbFileName / sizeof(WCHAR) > MAX_PATH)
256  {
257  ERR("Print Processor directory \"%S\" for Print Processor \"%S\" is too long!\n", wszFileName, pPrintProcessor->pwszName);
258  continue;
259  }
260 
261  // Construct the full path to the Print Processor.
262  CopyMemory(&wszPrintProcessorPath[cchPrintProcessorPath], wszFileName, cbFileName);
263 
264  // Try to load it.
265  hinstPrintProcessor = LoadLibraryW(wszPrintProcessorPath);
266  if (!hinstPrintProcessor)
267  {
268  ERR("LoadLibraryW failed for \"%S\" with error %lu!\n", wszPrintProcessorPath, GetLastError());
269  continue;
270  }
271 
272  // Get and verify all its function pointers.
273  pPrintProcessor->pfnClosePrintProcessor = (PClosePrintProcessor)GetProcAddress(hinstPrintProcessor, "ClosePrintProcessor");
274  if (!pPrintProcessor->pfnClosePrintProcessor)
275  {
276  ERR("Print Processor \"%S\" exports no ClosePrintProcessor!\n", wszPrintProcessorPath);
277  continue;
278  }
279 
280  pPrintProcessor->pfnControlPrintProcessor = (PControlPrintProcessor)GetProcAddress(hinstPrintProcessor, "ControlPrintProcessor");
281  if (!pPrintProcessor->pfnControlPrintProcessor)
282  {
283  ERR("Print Processor \"%S\" exports no ControlPrintProcessor!\n", wszPrintProcessorPath);
284  continue;
285  }
286 
287  pPrintProcessor->pfnEnumPrintProcessorDatatypesW = (PEnumPrintProcessorDatatypesW)GetProcAddress(hinstPrintProcessor, "EnumPrintProcessorDatatypesW");
288  if (!pPrintProcessor->pfnEnumPrintProcessorDatatypesW)
289  {
290  ERR("Print Processor \"%S\" exports no EnumPrintProcessorDatatypesW!\n", wszPrintProcessorPath);
291  continue;
292  }
293 
294  pPrintProcessor->pfnGetPrintProcessorCapabilities = (PGetPrintProcessorCapabilities)GetProcAddress(hinstPrintProcessor, "GetPrintProcessorCapabilities");
295  if (!pPrintProcessor->pfnGetPrintProcessorCapabilities)
296  {
297  ERR("Print Processor \"%S\" exports no GetPrintProcessorCapabilities!\n", wszPrintProcessorPath);
298  continue;
299  }
300 
301  pPrintProcessor->pfnOpenPrintProcessor = (POpenPrintProcessor)GetProcAddress(hinstPrintProcessor, "OpenPrintProcessor");
302  if (!pPrintProcessor->pfnOpenPrintProcessor)
303  {
304  ERR("Print Processor \"%S\" exports no OpenPrintProcessor!\n", wszPrintProcessorPath);
305  continue;
306  }
307 
308  pPrintProcessor->pfnPrintDocumentOnPrintProcessor = (PPrintDocumentOnPrintProcessor)GetProcAddress(hinstPrintProcessor, "PrintDocumentOnPrintProcessor");
309  if (!pPrintProcessor->pfnPrintDocumentOnPrintProcessor)
310  {
311  ERR("Print Processor \"%S\" exports no PrintDocumentOnPrintProcessor!\n", wszPrintProcessorPath);
312  continue;
313  }
314 
315  // Get all supported datatypes.
316  pPrintProcessor->pfnEnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, 0, &cbDatatypes, &pPrintProcessor->dwDatatypeCount);
317  pPrintProcessor->pDatatypesInfo1 = DllAllocSplMem(cbDatatypes);
318  if (!pPrintProcessor->pDatatypesInfo1)
319  {
320  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
321  ERR("DllAllocSplMem failed!\n");
322  goto Cleanup;
323  }
324 
325  if (!pPrintProcessor->pfnEnumPrintProcessorDatatypesW(NULL, NULL, 1, (PBYTE)pPrintProcessor->pDatatypesInfo1, cbDatatypes, &cbDatatypes, &pPrintProcessor->dwDatatypeCount))
326  {
327  ERR("EnumPrintProcessorDatatypesW failed for Print Processor \"%S\" with error %lu!\n", wszPrintProcessorPath, GetLastError());
328  continue;
329  }
330 
331  // Add the Print Processor to the list.
332  InsertTailList(&_PrintProcessorList, &pPrintProcessor->Entry);
333 
334  // Don't let the cleanup routines free this.
335  pPrintProcessor = NULL;
336  }
337 
338  dwErrorCode = ERROR_SUCCESS;
339 
340 Cleanup:
341  // Inside the loop
342  if (hSubSubKey)
343  RegCloseKey(hSubSubKey);
344 
345  if (pPrintProcessor)
346  {
347  if (pPrintProcessor->pwszName)
348  DllFreeSplStr(pPrintProcessor->pwszName);
349 
350  if (pPrintProcessor->pDatatypesInfo1)
351  DllFreeSplMem(pPrintProcessor->pDatatypesInfo1);
352 
353  DllFreeSplMem(pPrintProcessor);
354  }
355 
356  // Outside the loop
357  if (hSubKey)
358  RegCloseKey(hSubKey);
359 
360  if (hKey)
361  RegCloseKey(hKey);
362 
363  SetLastError(dwErrorCode);
364  return (dwErrorCode == ERROR_SUCCESS);
365 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
#define ERROR_SUCCESS
Definition: deptool.c:10
PDATATYPES_INFO_1W pDatatypesInfo1
Definition: precomp.h:102
PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
Definition: precomp.h:106
PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor
Definition: precomp.h:109
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
static LIST_ENTRY _PrintProcessorList
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
static DWORD _OpenEnvironment(PCWSTR pEnvironment, PHKEY hKey)
#define InsertTailList(ListHead, Entry)
#define DWORD
Definition: nt_native.h:44
DWORD(WINAPI * PGetPrintProcessorCapabilities)(LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD)
Definition: precomp.h:48
const WCHAR wszCurrentEnvironment[]
Definition: prtprocenv.h:11
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
BOOL WINAPI LocalGetPrintProcessorDirectory(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
#define LoadLibraryW(x)
Definition: compat.h:606
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
#define CopyMemory
Definition: winbase.h:1662
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
static const WCHAR L[]
Definition: oid.c:1250
LIST_ENTRY Entry
Definition: precomp.h:100
PClosePrintProcessor pfnClosePrintProcessor
Definition: precomp.h:104
static const WCHAR Cleanup[]
Definition: register.c:80
BOOL(WINAPI * PEnumPrintProcessorDatatypesW)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD)
BOOL(WINAPI * PControlPrintProcessor)(HANDLE, DWORD)
Definition: precomp.h:46
#define ERR(fmt,...)
Definition: debug.h:110
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities
Definition: precomp.h:107
BOOL(WINAPI * PPrintDocumentOnPrintProcessor)(HANDLE, LPWSTR)
Definition: precomp.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:130
HANDLE(WINAPI * POpenPrintProcessor)(LPWSTR, PPRINTPROCESSOROPENDATA)
Definition: precomp.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define GetProcAddress(x, y)
Definition: compat.h:612
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
POpenPrintProcessor pfnOpenPrintProcessor
Definition: precomp.h:108
PControlPrintProcessor pfnControlPrintProcessor
Definition: precomp.h:105
BYTE * PBYTE
Definition: pedump.c:66
BOOL(WINAPI * PClosePrintProcessor)(HANDLE)
Definition: precomp.h:45

Referenced by _InitializeLocalSpooler().

◆ LocalAddForm()

BOOL WINAPI LocalAddForm ( HANDLE  hPrinter,
DWORD  Level,
PBYTE  pForm 
)

Definition at line 409 of file forms.c.

410 {
411  DWORD dwErrorCode, Size, cbNeeded;
412  PFORM_INFO_LIST pfil;
413  PLOCAL_HANDLE pHandle;
414  REGISTRYFORMINFO rfi;
415  PFORM_INFO_1W pfi1w = (PFORM_INFO_1W)pForm;
416  PFORM_INFO_2W pfi2w = (PFORM_INFO_2W)pForm;
417 
418  FIXME("AddForm(%p, %lu, %p)\n", hPrinter, Level, pForm);
419 
420  // Check if this is a printer handle.
421  pHandle = (PLOCAL_HANDLE)hPrinter;
422  if (pHandle->HandleType != HandleType_Printer)
423  {
424  dwErrorCode = ERROR_INVALID_HANDLE;
425  goto Cleanup;
426  }
427 
428  // Only support 1 & 2
429  if (Level < 1 || Level > 2)
430  {
431  // The caller supplied an invalid level.
432  dwErrorCode = ERROR_INVALID_LEVEL;
433  goto Cleanup;
434  }
435 
436  pfil = FindForm( pfi1w->pName, NULL );
437  if ( pfil )
438  {
439  dwErrorCode = ERROR_FILE_EXISTS;
440  goto Cleanup;
441  }
442 
443  dwErrorCode = RegQueryValueExW( hFormsKey, pfi1w->pName, NULL, NULL, NULL, &cbNeeded );
444  if ( dwErrorCode == ERROR_SUCCESS )
445  {
446  dwErrorCode = ERROR_FILE_EXISTS;
447  goto Cleanup;
448  }
449 
450  if ( wcslen(pfi1w->pName) > FORMMAXNAMESIZE ) // Limit REG Name size.
451  {
452  dwErrorCode = ERROR_INVALID_PARAMETER;
453  goto Cleanup;
454  }
455 
456  Size = sizeof(FORM_INFO_LIST) + ((MAX_PATH + 1) * sizeof(WCHAR));
457 
458  pfil = DllAllocSplMem( Size );
459  if ( !pfil )
460  {
461  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
462  goto Cleanup;
463  }
464 
465  pfil->Sig = FORMINFOSIG;
466  pfil->Index = _dwLastForm++;
467  pfil->pName = wcscpy( (PWSTR)(pfil+1), pfi1w->pName );
468  pfil->Flags = pfi1w->Flags;
469  pfil->Size = pfi1w->Size;
470  pfil->ImageableArea = pfi1w->ImageableArea;
471  pfil->StringType = STRING_NONE;
472 
473  if ( Level > 1 )
474  {
475  pfil->pKeyword = pfi2w->pKeyword;
476  pfil->pMuiDll = pfi2w->pMuiDll;
477  pfil->pDisplayName = pfi2w->pDisplayName;
478  pfil->StringType = pfi2w->StringType;
479  pfil->dwResourceId = pfi2w->dwResourceId;
480  }
481 
482  rfi.Size = pfil->Size;
483  rfi.ImageableArea = pfil->ImageableArea;
484  rfi.Index = pfil->Index;
485  rfi.Flags = pfil->Flags;
486 
487  dwErrorCode = RegSetValueExW( hFormsKey, pfil->pName, 0, REG_BINARY, (PBYTE)&rfi, sizeof( rfi ) );
488 
489  BroadcastChange(pHandle);
490 
491  InsertTailList( &FormList, &pfil->List );
492 
493 Cleanup:
494  SetLastError(dwErrorCode);
495  return (dwErrorCode == ERROR_SUCCESS);
496 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static DWORD _dwLastForm
Definition: forms.c:22
#define STRING_NONE
Definition: winspool.h:672
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
HKEY hFormsKey
Definition: forms.c:225
#define ERROR_SUCCESS
Definition: deptool.c:10
RECTL ImageableArea
Definition: forms.c:219
#define REG_BINARY
Definition: nt_native.h:1496
uint16_t * PWSTR
Definition: typedefs.h:56
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
LPCWSTR pMuiDll
Definition: winspool.h:663
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
LIST_ENTRY List
Definition: forms.c:15
#define InsertTailList(ListHead, Entry)
LPCWSTR pDisplayName
Definition: winspool.h:665
enum _LOCAL_HANDLE::@4881 HandleType
DWORD Flags
Definition: winspool.h:633
#define FORMMAXNAMESIZE
Definition: forms.c:11
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:56
LIST_ENTRY FormList
Definition: forms.c:21
#define FIXME(fmt,...)
Definition: debug.h:111
RECTL ImageableArea
Definition: winspool.h:636
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
PFORM_INFO_LIST FASTCALL FindForm(WCHAR *pFormName, WCHAR *pKeyword)
Definition: forms.c:310
DWORD dwResourceId
Definition: winspool.h:664
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
DWORD Sig
Definition: forms.c:16
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _FORM_INFO_LIST FORM_INFO_LIST
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LPCSTR pKeyword
Definition: winspool.h:661
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD Index
Definition: forms.c:17
VOID BroadcastChange(PLOCAL_HANDLE pHandle)
Definition: printers.c:350
static const WCHAR Cleanup[]
Definition: register.c:80
struct _FORM_INFO_1W * PFORM_INFO_1W
#define FORMINFOSIG
Definition: forms.c:10
LPWSTR pName
Definition: winspool.h:634
DWORD StringType
Definition: winspool.h:662
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct _FORM_INFO_2W * PFORM_INFO_2W
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
BYTE * PBYTE
Definition: pedump.c:66
SIZEL Size
Definition: winspool.h:635

◆ LocalAddJob()

BOOL WINAPI LocalAddJob ( HANDLE  hPrinter,
DWORD  Level,
LPBYTE  pData,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

◆ LocalAddMonitor()

BOOL WINAPI LocalAddMonitor ( PWSTR  pName,
DWORD  Level,
PBYTE  pMonitors 
)

Definition at line 636 of file monitors.c.

637 {
639  LPMONITOR_INFO_2W mi2w;
640  HKEY hroot = NULL;
641  HKEY hentry = NULL;
642  DWORD disposition;
643  BOOL res = FALSE;
644  const WCHAR wszMonitorsPath[] = L"SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors\\";
645 
646  mi2w = (LPMONITOR_INFO_2W) pMonitors;
647 
648  FIXME("LocalAddMonitor(%s, %d, %p): %s %s %s\n", debugstr_w(pName), Level, pMonitors,
649  debugstr_w(mi2w->pName), debugstr_w(mi2w->pEnvironment), debugstr_w(mi2w->pDLLName));
650 
652  {
653  FIXME("server %s not supported\n", debugstr_w(pName));
655  return FALSE;
656  }
657 
658  if (!mi2w->pName || (!mi2w->pName[0]) )
659  {
660  FIXME("pName not valid : %s\n", debugstr_w(mi2w->pName));
662  return FALSE;
663  }
664 
665  env = validate_envW(mi2w->pEnvironment);
666  if (!env)
667  return FALSE; /* ERROR_INVALID_ENVIRONMENT */
668 
669  if (!mi2w->pDLLName || (!mi2w->pDLLName[0]) )
670  {
671  FIXME("pDLLName not valid : %s\n", debugstr_w(mi2w->pDLLName));
673  return FALSE;
674  }
675 
676  if (RegCreateKeyW(HKEY_LOCAL_MACHINE, wszMonitorsPath, &hroot) != ERROR_SUCCESS) {
677  ERR("unable to create key %s\n", debugstr_w(wszMonitorsPath));
678  return FALSE;
679  }
680 
681  if (RegCreateKeyExW(hroot, mi2w->pName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_QUERY_VALUE, NULL, &hentry, &disposition) == ERROR_SUCCESS)
682  {
683  /* Some installers set options for the port before calling AddMonitor.
684  We query the "Driver" entry to verify that the monitor is installed,
685  before we return an error.
686  When a user installs two print monitors at the same time with the
687  same name, a race condition is possible but silently ignored. */
688 
689  DWORD namesize = 0;
690 
691  if ((disposition == REG_OPENED_EXISTING_KEY) &&
692  (RegQueryValueExW(hentry, L"Driver", NULL, NULL, NULL, &namesize) == ERROR_SUCCESS))
693  {
694  FIXME("monitor %s already exists\n", debugstr_w(mi2w->pName));
695  /* 9x use ERROR_ALREADY_EXISTS */
697  }
698  else
699  {
700  INT len = (lstrlenW(mi2w->pDLLName) +1) * sizeof(WCHAR);
701 
702  res = (RegSetValueExW(hentry, L"Driver", 0, REG_SZ, (LPBYTE) mi2w->pDLLName, len) == ERROR_SUCCESS);
703 
704  /* Load and initialize the monitor. SetLastError() is called on failure */
705 
706  res = AddPrintMonitorList( mi2w->pName, mi2w->pDLLName );
707 
708  if ( !res )
709  {
710  RegDeleteKeyW(hroot, mi2w->pName);
711  }
712  else
713  SetLastError(ERROR_SUCCESS); /* Monitor installer depends on this */
714  }
715 
716  RegCloseKey(hentry);
717  }
718 
719  RegCloseKey(hroot);
720  return res;
721 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1085
#define lstrlenW
Definition: compat.h:609
int32_t INT
Definition: typedefs.h:58
LPWSTR pEnvironment
Definition: winspool.h:834
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
PPRINTENV_T validate_envW(LPCWSTR env)
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
static LPSTR pName
Definition: security.c:75
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
LPWSTR pDLLName
Definition: winspool.h:835
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED
Definition: winerror.h:1211
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
GLuint res
Definition: glext.h:9613
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
struct _MONITOR_INFO_2W * LPMONITOR_INFO_2W
BOOL AddPrintMonitorList(LPCWSTR pName, LPWSTR DllName)
Definition: monitors.c:457
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

◆ LocalAddPort()

BOOL WINAPI LocalAddPort ( LPWSTR  pName,
HWND  hWnd,
LPWSTR  pMonitorName 
)

Definition at line 286 of file ports.c.

287 {
288  DWORD lres;
289  BOOL res = FALSE;
290  PLOCAL_PRINT_MONITOR pPrintMonitor;
291 
292  FIXME("LocalAddPort(%S, %p, %s)\n", pName, hWnd, debugstr_w(pMonitorName));
293 
295  if (lres)
296  {
297  FIXME("server %s not supported\n", debugstr_w(pName));
299  return FALSE;
300  }
301 
302  /* an empty Monitorname is Invalid */
303  if (!pMonitorName[0])
304  {
306  return FALSE;
307  }
308 
309  pPrintMonitor = FindPrintMonitor( pMonitorName );
310  if (!pPrintMonitor )
311  {
313  return FALSE;
314  }
315 
316  if ( pPrintMonitor->bIsLevel2 && ((PMONITOR2)pPrintMonitor->pMonitor)->pfnAddPort )
317  {
318  res = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnAddPort(pPrintMonitor->hMonitor, pName, hWnd, pMonitorName);
319  }
320  else if ( !pPrintMonitor->bIsLevel2 && ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnAddPort )
321  {
322  res = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnAddPort(pName, hWnd, pMonitorName);
323  }
324  else
325  {
327  }
328 
329  if ( res )
330  {
331  DWORD cbNeeded, cReturned, i;
332  PPORT_INFO_1 pPorts;
333 
334  //
335  // Play it safe,,, we know its Monitor2.... This is ReactOS.
336  //
337  if ( LocalEnumPorts( pName, 1, NULL, 0, &cbNeeded, &cReturned ) )
338  {
339  pPorts = DllAllocSplMem( cbNeeded );
340  if (pPorts)
341  {
342  if ( LocalEnumPorts( pName, 1, (PBYTE)pPorts, cbNeeded, &cbNeeded, &cReturned ) )
343  {
344  for ( i = 0; i < cReturned; i++ )
345  {
346  if ( !FindPort( pPorts[i].pName ) )
347  {
348  CreatePortEntry( pPorts[i].pName, pPrintMonitor );
349  }
350  }
351  }
352  DllFreeSplMem( pPorts );
353  }
354  }
355  }
356 
357  return res;
358 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
PLOCAL_PORT FindPort(PCWSTR pwszName)
Definition: ports.c:15
BOOL WINAPI LocalEnumPorts(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: ports.c:164
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
struct _MONITOR2 * PMONITOR2
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PLOCAL_PRINT_MONITOR FindPrintMonitor(PCWSTR pwszName)
Definition: monitors.c:28
struct _MONITOREX * LPMONITOREX
BYTE * PBYTE
Definition: pedump.c:66
BOOL CreatePortEntry(PCWSTR pwszName, PLOCAL_PRINT_MONITOR pPrintMonitor)
Definition: ports.c:37

◆ LocalAddPortEx()

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

Definition at line 217 of file ports.c.

218 {
219  DWORD lres;
220  BOOL res = FALSE;
221  PLOCAL_PORT pPort;
222  PLOCAL_PRINT_MONITOR pPrintMonitor;
224 
225  FIXME("LocalAddPortEx(%S, %lu, %p, %S)\n", pName, Level, lpBuffer, lpMonitorName);
226 
228  if ( lres )
229  {
230  FIXME("server %s not supported\n", debugstr_w(pName));
232  return FALSE;
233  }
234 
235  if ( Level != 1 )
236  {
238  return FALSE;
239  }
240 
241  if ((!pi) || (!lpMonitorName) || (!lpMonitorName[0]))
242  {
244  return FALSE;
245  }
246 
247  pPrintMonitor = FindPrintMonitor( lpMonitorName );
248  if (!pPrintMonitor )
249  {
251  return FALSE;
252  }
253 
254  pPort = FindPort( pi->pName );
255  if ( pPort )
256  {
258  return FALSE;
259  }
260 
261  if ( pPrintMonitor->bIsLevel2 && ((PMONITOR2)pPrintMonitor->pMonitor)->pfnAddPortEx )
262  {
263  res = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnAddPortEx(pPrintMonitor->hMonitor, pName, Level, lpBuffer, lpMonitorName);
264  }
265  else if ( !pPrintMonitor->bIsLevel2 && ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnAddPortEx )
266  {
267  res = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnAddPortEx(pName, Level, lpBuffer, lpMonitorName);
268  }
269  else
270  {
272  }
273 
274  if ( res )
275  {
276  res = CreatePortEntry( pi->pName, pPrintMonitor );
277  }
278 
279  return res;
280 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
_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 debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
static LPSTR pName
Definition: security.c:75
static refpint_t pi[]
Definition: server.c:96
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
PLOCAL_PORT FindPort(PCWSTR pwszName)
Definition: ports.c:15
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
struct _MONITOR2 * PMONITOR2
PLOCAL_PRINT_MONITOR FindPrintMonitor(PCWSTR pwszName)
Definition: monitors.c:28
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _MONITOREX * LPMONITOREX
BOOL CreatePortEntry(PCWSTR pwszName, PLOCAL_PRINT_MONITOR pPrintMonitor)
Definition: ports.c:37

◆ LocalAddPrinterDriver()

BOOL WINAPI LocalAddPrinterDriver ( LPWSTR  pName,
DWORD  level,
LPBYTE  pDriverInfo 
)

Definition at line 1133 of file printerdrivers.c.

1134 {
1135  LONG lres;
1136 
1137  TRACE("(%s, %d, %p, 0x%x)\n", debugstr_w(pName), level, pDriverInfo);
1138 
1140 
1141  if (lres)
1142  {
1143  FIXME("server %s not supported\n", debugstr_w(pName));
1145  return FALSE;
1146  }
1147 
1148  // Should be APD_COPY_NEW_FILES. Cheap wine.
1149 
1150  return myAddPrinterDriverEx(level, pDriverInfo, APD_COPY_NEW_FILES, TRUE);
1151 }
GLint level
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define APD_COPY_NEW_FILES
Definition: winspool.h:606
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define SetLastError(x)
Definition: compat.h:611
BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags, BOOL lazy)
#define NULL
Definition: types.h:112
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89

◆ LocalAddPrinterDriverEx()

BOOL WINAPI LocalAddPrinterDriverEx ( LPWSTR  pName,
DWORD  level,
LPBYTE  pDriverInfo,
DWORD  dwFileCopyFlags 
)

Definition at line 1110 of file printerdrivers.c.

1111 {
1112  LONG lres;
1113 
1114  TRACE("(%s, %d, %p, 0x%x)\n", debugstr_w(pName), level, pDriverInfo, dwFileCopyFlags);
1115 
1117 
1118  if (lres)
1119  {
1120  FIXME("server %s not supported\n", debugstr_w(pName));
1122  return FALSE;
1123  }
1124 
1125  if ((dwFileCopyFlags & ~APD_COPY_FROM_DIRECTORY) != APD_COPY_ALL_FILES)
1126  {
1127  TRACE("Flags 0x%x ignored (using APD_COPY_ALL_FILES)\n", dwFileCopyFlags & ~APD_COPY_FROM_DIRECTORY);
1128  }
1129 
1130  return myAddPrinterDriverEx(level, pDriverInfo, dwFileCopyFlags, TRUE);
1131 }
GLint level
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
#define APD_COPY_FROM_DIRECTORY
Definition: winspool.h:607
#define APD_COPY_ALL_FILES
Definition: winspool.h:605
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define SetLastError(x)
Definition: compat.h:611
BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags, BOOL lazy)
#define NULL
Definition: types.h:112
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89

◆ LocalClosePrinter()

BOOL WINAPI LocalClosePrinter ( HANDLE  hPrinter)

Definition at line 1960 of file printers.c.

1961 {
1962  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1963 
1964  FIXME("LocalClosePrinter(%p)\n", hPrinter);
1965 
1966  if (!pHandle)
1967  {
1969  return FALSE;
1970  }
1971 
1972  if (pHandle->HandleType == HandleType_Port)
1973  {
1975  }
1976  else if (pHandle->HandleType == HandleType_Printer)
1977  {
1979  }
1980  else if (pHandle->HandleType == HandleType_PrintServer)
1981  {
1982  // Nothing to do.
1983  }
1984  else if (pHandle->HandleType == HandleType_Xcv)
1985  {
1987  }
1988  FIXME("LocalClosePrinter 1\n");
1989  // Free memory for the handle and the specific handle (if any).
1990  if (pHandle->pSpecificHandle)
1991  DllFreeSplMem(pHandle->pSpecificHandle);
1992  FIXME("LocalClosePrinter 2\n");
1993  DllFreeSplMem(pHandle);
1994  FIXME("LocalClosePrinter 3\n");
1995  return TRUE;
1996 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
enum _LOCAL_HANDLE::@4881 HandleType
static void _LocalClosePortHandle(PLOCAL_PORT_HANDLE pPortHandle)
Definition: printers.c:1926
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:56
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
PVOID pSpecificHandle
Definition: precomp.h:208
#define SetLastError(x)
Definition: compat.h:611
static void _LocalCloseXcvHandle(PLOCAL_XCV_HANDLE pXcvHandle)
Definition: printers.c:1950
static void _LocalClosePrinterHandle(PLOCAL_PRINTER_HANDLE pPrinterHandle)
Definition: printers.c:1937

◆ LocalCloseSpoolFileHandle()

BOOL WINAPI LocalCloseSpoolFileHandle ( HANDLE  hPrinter)

Definition at line 30 of file spoolfile.c.

31 {
32  FIXME("LocalCloseSpoolFileHandle(%p)\n", hPrinter);
33  return FALSE;
34 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ LocalCommitSpoolData()

BOOL WINAPI LocalCommitSpoolData ( HANDLE  hPrinter,
DWORD  cbCommit 
)

Definition at line 23 of file spoolfile.c.

24 {
25  FIXME("LocalCommitSpoolData(%p, %lu)\n", hPrinter, cbCommit);
26  return FALSE;
27 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ LocalConfigurePort()

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

Definition at line 361 of file ports.c.

362 {
363  LONG lres;
364  DWORD res;
365  PLOCAL_PORT pPrintPort;
366  PLOCAL_PRINT_MONITOR pPrintMonitor;
367 
368  FIXME("LocalConfigurePort(%S, %p, %S)\n", pName, hWnd, pPortName);
369 
371  if (lres)
372  {
373  FIXME("server %s not supported\n", debugstr_w(pName));
375  return FALSE;
376  }
377 
378  /* an empty Portname is Invalid, but can popup a Dialog */
379  if (!pPortName[0])
380  {
382  return FALSE;
383  }
384 
385  pPrintPort = FindPort(pPortName);
386  if (!pPrintPort )
387  {
389  return FALSE;
390  }
391 
392  pPrintMonitor = pPrintPort->pPrintMonitor;
393 
394  if ( pPrintMonitor->bIsLevel2 && ((PMONITOR2)pPrintMonitor->pMonitor)->pfnConfigurePort )
395  {
396  res = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnConfigurePort(pPrintMonitor->hMonitor, pName, hWnd, pPortName);
397  }
398  else if ( !pPrintMonitor->bIsLevel2 && ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnConfigurePort )
399  {
400  res = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnConfigurePort(pName, hWnd, pPortName);
401  }
402  else
403  {
405  }
406 
407  return res;
408 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
HWND hWnd
Definition: settings.c:17
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:91
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
PLOCAL_PORT FindPort(PCWSTR pwszName)
Definition: ports.c:15
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
struct _MONITOR2 * PMONITOR2
#define ERROR_INVALID_NAME
Definition: compat.h:103
struct _MONITOREX * LPMONITOREX

◆ LocalDeleteForm()

BOOL WINAPI LocalDeleteForm ( HANDLE  hPrinter,
PWSTR  pFormName 
)

Definition at line 499 of file forms.c.

500 {
501  DWORD dwErrorCode, cbNeeded;
502  PFORM_INFO_LIST pfil;
503  REGISTRYFORMINFO rfi;
504  PLOCAL_HANDLE pHandle;
505 
506  FIXME("DeleteForm(%p, %S)\n", hPrinter, pFormName);
507 
508  // Check if this is a printer handle.
509  pHandle = (PLOCAL_HANDLE)hPrinter;
510  if (pHandle->HandleType != HandleType_Printer)
511  {
512  dwErrorCode = ERROR_INVALID_HANDLE;
513  goto Cleanup;
514  }
515 
516  pfil = FindForm( pFormName, NULL );
517  if ( !pfil )
518  {
519  dwErrorCode = ERROR_INVALID_PARAMETER;
520  goto Cleanup;
521  }
522 
523  dwErrorCode = RegQueryValueExW( hFormsKey, pFormName, NULL, NULL, (PBYTE)&rfi, &cbNeeded );
524  if ( dwErrorCode != ERROR_SUCCESS )
525  {
526  goto Cleanup;
527  }
528 
529  dwErrorCode = RegDeleteValueW(hFormsKey, pFormName);
530  if ( dwErrorCode != ERROR_SUCCESS )
531  {
532  goto Cleanup;
533  }
534 
535  RemoveEntryList(&pfil->List);
536 
537  DllFreeSplMem(pfil);
538 
539  BroadcastChange(pHandle);
540 
541  dwErrorCode = ERROR_SUCCESS;
542 
543 Cleanup:
544  SetLastError(dwErrorCode);
545  return (dwErrorCode == ERROR_SUCCESS);
546 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
HKEY hFormsKey
Definition: forms.c:225
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LIST_ENTRY List
Definition: forms.c:15
enum _LOCAL_HANDLE::@4881 HandleType
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:56
#define FIXME(fmt,...)
Definition: debug.h:111
PFORM_INFO_LIST FASTCALL FindForm(WCHAR *pFormName, WCHAR *pKeyword)
Definition: forms.c:310
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
VOID BroadcastChange(PLOCAL_HANDLE pHandle)
Definition: printers.c:350
static const WCHAR Cleanup[]
Definition: register.c:80
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66

◆ LocalDeleteMonitor()

BOOL WINAPI LocalDeleteMonitor ( PWSTR  pName,
PWSTR  pEnvironment,
PWSTR  pMonitorName 
)

Definition at line 724 of file monitors.c.

725 {
726  HKEY hroot = NULL;
727  LONG lres;
728  PLOCAL_PRINT_MONITOR pPrintMonitor;
729  const WCHAR wszMonitorsPath[] = L"SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors\\";
730 
731  FIXME("LocalDeleteMonitor(%s, %s, %s)\n",debugstr_w(pName),debugstr_w(pEnvironment),
732  debugstr_w(pMonitorName));
733 
735  if (lres)
736  {
737  FIXME("server %s not supported\n", debugstr_w(pName));
739  return FALSE;
740  }
741 
742  /* pEnvironment is ignored in Windows for the local Computer */
743  if (!pMonitorName || !pMonitorName[0])
744  {
745  ERR("pMonitorName %s is invalid\n", debugstr_w(pMonitorName));
747  return FALSE;
748  }
749 
750  pPrintMonitor = FindPrintMonitor( pMonitorName );
751  if ( pPrintMonitor )
752  {
753  if ( pPrintMonitor->refcount ) pPrintMonitor->refcount--;
754 
755  if ( pPrintMonitor->refcount == 0 )
756  { /* Unload the monitor if it's loaded */
757  RemoveEntryList(&pPrintMonitor->Entry);
758 
759  if ( pPrintMonitor->bIsLevel2 )
760  {
761  PMONITOR2 pm2 = pPrintMonitor->pMonitor;
762  if ( pm2 && pm2->pfnShutdown )
763  {
764  pm2->pfnShutdown(pPrintMonitor->hMonitor);
765  }
766  }
767 
768  if ( pPrintMonitor->hModule )
769  FreeLibrary(pPrintMonitor->hModule);
770 
771  if (pPrintMonitor->pwszFileName)
772  DllFreeSplStr(pPrintMonitor->pwszFileName);
773 
774  if (pPrintMonitor->pwszName)
775  DllFreeSplStr(pPrintMonitor->pwszName);
776 
777  DllFreeSplMem(pPrintMonitor);
778  pPrintMonitor = NULL;
779  }
780  }
781  else
782  {
783  FIXME("Could not find %s\n", debugstr_w(pMonitorName));
784  }
785 
786  if (RegCreateKeyW(HKEY_LOCAL_MACHINE, wszMonitorsPath, &hroot) != ERROR_SUCCESS)
787  {
788  ERR("unable to create key %s\n", debugstr_w(wszMonitorsPath));
789  return FALSE;
790  }
791 
792  if (RegDeleteTreeW(hroot, pMonitorName) == ERROR_SUCCESS)
793  {
794  FIXME("%s deleted\n", debugstr_w(pMonitorName));
795  RegCloseKey(hroot);
796  return TRUE;
797  }
798 
799  FIXME("%s does not exist\n", debugstr_w(pMonitorName));
800  RegCloseKey(hroot);
801 
802  /* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
804  return FALSE;
805 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_UNKNOWN_PRINT_MONITOR
Definition: winerror.h:1205
#define FreeLibrary(x)
Definition: compat.h:607
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
LIST_ENTRY Entry
Definition: precomp.h:73
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1746
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:130
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
#define ERROR_INVALID_NAME
Definition: compat.h:103
static LPMONITOR2 pm2
Definition: localmon.c:46
PLOCAL_PRINT_MONITOR FindPrintMonitor(PCWSTR pwszName)
Definition: monitors.c:28
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ LocalDeletePort()

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

Definition at line 411 of file ports.c.

412 {
413  LONG lres;
414  DWORD res = FALSE;
415  PLOCAL_PORT pPrintPort;
416  PLOCAL_PRINT_MONITOR pPrintMonitor;
417 
418  FIXME("LocalDeletePort(%S, %p, %S)\n", pName, hWnd, pPortName);
419 
421  if (lres)
422  {
423  FIXME("server %s not supported\n", debugstr_w(pName));
425  return FALSE;
426  }
427 
428  if (!pPortName[0])
429  {
431  return FALSE;
432  }
433 
434  pPrintPort = FindPort(pPortName);
435  if (!pPrintPort )
436  {
438  return FALSE;
439  }
440 
441  pPrintMonitor = pPrintPort->pPrintMonitor;
442 
443  if ( pPrintMonitor->bIsLevel2 && ((PMONITOR2)pPrintMonitor->pMonitor)->pfnDeletePort )
444  {
445  res = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnDeletePort(pPrintMonitor->hMonitor, pName, hWnd, pPortName);
446  }
447  else if ( !pPrintMonitor->bIsLevel2 && ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnDeletePort )
448  {
449  res = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnDeletePort(pName, hWnd, pPortName);
450  }
451 
452  RemoveEntryList(&pPrintPort->Entry);
453 
454  DllFreeSplMem(pPrintPort);
455 
456  return res;
457 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LIST_ENTRY Entry
Definition: precomp.h:89
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
HWND hWnd
Definition: settings.c:17
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:91
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
PLOCAL_PORT FindPort(PCWSTR pwszName)
Definition: ports.c:15
#define NULL
Definition: types.h:112
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLuint res
Definition: glext.h:9613
LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
Definition: tools.c:89
struct _MONITOR2 * PMONITOR2
#define ERROR_INVALID_NAME
Definition: compat.h:103
struct _MONITOREX * LPMONITOREX

◆ LocalEndDocPrinter()

BOOL WINAPI LocalEndDocPrinter ( HANDLE  hPrinter)

Definition at line 1857 of file printers.c.

1858 {
1859  BOOL bReturnValue;
1860  DWORD dwErrorCode;
1861  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1862  PLOCAL_PORT_HANDLE pPortHandle;
1863  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1864 
1865  TRACE("LocalEndDocPrinter(%p)\n", hPrinter);
1866 
1867  // Sanity checks.
1868  if (!pHandle)
1869  {
1870  dwErrorCode = ERROR_INVALID_HANDLE;
1871  goto Cleanup;
1872  }
1873 
1874  // Port handles are an entirely different thing.
1875  if (pHandle->HandleType == HandleType_Port)
1876  {
1877  pPortHandle = (PLOCAL_PORT_HANDLE)pHandle->pSpecificHandle;
1878 
1879  // Call the monitor's EndDocPort function.
1880  if (pPortHandle->pPort->pPrintMonitor->bIsLevel2)
1881  bReturnValue = ((PMONITOR2)pPortHandle->pPort->pPrintMonitor->pMonitor)->pfnEndDocPort(pPortHandle->hPort);
1882  else
1883  bReturnValue = ((LPMONITOREX)pPortHandle->pPort->pPrintMonitor->pMonitor)->Monitor.pfnEndDocPort(pPortHandle->hPort);
1884 
1885  if (!bReturnValue)
1886  {
1887  // The EndDocPort function failed. Return its last error.
1888  dwErrorCode = GetLastError();
1889  goto Cleanup;
1890  }
1891 
1892  // We were successful!
1893  dwErrorCode = ERROR_SUCCESS;
1894  goto Cleanup;
1895  }
1896 
1897  // The remaining function deals with Printer handles only.
1898  if (pHandle->HandleType != HandleType_Printer)
1899  {
1900  dwErrorCode = ERROR_INVALID_HANDLE;
1901  goto Cleanup;
1902  }
1903 
1904  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1905 
1906  // We require StartDocPrinter or AddJob to be called first.
1907  if (!pPrinterHandle->bStartedDoc)
1908  {
1909  dwErrorCode = ERROR_SPL_NO_STARTDOC;
1910  goto Cleanup;
1911  }
1912 
1913  // TODO: Something like ScheduleJob
1914 
1915  // Finish the job.
1916  pPrinterHandle->bStartedDoc = FALSE;
1917  pPrinterHandle->pJob = NULL;
1918  dwErrorCode = ERROR_SUCCESS;
1919 
1920 Cleanup:
1921  SetLastError(dwErrorCode);
1922  return (dwErrorCode == ERROR_SUCCESS);
1923 }
PLOCAL_PORT pPort
Definition: precomp.h:183
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
struct _LOCAL_PORT_HANDLE * PLOCAL_PORT_HANDLE
Definition: precomp.h:59
if(dx==0 &&dy==0)
Definition: linetemp.h:174
enum _LOCAL_HANDLE::@4881 HandleType
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:56
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_SPL_NO_STARTDOC
Definition: winerror.h:1208
PVOID pSpecificHandle
Definition: precomp.h:208
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
static const WCHAR Cleanup[]
Definition: register.c:80
#define NULL
Definition: types.h:112
PLOCAL_JOB pJob
Definition: precomp.h:172
struct _MONITOR2 * PMONITOR2
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:63