ReactOS  0.4.15-dev-341-g17c5fb8
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 <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
 

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 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
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (localspl)
 
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)
 
PLOCAL_PORT FindPort (PCWSTR pwszName)
 
BOOL InitializePortList (void)
 
BOOL WINAPI LocalEnumPorts (PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
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 WINAPI LocalGetPrinterDriver (HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
 
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)
 
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)
 
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)
 
PWSTR AllocAndRegQueryWSZ (HKEY hKey, PCWSTR pwszValueName)
 
PDEVMODEW DuplicateDevMode (PDEVMODEW pInput)
 

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 37 of file precomp.h.

◆ IS_VALID_PRIORITY

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

Definition at line 38 of file precomp.h.

◆ SHD_WIN2003_SIGNATURE

#define SHD_WIN2003_SIGNATURE   0x4968

Definition at line 41 of file precomp.h.

◆ SKIPLIST_LEVELS

#define SKIPLIST_LEVELS   16

Definition at line 29 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 54 of file precomp.h.

◆ LOCAL_JOB

Definition at line 55 of file precomp.h.

◆ LOCAL_PORT

Definition at line 56 of file precomp.h.

◆ LOCAL_PORT_HANDLE

Definition at line 57 of file precomp.h.

◆ LOCAL_PRINT_MONITOR

Definition at line 58 of file precomp.h.

◆ LOCAL_PRINT_PROCESSOR

Definition at line 59 of file precomp.h.

◆ LOCAL_PRINTER

Definition at line 60 of file precomp.h.

◆ LOCAL_PRINTER_HANDLE

Definition at line 61 of file precomp.h.

◆ LOCAL_XCV_HANDLE

Definition at line 62 of file precomp.h.

◆ PClosePrintProcessor

typedef BOOL(WINAPI * PClosePrintProcessor) (HANDLE)

Definition at line 44 of file precomp.h.

◆ PControlPrintProcessor

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

Definition at line 45 of file precomp.h.

◆ PEnumPrintProcessorDatatypesW

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

Definition at line 46 of file precomp.h.

◆ PGetPrintProcessorCapabilities

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

Definition at line 47 of file precomp.h.

◆ PInitializePrintMonitor

typedef LPMONITOREX(WINAPI * PInitializePrintMonitor) (PWSTR)

Definition at line 50 of file precomp.h.

◆ PInitializePrintMonitor2

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

Definition at line 51 of file precomp.h.

◆ PLOCAL_HANDLE

Definition at line 54 of file precomp.h.

◆ PLOCAL_JOB

Definition at line 55 of file precomp.h.

◆ PLOCAL_PORT

Definition at line 56 of file precomp.h.

◆ PLOCAL_PORT_HANDLE

Definition at line 57 of file precomp.h.

◆ PLOCAL_PRINT_MONITOR

Definition at line 58 of file precomp.h.

◆ PLOCAL_PRINT_PROCESSOR

Definition at line 59 of file precomp.h.

◆ PLOCAL_PRINTER

Definition at line 60 of file precomp.h.

◆ PLOCAL_PRINTER_HANDLE

Definition at line 61 of file precomp.h.

◆ PLOCAL_XCV_HANDLE

Definition at line 62 of file precomp.h.

◆ POpenPrintProcessor

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

Definition at line 48 of file precomp.h.

◆ PPrintDocumentOnPrintProcessor

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

Definition at line 49 of file precomp.h.

◆ PSHD_HEADER

Definition at line 63 of file precomp.h.

◆ SHD_HEADER

Definition at line 63 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:55
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
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:36
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
BYTE * PBYTE
Definition: pedump.c:66

Referenced by InitializePrinterList(), and InitializePrintMonitorList().

◆ 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:143
PDEVMODEW pDevMode
Definition: precomp.h:170
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:783
#define TRUE
Definition: types.h:120
#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
static BOOL _GetNextJobID(PDWORD dwJobID)
Definition: jobs.c:73
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PWSTR pwszMachineName
Definition: precomp.h:156
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
SKIPLIST JobList
Definition: precomp.h:126
#define DEF_PRIORITY
Definition: winspool.h:230
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
DWORD dwPriority
Definition: precomp.h:142
PDEVMODEW pDevMode
Definition: precomp.h:157
#define JOB_STATUS_SPOOLING
Definition: winspool.h:341
DWORD dwJobID
Definition: precomp.h:136
BOOL InsertElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:250
PWSTR pwszDatatype
Definition: precomp.h:147
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:124
smooth NULL
Definition: ftsmooth.c:416
RPCRTAPI RPC_STATUS RPC_ENTRY RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, RPC_BINDING_HANDLE *ServerBinding)
Definition: rpc_binding.c:1642
DWORD dwStatus
Definition: precomp.h:155
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:140
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
PWSTR pwszNotifyName
Definition: precomp.h:145
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:146
#define UNLEN
Definition: sspi.c:28
PDEVMODEW DuplicateDevMode(PDEVMODEW pInput)
Definition: tools.c:61
PLOCAL_JOB pJob
Definition: precomp.h:168
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:141
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
const WCHAR wszDefaultDocumentName[]
Definition: main.c:25
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
SKIPLIST GlobalJobList
Definition: jobs.c:11
PWSTR pwszUserName
Definition: precomp.h:144
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by LocalAddJob(), and LocalStartDocPrinter().

◆ 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
smooth NULL
Definition: ftsmooth.c:416
WORD dmSize
Definition: wingdi.h:1619
#define CopyMemory
Definition: winbase.h:1646
#define ERR(fmt,...)
Definition: debug.h:110
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 }
#define TRUE
Definition: types.h:120
PDATATYPES_INFO_1W pDatatypesInfo1
Definition: precomp.h:98
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 TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wcsicmp
Definition: string.h:1152

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

◆ FindPort()

PLOCAL_PORT FindPort ( PCWSTR  pwszName)

Definition at line 15 of file ports.c.

16 {
17  PLIST_ENTRY pEntry;
18  PLOCAL_PORT pPort;
19 
20  TRACE("FindPort(%S)\n", pwszName);
21 
22  if (!pwszName)
23  return NULL;
24 
25  for (pEntry = _PortList.Flink; pEntry != &_PortList; pEntry = pEntry->Flink)
26  {
27  pPort = CONTAINING_RECORD(pEntry, LOCAL_PORT, Entry);
28 
29  if (_wcsicmp(pPort->pwszName, pwszName) == 0)
30  return pPort;
31  }
32 
33  return NULL;
34 }
PWSTR pwszName
Definition: precomp.h:86
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:118
static LIST_ENTRY _PortList
Definition: ports.c:11
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 _LocalOpenPortHandle(), _LocalOpenXcvHandle(), and InitializePrinterList().

◆ FindPrintMonitor()

PLOCAL_PRINT_MONITOR FindPrintMonitor ( PCWSTR  pwszName)

Definition at line 28 of file monitors.c.

29 {
30  PLIST_ENTRY pEntry;
31  PLOCAL_PRINT_MONITOR pPrintMonitor;
32 
33  TRACE("FindPrintMonitor(%S)\n", pwszName);
34 
35  if (!pwszName)
36  return NULL;
37 
38  for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink)
39  {
40  pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry);
41 
42  if (_wcsicmp(pPrintMonitor->pwszName, pwszName) == 0)
43  return pPrintMonitor;
44  }
45 
46  return NULL;
47 }
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:118
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
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().

◆ FindPrintProcessor()

PLOCAL_PRINT_PROCESSOR FindPrintProcessor ( PCWSTR  pwszName)

Definition at line 102 of file printprocessors.c.

103 {
104  PLIST_ENTRY pEntry;
105  PLOCAL_PRINT_PROCESSOR pPrintProcessor;
106 
107  TRACE("FindPrintProcessor(%S)\n", pwszName);
108 
109  if (!pwszName)
110  return NULL;
111 
112  for (pEntry = _PrintProcessorList.Flink; pEntry != &_PrintProcessorList; pEntry = pEntry->Flink)
113  {
114  pPrintProcessor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_PROCESSOR, Entry);
115 
116  if (wcsicmp(pPrintProcessor->pwszName, pwszName) == 0)
117  return pPrintProcessor;
118  }
119 
120  return NULL;
121 }
static LIST_ENTRY _PrintProcessorList
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:118
#define wcsicmp
Definition: string.h:1152
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:148
uint16_t * PWSTR
Definition: typedefs.h:55
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PWSTR pwszMachineName
Definition: precomp.h:156
SKIPLIST JobList
Definition: precomp.h:126
PDEVMODEW pDevMode
Definition: precomp.h:157
DWORD dwJobID
Definition: precomp.h:136
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
PWSTR pwszDatatype
Definition: precomp.h:147
smooth NULL
Definition: ftsmooth.c:416
DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
Definition: jobs.c:146
PWSTR pwszPrintProcessorParameters
Definition: precomp.h:149
#define TRACE(s)
Definition: solgame.cpp:4
PLOCAL_PRINTER pPrinter
Definition: precomp.h:140
PWSTR pwszNotifyName
Definition: precomp.h:145
static const WCHAR L[]
Definition: oid.c:1250
PWSTR pwszDocumentName
Definition: precomp.h:146
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:129
PVOID DeleteElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:146
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PWSTR pwszStatus
Definition: precomp.h:150
SKIPLIST GlobalJobList
Definition: jobs.c:11
PWSTR pwszUserName
Definition: precomp.h:144

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 TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define CopyMemory
Definition: winbase.h:1646
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().

◆ 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:55
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:400
SKIPLIST JobList
Definition: precomp.h:126
_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:136
PLOCAL_JOB ReadJobShadowFile(PCWSTR pwszFilePath)
Definition: jobs.c:1187
BOOL InsertElementSkiplist(PSKIPLIST Skiplist, PVOID Element)
Definition: skiplist.c:250
smooth NULL
Definition: ftsmooth.c:416
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:140
#define MAX_PATH
Definition: compat.h:26
#define CopyMemory
Definition: winbase.h:1646
DWORD cchJobDirectory
Definition: main.c:14
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
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 wcsicmp
Definition: string.h:1152
#define ERR(fmt,...)
Definition: debug.h:110
#define IS_VALID_JOB_ID(ID)
Definition: precomp.h:37
WCHAR wszJobDirectory[MAX_PATH]
Definition: main.c:13
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 37 of file ports.c.

38 {
39  BOOL bReturnValue;
40  DWORD cbNeeded;
41  DWORD cbPortName;
42  DWORD dwErrorCode;
43  DWORD dwReturned;
44  DWORD i;
45  PLOCAL_PORT pPort;
46  PLOCAL_PRINT_MONITOR pPrintMonitor;
47  PLIST_ENTRY pEntry;
49  PPORT_INFO_1W pPortInfo1 = NULL;
50 
51  TRACE("InitializePortList()\n");
52 
53  // Initialize an empty list for our Ports.
55 
56  // Loop through all Print Monitors.
57  for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink)
58  {
59  // Cleanup from the previous run.
60  if (pPortInfo1)
61  {
62  DllFreeSplMem(pPortInfo1);
63  pPortInfo1 = NULL;
64  }
65 
66  pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry);
67 
68  // Determine the required buffer size for EnumPorts.
69  if (pPrintMonitor->bIsLevel2)
70  bReturnValue = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnEnumPorts(pPrintMonitor->hMonitor, NULL, 1, NULL, 0, &cbNeeded, &dwReturned);
71  else
72  bReturnValue = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnEnumPorts(NULL, 1, NULL, 0, &cbNeeded, &dwReturned);
73 
74  // Check the returned error code.
76  {
77  ERR("Print Monitor \"%S\" failed with error %lu on EnumPorts!\n", pPrintMonitor->pwszName, GetLastError());
78  continue;
79  }
80 
81  // Allocate a buffer large enough.
82  pPortInfo1 = DllAllocSplMem(cbNeeded);
83  if (!pPortInfo1)
84  {
85  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
86  ERR("DllAllocSplMem failed!\n");
87  goto Cleanup;
88  }
89 
90  // Get the ports handled by this monitor.
91  if (pPrintMonitor->bIsLevel2)
92  bReturnValue = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnEnumPorts(pPrintMonitor->hMonitor, NULL, 1, (PBYTE)pPortInfo1, cbNeeded, &cbNeeded, &dwReturned);
93  else
94  bReturnValue = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnEnumPorts(NULL, 1, (PBYTE)pPortInfo1, cbNeeded, &cbNeeded, &dwReturned);
95 
96  // Check the return value.
97  if (!bReturnValue)
98  {
99  ERR("Print Monitor \"%S\" failed with error %lu on EnumPorts!\n", pPrintMonitor->pwszName, GetLastError());
100  continue;
101  }
102 
103  // Loop through all returned ports.
104  p = pPortInfo1;
105 
106  for (i = 0; i < dwReturned; i++)
107  {
108  cbPortName = (wcslen(p->pName) + 1) * sizeof(WCHAR);
109 
110  // Create a new LOCAL_PORT structure for it.
111  pPort = DllAllocSplMem(sizeof(LOCAL_PORT) + cbPortName);
112  if (!pPort)
113  {
114  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
115  ERR("DllAllocSplMem failed!\n");
116  goto Cleanup;
117  }
118 
119  pPort->pPrintMonitor = pPrintMonitor;
120  pPort->pwszName = (PWSTR)((PBYTE)pPort + sizeof(LOCAL_PORT));
121  CopyMemory(pPort->pwszName, p->pName, cbPortName);
122 
123  // Insert it into the list and advance to the next port.
124  InsertTailList(&_PortList, &pPort->Entry);
125  p++;
126  }
127  }
128 
129  dwErrorCode = ERROR_SUCCESS;
130 
131 Cleanup:
132  // Inside the loop
133  if (pPortInfo1)
134  DllFreeSplMem(pPortInfo1);
135 
136  SetLastError(dwErrorCode);
137  return (dwErrorCode == ERROR_SUCCESS);
138 }
LIST_ENTRY Entry
Definition: precomp.h:85
PWSTR pwszName
Definition: precomp.h:86
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:55
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:87
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define InsertTailList(ListHead, Entry)
struct _LOCAL_PORT LOCAL_PORT
Definition: precomp.h:56
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
Definition: typedefs.h:118
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
static LIST_ENTRY _PortList
Definition: ports.c:11
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
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
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
base of all file and directory entries
Definition: entries.h:82
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

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:126
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:55
DWORD dwAttributes
Definition: precomp.h:117
PWSTR pwszPrinterDriver
Definition: precomp.h:120
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:119
#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
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
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:124
smooth NULL
Definition: ftsmooth.c:416
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:418
#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:122
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:121
PDEVMODEW pDefaultDevMode
Definition: precomp.h:123
#define ERR(fmt,...)
Definition: debug.h:110
DWORD dwStatus
Definition: precomp.h:118
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:129
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:125
BYTE * PBYTE
Definition: pedump.c:66
PWSTR pwszPrinterName
Definition: precomp.h:115

Referenced by _InitializeLocalSpooler().

◆ InitializePrintMonitorList()

BOOL InitializePrintMonitorList ( void  )

Definition at line 50 of file monitors.c.

51 {
52  const WCHAR wszMonitorsPath[] = L"SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors";
53  const DWORD cchMonitorsPath = _countof(wszMonitorsPath) - 1;
54 
55  DWORD cchMaxSubKey;
56  DWORD cchPrintMonitorName;
57  DWORD dwErrorCode;
58  DWORD dwSubKeys;
59  DWORD i;
60  HINSTANCE hinstPrintMonitor = NULL;
61  HKEY hKey = NULL;
62  HKEY hSubKey = NULL;
63  MONITORINIT MonitorInit;
64  PInitializePrintMonitor pfnInitializePrintMonitor;
65  PInitializePrintMonitor2 pfnInitializePrintMonitor2;
66  PLOCAL_PRINT_MONITOR pPrintMonitor = NULL;
67  PWSTR pwszRegistryPath = NULL;
68 
69  TRACE("InitializePrintMonitorList()\n");
70 
71  // Initialize an empty list for our Print Monitors.
73 
74  // Open the key containing Print Monitors.
75  dwErrorCode = (DWORD)RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszMonitorsPath, 0, KEY_READ, &hKey);
76  if (dwErrorCode != ERROR_SUCCESS)
77  {
78  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
79  goto Cleanup;
80  }
81 
82  // Get the number of Print Providers and maximum sub key length.
83  dwErrorCode = (DWORD)RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwSubKeys, &cchMaxSubKey, NULL, NULL, NULL, NULL, NULL, NULL);
84  if (dwErrorCode != ERROR_SUCCESS)
85  {
86  ERR("RegQueryInfoKeyW failed with status %lu!\n", dwErrorCode);
87  goto Cleanup;
88  }
89 
90  // Loop through all available Print Providers.
91  for (i = 0; i < dwSubKeys; i++)
92  {
93  // Cleanup tasks from the previous run
94  if (hSubKey)
95  {
96  RegCloseKey(hSubKey);
97  hSubKey = NULL;
98  }
99 
100  if (pwszRegistryPath)
101  {
102  DllFreeSplMem(pwszRegistryPath);
103  pwszRegistryPath = NULL;
104  }
105 
106  if (pPrintMonitor)
107  {
108  if (pPrintMonitor->pwszFileName)
109  DllFreeSplMem(pPrintMonitor->pwszFileName);
110 
111  if (pPrintMonitor->pwszName)
112  DllFreeSplMem(pPrintMonitor->pwszName);
113 
114  DllFreeSplMem(pPrintMonitor);
115  pPrintMonitor = NULL;
116  }
117 
118  // Create a new LOCAL_PRINT_MONITOR structure for it.
119  pPrintMonitor = DllAllocSplMem(sizeof(LOCAL_PRINT_MONITOR));
120  if (!pPrintMonitor)
121  {
122  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
123  ERR("DllAllocSplMem failed!\n");
124  goto Cleanup;
125  }
126 
127  // Allocate memory for the Print Monitor Name.
128  pPrintMonitor->pwszName = DllAllocSplMem((cchMaxSubKey + 1) * sizeof(WCHAR));
129  if (!pPrintMonitor->pwszName)
130  {
131  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
132  ERR("DllAllocSplMem failed!\n");
133  goto Cleanup;
134  }
135 
136  // Get the name of this Print Monitor.
137  cchPrintMonitorName = cchMaxSubKey + 1;
138  dwErrorCode = (DWORD)RegEnumKeyExW(hKey, i, pPrintMonitor->pwszName, &cchPrintMonitorName, NULL, NULL, NULL, NULL);
139  if (dwErrorCode != ERROR_SUCCESS)
140  {
141  ERR("RegEnumKeyExW failed for iteration %lu with status %lu!\n", i, dwErrorCode);
142  continue;
143  }
144 
145  // Open this Print Monitor's registry key.
146  dwErrorCode = (DWORD)RegOpenKeyExW(hKey, pPrintMonitor->pwszName, 0, KEY_READ, &hSubKey);
147  if (dwErrorCode != ERROR_SUCCESS)
148  {
149  ERR("RegOpenKeyExW failed for Print Provider \"%S\" with status %lu!\n", pPrintMonitor->pwszName, dwErrorCode);
150  continue;
151  }
152 
153  // Get the file name of the Print Monitor.
154  pPrintMonitor->pwszFileName = AllocAndRegQueryWSZ(hSubKey, L"Driver");
155  if (!pPrintMonitor->pwszFileName)
156  continue;
157 
158  // Try to load it.
159  hinstPrintMonitor = LoadLibraryW(pPrintMonitor->pwszFileName);
160  if (!hinstPrintMonitor)
161  {
162  ERR("LoadLibraryW failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
163  continue;
164  }
165 
166  // Try to find a Level 2 initialization routine first.
167  pfnInitializePrintMonitor2 = (PInitializePrintMonitor2)GetProcAddress(hinstPrintMonitor, "InitializePrintMonitor2");
168  if (pfnInitializePrintMonitor2)
169  {
170  // Prepare a MONITORINIT structure.
171  MonitorInit.cbSize = sizeof(MONITORINIT);
172  MonitorInit.bLocal = TRUE;
173 
174  // TODO: Fill the other fields.
175 
176  // Call the Level 2 initialization routine.
177  pPrintMonitor->pMonitor = (PMONITOR2)pfnInitializePrintMonitor2(&MonitorInit, &pPrintMonitor->hMonitor);
178  if (!pPrintMonitor->pMonitor)
179  {
180  ERR("InitializePrintMonitor2 failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
181  continue;
182  }
183 
184  pPrintMonitor->bIsLevel2 = TRUE;
185  }
186  else
187  {
188  // Try to find a Level 1 initialization routine then.
189  pfnInitializePrintMonitor = (PInitializePrintMonitor)GetProcAddress(hinstPrintMonitor, "InitializePrintMonitor");
190  if (pfnInitializePrintMonitor)
191  {
192  // Construct the registry path.
193  pwszRegistryPath = DllAllocSplMem((cchMonitorsPath + 1 + cchPrintMonitorName + 1) * sizeof(WCHAR));
194  if (!pwszRegistryPath)
195  {
196  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
197  ERR("DllAllocSplMem failed!\n");
198  goto Cleanup;
199  }
200 
201  CopyMemory(pwszRegistryPath, wszMonitorsPath, cchMonitorsPath * sizeof(WCHAR));
202  pwszRegistryPath[cchMonitorsPath] = L'\\';
203  CopyMemory(&pwszRegistryPath[cchMonitorsPath + 1], pPrintMonitor->pwszName, (cchPrintMonitorName + 1) * sizeof(WCHAR));
204 
205  // Call the Level 1 initialization routine.
206  pPrintMonitor->pMonitor = (LPMONITOREX)pfnInitializePrintMonitor(pwszRegistryPath);
207  if (!pPrintMonitor->pMonitor)
208  {
209  ERR("InitializePrintMonitor failed for \"%S\" with error %lu!\n", pPrintMonitor->pwszFileName, GetLastError());
210  continue;
211  }
212  }
213  else
214  {
215  ERR("No initialization routine found for \"%S\"!\n", pPrintMonitor->pwszFileName);
216  continue;
217  }
218  }
219 
220  // Add this Print Monitor to the list.
221  InsertTailList(&PrintMonitorList, &pPrintMonitor->Entry);
222 
223  // Don't let the cleanup routine free this.
224  pPrintMonitor = NULL;
225  }
226 
227  dwErrorCode = ERROR_SUCCESS;
228 
229 Cleanup:
230  // Inside the loop
231  if (hSubKey)
232  RegCloseKey(hSubKey);
233 
234  if (pwszRegistryPath)
235  DllFreeSplMem(pwszRegistryPath);
236 
237  if (pPrintMonitor)
238  {
239  if (pPrintMonitor->pwszFileName)
240  DllFreeSplMem(pPrintMonitor->pwszFileName);
241 
242  if (pPrintMonitor->pwszName)
243  DllFreeSplMem(pPrintMonitor->pwszName);
244 
245  DllFreeSplMem(pPrintMonitor);
246  }
247 
248  // Outside the loop
249  if (hKey)
250  RegCloseKey(hKey);
251 
252  SetLastError(dwErrorCode);
253  return (dwErrorCode == ERROR_SUCCESS);
254 }
LPMONITOR2(WINAPI * PInitializePrintMonitor2)(PMONITORINIT, PHANDLE)
Definition: precomp.h:51
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:55
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:1059
#define InsertTailList(ListHead, Entry)
#define DWORD
Definition: nt_native.h:44
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define LoadLibraryW(x)
Definition: compat.h:413
smooth NULL
Definition: ftsmooth.c:416
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:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
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:71
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
DWORD cbSize
Definition: winsplp.h:746
#define ERR(fmt,...)
Definition: debug.h:110
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
LPMONITOREX(WINAPI * PInitializePrintMonitor)(PWSTR)
Definition: precomp.h:50
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:419
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 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.
168  dwErrorCode = _OpenEnvironment(wszCurrentEnvironment, &hKey);
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:98
PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
Definition: precomp.h:102
PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor
Definition: precomp.h:105
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:55
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:1059
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:47
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
const WCHAR wszCurrentEnvironment[]
Definition: prtprocenv.h:11
BOOL WINAPI LocalGetPrintProcessorDirectory(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
#define LoadLibraryW(x)
Definition: compat.h:413
smooth NULL
Definition: ftsmooth.c:416
#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:26
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
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:96
PClosePrintProcessor pfnClosePrintProcessor
Definition: precomp.h:100
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:45
#define ERR(fmt,...)
Definition: debug.h:110
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities
Definition: precomp.h:103
BOOL(WINAPI * PPrintDocumentOnPrintProcessor)(HANDLE, LPWSTR)
Definition: precomp.h:49
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:129
HANDLE(WINAPI * POpenPrintProcessor)(LPWSTR, PPRINTPROCESSOROPENDATA)
Definition: precomp.h:48
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define GetProcAddress(x, y)
Definition: compat.h:419
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:104
PControlPrintProcessor pfnControlPrintProcessor
Definition: precomp.h:101
BYTE * PBYTE
Definition: pedump.c:66
BOOL(WINAPI * PClosePrintProcessor)(HANDLE)
Definition: precomp.h:44

Referenced by _InitializeLocalSpooler().

◆ LocalAddJob()

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

◆ LocalClosePrinter()

BOOL WINAPI LocalClosePrinter ( HANDLE  hPrinter)

Definition at line 1923 of file printers.c.

1924 {
1925  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1926 
1927  TRACE("LocalClosePrinter(%p)\n", hPrinter);
1928 
1929  if (!pHandle)
1930  {
1932  return FALSE;
1933  }
1934 
1935  if (pHandle->HandleType == HandleType_Port)
1936  {
1938  }
1939  else if (pHandle->HandleType == HandleType_Printer)
1940  {
1942  }
1943  else if (pHandle->HandleType == HandleType_PrintServer)
1944  {
1945  // Nothing to do.
1946  }
1947  else if (pHandle->HandleType == HandleType_Xcv)
1948  {
1950  }
1951 
1952  // Free memory for the handle and the specific handle (if any).
1953  if (pHandle->pSpecificHandle)
1954  DllFreeSplMem(pHandle->pSpecificHandle);
1955 
1956  DllFreeSplMem(pHandle);
1957 
1958  return TRUE;
1959 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static void _LocalClosePortHandle(PLOCAL_PORT_HANDLE pPortHandle)
Definition: printers.c:1891
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
PVOID pSpecificHandle
Definition: precomp.h:204
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static void _LocalCloseXcvHandle(PLOCAL_XCV_HANDLE pXcvHandle)
Definition: printers.c:1913
static void _LocalClosePrinterHandle(PLOCAL_PRINTER_HANDLE pPrinterHandle)
Definition: printers.c:1901

◆ LocalEndDocPrinter()

BOOL WINAPI LocalEndDocPrinter ( HANDLE  hPrinter)

Definition at line 1822 of file printers.c.

1823 {
1824  BOOL bReturnValue;
1825  DWORD dwErrorCode;
1826  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1827  PLOCAL_PORT_HANDLE pPortHandle;
1828  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1829 
1830  TRACE("LocalEndDocPrinter(%p)\n", hPrinter);
1831 
1832  // Sanity checks.
1833  if (!pHandle)
1834  {
1835  dwErrorCode = ERROR_INVALID_HANDLE;
1836  goto Cleanup;
1837  }
1838 
1839  // Port handles are an entirely different thing.
1840  if (pHandle->HandleType == HandleType_Port)
1841  {
1842  pPortHandle = (PLOCAL_PORT_HANDLE)pHandle->pSpecificHandle;
1843 
1844  // Call the monitor's EndDocPort function.
1845  if (pPortHandle->pPort->pPrintMonitor->bIsLevel2)
1846  bReturnValue = ((PMONITOR2)pPortHandle->pPort->pPrintMonitor->pMonitor)->pfnEndDocPort(pPortHandle->hPort);
1847  else
1848  bReturnValue = ((LPMONITOREX)pPortHandle->pPort->pPrintMonitor->pMonitor)->Monitor.pfnEndDocPort(pPortHandle->hPort);
1849 
1850  if (!bReturnValue)
1851  {
1852  // The EndDocPort function failed. Return its last error.
1853  dwErrorCode = GetLastError();
1854  goto Cleanup;
1855  }
1856 
1857  // We were successful!
1858  dwErrorCode = ERROR_SUCCESS;
1859  goto Cleanup;
1860  }
1861 
1862  // The remaining function deals with Printer handles only.
1863  if (pHandle->HandleType != HandleType_Printer)
1864  {
1865  dwErrorCode = ERROR_INVALID_HANDLE;
1866  goto Cleanup;
1867  }
1868 
1869  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1870 
1871  // We require StartDocPrinter or AddJob to be called first.
1872  if (!pPrinterHandle->bStartedDoc)
1873  {
1874  dwErrorCode = ERROR_SPL_NO_STARTDOC;
1875  goto Cleanup;
1876  }
1877 
1878  // TODO: Something like ScheduleJob
1879 
1880  // Finish the job.
1881  pPrinterHandle->bStartedDoc = FALSE;
1882  pPrinterHandle->pJob = NULL;
1883  dwErrorCode = ERROR_SUCCESS;
1884 
1885 Cleanup:
1886  SetLastError(dwErrorCode);
1887  return (dwErrorCode == ERROR_SUCCESS);
1888 }
PLOCAL_PORT pPort
Definition: precomp.h:179
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:87
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _LOCAL_PORT_HANDLE * PLOCAL_PORT_HANDLE
Definition: precomp.h:57
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_SPL_NO_STARTDOC
Definition: winerror.h:1208
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80
PLOCAL_JOB pJob
Definition: precomp.h:168
struct _MONITOR2 * PMONITOR2
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
struct _MONITOREX * LPMONITOREX

◆ LocalEndPagePrinter()

BOOL WINAPI LocalEndPagePrinter ( HANDLE  hPrinter)

Definition at line 1799 of file printers.c.

1800 {
1801  DWORD dwErrorCode;
1802  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1803 
1804  TRACE("LocalEndPagePrinter(%p)\n", hPrinter);
1805 
1806  // Sanity checks.
1807  if (!pHandle || pHandle->HandleType != HandleType_Printer)
1808  {
1809  dwErrorCode = ERROR_INVALID_HANDLE;
1810  goto Cleanup;
1811  }
1812 
1813  // This function doesn't do anything else for now.
1814  dwErrorCode = ERROR_SUCCESS;
1815 
1816 Cleanup:
1817  SetLastError(dwErrorCode);
1818  return (dwErrorCode == ERROR_SUCCESS);
1819 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80

◆ LocalEnumJobs()

BOOL WINAPI LocalEnumJobs ( HANDLE  hPrinter,
DWORD  FirstJob,
DWORD  NoJobs,
DWORD  Level,
PBYTE  pStart,
DWORD  cbBuf,
LPDWORD  pcbNeeded,
LPDWORD  pcReturned 
)

Definition at line 1022 of file jobs.c.

1023 {
1024  DWORD dwErrorCode;
1025  DWORD i;
1026  PBYTE pEnd;
1027  PLOCAL_HANDLE pHandle;
1028  PLOCAL_JOB pJob;
1029  PSKIPLIST_NODE pFirstJobNode;
1030  PSKIPLIST_NODE pNode;
1031  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1032 
1033  TRACE("LocalEnumJobs(%p, %lu, %lu, %lu, %p, %lu, %p, %p)\n", hPrinter, FirstJob, NoJobs, Level, pStart, cbBuf, pcbNeeded, pcReturned);
1034 
1035  // Check if this is a printer handle.
1036  pHandle = (PLOCAL_HANDLE)hPrinter;
1037  if (pHandle->HandleType != HandleType_Printer)
1038  {
1039  dwErrorCode = ERROR_INVALID_HANDLE;
1040  goto Cleanup;
1041  }
1042 
1043  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1044 
1045  // Check the level.
1046  if (Level > 2)
1047  {
1048  dwErrorCode = ERROR_INVALID_LEVEL;
1049  goto Cleanup;
1050  }
1051 
1052  // Begin counting.
1053  *pcbNeeded = 0;
1054  *pcReturned = 0;
1055 
1056  // Lookup the node of the first job requested by the caller in the Printer's Job List.
1057  pFirstJobNode = LookupNodeByIndexSkiplist(&pPrinterHandle->pPrinter->JobList, FirstJob);
1058 
1059  // Count the required buffer size and the number of jobs.
1060  i = 0;
1061  pNode = pFirstJobNode;
1062 
1063  while (i < NoJobs && pNode)
1064  {
1065  pJob = (PLOCAL_JOB)pNode->Element;
1066 
1067  if (Level == 1)
1069  else if (Level == 2)
1071 
1072  // We stop either when there are no more jobs in the list or when the caller didn't request more, whatever comes first.
1073  i++;
1074  pNode = pNode->Next[0];
1075  }
1076 
1077  // Check if the supplied buffer is large enough.
1078  if (cbBuf < *pcbNeeded)
1079  {
1080  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
1081  goto Cleanup;
1082  }
1083 
1084  // Copy over the Job information.
1085  i = 0;
1086  pNode = pFirstJobNode;
1087  pEnd = &pStart[*pcbNeeded];
1088 
1089  while (i < NoJobs && pNode)
1090  {
1091  pJob = (PLOCAL_JOB)pNode->Element;
1092 
1093  if (Level == 1)
1094  _LocalGetJobLevel1(pJob, (PJOB_INFO_1W*)&pStart, &pEnd, NULL);
1095  else if (Level == 2)
1096  _LocalGetJobLevel2(pJob, (PJOB_INFO_2W*)&pStart, &pEnd, NULL);
1097 
1098  // We stop either when there are no more jobs in the list or when the caller didn't request more, whatever comes first.
1099  i++;
1100  pNode = pNode->Next[0];
1101  }
1102 
1103  *pcReturned = i;
1104  dwErrorCode = ERROR_SUCCESS;
1105 
1106 Cleanup:
1107  SetLastError(dwErrorCode);
1108  return (dwErrorCode == ERROR_SUCCESS);
1109 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
SKIPLIST JobList
Definition: precomp.h:126
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
PSKIPLIST_NODE LookupNodeByIndexSkiplist(PSKIPLIST Skiplist, DWORD ElementIndex)
Definition: skiplist.c:412
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
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
static void _LocalGetJobLevel1(PLOCAL_JOB pJob, PJOB_INFO_1W *ppJobInfo, PBYTE *ppJobInfoEnd, PDWORD pcbNeeded)
Definition: jobs.c:450
static void _LocalGetJobLevel2(PLOCAL_JOB pJob, PJOB_INFO_2W *ppJobInfo, PBYTE *ppJobInfoEnd, PDWORD pcbNeeded)
Definition: jobs.c:524
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _SKIPLIST_NODE * Next[SKIPLIST_LEVELS]
Definition: skiplist.h:30
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80
struct _LOCAL_JOB * PLOCAL_JOB
Definition: precomp.h:55
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PVOID Element
Definition: skiplist.h:31
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalEnumMonitors()

BOOL WINAPI LocalEnumMonitors ( PWSTR  pName,
DWORD  Level,
PBYTE  pMonitors,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 311 of file monitors.c.

312 {
313  DWORD dwErrorCode;
314  PBYTE pMonitorInfoEnd;
315  PLIST_ENTRY pEntry;
316  PLOCAL_PRINT_MONITOR pPrintMonitor;
317 
318  TRACE("LocalEnumMonitors(%S, %lu, %p, %lu, %p, %p)\n", pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned);
319 
320  // Sanity checks.
321  if (Level > 2)
322  {
323  dwErrorCode = ERROR_INVALID_LEVEL;
324  goto Cleanup;
325  }
326 
327  // Begin counting.
328  *pcbNeeded = 0;
329  *pcReturned = 0;
330 
331  // Count the required buffer size and the number of monitors.
332  for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink)
333  {
334  pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry);
335 
336  if (Level == 1)
337  _LocalGetMonitorLevel1(pPrintMonitor, NULL, NULL, pcbNeeded);
338  else if (Level == 2)
339  _LocalGetMonitorLevel2(pPrintMonitor, NULL, NULL, pcbNeeded);
340  }
341 
342  // Check if the supplied buffer is large enough.
343  if (cbBuf < *pcbNeeded)
344  {
345  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
346  goto Cleanup;
347  }
348 
349  // Copy over the Monitor information.
350  pMonitorInfoEnd = &pMonitors[*pcbNeeded];
351 
352  for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink)
353  {
354  pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry);
355 
356  if (Level == 1)
357  _LocalGetMonitorLevel1(pPrintMonitor, (PMONITOR_INFO_1W*)&pMonitors, &pMonitorInfoEnd, NULL);
358  else if (Level == 2)
359  _LocalGetMonitorLevel2(pPrintMonitor, (PMONITOR_INFO_2W*)&pMonitors, &pMonitorInfoEnd, NULL);
360 
361  (*pcReturned)++;
362  }
363 
364  dwErrorCode = ERROR_SUCCESS;
365 
366 Cleanup:
367  SetLastError(dwErrorCode);
368  return (dwErrorCode == ERROR_SUCCESS);
369 }
#define ERROR_SUCCESS
Definition: deptool.c:10
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static void _LocalGetMonitorLevel2(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_2W *ppMonitorInfo, PBYTE *ppMonitorInfoEnd, PDWORD pcbNeeded)
Definition: monitors.c:280
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
Definition: typedefs.h:118
static const WCHAR Cleanup[]
Definition: register.c:80
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
BYTE * PBYTE
Definition: pedump.c:66
static void _LocalGetMonitorLevel1(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_1W *ppMonitorInfo, PBYTE *ppMonitorInfoEnd, PDWORD pcbNeeded)
Definition: monitors.c:257
base of all file and directory entries
Definition: entries.h:82
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalEnumPorts()

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

Definition at line 141 of file ports.c.

142 {
143  BOOL bReturnValue = TRUE;
144  DWORD cbCallBuffer;
145  DWORD cbNeeded;
146  DWORD dwReturned;
147  PBYTE pCallBuffer;
148  PLOCAL_PRINT_MONITOR pPrintMonitor;
149  PLIST_ENTRY pEntry;
150 
151  TRACE("LocalEnumPorts(%S, %lu, %p, %lu, %p, %p)\n", pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
152 
153  // Begin counting.
154  *pcbNeeded = 0;
155  *pcReturned = 0;
156 
157  // At the beginning, we have the full buffer available.
158  cbCallBuffer = cbBuf;
159  pCallBuffer = pPorts;
160 
161  // Loop through all Print Monitors.
162  for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink)
163  {
164  pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry);
165 
166  // Call the EnumPorts function of this Print Monitor.
167  cbNeeded = 0;
168  dwReturned = 0;
169 
170  if (pPrintMonitor->bIsLevel2)
171  bReturnValue = ((PMONITOR2)pPrintMonitor->pMonitor)->pfnEnumPorts(pPrintMonitor->hMonitor, pName, Level, pCallBuffer, cbCallBuffer, &cbNeeded, &dwReturned);
172  else
173  bReturnValue = ((LPMONITOREX)pPrintMonitor->pMonitor)->Monitor.pfnEnumPorts(pName, Level, pCallBuffer, cbCallBuffer, &cbNeeded, &dwReturned);
174 
175  // Add the returned counts to the total values.
176  *pcbNeeded += cbNeeded;
177  *pcReturned += dwReturned;
178 
179  // Reduce the available buffer size for the next call without risking an underflow.
180  if (cbNeeded < cbCallBuffer)
181  cbCallBuffer -= cbNeeded;
182  else
183  cbCallBuffer = 0;
184 
185  // Advance the buffer if the caller provided it.
186  if (pCallBuffer)
187  pCallBuffer += cbNeeded;
188  }
189 
190  return bReturnValue;
191 }
#define TRUE
Definition: types.h:120
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
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:120
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: typedefs.h:118
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
LIST_ENTRY PrintMonitorList
Definition: monitors.c:11
struct _MONITOR2 * PMONITOR2
struct _MONITOREX * LPMONITOREX
BYTE * PBYTE
Definition: pedump.c:66
base of all file and directory entries
Definition: entries.h:82

◆ LocalEnumPrinters()

BOOL WINAPI LocalEnumPrinters ( DWORD  Flags,
LPWSTR  Name,
DWORD  Level,
LPBYTE  pPrinterEnum,
DWORD  cbBuf,
LPDWORD  pcbNeeded,
LPDWORD  pcReturned 
)

Definition at line 865 of file printers.c.

866 {
867  DWORD cchComputerName = 0;
868  DWORD dwErrorCode;
869  PBYTE pPrinterInfoEnd;
870  PSKIPLIST_NODE pNode;
871  WCHAR wszComputerName[2 + MAX_COMPUTERNAME_LENGTH + 1 + 1] = { 0 };
872  PLOCAL_PRINTER pPrinter;
873 
874  TRACE("LocalEnumPrinters(%lu, %S, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
875 
876  // Do no sanity checks or assertions for pcbNeeded and pcReturned here.
877  // This is verified and required by localspl_apitest!
878 
879  // Begin counting.
880  *pcbNeeded = 0;
881  *pcReturned = 0;
882 
884  {
885  // If the flags for the Network Print Provider are given, bail out with ERROR_INVALID_NAME.
886  // This is the internal way for a Print Provider to signal that it doesn't handle this request.
887  dwErrorCode = ERROR_INVALID_NAME;
888  goto Cleanup;
889  }
890 
892  {
893  // The Local Print Provider is the right destination for the request, but without any of these flags,
894  // there is no information that can be returned.
895  // So just signal a successful request.
896  dwErrorCode = ERROR_SUCCESS;
897  goto Cleanup;
898  }
899 
900  if (Level == 3 || Level > 5)
901  {
902  // The caller supplied an invalid level for EnumPrinters.
903  dwErrorCode = ERROR_INVALID_LEVEL;
904  goto Cleanup;
905  }
906 
907  if (Level == 1 && Flags & PRINTER_ENUM_NAME && !Name)
908  {
909  // The caller wants information about this Print Provider.
910  // spoolss packs this into an array of information about all Print Providers.
911  dwErrorCode = _DumpLevel1PrintProviderInformation(pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
912  goto Cleanup;
913  }
914 
915  // Check the supplied Name parameter (if any).
916  // This may return a Computer Name string we later prepend to the output.
917  dwErrorCode = _LocalEnumPrintersCheckName(Flags, Name, wszComputerName, &cchComputerName);
918  if (dwErrorCode != ERROR_SUCCESS)
919  goto Cleanup;
920 
921  // Count the required buffer size and the number of printers.
922  for (pNode = PrinterList.Head.Next[0]; pNode; pNode = pNode->Next[0])
923  {
924  pPrinter = (PLOCAL_PRINTER)pNode->Element;
925 
926  // TODO: If PRINTER_ENUM_SHARED is given, add this Printer if it's shared instead of just ignoring it.
928  {
929  FIXME("Printer Sharing is not supported yet, returning no printers!\n");
930  continue;
931  }
932 
933  pfnGetPrinterLevels[Level](pPrinter, NULL, NULL, pcbNeeded, cchComputerName, wszComputerName);
934  }
935 
936  // Check if the supplied buffer is large enough.
937  if (cbBuf < *pcbNeeded)
938  {
939  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
940  goto Cleanup;
941  }
942 
943  // Copy over the Printer information.
944  pPrinterInfoEnd = &pPrinterEnum[*pcbNeeded];
945 
946  for (pNode = PrinterList.Head.Next[0]; pNode; pNode = pNode->Next[0])
947  {
948  pPrinter = (PLOCAL_PRINTER)pNode->Element;
949 
950  // TODO: If PRINTER_ENUM_SHARED is given, add this Printer if it's shared instead of just ignoring it.
952  continue;
953 
954  pfnGetPrinterLevels[Level](pPrinter, &pPrinterEnum, &pPrinterInfoEnd, NULL, cchComputerName, wszComputerName);
955  (*pcReturned)++;
956  }
957 
958  dwErrorCode = ERROR_SUCCESS;
959 
960 Cleanup:
961  SetLastError(dwErrorCode);
962  return (dwErrorCode == ERROR_SUCCESS);
963 }
#define PRINTER_ENUM_CONNECTIONS
Definition: winspool.h:804
#define PRINTER_ENUM_NETWORK
Definition: winspool.h:809
#define ERROR_SUCCESS
Definition: deptool.c:10
SKIPLIST_NODE Head
Definition: skiplist.h:37
#define PRINTER_ENUM_SHARED
Definition: winspool.h:808
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
static const PLocalGetPrinterLevelFunc pfnGetPrinterLevels[]
Definition: printers.c:28
SKIPLIST PrinterList
Definition: printers.c:11
#define PRINTER_ENUM_REMOTE
Definition: winspool.h:807
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PRINTER_ENUM_NAME
Definition: winspool.h:806
struct _SKIPLIST_NODE * Next[SKIPLIST_LEVELS]
Definition: skiplist.h:30
#define PRINTER_ENUM_LOCAL
Definition: winspool.h:803
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
static const WCHAR Cleanup[]
Definition: register.c:80
struct _LOCAL_PRINTER * PLOCAL_PRINTER
Definition: precomp.h:60
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PVOID Element
Definition: skiplist.h:31
static DWORD _DumpLevel1PrintProviderInformation(PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: printers.c:468
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
static DWORD _LocalEnumPrintersCheckName(DWORD Flags, PCWSTR Name, PWSTR pwszComputerName, PDWORD pcchComputerName)
Definition: printers.c:373
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalEnumPrintProcessorDatatypes()

BOOL WINAPI LocalEnumPrintProcessorDatatypes ( LPWSTR  pName,
LPWSTR  pPrintProcessorName,
DWORD  Level,
LPBYTE  pDatatypes,
DWORD  cbBuf,
LPDWORD  pcbNeeded,
LPDWORD  pcReturned 
)

Definition at line 402 of file printprocessors.c.

403 {
404  DWORD dwErrorCode;
405  PLOCAL_PRINT_PROCESSOR pPrintProcessor;
406 
407  TRACE("LocalEnumPrintProcessorDatatypes(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
408 
409  // Sanity checks
410  if (Level != 1)
411  {
412  dwErrorCode = ERROR_INVALID_LEVEL;
413  goto Cleanup;
414  }
415 
416  // Try to find the Print Processor.
417  pPrintProcessor = FindPrintProcessor(pPrintProcessorName);
418  if (!pPrintProcessor)
419  {
420  dwErrorCode = ERROR_UNKNOWN_PRINTPROCESSOR;
421  goto Cleanup;
422  }
423 
424  // Call its EnumPrintProcessorDatatypesW function.
425  if (pPrintProcessor->pfnEnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned))
426  dwErrorCode = ERROR_SUCCESS;
427  else
428  dwErrorCode = GetLastError();
429 
430 Cleanup:
431  SetLastError(dwErrorCode);
432  return (dwErrorCode == ERROR_SUCCESS);
433 }
#define ERROR_SUCCESS
Definition: deptool.c:10
PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
Definition: precomp.h:102
PLOCAL_PRINT_PROCESSOR FindPrintProcessor(PCWSTR pwszName)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERROR_UNKNOWN_PRINTPROCESSOR
Definition: winerror.h:1105
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196

◆ LocalEnumPrintProcessors()

BOOL WINAPI LocalEnumPrintProcessors ( LPWSTR  pName,
LPWSTR  pEnvironment,
DWORD  Level,
LPBYTE  pPrintProcessorInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded,
LPDWORD  pcReturned 
)

Definition at line 471 of file printprocessors.c.

472 {
473  DWORD cchMaxSubKey;
474  DWORD cchPrintProcessor;
475  DWORD dwErrorCode;
476  DWORD dwPrintProcessorCount;
477  DWORD i;
478  HKEY hKey = NULL;
479  HKEY hSubKey = NULL;
480  PBYTE pCurrentOutputPrintProcessor;
481  PBYTE pCurrentOutputPrintProcessorInfo;
482  PRINTPROCESSOR_INFO_1W PrintProcessorInfo1;
483  PWSTR pwszTemp = NULL;
484 
485  TRACE("LocalEnumPrintProcessors(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned);
486 
487  // Sanity checks
488  if (Level != 1)
489  {
490  dwErrorCode = ERROR_INVALID_LEVEL;
491  goto Cleanup;
492  }
493 
494  if (!pcbNeeded || !pcReturned)
495  {
496  // This error is also caught by RPC and returned as RPC_X_NULL_REF_POINTER.
497  dwErrorCode = ERROR_INVALID_PARAMETER;
498  goto Cleanup;
499  }
500 
501  // Verify pEnvironment and open its registry key.
502  // We use the registry and not the PrintProcessorList here, because the caller may request information about a different environment.
503  dwErrorCode = _OpenEnvironment(pEnvironment, &hKey);
504  if (dwErrorCode != ERROR_SUCCESS)
505  goto Cleanup;
506 
507  // Open the "Print Processors" subkey.
508  dwErrorCode = (DWORD)RegOpenKeyExW(hKey, L"Print Processors", 0, KEY_READ, &hSubKey);
509  if (dwErrorCode != ERROR_SUCCESS)
510  {
511  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
512  goto Cleanup;
513  }
514 
515  // Get the number of Print Processors and maximum sub key length.
516  dwErrorCode = (DWORD)RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &dwPrintProcessorCount, &cchMaxSubKey, NULL, NULL, NULL, NULL, NULL, NULL);
517  if (dwErrorCode != ERROR_SUCCESS)
518  {
519  ERR("RegQueryInfoKeyW failed with status %lu!\n", dwErrorCode);
520  goto Cleanup;
521  }
522 
523  // Allocate a temporary buffer to let RegEnumKeyExW succeed.
524  pwszTemp = DllAllocSplMem((cchMaxSubKey + 1) * sizeof(WCHAR));
525  if (!pwszTemp)
526  {
527  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
528  ERR("DllAllocSplMem failed!\n");
529  goto Cleanup;
530  }
531 
532  // Determine the required size of the output buffer.
533  *pcbNeeded = 0;
534 
535  for (i = 0; i < dwPrintProcessorCount; i++)
536  {
537  // RegEnumKeyExW sucks! Unlike similar API functions, it only returns the actual numbers of characters copied when you supply a buffer large enough.
538  // So use pwszTemp with its size cchMaxSubKey for this.
539  cchPrintProcessor = cchMaxSubKey + 1;
540  dwErrorCode = (DWORD)RegEnumKeyExW(hSubKey, i, pwszTemp, &cchPrintProcessor, NULL, NULL, NULL, NULL);
541  if (dwErrorCode != ERROR_SUCCESS)
542  {
543  ERR("RegEnumKeyExW failed with status %lu!\n", dwErrorCode);
544  goto Cleanup;
545  }
546 
547  *pcbNeeded += sizeof(PRINTPROCESSOR_INFO_1W) + (cchPrintProcessor + 1) * sizeof(WCHAR);
548  }
549 
550  // Check if the supplied buffer is large enough.
551  if (cbBuf < *pcbNeeded)
552  {
553  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
554  goto Cleanup;
555  }
556 
557  // Put the Print Processor strings right after the last PRINTPROCESSOR_INFO_1W structure.
558  pCurrentOutputPrintProcessorInfo = pPrintProcessorInfo;
559  pCurrentOutputPrintProcessor = pPrintProcessorInfo + dwPrintProcessorCount * sizeof(PRINTPROCESSOR_INFO_1W);
560 
561  // Copy over all Print Processors.
562  for (i = 0; i < dwPrintProcessorCount; i++)
563  {
564  // This isn't really correct, but doesn't cause any harm, because we've extensively checked the size of the supplied buffer above.
565  cchPrintProcessor = cchMaxSubKey + 1;
566 
567  // Copy the Print Processor name.
568  dwErrorCode = (DWORD)RegEnumKeyExW(hSubKey, i, (PWSTR)pCurrentOutputPrintProcessor, &cchPrintProcessor, NULL, NULL, NULL, NULL);
569  if (dwErrorCode != ERROR_SUCCESS)
570  {
571  ERR("RegEnumKeyExW failed with status %lu!\n", dwErrorCode);
572  goto Cleanup;
573  }
574 
575  // Fill and copy the PRINTPROCESSOR_INFO_1W structure belonging to this Print Processor.
576  PrintProcessorInfo1.pName = (PWSTR)pCurrentOutputPrintProcessor;
577  CopyMemory(pCurrentOutputPrintProcessorInfo, &PrintProcessorInfo1, sizeof(PRINTPROCESSOR_INFO_1W));
578 
579  // Advance to the next PRINTPROCESSOR_INFO_1W location and string location in the output buffer.
580  pCurrentOutputPrintProcessor += (cchPrintProcessor + 1) * sizeof(WCHAR);
581  pCurrentOutputPrintProcessorInfo += sizeof(PRINTPROCESSOR_INFO_1W);
582  }
583 
584  // We've finished successfully!
585  *pcReturned = dwPrintProcessorCount;
586  dwErrorCode = ERROR_SUCCESS;
587 
588 Cleanup:
589  if (pwszTemp)
590  DllFreeSplMem(pwszTemp);
591 
592  if (hSubKey)
593  RegCloseKey(hSubKey);
594 
595  if (hKey)
596  RegCloseKey(hKey);
597 
598  SetLastError(dwErrorCode);
599  return (dwErrorCode == ERROR_SUCCESS);
600 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:55
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static DWORD _OpenEnvironment(PCWSTR pEnvironment, PHKEY hKey)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define DWORD
Definition: nt_native.h:44
struct _PRINTPROCESSOR_INFO_1W PRINTPROCESSOR_INFO_1W
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
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
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
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
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalGetJob()

BOOL WINAPI LocalGetJob ( HANDLE  hPrinter,
DWORD  JobId,
DWORD  Level,
PBYTE  pStart,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

Definition at line 655 of file jobs.c.

656 {
657  DWORD dwErrorCode;
658  PBYTE pEnd = &pStart[cbBuf];
659  PLOCAL_HANDLE pHandle;
660  PLOCAL_JOB pJob;
661  PLOCAL_PRINTER_HANDLE pPrinterHandle;
662 
663  TRACE("LocalGetJob(%p, %lu, %lu, %p, %lu, %p)\n", hPrinter, JobId, Level, pStart, cbBuf, pcbNeeded);
664 
665  // Check if this is a printer handle.
666  pHandle = (PLOCAL_HANDLE)hPrinter;
667  if (pHandle->HandleType != HandleType_Printer)
668  {
669  dwErrorCode = ERROR_INVALID_HANDLE;
670  goto Cleanup;
671  }
672 
673  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
674 
675  // Get the desired job.
676  pJob = LookupElementSkiplist(&GlobalJobList, &JobId, NULL);
677  if (!pJob || pJob->pPrinter != pPrinterHandle->pPrinter)
678  {
679  dwErrorCode = ERROR_INVALID_PARAMETER;
680  goto Cleanup;
681  }
682 
683  if (Level > 2)
684  {
685  // The caller supplied an invalid level for GetJob.
686  dwErrorCode = ERROR_INVALID_LEVEL;
687  goto Cleanup;
688  }
689 
690  // Count the required buffer size.
691  *pcbNeeded = 0;
692 
693  if (Level == 1)
695  else if (Level == 2)
697 
698  // Check if the supplied buffer is large enough.
699  if (cbBuf < *pcbNeeded)
700  {
701  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
702  goto Cleanup;
703  }
704 
705  // Copy over the Job information.
706  pEnd = &pStart[*pcbNeeded];
707 
708  if (Level == 1)
709  _LocalGetJobLevel1(pJob, (PJOB_INFO_1W*)&pStart, &pEnd, NULL);
710  else if (Level == 2)
711  _LocalGetJobLevel2(pJob, (PJOB_INFO_2W*)&pStart, &pEnd, NULL);
712 
713  dwErrorCode = ERROR_SUCCESS;
714 
715 Cleanup:
716  SetLastError(dwErrorCode);
717  return (dwErrorCode == ERROR_SUCCESS);
718 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
static void _LocalGetJobLevel1(PLOCAL_JOB pJob, PJOB_INFO_1W *ppJobInfo, PBYTE *ppJobInfoEnd, PDWORD pcbNeeded)
Definition: jobs.c:450
static void _LocalGetJobLevel2(PLOCAL_JOB pJob, PJOB_INFO_2W *ppJobInfo, PBYTE *ppJobInfoEnd, PDWORD pcbNeeded)
Definition: jobs.c:524
#define TRACE(s)
Definition: solgame.cpp:4
PLOCAL_PRINTER pPrinter
Definition: precomp.h:140
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80
PVOID LookupElementSkiplist(PSKIPLIST Skiplist, PVOID Element, PDWORD ElementIndex)
Definition: skiplist.c:357
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
BYTE * PBYTE
Definition: pedump.c:66
SKIPLIST GlobalJobList
Definition: jobs.c:11
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalGetPrinter()

BOOL WINAPI LocalGetPrinter ( HANDLE  hPrinter,
DWORD  Level,
LPBYTE  pPrinter,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

Definition at line 966 of file printers.c.

967 {
968  // We never prepend a Computer Name to the output, but need to provide an empty string,
969  // because this variable is passed to StringCbCopyExW.
970  const WCHAR wszDummyComputerName[] = L"";
971 
972  DWORD dwErrorCode;
973  PBYTE pPrinterEnd;
974  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
975  PLOCAL_PRINTER_HANDLE pPrinterHandle;
976 
977  TRACE("LocalGetPrinter(%p, %lu, %p, %lu, %p)\n", hPrinter, Level, pPrinter, cbBuf, pcbNeeded);
978 
979  // Sanity checks.
980  if (!pHandle)
981  {
982  dwErrorCode = ERROR_INVALID_HANDLE;
983  goto Cleanup;
984  }
985 
986  // Check if this is a printer handle.
987  if (pHandle->HandleType != HandleType_Printer)
988  {
989  dwErrorCode = ERROR_INVALID_HANDLE;
990  goto Cleanup;
991  }
992 
993  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
994 
995  if (Level > 9)
996  {
997  // The caller supplied an invalid level for GetPrinter.
998  dwErrorCode = ERROR_INVALID_LEVEL;
999  goto Cleanup;
1000  }
1001 
1002  // Count the required buffer size.
1003  *pcbNeeded = 0;
1004  pfnGetPrinterLevels[Level](pPrinterHandle->pPrinter, NULL, NULL, pcbNeeded, 0, wszDummyComputerName);
1005 
1006  // Check if the supplied buffer is large enough.
1007  if (cbBuf < *pcbNeeded)
1008  {
1009  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
1010  goto Cleanup;
1011  }
1012 
1013  // Copy over the Printer information.
1014  pPrinterEnd = &pPrinter[*pcbNeeded];
1015  pfnGetPrinterLevels[Level](pPrinterHandle->pPrinter, &pPrinter, &pPrinterEnd, NULL, 0, wszDummyComputerName);
1016  dwErrorCode = ERROR_SUCCESS;
1017 
1018 Cleanup:
1019  SetLastError(dwErrorCode);
1020  return (dwErrorCode == ERROR_SUCCESS);
1021 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
static const PLocalGetPrinterLevelFunc pfnGetPrinterLevels[]
Definition: printers.c:28
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalGetPrinterData()

DWORD WINAPI LocalGetPrinterData ( HANDLE  hPrinter,
PWSTR  pValueName,
PDWORD  pType,
PBYTE  pData,
DWORD  nSize,
PDWORD  pcbNeeded 
)

Definition at line 11 of file printerdata.c.

12 {
13  TRACE("LocalGetPrinterData(%p, %S, %p, %p, %lu, %p)\n", hPrinter, pValueName, pType, pData, nSize, pcbNeeded);
14 
15  // The ReactOS Printing Stack forwards all GetPrinterData calls to GetPrinterDataEx as soon as possible.
16  // This function may only be called if localspl.dll is used together with Windows Printing Stack components.
17  WARN("This function should never be called!\n");
18  return LocalGetPrinterDataEx(hPrinter, L"PrinterDriverData", pValueName, pType, pData, nSize, pcbNeeded);
19 }
DWORD WINAPI LocalGetPrinterDataEx(HANDLE hPrinter, PCWSTR pKeyName, PCWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
Definition: printerdata.c:314
#define WARN(fmt,...)
Definition: debug.h:112
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2037
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR L[]
Definition: oid.c:1250
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

◆ LocalGetPrinterDataEx()

DWORD WINAPI LocalGetPrinterDataEx ( HANDLE  hPrinter,
PCWSTR  pKeyName,
PCWSTR  pValueName,
PDWORD  pType,
PBYTE  pData,
DWORD  nSize,
PDWORD  pcbNeeded 
)

Definition at line 314 of file printerdata.c.

315 {
316  BYTE Temp;
317  DWORD dwErrorCode;
318  DWORD dwTemp;
319  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
320 
321  TRACE("LocalGetPrinterDataEx(%p, %S, %S, %p, %p, %lu, %p)\n", hPrinter, pKeyName, pValueName, pType, pData, nSize, pcbNeeded);
322 
323  // Even if GetPrinterDataExW in winspool ensures that the RPC function is never called without a valid pointer for pType,
324  // it's officially optional. Windows' fpGetPrinterDataEx also works with NULL for pType!
325  // Ensure here that it is always set to simplify the code later.
326  if (!pType)
327  pType = &dwTemp;
328 
329  // pData is later fed to RegQueryValueExW in many cases. When calling it with zero buffer size, RegQueryValueExW returns a
330  // different error code based on whether pData is NULL or something else.
331  // Ensure here that ERROR_MORE_DATA is always returned.
332  if (!pData)
333  pData = &Temp;
334 
335  if (!pHandle)
336  {
337  dwErrorCode = ERROR_INVALID_HANDLE;
338  }
339  else if (!pcbNeeded)
340  {
341  dwErrorCode = ERROR_INVALID_PARAMETER;
342  }
343  else if (pHandle->HandleType == HandleType_Printer)
344  {
345  dwErrorCode = _LocalGetPrinterHandleData(pHandle->pSpecificHandle, pKeyName, pValueName, pType, pData, nSize, pcbNeeded);
346  }
347  else if (pHandle->HandleType == HandleType_PrintServer)
348  {
349  dwErrorCode = _LocalGetPrintServerHandleData(pValueName, pType, pData, nSize, pcbNeeded);
350  }
351  else
352  {
353  dwErrorCode = ERROR_INVALID_HANDLE;
354  }
355 
356  SetLastError(dwErrorCode);
357  return dwErrorCode;
358 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static DWORD _LocalGetPrinterHandleData(PLOCAL_PRINTER_HANDLE pPrinterHandle, PCWSTR pKeyName, PCWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
Definition: printerdata.c:49
static DWORD _LocalGetPrintServerHandleData(PCWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
Definition: printerdata.c:82
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2037
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
PVOID pSpecificHandle
Definition: precomp.h:204
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
unsigned char BYTE
Definition: xxhash.c:193
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by LocalGetPrinterData().

◆ LocalGetPrinterDriver()

BOOL WINAPI LocalGetPrinterDriver ( HANDLE  hPrinter,
LPWSTR  pEnvironment,
DWORD  Level,
LPBYTE  pDriverInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

Definition at line 278 of file printerdrivers.c.

279 {
280  DWORD dwErrorCode;
281  PBYTE pEnd = &pDriverInfo[cbBuf];
282  PLOCAL_HANDLE pHandle;
283  PLOCAL_PRINTER_HANDLE pPrinterHandle;
284 
285  TRACE("LocalGetPrinterDriver(%p, %lu, %lu, %p, %lu, %p)\n", hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded);
286 
288 
289  // Check if this is a printer handle.
290  pHandle = (PLOCAL_HANDLE)hPrinter;
291  if (pHandle->HandleType != HandleType_Printer)
292  {
293  dwErrorCode = ERROR_INVALID_HANDLE;
294  goto Cleanup;
295  }
296 
297  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
298 
299  // Only support 5 levels for now
300  if (Level > 5)
301  {
302  // The caller supplied an invalid level.
303  dwErrorCode = ERROR_INVALID_LEVEL;
304  goto Cleanup;
305  }
306 
307  // Count the required buffer size.
308  *pcbNeeded = 0;
309 
310  if (Level == 1)
311  _LocalGetPrinterDriverLevel1(pPrinterHandle, NULL, NULL, pcbNeeded);
312  else if (Level == 2)
313  _LocalGetPrinterDriverLevel2(pPrinterHandle, NULL, NULL, pcbNeeded);
314  else if (Level == 3)
315  _LocalGetPrinterDriverLevel3(pPrinterHandle, NULL, NULL, pcbNeeded);
316  else if (Level == 4)
317  _LocalGetPrinterDriverLevel4(pPrinterHandle, NULL, NULL, pcbNeeded);
318  else if (Level == 5)
319  _LocalGetPrinterDriverLevel5(pPrinterHandle, NULL, NULL, pcbNeeded);
320 
321  // Check if the supplied buffer is large enough.
322  if (cbBuf < *pcbNeeded)
323  {
324  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
325  goto Cleanup;
326  }
327 
328  // Copy over the information.
329  pEnd = &pDriverInfo[*pcbNeeded];
330 
331  if (Level == 1)
332  _LocalGetPrinterDriverLevel1(pPrinterHandle, (PDRIVER_INFO_1W*)&pDriverInfo, &pEnd, NULL);
333  else if (Level == 2)
334  _LocalGetPrinterDriverLevel2(pPrinterHandle, (PDRIVER_INFO_2W*)&pDriverInfo, &pEnd, NULL);
335  else if (Level == 3)
336  _LocalGetPrinterDriverLevel3(pPrinterHandle, (PDRIVER_INFO_3W*)&pDriverInfo, &pEnd, NULL);
337  else if (Level == 4)
338  _LocalGetPrinterDriverLevel4(pPrinterHandle, (PDRIVER_INFO_4W*)&pDriverInfo, &pEnd, NULL);
339  else if (Level == 5)
340  _LocalGetPrinterDriverLevel5(pPrinterHandle, (PDRIVER_INFO_5W*)&pDriverInfo, &pEnd, NULL);
341 
342  dwErrorCode = ERROR_SUCCESS;
343 
344 Cleanup:
345  SetLastError(dwErrorCode);
346  return (dwErrorCode == ERROR_SUCCESS);
347 }
static void _LocalGetPrinterDriverLevel5(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_5W *ppDriverInfo, PBYTE *ppDriverInfoEnd, PDWORD pcbNeeded)
#define ERROR_SUCCESS
Definition: deptool.c:10
static void _LocalGetPrinterDriverLevel4(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_4W *ppDriverInfo, PBYTE *ppDriverInfoEnd, PDWORD pcbNeeded)
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static void _LocalGetPrinterDriverLevel2(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_2W *ppDriverInfo, PBYTE *ppDriverInfoEnd, PDWORD pcbNeeded)
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL DoInitPrinterDriversInternal(void)
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80
static void _LocalGetPrinterDriverLevel3(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_3W *ppDriverInfo, PBYTE *ppDriverInfoEnd, PDWORD pcbNeeded)
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
static void _LocalGetPrinterDriverLevel1(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_1W *ppDriverInfo, PBYTE *ppDriverInfoEnd, PDWORD pcbNeeded)
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ LocalGetPrintProcessorDirectory()

BOOL WINAPI LocalGetPrintProcessorDirectory ( LPWSTR  pName,
LPWSTR  pEnvironment,
DWORD  Level,
LPBYTE  pPrintProcessorInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded 
)

◆ LocalOpenPrinter()

BOOL WINAPI LocalOpenPrinter ( PWSTR  lpPrinterName,
HANDLE phPrinter,
PPRINTER_DEFAULTSW  pDefault 
)

Definition at line 1364 of file printers.c.

1365 {
1366  DWORD cchComputerName;
1367  DWORD cchFirstParameter;
1368  DWORD dwErrorCode;
1369  PWSTR p = lpPrinterName;
1370  PWSTR pwszFirstParameter = NULL;
1371  PWSTR pwszSecondParameter;
1372  WCHAR wszComputerName[MAX_COMPUTERNAME_LENGTH + 1];
1373 
1374  TRACE("LocalOpenPrinter(%S, %p, %p)\n", lpPrinterName, phPrinter, pDefault);
1375 
1376  ASSERT(phPrinter);
1377  *phPrinter = NULL;
1378 
1379  if (!lpPrinterName)
1380  {
1381  // The caller wants a Print Server handle and provided a NULL string.
1382  dwErrorCode = _LocalOpenPrintServerHandle(phPrinter);
1383  goto Cleanup;
1384  }
1385 
1386  // Skip any server name in the first parameter.
1387  // Does lpPrinterName begin with two backslashes to indicate a server name?
1388  if (lpPrinterName[0] == L'\\' && lpPrinterName[1] == L'\\')
1389  {
1390  // Skip these two backslashes.
1391  lpPrinterName += 2;
1392 
1393  // Look for the terminating null character or closing backslash.
1394  p = lpPrinterName;
1395  while (*p != L'\0' && *p != L'\\')
1396  p++;
1397 
1398  // Get the local computer name for comparison.
1399  cchComputerName = _countof(wszComputerName);
1400  if (!GetComputerNameW(wszComputerName, &cchComputerName))
1401  {
1402  dwErrorCode = GetLastError();
1403  ERR("GetComputerNameW failed with error %lu!\n", dwErrorCode);
1404  goto Cleanup;
1405  }
1406 
1407  // Now compare this string excerpt with the local computer name.
1408  // The input parameter may not be writable, so we can't null-terminate the input string at this point.
1409  // This print provider only supports local printers, so both strings have to match.
1410  if (p - lpPrinterName != cchComputerName || _wcsnicmp(lpPrinterName, wszComputerName, cchComputerName) != 0)
1411  {
1412  dwErrorCode = ERROR_INVALID_NAME;
1413  goto Cleanup;
1414  }
1415 
1416  // If lpPrinterName is only "\\COMPUTERNAME" with nothing more, the caller wants a handle to the local Print Server.
1417  if (!*p)
1418  {
1419  // The caller wants a Print Server handle and provided a string like:
1420  // "\\COMPUTERNAME"
1421  dwErrorCode = _LocalOpenPrintServerHandle(phPrinter);
1422  goto Cleanup;
1423  }
1424 
1425  // We have checked the server name and don't need it anymore.
1426  lpPrinterName = p + 1;
1427  }
1428 
1429  // Look for a comma. If it exists, it indicates the end of the first parameter.
1430  pwszSecondParameter = wcschr(lpPrinterName, L',');
1431  if (pwszSecondParameter)
1432  cchFirstParameter = pwszSecondParameter - p;
1433  else
1434  cchFirstParameter = wcslen(lpPrinterName);
1435 
1436  // We must have at least one parameter.
1437  if (!cchFirstParameter && !pwszSecondParameter)
1438  {
1439  dwErrorCode = ERROR_INVALID_NAME;
1440  goto Cleanup;
1441  }
1442 
1443  // Do we have a first parameter?
1444  if (cchFirstParameter)
1445  {
1446  // Yes, extract it.
1447  // No null-termination is necessary here, because DllAllocSplMem returns a zero-initialized buffer.
1448  pwszFirstParameter = DllAllocSplMem((cchFirstParameter + 1) * sizeof(WCHAR));
1449  CopyMemory(pwszFirstParameter, lpPrinterName, cchFirstParameter * sizeof(WCHAR));
1450  }
1451 
1452  // Do we have a second parameter?
1453  if (pwszSecondParameter)
1454  {
1455  // Yes, skip the comma at the beginning.
1456  ++pwszSecondParameter;
1457 
1458  // Skip whitespace as well.
1459  while (*pwszSecondParameter == L' ')
1460  ++pwszSecondParameter;
1461  }
1462 
1463  // Now we can finally check the type of handle actually requested.
1464  if (pwszFirstParameter && pwszSecondParameter && wcsncmp(pwszSecondParameter, L"Port", 4) == 0)
1465  {
1466  // The caller wants a port handle and provided a string like:
1467  // "LPT1:, Port"
1468  // "\\COMPUTERNAME\LPT1:, Port"
1469  dwErrorCode = _LocalOpenPortHandle(pwszFirstParameter, phPrinter);
1470  }
1471  else if (!pwszFirstParameter && pwszSecondParameter && wcsncmp(pwszSecondParameter, L"Xcv", 3) == 0)
1472  {
1473  // The caller wants an Xcv handle and provided a string like:
1474  // ", XcvMonitor Local Port"
1475  // "\\COMPUTERNAME\, XcvMonitor Local Port"
1476  // ", XcvPort LPT1:"
1477  // "\\COMPUTERNAME\, XcvPort LPT1:"
1478  dwErrorCode = _LocalOpenXcvHandle(pwszSecondParameter, phPrinter);
1479  }
1480  else
1481  {
1482  // The caller wants a Printer or Printer Job handle and provided a string like:
1483  // "HP DeskJet"
1484  // "\\COMPUTERNAME\HP DeskJet"
1485  // "HP DeskJet, Job 5"
1486  // "\\COMPUTERNAME\HP DeskJet, Job 5"
1487  dwErrorCode = _LocalOpenPrinterHandle(pwszFirstParameter, pwszSecondParameter, phPrinter, pDefault);
1488  }
1489 
1490 Cleanup:
1491  if (pwszFirstParameter)
1492  DllFreeSplMem(pwszFirstParameter);
1493 
1494  SetLastError(dwErrorCode);
1495  return (dwErrorCode == ERROR_SUCCESS);
1496 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:55
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
_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)
static DWORD _LocalOpenPrintServerHandle(PHANDLE phPrinter)
Definition: printers.c:1239
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:443
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
static DWORD _LocalOpenPrinterHandle(PWSTR pwszPrinterName, PWSTR pwszJobParameter, PHANDLE phPrinter, PPRINTER_DEFAULTSW pDefault)
Definition: printers.c:1098
#define ERROR_INVALID_NAME
Definition: compat.h:93
static DWORD _LocalOpenXcvHandle(PWSTR pwszParameter, PHANDLE phPrinter)
Definition: printers.c:1261
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
static DWORD _LocalOpenPortHandle(PWSTR pwszPortName, PHANDLE phPrinter)
Definition: printers.c:1024
GLfloat GLfloat p
Definition: glext.h:8902
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ LocalReadPrinter()

BOOL WINAPI LocalReadPrinter ( HANDLE  hPrinter,
PVOID  pBuf,
DWORD  cbBuf,
PDWORD  pNoBytesRead 
)

Definition at line 1499 of file printers.c.

1500 {
1501  BOOL bReturnValue;
1502  DWORD dwErrorCode;
1503  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1504  PLOCAL_PORT_HANDLE pPortHandle;
1505  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1506 
1507  TRACE("LocalReadPrinter(%p, %p, %lu, %p)\n", hPrinter, pBuf, cbBuf, pNoBytesRead);
1508 
1509  // Sanity checks.
1510  if (!pHandle)
1511  {
1512  dwErrorCode = ERROR_INVALID_HANDLE;
1513  goto Cleanup;
1514  }
1515 
1516  // Port handles are an entirely different thing.
1517  if (pHandle->HandleType == HandleType_Port)
1518  {
1519  pPortHandle = (PLOCAL_PORT_HANDLE)pHandle->pSpecificHandle;
1520 
1521  // Call the monitor's ReadPort function.
1522  if (pPortHandle->pPort->pPrintMonitor->bIsLevel2)
1523  bReturnValue = ((PMONITOR2)pPortHandle->pPort->pPrintMonitor->pMonitor)->pfnReadPort(pPortHandle->hPort, pBuf, cbBuf, pNoBytesRead);
1524  else
1525  bReturnValue = ((LPMONITOREX)pPortHandle->pPort->pPrintMonitor->pMonitor)->Monitor.pfnReadPort(pPortHandle->hPort, pBuf, cbBuf, pNoBytesRead);
1526 
1527  if (!bReturnValue)
1528  {
1529  // The ReadPort function failed. Return its last error.
1530  dwErrorCode = GetLastError();
1531  goto Cleanup;
1532  }
1533 
1534  // We were successful!
1535  dwErrorCode = ERROR_SUCCESS;
1536  goto Cleanup;
1537  }
1538 
1539  // The remaining function deals with Printer handles only.
1540  if (pHandle->HandleType != HandleType_Printer)
1541  {
1542  dwErrorCode = ERROR_INVALID_HANDLE;
1543  goto Cleanup;
1544  }
1545 
1546  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1547 
1548  // ReadPrinter needs an opened SPL file to work.
1549  // This only works if a Printer Job Handle was requested in OpenPrinter.
1550  if (pPrinterHandle->hSPLFile == INVALID_HANDLE_VALUE)
1551  {
1552  dwErrorCode = ERROR_INVALID_HANDLE;
1553  goto Cleanup;
1554  }
1555 
1556  // Pass the parameters to ReadFile.
1557  if (!ReadFile(pPrinterHandle->hSPLFile, pBuf, cbBuf, pNoBytesRead, NULL))
1558  {
1559  dwErrorCode = GetLastError();
1560  ERR("ReadFile failed with error %lu!\n", dwErrorCode);
1561  goto Cleanup;
1562  }
1563 
1564  dwErrorCode = ERROR_SUCCESS;
1565 
1566 Cleanup:
1567  SetLastError(dwErrorCode);
1568  return (dwErrorCode == ERROR_SUCCESS);
1569 }
PLOCAL_PORT pPort
Definition: precomp.h:179
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
PLOCAL_PRINT_MONITOR pPrintMonitor
Definition: precomp.h:87
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _LOCAL_PORT_HANDLE * PLOCAL_PORT_HANDLE
Definition: precomp.h:57
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
struct _MONITOR2 * PMONITOR2
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
struct _MONITOREX * LPMONITOREX
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

◆ LocalScheduleJob()

BOOL WINAPI LocalScheduleJob ( HANDLE  hPrinter,
DWORD  dwJobID 
)

Definition at line 1112 of file jobs.c.

1113 {
1115  DWORD dwErrorCode;
1116  HANDLE hThread;
1117  PLOCAL_JOB pJob;
1118  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1119  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1120  WCHAR wszFullPath[MAX_PATH];
1121 
1122  TRACE("LocalScheduleJob(%p, %lu)\n", hPrinter, dwJobID);
1123 
1124  // Check if this is a printer handle.
1125  if (pHandle->HandleType != HandleType_Printer)
1126  {
1127  dwErrorCode = ERROR_INVALID_HANDLE;
1128  goto Cleanup;
1129  }
1130 
1131  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1132 
1133  // Check if the Job ID is valid.
1134  pJob = LookupElementSkiplist(&GlobalJobList, &dwJobID, NULL);
1135  if (!pJob || pJob->pPrinter != pPrinterHandle->pPrinter)
1136  {
1137  dwErrorCode = ERROR_INVALID_PARAMETER;
1138  goto Cleanup;
1139  }
1140 
1141  // Check if this Job was started with AddJob.
1142  if (!pJob->bAddedJob)
1143  {
1144  dwErrorCode = ERROR_SPL_NO_ADDJOB;
1145  goto Cleanup;
1146  }
1147 
1148  // Construct the full path to the spool file.
1149  GetJobFilePath(L"SPL", dwJobID, wszFullPath);
1150 
1151  // Check if it exists.
1152  dwAttributes = GetFileAttributesW(wszFullPath);
1154  {
1155  dwErrorCode = ERROR_SPOOL_FILE_NOT_FOUND;
1156  goto Cleanup;
1157  }
1158 
1159  // Spooling is finished at this point.
1160  pJob->dwStatus &= ~JOB_STATUS_SPOOLING;
1161 
1162  // Write the job data into the shadow file.
1163  wcscpy(wcsrchr(wszFullPath, L'.'), L".SHD");
1164  WriteJobShadowFile(wszFullPath, pJob);
1165 
1166  // Create the thread for performing the printing process.
1168  if (!hThread)
1169  {
1170  dwErrorCode = GetLastError();
1171  ERR("CreateThread failed with error %lu!\n", dwErrorCode);
1172  goto Cleanup;
1173  }
1174 
1175  // We don't need the thread handle. Keeping it open blocks the thread from terminating.
1177 
1178  // ScheduleJob has done its job. The rest happens inside the thread.
1179  dwErrorCode = ERROR_SUCCESS;
1180 
1181 Cleanup:
1182  SetLastError(dwErrorCode);
1183  return (dwErrorCode == ERROR_SUCCESS);
1184 }
#define ERROR_SPOOL_FILE_NOT_FOUND
Definition: winerror.h:1207
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
#define CloseHandle
Definition: compat.h:407
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL bAddedJob
Definition: precomp.h:138
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI PrintingThreadProc(PLOCAL_JOB pJob)
DWORD dwAttributes
Definition: vdmdbg.h:34
#define JOB_STATUS_SPOOLING
Definition: winspool.h:341
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
Definition: jobs.c:146
BOOL WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
Definition: jobs.c:1300
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
DWORD dwStatus
Definition: precomp.h:155
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
PLOCAL_PRINTER pPrinter
Definition: precomp.h:140
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_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
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
PVOID LookupElementSkiplist(PSKIPLIST Skiplist, PVOID Element, PDWORD ElementIndex)
Definition: skiplist.c:357
HANDLE hThread
Definition: wizard.c:27
#define ERROR_SPL_NO_ADDJOB
Definition: winerror.h:1209
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
SKIPLIST GlobalJobList
Definition: jobs.c:11

◆ LocalSetJob()

BOOL WINAPI LocalSetJob ( HANDLE  hPrinter,
DWORD  JobId,
DWORD  Level,
PBYTE  pJobInfo,
DWORD  Command 
)

Definition at line 949 of file jobs.c.

950 {
951  DWORD dwErrorCode = ERROR_SUCCESS;
952  PLOCAL_HANDLE pHandle;
953  PLOCAL_JOB pJob;
954  PLOCAL_PRINTER_HANDLE pPrinterHandle;
955  WCHAR wszFullPath[MAX_PATH];
956 
957  TRACE("LocalSetJob(%p, %lu, %lu, %p, %lu)\n", hPrinter, JobId, Level, pJobInfo, Command);
958 
959  // Check if this is a printer handle.
960  pHandle = (PLOCAL_HANDLE)hPrinter;
961  if (!pHandle || pHandle->HandleType != HandleType_Printer)
962  {
963  dwErrorCode = ERROR_INVALID_HANDLE;
964  goto Cleanup;
965  }
966 
967  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
968 
969  // Get the desired job.
970  pJob = LookupElementSkiplist(&GlobalJobList, &JobId, NULL);
971  if (!pJob || pJob->pPrinter != pPrinterHandle->pPrinter)
972  {
973  dwErrorCode = ERROR_INVALID_PARAMETER;
974  goto Cleanup;
975  }
976 
977  // Set new job information if a valid level was given.
978  if (Level == 1)
979  dwErrorCode = _LocalSetJobLevel1(pPrinterHandle, pJob, (PJOB_INFO_1W)pJobInfo);
980  else if (Level == 2)
981  dwErrorCode = _LocalSetJobLevel2(pPrinterHandle, pJob, (PJOB_INFO_2W)pJobInfo);
982 
983  if (dwErrorCode != ERROR_SUCCESS)
984  goto Cleanup;
985 
986  // If we do spooled printing, the job information is written down into a shadow file.
987  if (!(pPrinterHandle->pPrinter->dwAttributes & PRINTER_ATTRIBUTE_DIRECT))
988  {
989  // Write the job data into the shadow file.
990  GetJobFilePath(L"SHD", JobId, wszFullPath);
991  WriteJobShadowFile(wszFullPath, pJob);
992  }
993 
994  // Perform an additional command if desired.
995  if (Command)
996  {
998  {
999  // This indicates the end of the Print Job.
1000 
1001  // Cancel the Job at the Print Processor.
1002  if (pJob->hPrintProcessor)
1004 
1005  FreeJob(pJob);
1006 
1007  // TODO: All open handles associated with the job need to be invalidated.
1008  // This certainly needs handle tracking...
1009  }
1010  else
1011  {
1012  ERR("Unimplemented SetJob Command: %lu!\n", Command);
1013  }
1014  }
1015 
1016 Cleanup:
1017  SetLastError(dwErrorCode);
1018  return (dwErrorCode == ERROR_SUCCESS);
1019 }
static DWORD _LocalSetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PJOB_INFO_2W pJobInfo)
Definition: jobs.c:818
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwAttributes
Definition: precomp.h:117
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define JOB_CONTROL_CANCEL
Definition: winspool.h:332
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
Definition: shell.h:41
void FreeJob(PLOCAL_JOB pJob)
Definition: jobs.c:1452
struct _LOCAL_HANDLE * PLOCAL_HANDLE
Definition: precomp.h:54
smooth NULL
Definition: ftsmooth.c:416
PVOID pSpecificHandle
Definition: precomp.h:204
DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput)
Definition: jobs.c:146
BOOL WriteJobShadowFile(PWSTR pwszFilePath, const PLOCAL_JOB pJob)
Definition: jobs.c:1300
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
PLOCAL_PRINTER pPrinter
Definition: precomp.h:140
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PRINTER_ATTRIBUTE_DIRECT
Definition: winspool.h:209
#define SetLastError(x)
Definition: compat.h:418
enum _LOCAL_HANDLE::@4191 HandleType
static const WCHAR L[]
Definition: oid.c:1250
#define JOB_CONTROL_SENT_TO_PRINTER
Definition: winspool.h:335
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
PVOID LookupElementSkiplist(PSKIPLIST Skiplist, PVOID Element, PDWORD ElementIndex)
Definition: skiplist.c:357
HANDLE hPrintProcessor
Definition: precomp.h:139
PLOCAL_PRINT_PROCESSOR pPrintProcessor
Definition: precomp.h:141
struct _LOCAL_PRINTER_HANDLE * PLOCAL_PRINTER_HANDLE
Definition: precomp.h:61
PControlPrintProcessor pfnControlPrintProcessor
Definition: precomp.h:101
PLOCAL_PRINTER pPrinter
Definition: precomp.h:167
static DWORD _LocalSetJobLevel1(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PJOB_INFO_1W pJobInfo)
Definition: jobs.c:721
SKIPLIST GlobalJobList
Definition: jobs.c:11

◆ LocalSetPrinterData()

DWORD WINAPI LocalSetPrinterData ( HANDLE  hPrinter,
PWSTR  pValueName,
DWORD  Type,
PBYTE  pData,
DWORD  cbData 
)

Definition at line 361 of file printerdata.c.

362 {
363  TRACE("LocalSetPrinterData(%p, %S, %lu, %p, %lu)\n", hPrinter, pValueName, Type, pData, cbData);
364 
365  // The ReactOS Printing Stack forwards all SetPrinterData calls to SetPrinterDataEx as soon as possible.
366  // This function may only be called if localspl.dll is used together with Windows Printing Stack components.
367  WARN("This function should never be called!\n");
368  return LocalSetPrinterDataEx(hPrinter, L"PrinterDriverData", pValueName, Type, pData, cbData);
369 }
Type
Definition: Type.h:6
#define WARN(fmt,...)
Definition: debug.h:112
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR L[]
Definition: oid.c:1250
DWORD WINAPI LocalSetPrinterDataEx(HANDLE hPrinter, PCWSTR pKeyName, PCWSTR pValueName, DWORD Type, PBYTE pData, DWORD cbData)
Definition: printerdata.c:450
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

◆ LocalSetPrinterDataEx()

DWORD WINAPI LocalSetPrinterDataEx ( HANDLE  hPrinter,
LPCWSTR  pKeyName,
LPCWSTR  pValueName,
DWORD  Type,
LPBYTE  pData,
DWORD  cbData 
)

◆ LocalStartDocPrinter()

DWORD WINAPI LocalStartDocPrinter ( HANDLE  hPrinter,
DWORD  Level,
LPBYTE  pDocInfo 
)

◆ LocalStartPagePrinter()

BOOL WINAPI LocalStartPagePrinter ( HANDLE  hPrinter)

Definition at line 1689 of file printers.c.

1690 {
1691  DWORD dwErrorCode;
1692  PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
1693  PLOCAL_PRINTER_HANDLE pPrinterHandle;
1694 
1695  TRACE("LocalStartPagePrinter(%p)\n", hPrinter);
1696 
1697  // Sanity checks.
1698  if (!pHandle || pHandle->HandleType != HandleType_Printer)
1699  {
1700  dwErrorCode = ERROR_INVALID_HANDLE;
1701  goto Cleanup;
1702  }
1703 
1704  pPrinterHandle = (PLOCAL_PRINTER_HANDLE)pHandle->pSpecificHandle;
1705 
1706  // We require StartDocPrinter or AddJob to be called first.
1707  if (!pPrinterHandle->bStartedDoc)
1708  {
1709  dwErrorCode = ERROR_SPL_NO_STARTDOC;
1710  goto Cleanup;
1711  }
1712 
1713  // Increase the page count.
1714  ++pPrinterHandle->pJob->dwTotalPages;
1715  dwErrorCode = ERROR_SUCCESS;
1716 
1717 Cleanup