ReactOS  0.4.15-dev-1039-gb9754fa
printers.c File Reference
#include "precomp.h"
#include <marshalling/printers.h>
#include <strsafe.h>
Include dependency graph for printers.c:

Go to the source code of this file.

Classes

struct  _COMPUI_USERDATA
 

Macros

#define QSM_DOWNLOADINGFONTS   0x0001
 
#define QSM_XPS_PASS   0x0002
 

Typedefs

typedef DWORD(WINAPIDEVICECAPABILITIES) (HANDLE, PWSTR, WORD, PVOID, PDEVMODEW)
 
typedef LONG(WINAPIDEVICEPROPERTYSHEETS) (PPROPSHEETUI_INFO, LPARAM)
 
typedef LONG(WINAPIDOCUMENTPROPERTYSHEETS) (PPROPSHEETUI_INFO, LPARAM)
 
typedef LONG(WINAPICOMMONPROPERTYSHEETUIW) (HWND, PFNPROPSHEETUI, LPARAM, LPDWORD)
 
typedef LONG(WINAPIQUERYCOLORPROFILE) (HANDLE, PDEVMODEW, ULONG, PVOID, ULONG *, FLONG *)
 
typedef BOOL(WINAPISPOOLERPRINTEREVENT) (LPWSTR, int, DWORD, LPARAM)
 
typedef BOOL(WINAPIDEVQUERYPRINT) (HANDLE, LPDEVMODEW, DWORD *)
 
typedef BOOL(WINAPIDEVQUERYPRINTEX) (PDEVQUERYPRINT_INFO)
 
typedef LONG(WINAPICONSTRUCTPRINTERFRIENDLYNAME) (PWSTR, PVOID, LPDWORD)
 
typedef struct _COMPUI_USERDATA COMPUI_USERDATA
 
typedef struct _COMPUI_USERDATAPCOMPUI_USERDATA
 

Functions

LONG WINAPI ConstructPrinterFriendlyName (PWSTR, PVOID, LPDWORD Size)
 
static DWORD _StartDocPrinterSpooled (PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1, PADDJOB_INFO_1W pAddJobInfo1)
 
static DWORD _StartDocPrinterWithRPC (PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1)
 
BOOL WINAPI AbortPrinter (HANDLE hPrinter)
 
HANDLE WINAPI AddPrinterA (PSTR pName, DWORD Level, PBYTE pPrinter)
 
HANDLE WINAPI AddPrinterW (PWSTR pName, DWORD Level, PBYTE pPrinter)
 
BOOL WINAPI ClosePrinter (HANDLE hPrinter)
 
BOOL WINAPI DeletePrinter (HANDLE hPrinter)
 
HMODULE WINAPI LoadPrinterDriver (HANDLE hspool)
 
DWORD WINAPI DeviceCapabilitiesA (LPCSTR pDevice, LPCSTR pPort, WORD fwCapability, LPSTR pOutput, const DEVMODEA *pDevMode)
 
DWORD WINAPI DeviceCapabilitiesW (LPCWSTR pDevice, LPCWSTR pPort, WORD fwCapability, LPWSTR pOutput, const DEVMODEW *pDevMode)
 
BOOL WINAPI DevQueryPrint (HANDLE hPrinter, LPDEVMODEW pDevMode, DWORD *pResID)
 
BOOL WINAPI DevQueryPrintEx (PDEVQUERYPRINT_INFO pDQPInfo)
 
INT WINAPI DocumentEvent (HANDLE hPrinter, HDC hdc, int iEsc, ULONG cbIn, PVOID pvIn, ULONG cbOut, PVOID pvOut)
 
LONG WINAPI DocumentPropertiesA (HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName, PDEVMODEA pDevModeOutput, PDEVMODEA pDevModeInput, DWORD fMode)
 
PRINTER_INFO_9Wget_devmodeW (HANDLE hprn)
 
BOOL FASTCALL CreateUIUserData (ULONG_PTR *puserdata, HANDLE hPrinter)
 
VOID FASTCALL DestroyUIUserData (ULONG_PTR *puserdata)
 
BOOL FASTCALL IntFixUpDevModeNames (PDOCUMENTPROPERTYHEADER pdphdr)
 
LONG WINAPI CreatePrinterFriendlyName (PCOMPUI_USERDATA pcui_ud, LPWSTR pszPrinterName)
 
LONG WINAPI DocumentPropertySheets (PPROPSHEETUI_INFO pCPSUIInfo, LPARAM lparam)
 
LONG WINAPI DevicePropertySheets (PPROPSHEETUI_INFO pCPSUIInfo, LPARAM lparam)
 
LONG WINAPI CallCommonPropertySheetUI (HWND hWnd, PFNPROPSHEETUI pfnPropSheetUI, LPARAM lparam, LPDWORD pResult)
 
LONG WINAPI DocumentPropertiesW (HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
 
BOOL WINAPI PrinterProperties (HWND hWnd, HANDLE hPrinter)
 
BOOL WINAPI EndDocPrinter (HANDLE hPrinter)
 
BOOL WINAPI EndPagePrinter (HANDLE hPrinter)
 
BOOL WINAPI EnumPrintersA (DWORD Flags, PSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI EnumPrintersW (DWORD Flags, PWSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI FlushPrinter (HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pcWritten, DWORD cSleep)
 
BOOL WINAPI GetDefaultPrinterA (LPSTR pszBuffer, LPDWORD pcchBuffer)
 
BOOL WINAPI GetDefaultPrinterW (LPWSTR pszBuffer, LPDWORD pcchBuffer)
 
BOOL WINAPI GetPrinterA (HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI GetPrinterW (HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
 
BOOL WINAPI OpenPrinterA (LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
 
BOOL WINAPI OpenPrinterW (LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
 
DWORD WINAPI PrinterMessageBoxA (HANDLE hPrinter, DWORD Error, HWND hWnd, LPSTR pText, LPSTR pCaption, DWORD dwType)
 
DWORD WINAPI PrinterMessageBoxW (HANDLE hPrinter, DWORD Error, HWND hWnd, LPWSTR pText, LPWSTR pCaption, DWORD dwType)
 
BOOL WINAPI QueryColorProfile (HANDLE hPrinter, PDEVMODEW pdevmode, ULONG ulQueryMode, VOID *pvProfileData, ULONG *pcbProfileData, FLONG *pflProfileData)
 
BOOL WINAPI QuerySpoolMode (HANDLE hPrinter, PDWORD downloadFontsFlags, PDWORD dwVersion)
 
DWORD WINAPI QueryRemoteFonts (HANDLE hPrinter, PUNIVERSAL_FONT_ID pufi, ULONG NumberOfUFIs)
 
BOOL WINAPI ReadPrinter (HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pNoBytesRead)
 
BOOL WINAPI ResetPrinterA (HANDLE hPrinter, PPRINTER_DEFAULTSA pDefault)
 
BOOL WINAPI ResetPrinterW (HANDLE hPrinter, PPRINTER_DEFAULTSW pDefault)
 
BOOL WINAPI SeekPrinter (HANDLE hPrinter, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER pliNewPointer, DWORD dwMoveMethod, BOOL bWrite)
 
BOOL WINAPI SetDefaultPrinterA (LPCSTR pszPrinter)
 
BOOL WINAPI SetDefaultPrinterW (LPCWSTR pszPrinter)
 
BOOL WINAPI SetPrinterA (HANDLE hPrinter, DWORD Level, PBYTE pPrinter, DWORD Command)
 
BOOL WINAPI SetPrinterW (HANDLE hPrinter, DWORD Level, PBYTE pPrinter, DWORD Command)
 
BOOL WINAPI SplDriverUnloadComplete (LPWSTR pDriverFile)
 
BOOL WINAPI SpoolerPrinterEvent (LPWSTR pPrinterName, INT DriverEvent, DWORD Flags, LPARAM lParam)
 
INT_PTR CALLBACK file_dlg_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
LPWSTR WINAPI StartDocDlgW (HANDLE hPrinter, DOCINFOW *doc)
 
LPSTR WINAPI StartDocDlgA (HANDLE hPrinter, DOCINFOA *doc)
 
DWORD WINAPI StartDocPrinterA (HANDLE hPrinter, DWORD Level, PBYTE pDocInfo)
 
DWORD WINAPI StartDocPrinterW (HANDLE hPrinter, DWORD Level, PBYTE pDocInfo)
 
BOOL WINAPI StartPagePrinter (HANDLE hPrinter)
 
BOOL WINAPI WritePrinter (HANDLE hPrinter, PVOID pBuf, DWORD cbBuf, PDWORD pcWritten)
 
BOOL WINAPI XcvDataW (HANDLE hXcv, PCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded, PDWORD pdwStatus)
 

Variables

HINSTANCE hinstWinSpool
 
static DEVICECAPABILITIES fpDeviceCapabilities
 
static DEVICEPROPERTYSHEETS fpDevicePropertySheets
 
static DOCUMENTPROPERTYSHEETS fpDocumentPropertySheets
 
static COMMONPROPERTYSHEETUIW fpCommonPropertySheetUIW
 
static QUERYCOLORPROFILE fpQueryColorProfile
 
static SPOOLERPRINTEREVENT fpPrinterEvent
 
static DEVQUERYPRINT fpDevQueryPrint
 
static DEVQUERYPRINTEX fpDevQueryPrintEx
 
static CONSTRUCTPRINTERFRIENDLYNAME fpConstructPrinterFriendlyName
 
static const WCHAR wszWindowsKey [] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
 
static const WCHAR wszDeviceValue [] = L"Device"
 
static const WCHAR FILE_Port [] = {'F','I','L','E',':',0}
 

Macro Definition Documentation

◆ QSM_DOWNLOADINGFONTS

#define QSM_DOWNLOADINGFONTS   0x0001

Definition at line 2764 of file printers.c.

◆ QSM_XPS_PASS

#define QSM_XPS_PASS   0x0002

Definition at line 2779 of file printers.c.

Typedef Documentation

◆ COMMONPROPERTYSHEETUIW

typedef LONG(WINAPI * COMMONPROPERTYSHEETUIW) (HWND, PFNPROPSHEETUI, LPARAM, LPDWORD)

Definition at line 26 of file printers.c.

◆ COMPUI_USERDATA

◆ CONSTRUCTPRINTERFRIENDLYNAME

typedef LONG(WINAPI * CONSTRUCTPRINTERFRIENDLYNAME) (PWSTR, PVOID, LPDWORD)

Definition at line 45 of file printers.c.

◆ DEVICECAPABILITIES

typedef DWORD(WINAPI * DEVICECAPABILITIES) (HANDLE, PWSTR, WORD, PVOID, PDEVMODEW)

Definition at line 18 of file printers.c.

◆ DEVICEPROPERTYSHEETS

typedef LONG(WINAPI * DEVICEPROPERTYSHEETS) (PPROPSHEETUI_INFO, LPARAM)

Definition at line 21 of file printers.c.

◆ DEVQUERYPRINT

typedef BOOL(WINAPI * DEVQUERYPRINT) (HANDLE, LPDEVMODEW, DWORD *)

Definition at line 35 of file printers.c.

◆ DEVQUERYPRINTEX

typedef BOOL(WINAPI * DEVQUERYPRINTEX) (PDEVQUERYPRINT_INFO)

Definition at line 38 of file printers.c.

◆ DOCUMENTPROPERTYSHEETS

typedef LONG(WINAPI * DOCUMENTPROPERTYSHEETS) (PPROPSHEETUI_INFO, LPARAM)

Definition at line 23 of file printers.c.

◆ PCOMPUI_USERDATA

◆ QUERYCOLORPROFILE

typedef LONG(WINAPI * QUERYCOLORPROFILE) (HANDLE, PDEVMODEW, ULONG, PVOID, ULONG *, FLONG *)

Definition at line 29 of file printers.c.

◆ SPOOLERPRINTEREVENT

typedef BOOL(WINAPI * SPOOLERPRINTEREVENT) (LPWSTR, int, DWORD, LPARAM)

Definition at line 32 of file printers.c.

Function Documentation

◆ _StartDocPrinterSpooled()

static DWORD _StartDocPrinterSpooled ( PSPOOLER_HANDLE  pHandle,
PDOC_INFO_1W  pDocInfo1,
PADDJOB_INFO_1W  pAddJobInfo1 
)
static

Definition at line 65 of file printers.c.

66 {
67  DWORD cbNeeded;
68  DWORD dwErrorCode;
69  PJOB_INFO_1W pJobInfo1 = NULL;
70 
71  // Create the spool file.
73  if (pHandle->hSPLFile == INVALID_HANDLE_VALUE)
74  {
75  dwErrorCode = GetLastError();
76  ERR("CreateFileW failed for \"%S\" with error %lu!\n", pAddJobInfo1->Path, dwErrorCode);
77  goto Cleanup;
78  }
79 
80  // Get the size of the job information.
81  GetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, NULL, 0, &cbNeeded);
83  {
84  dwErrorCode = GetLastError();
85  ERR("GetJobW failed with error %lu!\n", dwErrorCode);
86  goto Cleanup;
87  }
88 
89  // Allocate enough memory for the returned job information.
90  pJobInfo1 = HeapAlloc(hProcessHeap, 0, cbNeeded);
91  if (!pJobInfo1)
92  {
93  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
94  ERR("HeapAlloc failed!\n");
95  goto Cleanup;
96  }
97 
98  // Get the job information.
99  if (!GetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, cbNeeded, &cbNeeded))
100  {
101  dwErrorCode = GetLastError();
102  ERR("GetJobW failed with error %lu!\n", dwErrorCode);
103  goto Cleanup;
104  }
105 
106  // Add our document information.
107  if (pDocInfo1->pDatatype)
108  pJobInfo1->pDatatype = pDocInfo1->pDatatype;
109 
110  pJobInfo1->pDocument = pDocInfo1->pDocName;
111 
112  // Set the new job information.
113  if (!SetJobW((HANDLE)pHandle, pAddJobInfo1->JobId, 1, (PBYTE)pJobInfo1, 0))
114  {
115  dwErrorCode = GetLastError();
116  ERR("SetJobW failed with error %lu!\n", dwErrorCode);
117  goto Cleanup;
118  }
119 
120  // We were successful!
121  pHandle->dwJobID = pAddJobInfo1->JobId;
122  dwErrorCode = ERROR_SUCCESS;
123 
124 Cleanup:
125  if (pJobInfo1)
126  HeapFree(hProcessHeap, 0, pJobInfo1);
127 
128  return dwErrorCode;
129 }
LPWSTR pDocName
Definition: winspool.h:616
#define ERROR_SUCCESS
Definition: deptool.c:10
WINBOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded)
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
HANDLE hSPLFile
Definition: precomp.h:51
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LPWSTR pDatatype
Definition: winspool.h:618
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:489
WINBOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob, DWORD Command)
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by StartDocPrinterW().

◆ _StartDocPrinterWithRPC()

static DWORD _StartDocPrinterWithRPC ( PSPOOLER_HANDLE  pHandle,
PDOC_INFO_1W  pDocInfo1 
)
static

Definition at line 132 of file printers.c.

133 {
134  DWORD dwErrorCode;
135  WINSPOOL_DOC_INFO_CONTAINER DocInfoContainer;
136 
137  DocInfoContainer.Level = 1;
138  DocInfoContainer.DocInfo.pDocInfo1 = (WINSPOOL_DOC_INFO_1*)pDocInfo1;
139 
141  {
142  dwErrorCode = _RpcStartDocPrinter(pHandle->hPrinter, &DocInfoContainer, &pHandle->dwJobID);
143  }
145  {
146  dwErrorCode = RpcExceptionCode();
147  ERR("_RpcStartDocPrinter failed with exception code %lu!\n", dwErrorCode);
148  }
149  RpcEndExcept;
150 
151  return dwErrorCode;
152 }
#define RpcEndExcept
Definition: rpc.h:128
DWORD dwJobID
Definition: precomp.h:49
DWORD _RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER *pDocInfoContainer, DWORD *pJobId)
Definition: printers.c:319
union _WINSPOOL_DOC_INFO_CONTAINER::@3397 DocInfo
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
unsigned long DWORD
Definition: ntddk_ex.h:95
WINSPOOL_DOC_INFO_1 * pDocInfo1
Definition: winspool.idl:577
#define ERR(fmt,...)
Definition: debug.h:110
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

Referenced by StartDocPrinterW().

◆ AbortPrinter()

BOOL WINAPI AbortPrinter ( HANDLE  hPrinter)

Definition at line 155 of file printers.c.

156 {
157  DWORD dwErrorCode;
158  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
159 
160  TRACE("AbortPrinter(%p)\n", hPrinter);
161 
162  // Sanity checks.
163  if (!pHandle)
164  {
165  dwErrorCode = ERROR_INVALID_HANDLE;
166  goto Cleanup;
167  }
168 
169  pHandle->bTrayIcon = pHandle->bStartedDoc = FALSE;
170 
171  if ( pHandle->hSPLFile != INVALID_HANDLE_VALUE && pHandle->bJob )
172  {
173  // Close any open file handle.
174  CloseHandle( pHandle->hSPLFile );
175  pHandle->hSPLFile = INVALID_HANDLE_VALUE;
176 
177  SetJobW( hPrinter, pHandle->dwJobID, 0, NULL, JOB_CONTROL_DELETE );
178 
179  return ScheduleJob( hPrinter, pHandle->dwJobID );
180  }
181 
182  // Do the RPC call.
184  {
185  dwErrorCode = _RpcAbortPrinter(&pHandle->hPrinter);
186  }
188  {
189  dwErrorCode = RpcExceptionCode();
190  ERR("_RpcAbortPrinter failed with exception code %lu!\n", dwErrorCode);
191  }
192  RpcEndExcept;
193 
194 Cleanup:
195  SetLastError(dwErrorCode);
196  return (dwErrorCode == ERROR_SUCCESS);
197 }
WINBOOL WINAPI ScheduleJob(HANDLE hPrinter, DWORD JobId)
Definition: jobs.c:56
#define RpcEndExcept
Definition: rpc.h:128
#define CloseHandle
Definition: compat.h:487
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define JOB_CONTROL_DELETE
Definition: winspool.h:334
BOOL bStartedDoc
Definition: precomp.h:41
DWORD dwJobID
Definition: precomp.h:49
#define FALSE
Definition: types.h:117
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
HANDLE hSPLFile
Definition: precomp.h:51
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
DWORD _RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: printers.c:12
WINBOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob, DWORD Command)
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
BOOL bTrayIcon
Definition: precomp.h:45
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

◆ AddPrinterA()

HANDLE WINAPI AddPrinterA ( PSTR  pName,
DWORD  Level,
PBYTE  pPrinter 
)

Definition at line 200 of file printers.c.

201 {
202  UNICODE_STRING pNameW, usBuffer;
203  PWSTR pwstrNameW;
204  PRINTER_INFO_2W *ppi2w = (PRINTER_INFO_2W*)pPrinter;
205  PRINTER_INFO_2A *ppi2a = (PRINTER_INFO_2A*)pPrinter;
206  HANDLE ret = NULL;
207  PWSTR pwszPrinterName = NULL;
208  PWSTR pwszServerName = NULL;
209  PWSTR pwszShareName = NULL;
210  PWSTR pwszPortName = NULL;
211  PWSTR pwszDriverName = NULL;
212  PWSTR pwszComment = NULL;
213  PWSTR pwszLocation = NULL;
214  PWSTR pwszSepFile = NULL;
215  PWSTR pwszPrintProcessor = NULL;
216  PWSTR pwszDatatype = NULL;
217  PWSTR pwszParameters = NULL;
218  PDEVMODEW pdmw = NULL;
219 
220  TRACE("AddPrinterA(%s, %d, %p)\n", debugstr_a(pName), Level, pPrinter);
221 
222  if(Level != 2)
223  {
224  ERR("Level = %d, unsupported!\n", Level);
226  return NULL;
227  }
228 
229  pwstrNameW = AsciiToUnicode(&pNameW,pName);
230 
231  if (ppi2a->pShareName)
232  {
233  pwszShareName = AsciiToUnicode(&usBuffer, ppi2a->pShareName);
234  if (!(ppi2w->pShareName = pwszShareName)) goto Cleanup;
235  }
236  if (ppi2a->pPortName)
237  {
238  pwszPortName = AsciiToUnicode(&usBuffer, ppi2a->pPortName);
239  if (!(ppi2w->pPortName = pwszPortName)) goto Cleanup;
240  }
241  if (ppi2a->pDriverName)
242  {
243  pwszDriverName = AsciiToUnicode(&usBuffer, ppi2a->pDriverName);
244  if (!(ppi2w->pDriverName = pwszDriverName)) goto Cleanup;
245  }
246  if (ppi2a->pComment)
247  {
248  pwszComment = AsciiToUnicode(&usBuffer, ppi2a->pComment);
249  if (!(ppi2w->pComment = pwszComment)) goto Cleanup;
250  }
251  if (ppi2a->pLocation)
252  {
253  pwszLocation = AsciiToUnicode(&usBuffer, ppi2a->pLocation);
254  if (!(ppi2w->pLocation = pwszLocation)) goto Cleanup;
255  }
256  if (ppi2a->pSepFile)
257  {
258  pwszSepFile = AsciiToUnicode(&usBuffer, ppi2a->pSepFile);
259  if (!(ppi2w->pSepFile = pwszSepFile)) goto Cleanup;
260  }
261  if (ppi2a->pServerName)
262  {
263  pwszPrintProcessor = AsciiToUnicode(&usBuffer, ppi2a->pPrintProcessor);
264  if (!(ppi2w->pPrintProcessor = pwszPrintProcessor)) goto Cleanup;
265  }
266  if (ppi2a->pDatatype)
267  {
268  pwszDatatype = AsciiToUnicode(&usBuffer, ppi2a->pDatatype);
269  if (!(ppi2w->pDatatype = pwszDatatype)) goto Cleanup;
270  }
271  if (ppi2a->pParameters)
272  {
273  pwszParameters = AsciiToUnicode(&usBuffer, ppi2a->pParameters);
274  if (!(ppi2w->pParameters = pwszParameters)) goto Cleanup;
275  }
276  if ( ppi2a->pDevMode )
277  {
279  ppi2w->pDevMode = pdmw;
280  }
281  if (ppi2a->pServerName)
282  {
283  pwszServerName = AsciiToUnicode(&usBuffer, ppi2a->pServerName);
284  if (!(ppi2w->pPrinterName = pwszServerName)) goto Cleanup;
285  }
286  if (ppi2a->pPrinterName)
287  {
288  pwszPrinterName = AsciiToUnicode(&usBuffer, ppi2a->pPrinterName);
289  if (!(ppi2w->pPrinterName = pwszPrinterName)) goto Cleanup;
290  }
291 
292  ret = AddPrinterW(pwstrNameW, Level, (LPBYTE)ppi2w);
293 
294 Cleanup:
295  if (pdmw) HeapFree(hProcessHeap, 0, pdmw);
296  if (pwszPrinterName) HeapFree(hProcessHeap, 0, pwszPrinterName);
297  if (pwszServerName) HeapFree(hProcessHeap, 0, pwszServerName);
298  if (pwszShareName) HeapFree(hProcessHeap, 0, pwszShareName);
299  if (pwszPortName) HeapFree(hProcessHeap, 0, pwszPortName);
300  if (pwszDriverName) HeapFree(hProcessHeap, 0, pwszDriverName);
301  if (pwszComment) HeapFree(hProcessHeap, 0, pwszComment);
302  if (pwszLocation) HeapFree(hProcessHeap, 0, pwszLocation);
303  if (pwszSepFile) HeapFree(hProcessHeap, 0, pwszSepFile);
304  if (pwszPrintProcessor) HeapFree(hProcessHeap, 0, pwszPrintProcessor);
305  if (pwszDatatype) HeapFree(hProcessHeap, 0, pwszDatatype);
306  if (pwszParameters) HeapFree(hProcessHeap, 0, pwszParameters);
307 
308  RtlFreeUnicodeString(&pNameW);
309  return ret;
310 }
LPWSTR pDatatype
Definition: winspool.h:72
uint16_t * PWSTR
Definition: typedefs.h:56
LPSTR pServerName
Definition: winspool.h:38
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
LPSTR pSepFile
Definition: winspool.h:46
LPWSTR pDriverName
Definition: winspool.h:66
void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput)
Definition: devmode.c:285
LPSTR pShareName
Definition: winspool.h:40
LPWSTR pLocation
Definition: winspool.h:68
unsigned char * LPBYTE
Definition: typedefs.h:53
HANDLE WINAPI AddPrinterW(PWSTR pName, DWORD Level, PBYTE pPrinter)
Definition: printers.c:105
LPWSTR pShareName
Definition: winspool.h:64
smooth NULL
Definition: ftsmooth.c:416
LPSTR pDriverName
Definition: winspool.h:42
wstring AsciiToUnicode(const char *AsciiString)
Definition: tools.cpp:220
LPSTR pPrinterName
Definition: winspool.h:39
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
#define debugstr_a
Definition: kernel32.h:31
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:500
LPSTR pLocation
Definition: winspool.h:44
LPWSTR pSepFile
Definition: winspool.h:70
int ret
LPSTR pPortName
Definition: winspool.h:41
static const WCHAR Cleanup[]
Definition: register.c:80
LPDEVMODEW pDevMode
Definition: winspool.h:69
LPDEVMODEA pDevMode
Definition: winspool.h:45
#define ERR(fmt,...)
Definition: debug.h:110
LPSTR pComment
Definition: winspool.h:43
LPWSTR pPortName
Definition: winspool.h:65
LPSTR pParameters
Definition: winspool.h:49
LPWSTR pPrinterName
Definition: winspool.h:63
LPWSTR pComment
Definition: winspool.h:67
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
LPSTR pDatatype
Definition: winspool.h:48
LPWSTR pParameters
Definition: winspool.h:73
LPWSTR pPrintProcessor
Definition: winspool.h:71
#define HeapFree(x, y, z)
Definition: compat.h:483
LPSTR pPrintProcessor
Definition: winspool.h:47
HANDLE hProcessHeap
Definition: kbswitch.c:25

◆ AddPrinterW()

HANDLE WINAPI AddPrinterW ( PWSTR  pName,
DWORD  Level,
PBYTE  pPrinter 
)

Definition at line 313 of file printers.c.

314 {
315  DWORD dwErrorCode;
316  WINSPOOL_PRINTER_CONTAINER PrinterContainer;
317  WINSPOOL_DEVMODE_CONTAINER DevModeContainer;
318  WINSPOOL_SECURITY_CONTAINER SecurityContainer;
320  DWORD size;
321  HANDLE hPrinter = NULL, hHandle = NULL;
322  PSPOOLER_HANDLE pHandle = NULL;
323 
324  TRACE("AddPrinterW(%S, %lu, %p)\n", pName, Level, pPrinter);
325 
326  DevModeContainer.cbBuf = 0;
327  DevModeContainer.pDevMode = NULL;
328 
329  SecurityContainer.cbBuf = 0;
330  SecurityContainer.pSecurity = NULL;
331 
332  if ( Level != 2 )
333  {
334  FIXME( "Unsupported level %d\n", Level );
336  return hHandle;
337  }
338  else
339  {
340  PPRINTER_INFO_2W pi2w = (PPRINTER_INFO_2W)pPrinter;
341  if ( pi2w )
342  {
343  if ( pi2w->pDevMode )
344  {
345  if ( IsValidDevmodeNoSizeW( pi2w->pDevMode ) )
346  {
347  DevModeContainer.cbBuf = pi2w->pDevMode->dmSize + pi2w->pDevMode->dmDriverExtra;
348  DevModeContainer.pDevMode = (PBYTE)pi2w->pDevMode;
349  }
350  }
351 
352  if ( pi2w->pSecurityDescriptor )
353  {
354  sd = get_sd( pi2w->pSecurityDescriptor, &size );
355  if ( sd )
356  {
357  SecurityContainer.cbBuf = size;
358  SecurityContainer.pSecurity = (PBYTE)sd;
359  }
360  }
361  }
362  else
363  {
365  return hHandle;
366  }
367  }
368 
369  PrinterContainer.PrinterInfo.pPrinterInfo1 = (WINSPOOL_PRINTER_INFO_1*)pPrinter;
370  PrinterContainer.Level = Level;
371 
372  // Do the RPC call
374  {
375  dwErrorCode = _RpcAddPrinter( pName, &PrinterContainer, &DevModeContainer, &SecurityContainer, &hPrinter );
376  }
378  {
379  dwErrorCode = RpcExceptionCode();
380  }
381  RpcEndExcept;
382 
383  if (hPrinter)
384  {
385  // Create a new SPOOLER_HANDLE structure.
387  if (!pHandle)
388  {
389  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
390  ERR("HeapAlloc failed!\n");
391  _RpcDeletePrinter(hPrinter);
392  _RpcClosePrinter(hPrinter);
393  goto Cleanup;
394  }
395 
396  pHandle->Sig = SPOOLER_HANDLE_SIG;
397  pHandle->hPrinter = hPrinter;
398  pHandle->hSPLFile = INVALID_HANDLE_VALUE;
400  hHandle = (HANDLE)pHandle;
401  }
402 
403 Cleanup:
404  if ( sd ) HeapFree( GetProcessHeap(), 0, sd );
405 
406  SetLastError(dwErrorCode);
407  return hHandle;
408 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static HRESULT get_sd(SECURITY_DESCRIPTOR **sd, DWORD *size)
Definition: security.c:61
#define RpcEndExcept
Definition: rpc.h:128
struct _PRINTER_INFO_2W * PPRINTER_INFO_2W
union _WINSPOOL_PRINTER_CONTAINER::@3403 PrinterInfo
DWORD _RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: printers.c:66
WORD dmDriverExtra
Definition: wingdi.h:1620
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define SPOOLER_HANDLE_SIG
Definition: precomp.h:32
DWORD _RpcAddPrinter(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, WINSPOOL_PRINTER_HANDLE *pHandle)
Definition: printers.c:31
WINSPOOL_PRINTER_INFO_1 * pPrinterInfo1
Definition: winspool.idl:698
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
HANDLE hSPLFile
Definition: precomp.h:51
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD_PTR Sig
Definition: precomp.h:40
HANDLE hSpoolFileHandle
Definition: precomp.h:53
WORD dmSize
Definition: wingdi.h:1619
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR sd[]
Definition: suminfo.c:287
static const WCHAR Cleanup[]
Definition: register.c:80
LPDEVMODEW pDevMode
Definition: winspool.h:69
#define ERR(fmt,...)
Definition: debug.h:110
PSECURITY_DESCRIPTOR pSecurityDescriptor
Definition: winspool.h:74
BOOL WINAPI IsValidDevmodeNoSizeW(PDEVMODEW pDevmode)
Definition: devmode.c:238
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD _RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter)
Definition: printers.c:45
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hProcessHeap
Definition: kbswitch.c:25
HANDLE hPrinter
Definition: precomp.h:50

◆ CallCommonPropertySheetUI()

LONG WINAPI CallCommonPropertySheetUI ( HWND  hWnd,
PFNPROPSHEETUI  pfnPropSheetUI,
LPARAM  lparam,
LPDWORD  pResult 
)

Definition at line 1131 of file printers.c.

1132 {
1133  HMODULE hLibrary = NULL;
1135 
1136  FIXME("CallCommonPropertySheetUI(%p, %p, 0x%lx, %p)\n", hWnd, pfnPropSheetUI, lparam, pResult);
1137 
1138  if ( ( hLibrary = LoadLibraryA( "compstui.dll" ) ) )
1139  {
1140  fpCommonPropertySheetUIW = (PVOID) GetProcAddress(hLibrary, "CommonPropertySheetUIW");
1141 
1143  {
1144  Ret = fpCommonPropertySheetUIW( hWnd, pfnPropSheetUI, lparam, pResult );
1145  }
1146 
1148  }
1149  return Ret;
1150 }
HWND hWnd
Definition: settings.c:17
static COMMONPROPERTYSHEETUIW fpCommonPropertySheetUIW
Definition: printers.c:27
long LONG
Definition: pedump.c:60
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR_CPSUI_GETLASTERROR
Definition: compstui.h:644
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:496
HMODULE hLibrary
Definition: odbccp32.c:12
#define GetProcAddress(x, y)
Definition: compat.h:501

Referenced by DocumentPropertiesW(), and PrinterProperties().

◆ ClosePrinter()

BOOL WINAPI ClosePrinter ( HANDLE  hPrinter)

Definition at line 411 of file printers.c.

412 {
413  DWORD dwErrorCode;
414  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
415 
416  TRACE("ClosePrinter(%p)\n", hPrinter);
417 
418  // Sanity checks.
419  if ( IntProtectHandle( hPrinter, TRUE ) )
420  {
421  dwErrorCode = ERROR_INVALID_HANDLE;
422  goto Cleanup;
423  }
424 
425  // Do the RPC call.
427  {
428  dwErrorCode = _RpcClosePrinter(&pHandle->hPrinter);
429  }
431  {
432  dwErrorCode = RpcExceptionCode();
433  ERR("_RpcClosePrinter failed with exception code %lu!\n", dwErrorCode);
434  }
435  RpcEndExcept;
436 
437  // Close any open file handle.
438  if (pHandle->hSPLFile != INVALID_HANDLE_VALUE)
439  CloseHandle(pHandle->hSPLFile);
440 
441  pHandle->Sig = -1;
442 
443  // Free the memory for the handle.
444  HeapFree(hProcessHeap, 0, pHandle);
445 
446 Cleanup:
447  SetLastError(dwErrorCode);
448  return (dwErrorCode == ERROR_SUCCESS);
449 }
#define RpcEndExcept
Definition: rpc.h:128
#define CloseHandle
Definition: compat.h:487
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
LONG WINAPI IntProtectHandle(HANDLE, BOOL)
Definition: utils.c:105
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE hSPLFile
Definition: precomp.h:51
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR Sig
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
DWORD _RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter)
Definition: printers.c:45
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
#define HeapFree(x, y, z)
Definition: compat.h:483
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hProcessHeap
Definition: kbswitch.c:25
HANDLE hPrinter
Definition: precomp.h:50

Referenced by AdvancedSetupDialog(), GetMonitorUI(), LocalmonClosePort(), LocalmonEndDocPort(), localui_AddPortUI(), localui_ConfigurePortUI(), localui_DeletePortUI(), pagesetup_change_printer(), pagesetup_printer_properties(), PRINTDLG_ChangePrinterA(), PRINTDLG_ChangePrinterW(), PRINTDLG_WMCommandA(), PRINTDLG_WMCommandW(), PrintDlgA(), PrintDlgExA(), PrintDlgExW(), PrintDlgW(), PrintRawJob(), START_TEST(), test_ClosePrinter(), test_DocumentProperties(), test_EnumForms(), test_GetPrinter(), test_GetPrinterData(), test_GetPrinterDataEx(), test_GetPrinterDriver(), test_OpenPrinter(), test_OpenPrinter_defaults(), test_XcvDataW_MonitorUI(), test_XcvDataW_PortIsValid(), and wmain().

◆ ConstructPrinterFriendlyName()

LONG WINAPI ConstructPrinterFriendlyName ( PWSTR  ,
PVOID  ,
LPDWORD  Size 
)

◆ CreatePrinterFriendlyName()

LONG WINAPI CreatePrinterFriendlyName ( PCOMPUI_USERDATA  pcui_ud,
LPWSTR  pszPrinterName 
)

Definition at line 851 of file printers.c.

852 {
853  LONG Result = 0;
854  DWORD Size = 0;
856 
857  hLibrary = LoadLibraryA( "printui.dll" );
858 
859  if ( hLibrary )
860  {
861  fpConstructPrinterFriendlyName = (PVOID)GetProcAddress( hLibrary, "ConstructPrinterFriendlyName" );
862 
864  {
865  if ( !fpConstructPrinterFriendlyName( pszPrinterName, NULL, &Size ) )
866  {
868  {
869  PWSTR pwstr = DllAllocSplMem( (Size + 1) * sizeof(WCHAR) );
870 
871  pcui_ud->pszPrinterName = pwstr;
872 
873  if ( pwstr )
874  Result = fpConstructPrinterFriendlyName( pszPrinterName, pwstr, &Size );
875  }
876  }
877  }
879  }
880 
881  if ( !Result )
882  {
883  DllFreeSplMem( pcui_ud->pszPrinterName );
884  pcui_ud->pszPrinterName = AllocSplStr( pszPrinterName );
885  }
886 
887  return Result;
888 }
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
long LONG
Definition: pedump.c:60
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
LPWSTR pszPrinterName
Definition: printers.c:54
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:496
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE hLibrary
Definition: odbccp32.c:12
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define GetProcAddress(x, y)
Definition: compat.h:501
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
static CONSTRUCTPRINTERFRIENDLYNAME fpConstructPrinterFriendlyName
Definition: printers.c:46
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DevicePropertySheets(), and DocumentPropertySheets().

◆ CreateUIUserData()

BOOL FASTCALL CreateUIUserData ( ULONG_PTR puserdata,
HANDLE  hPrinter 
)

Definition at line 769 of file printers.c.

770 {
771  PCOMPUI_USERDATA pcui_ud = DllAllocSplMem( sizeof(COMPUI_USERDATA) );
772 
773  *puserdata = (ULONG_PTR)pcui_ud;
774  FIXME("CreateUIUserData\n");
775  if ( pcui_ud )
776  {
777  pcui_ud->hModule = LoadPrinterDriver( hPrinter );
778 
779  if ( !pcui_ud->hModule )
780  {
781  DllFreeSplMem( pcui_ud );
782  *puserdata = 0;
783  }
784  }
785  return *puserdata != 0;
786 }
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define FIXME(fmt,...)
Definition: debug.h:111
HMODULE hModule
Definition: printers.c:53
HMODULE WINAPI LoadPrinterDriver(HANDLE hspool)
Definition: printers.c:488
#define ULONG_PTR
Definition: config.h:101
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95

Referenced by DevicePropertySheets(), and DocumentPropertySheets().

◆ DeletePrinter()

BOOL WINAPI DeletePrinter ( HANDLE  hPrinter)

Definition at line 452 of file printers.c.

453 {
454  DWORD dwErrorCode;
455  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
456 
457  TRACE("DeletePrinter(%p)\n", hPrinter);
458 
459  // Sanity checks.
460  if (!pHandle)
461  {
462  dwErrorCode = ERROR_INVALID_HANDLE;
463  goto Cleanup;
464  }
465 
466  // Do the RPC call.
468  {
469  dwErrorCode = _RpcDeletePrinter(&pHandle->hPrinter);
470  }
472  {
473  dwErrorCode = RpcExceptionCode();
474  ERR("_RpcDeletePrinter failed with exception code %lu!\n", dwErrorCode);
475  }
476  RpcEndExcept;
477 
478 Cleanup:
479  SetLastError(dwErrorCode);
480  return (dwErrorCode == ERROR_SUCCESS);
481 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD _RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: printers.c:66
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

◆ DestroyUIUserData()

VOID FASTCALL DestroyUIUserData ( ULONG_PTR puserdata)

Definition at line 790 of file printers.c.

791 {
792  PCOMPUI_USERDATA pcui_ud = (PCOMPUI_USERDATA)*puserdata;
793  FIXME("DestroyUIUserData\n");
794  if ( pcui_ud )
795  {
796  if ( pcui_ud->hModule )
797  {
798  FreeLibrary( pcui_ud->hModule );
799  pcui_ud->hModule = NULL;
800  }
801 
802  if ( pcui_ud->pszPrinterName )
803  {
804  DllFreeSplMem( pcui_ud->pszPrinterName );
805  pcui_ud->pszPrinterName = NULL;
806  }
807 
808  DllFreeSplMem( pcui_ud );
809  *puserdata = 0;
810  }
811 }
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
#define FIXME(fmt,...)
Definition: debug.h:111
LPWSTR pszPrinterName
Definition: printers.c:54
smooth NULL
Definition: ftsmooth.c:416
HMODULE hModule
Definition: printers.c:53
#define FreeLibrary(x)
Definition: compat.h:496
struct _COMPUI_USERDATA * PCOMPUI_USERDATA

Referenced by DevicePropertySheets(), and DocumentPropertySheets().

◆ DeviceCapabilitiesA()

DWORD WINAPI DeviceCapabilitiesA ( LPCSTR  pDevice,
LPCSTR  pPort,
WORD  fwCapability,
LPSTR  pOutput,
const DEVMODEA pDevMode 
)

Definition at line 529 of file printers.c.

530 {
532  PDEVMODEW pdmwInput = NULL;
533  BOOL bReturnValue = GDI_ERROR;
534  DWORD cch;
535 
536  FIXME("DeviceCapabilitiesA(%s, %s, %hu, %p, %p)\n", pDevice, pPort, fwCapability, pOutput, pDevMode);
537 
538  if (pDevice)
539  {
540  // Convert pName to a Unicode string pwszDeviceName.
541  cch = strlen(pDevice);
542 
543  pwszDeviceName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
544  if (!pwszDeviceName)
545  {
547  ERR("HeapAlloc failed!\n");
548  goto Cleanup;
549  }
550 
551  MultiByteToWideChar(CP_ACP, 0, pDevice, -1, pwszDeviceName, cch + 1);
552  }
553 
554  if (pDevMode)
555  {
556  RosConvertAnsiDevModeToUnicodeDevmode((PDEVMODEA)pDevMode, &pdmwInput);
557  }
558 
559  // pPort is ignored so no need to pass it.
560  bReturnValue = DeviceCapabilitiesW( pwszDeviceName, NULL, fwCapability, (LPWSTR)pOutput, (const DEVMODEW*) pdmwInput );
561 
562 Cleanup:
563  if(pwszDeviceName)
565 
566  if (pdmwInput)
567  HeapFree(hProcessHeap, 0, pdmwInput);
568 
569  return bReturnValue;
570 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
uint16_t * PWSTR
Definition: typedefs.h:56
#define CP_ACP
Definition: compat.h:109
DWORD WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort, WORD fwCapability, LPWSTR pOutput, const DEVMODEW *pDevMode)
Definition: printers.c:573
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput)
Definition: devmode.c:285
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3553
#define ERR(fmt,...)
Definition: debug.h:110
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GDI_ERROR
Definition: wingdi.h:1308
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25

◆ DeviceCapabilitiesW()

DWORD WINAPI DeviceCapabilitiesW ( LPCWSTR  pDevice,
LPCWSTR  pPort,
WORD  fwCapability,
LPWSTR  pOutput,
const DEVMODEW pDevMode 
)

Definition at line 573 of file printers.c.

574 {
575  HANDLE hPrinter;
577  DWORD iDevCap = GDI_ERROR;
578 
579  FIXME("DeviceCapabilitiesW(%S, %S, %hu, %p, %p)\n", pDevice, pPort, fwCapability, pOutput, pDevMode);
580 
581  if ( pDevMode )
582  {
583  if (!IsValidDevmodeNoSizeW( (PDEVMODEW)pDevMode ) )
584  {
585  ERR("DeviceCapabilitiesW : Devode Invalid\n");
586  return -1;
587  }
588  }
589 
590  if ( OpenPrinterW( (LPWSTR)pDevice, &hPrinter, NULL ) )
591  {
592  hLibrary = LoadPrinterDriver( hPrinter );
593 
594  if ( hLibrary )
595  {
596  fpDeviceCapabilities = (PVOID)GetProcAddress( hLibrary, "DrvDeviceCapabilities" );
597 
598  if ( fpDeviceCapabilities )
599  {
600  iDevCap = fpDeviceCapabilities( hPrinter, (PWSTR)pDevice, fwCapability, pOutput, (PDEVMODE)pDevMode );
601  }
602 
604  }
605 
606  ClosePrinter( hPrinter );
607  }
608 
609  return iDevCap;
610 }
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
BOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
#define FreeLibrary(x)
Definition: compat.h:496
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE WINAPI LoadPrinterDriver(HANDLE hspool)
Definition: printers.c:488
HMODULE hLibrary
Definition: odbccp32.c:12
#define ERR(fmt,...)
Definition: debug.h:110
BOOL WINAPI IsValidDevmodeNoSizeW(PDEVMODEW pDevmode)
Definition: devmode.c:238
BOOL WINAPI OpenPrinterW(PWSTR pPrinterName, PHANDLE phPrinter, PPRINTER_DEFAULTSW pDefault)
Definition: printers.c:345
static DEVICECAPABILITIES fpDeviceCapabilities
Definition: printers.c:19
#define GetProcAddress(x, y)
Definition: compat.h:501
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GDI_ERROR
Definition: wingdi.h:1308

Referenced by DeviceCapabilitiesA().

◆ DevicePropertySheets()

LONG WINAPI DevicePropertySheets ( PPROPSHEETUI_INFO  pCPSUIInfo,
LPARAM  lparam 
)

Definition at line 1045 of file printers.c.

1046 {
1047  LONG Result = 0;
1048  PDEVICEPROPERTYHEADER pdphdr;
1049 
1050  FIXME("DevicePropertySheets(%p, 0x%lx)\n", pCPSUIInfo, lparam);
1051 
1052  if ( pCPSUIInfo )
1053  {
1054  PSETRESULT_INFO psri;
1055  PPROPSHEETUI_INFO_HEADER ppsuiihdr;
1056  PCOMPUI_USERDATA pcui_ud;
1057  pdphdr = (PDEVICEPROPERTYHEADER)pCPSUIInfo->lParamInit;
1058 
1059  if ( pdphdr->cbSize < sizeof(DEVICEPROPERTYHEADER) )
1060  {
1062  return Result;
1063  }
1064 
1065  switch ( pCPSUIInfo->Reason )
1066  {
1068  {
1069  FIXME("DevPS : PROPSHEETUI_REASON_INIT\n");
1070  if ( CreateUIUserData( &pCPSUIInfo->UserData, pdphdr->hPrinter ) )
1071  {
1072  pcui_ud = (PCOMPUI_USERDATA)pCPSUIInfo->UserData;
1073 
1074  fpDevicePropertySheets = (PVOID)GetProcAddress( pcui_ud->hModule, "DrvDevicePropertySheets" );
1075 
1076  if ( fpDevicePropertySheets )
1077  {
1078  pCPSUIInfo->pfnComPropSheet( pCPSUIInfo->hComPropSheet,
1080  -3, // What type of handle is this?
1081  0 ); // Not used, must be zero.
1082 
1083  Result = pCPSUIInfo->pfnComPropSheet( pCPSUIInfo->hComPropSheet,
1086  pCPSUIInfo->lParamInit );
1087  break;
1088  }
1089  FIXME("DevPS : PROPSHEETUI_REASON_INIT Fail\n");
1090  DestroyUIUserData( &pCPSUIInfo->UserData );
1091  }
1092  }
1093  break;
1094 
1096  FIXME("DevPS : PROPSHEETUI_REASON_GET_INFO_HEADER\n");
1097 
1098  ppsuiihdr = (PPROPSHEETUI_INFO_HEADER)lparam;
1099 
1100  pcui_ud = (PCOMPUI_USERDATA)pCPSUIInfo->UserData;
1101 
1102  CreatePrinterFriendlyName( pcui_ud, pdphdr->pszPrinterName );
1103 
1105  ppsuiihdr->pTitle = pcui_ud->pszPrinterName;
1106  ppsuiihdr->hInst = hinstWinSpool;
1107  ppsuiihdr->IconID = IDI_CPSUI_DOCUMENT;
1108 
1109  Result = CPSUI_OK;
1110  break;
1111 
1113  FIXME("DevPS : PROPSHEETUI_REASON_DESTROY\n");
1114  DestroyUIUserData( &pCPSUIInfo->UserData );
1115  Result = CPSUI_OK;
1116  break;
1117 
1119  FIXME("DevPS : PROPSHEETUI_REASON_SET_RESULT\n");
1120  psri = (PSETRESULT_INFO)lparam;
1121  pCPSUIInfo->Result = psri->Result;
1122  Result = CPSUI_OK;
1123  break;
1124  }
1125  }
1126  return Result;
1127 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define IDI_CPSUI_DOCUMENT
Definition: compstui.h:88
struct _PROPSHEETUI_INFO_HEADER * PPROPSHEETUI_INFO_HEADER
HANDLE hComPropSheet
Definition: compstui.h:889
#define PSUIHDRF_PROPTITLE
Definition: compstui.h:693
#define CPSUI_OK
Definition: compstui.h:640
#define PROPSHEETUI_REASON_GET_INFO_HEADER
Definition: compstui.h:628
long LONG
Definition: pedump.c:60
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define FIXME(fmt,...)
Definition: debug.h:111
PFNCOMPROPSHEET pfnComPropSheet
Definition: compstui.h:890
LPWSTR pszPrinterName
Definition: printers.c:54
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
ULONG_PTR Result
Definition: compstui.h:893
HMODULE hModule
Definition: printers.c:53
struct _COMPUI_USERDATA * PCOMPUI_USERDATA
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _DEVICEPROPERTYHEADER * PDEVICEPROPERTYHEADER
static DEVICEPROPERTYSHEETS fpDevicePropertySheets
Definition: printers.c:22
#define SetLastError(x)
Definition: compat.h:500
LPARAM lParamInit
Definition: compstui.h:891
HINSTANCE hinstWinSpool
Definition: main.c:12
#define PSUIHDRF_NOAPPLYNOW
Definition: compstui.h:692
struct _SETRESULT_INFO * PSETRESULT_INFO
#define PROPSHEETUI_REASON_INIT
Definition: compstui.h:627
#define PROPSHEETUI_REASON_DESTROY
Definition: compstui.h:629
LONG WINAPI CreatePrinterFriendlyName(PCOMPUI_USERDATA pcui_ud, LPWSTR pszPrinterName)
Definition: printers.c:851
BOOL FASTCALL CreateUIUserData(ULONG_PTR *puserdata, HANDLE hPrinter)
Definition: printers.c:769
#define PROPSHEETUI_REASON_SET_RESULT
Definition: compstui.h:630
ULONG_PTR UserData
Definition: compstui.h:892
#define GetProcAddress(x, y)
Definition: compat.h:501
VOID FASTCALL DestroyUIUserData(ULONG_PTR *puserdata)
Definition: printers.c:790
LRESULT Result
Definition: compstui.h:849
#define CPSFUNC_ADD_PFNPROPSHEETUIW
Definition: compstui.h:552
#define CPSFUNC_SET_FUSION_CONTEXT
Definition: compstui.h:575

Referenced by PrinterProperties().

◆ DevQueryPrint()

BOOL WINAPI DevQueryPrint ( HANDLE  hPrinter,
LPDEVMODEW  pDevMode,
DWORD pResID 
)

Definition at line 614 of file printers.c.

615 {
617  BOOL Ret = FALSE;
618 
619  hLibrary = LoadPrinterDriver( hPrinter );
620 
621  if ( hLibrary )
622  {
623  fpDevQueryPrint = (PVOID)GetProcAddress( hLibrary, "DevQueryPrint" );
624 
625  if ( fpDevQueryPrint )
626  {
627  Ret = fpDevQueryPrint( hPrinter, pDevMode, pResID );
628  }
629 
631  }
632  return Ret;
633 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static DEVQUERYPRINT fpDevQueryPrint
Definition: printers.c:36
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:496
HMODULE WINAPI LoadPrinterDriver(HANDLE hspool)
Definition: printers.c:488
HMODULE hLibrary
Definition: odbccp32.c:12
#define GetProcAddress(x, y)
Definition: compat.h:501

◆ DevQueryPrintEx()

BOOL WINAPI DevQueryPrintEx ( PDEVQUERYPRINT_INFO  pDQPInfo)

Definition at line 636 of file printers.c.

637 {
639  BOOL Ret = FALSE;
640 
641  hLibrary = LoadPrinterDriver( pDQPInfo->hPrinter );
642 
643  if ( hLibrary )
644  {
645  fpDevQueryPrintEx = (PVOID)GetProcAddress( hLibrary, "DevQueryPrintEx" );
646 
647  if ( fpDevQueryPrintEx )
648  {
649  Ret = fpDevQueryPrintEx( pDQPInfo );
650  }
651 
653  }
654  return Ret;
655 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static DEVQUERYPRINTEX fpDevQueryPrintEx
Definition: printers.c:39
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:496
HMODULE WINAPI LoadPrinterDriver(HANDLE hspool)
Definition: printers.c:488
HMODULE hLibrary
Definition: odbccp32.c:12
#define GetProcAddress(x, y)
Definition: compat.h:501

◆ DocumentEvent()

INT WINAPI DocumentEvent ( HANDLE  hPrinter,
HDC  hdc,
int  iEsc,
ULONG  cbIn,
PVOID  pvIn,
ULONG  cbOut,
PVOID  pvOut 
)

Definition at line 658 of file printers.c.

659 {
660  FIXME("DocumentEvent(%p, %p, %lu, %lu, %p, %lu, %p)\n", hPrinter, hdc, iEsc, cbIn, pvIn, cbOut, pvOut);
663 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define DOCUMENTEVENT_UNSUPPORTED
Definition: winddiui.h:90
HDC hdc
Definition: main.c:9
_In_ ULONG iEsc
Definition: winddi.h:3529
#define UNIMPLEMENTED
Definition: debug.h:115

◆ DocumentPropertiesA()

LONG WINAPI DocumentPropertiesA ( HWND  hWnd,
HANDLE  hPrinter,
LPSTR  pDeviceName,
PDEVMODEA  pDevModeOutput,
PDEVMODEA  pDevModeInput,
DWORD  fMode 
)

Definition at line 666 of file printers.c.

667 {
669  PDEVMODEW pdmwInput = NULL;
670  PDEVMODEW pdmwOutput = NULL;
671  LONG lReturnValue = -1;
672  DWORD cch;
673 
674  FIXME("DocumentPropertiesA(%p, %p, %s, %p, %p, %lu)\n", hWnd, hPrinter, pDeviceName, pDevModeOutput, pDevModeInput, fMode);
675 
676  if (pDeviceName)
677  {
678  // Convert pName to a Unicode string pwszDeviceName.
679  cch = strlen(pDeviceName);
680 
681  pwszDeviceName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
682  if (!pwszDeviceName)
683  {
685  ERR("HeapAlloc failed!\n");
686  goto Cleanup;
687  }
688 
689  MultiByteToWideChar(CP_ACP, 0, pDeviceName, -1, pwszDeviceName, cch + 1);
690  }
691 
692  if (pDevModeInput)
693  {
694  // Create working buffer for input to DocumentPropertiesW.
695  RosConvertAnsiDevModeToUnicodeDevmode(pDevModeInput, &pdmwInput);
696  }
697 
698  if (pDevModeOutput)
699  {
700  // Create working buffer for output from DocumentPropertiesW.
701 
702  // Do it RIGHT! Get the F...ing Size!
704 
705  if ( Size < 0 )
706  {
707  goto Cleanup;
708  }
709 
710  pdmwOutput = HeapAlloc(hProcessHeap, 0, Size);
711  if (!pdmwOutput)
712  {
714  ERR("HeapAlloc failed!\n");
715  goto Cleanup;
716  }
717  }
718 
719  lReturnValue = DocumentPropertiesW(hWnd, hPrinter, pwszDeviceName, pdmwOutput, pdmwInput, fMode);
720  FIXME("lReturnValue from DocumentPropertiesW is '%ld'.\n", lReturnValue);
721 
722  if (lReturnValue < 0)
723  {
724  FIXME("DocumentPropertiesW failed!\n");
725  goto Cleanup;
726  }
727 
728  if (pdmwOutput)
729  {
730  RosConvertUnicodeDevModeToAnsiDevmode(pdmwOutput, pDevModeOutput);
731  }
732 
733 Cleanup:
734  if(pwszDeviceName)
736 
737  if (pdmwInput)
738  HeapFree(hProcessHeap, 0, pdmwInput);
739 
740  if (pdmwOutput)
741  HeapFree(hProcessHeap, 0, pdmwOutput);
742 
743  return lReturnValue;
744 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
uint16_t * PWSTR
Definition: typedefs.h:56
#define CP_ACP
Definition: compat.h:109
HWND hWnd
Definition: settings.c:17
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
Definition: printers.c:1153
void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput)
Definition: devmode.c:285
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:111
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
void RosConvertUnicodeDevModeToAnsiDevmode(PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput)
Definition: devmode.c:353
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
static const WCHAR Cleanup[]
Definition: register.c:80
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3553
#define ERR(fmt,...)
Definition: debug.h:110
#define MultiByteToWideChar
Definition: compat.h:110
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by PRINTDLG_ChangePrinterA(), PRINTDLG_WMCommandA(), and test_DocumentProperties().

◆ DocumentPropertiesW()

LONG WINAPI DocumentPropertiesW ( HWND  hWnd,
HANDLE  hPrinter,
LPWSTR  pDeviceName,
PDEVMODEW  pDevModeOutput,
PDEVMODEW  pDevModeInput,
DWORD  fMode 
)

Definition at line 1153 of file printers.c.

1154 {
1155  HANDLE hUseHandle = NULL;
1156  DOCUMENTPROPERTYHEADER docprophdr;
1157  LONG Result = IDOK;
1158 
1159  FIXME("DocumentPropertiesW(%p, %p, %S, %p, %p, %lu)\n", hWnd, hPrinter, pDeviceName, pDevModeOutput, pDevModeInput, fMode);
1160 
1161  if (hPrinter)
1162  {
1163  hUseHandle = hPrinter;
1164  }
1165  else if (!OpenPrinterW(pDeviceName, &hUseHandle, NULL))
1166  {
1167  ERR("No handle, and no usable printer name passed in\n");
1168  return -1;
1169  }
1170 
1171  if ( !(fMode & DM_IN_BUFFER ) ||
1172  ( ( pDevModeInput && !IsValidDevmodeNoSizeW( (PDEVMODEW)pDevModeInput ) ) ) )
1173  {
1174  pDevModeInput = NULL;
1175  fMode &= ~DM_IN_BUFFER;
1176  }
1177 
1178  docprophdr.cbSize = sizeof(DOCUMENTPROPERTYHEADER);
1179  docprophdr.Reserved = 0;
1180  docprophdr.hPrinter = hUseHandle;
1181  docprophdr.pszPrinterName = pDeviceName;
1182  docprophdr.cbOut = 0;
1183 
1184  if ( pDevModeOutput )
1185  {
1186  docprophdr.pdmIn = NULL;
1187  docprophdr.pdmOut = NULL;
1188  docprophdr.fMode = 0;
1189  FIXME("DPW : Call DocumentPropertySheets with pDevModeOutput %p\n",pDevModeOutput);
1190  docprophdr.cbOut = DocumentPropertySheets( NULL, (LPARAM)&docprophdr );
1191  }
1192 
1193  docprophdr.pdmIn = pDevModeInput;
1194  docprophdr.pdmOut = pDevModeOutput;
1195  docprophdr.fMode = fMode;
1196 
1197  if ( fMode & DM_IN_PROMPT )
1198  {
1199  Result = CPSUI_CANCEL;
1200 
1201  //
1202  // Now call the Property Sheet for Print > Properties.
1203  //
1205  {
1206  FIXME("CallCommonPropertySheetUI return error\n");
1208  }
1209  else
1210  Result = (Result == CPSUI_OK) ? IDOK : IDCANCEL;
1211  FIXME("CallCommonPropertySheetUI returned\n");
1212  }
1213  else
1214  {
1215  FIXME("DPW : CallDocumentPropertySheets\n");
1216  Result = DocumentPropertySheets( NULL, (LPARAM)&docprophdr );
1217  }
1218 
1220  {
1221  if ( pDevModeOutput )
1222  {
1223  if ( !IsValidDevmodeNoSizeW( pDevModeOutput ) )
1224  {
1225  ERR("DPW : Improper pDevModeOutput size.\n");
1226  Result = -1;
1227  }
1228  }
1229  else
1230  {
1231  ERR("No pDevModeOutput\n");
1232  }
1233  }
1234 
1235  if (hUseHandle && !hPrinter)
1236  ClosePrinter(hUseHandle);
1237  return Result;
1238 }
#define IDOK
Definition: winuser.h:824
LONG WINAPI CallCommonPropertySheetUI(HWND hWnd, PFNPROPSHEETUI pfnPropSheetUI, LPARAM lparam, LPDWORD pResult)
Definition: printers.c:1131
#define DM_IN_PROMPT
Definition: windef.h:358
#define ERR_CPSUI_ALLOCMEM_FAILED
Definition: compstui.h:645
HWND hWnd
Definition: settings.c:17
#define CPSUI_OK
Definition: compstui.h:640
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR_CPSUI_GETLASTERROR
Definition: compstui.h:644
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
struct _DOCUMENTPROPERTYHEADER DOCUMENTPROPERTYHEADER
BOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:176
#define ERR(fmt,...)
Definition: debug.h:110
#define DM_IN_BUFFER
Definition: windef.h:357
BOOL WINAPI IsValidDevmodeNoSizeW(PDEVMODEW pDevmode)
Definition: devmode.c:238
LONG WINAPI DocumentPropertySheets(PPROPSHEETUI_INFO pCPSUIInfo, LPARAM lparam)
Definition: printers.c:895
BOOL WINAPI OpenPrinterW(PWSTR pPrinterName, PHANDLE phPrinter, PPRINTER_DEFAULTSW pDefault)
Definition: printers.c:345
#define CPSUI_CANCEL
Definition: compstui.h:639
uint32_t * LPDWORD
Definition: typedefs.h:59
#define IDCANCEL
Definition: winuser.h:825
LONG(FAR * PFNPROPSHEETUI)(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam)
Definition: compstui.h:905

Referenced by DocumentPropertiesA(), pagesetup_change_printer(), pagesetup_printer_properties(), PRINTDLG_ChangePrinterW(), and PRINTDLG_WMCommandW().

◆ DocumentPropertySheets()

LONG WINAPI DocumentPropertySheets ( PPROPSHEETUI_INFO  pCPSUIInfo,
LPARAM  lparam 
)

Definition at line 895 of file printers.c.

896 {
897  LONG Result = -1;
899 
900  FIXME("DocumentPropertySheets(%p, 0x%lx)\n", pCPSUIInfo, lparam);
901 
902  // If pPSUIInfo is NULL, and if either lParam -> fMode is zero or lParam -> pdmOut is NULL,
903  // this function should return the size, in bytes, of the printer's DEVMODEW structure.
904  if ( !pCPSUIInfo && lparam )
905  {
907 
908  if ( pdphdr->cbSize >= sizeof(PDOCUMENTPROPERTYHEADER) &&
909  !(pdphdr->fMode & DM_PROMPT) )
910  {
912 
913  if ( hLibrary )
914  {
915  fpDocumentPropertySheets = (PVOID)GetProcAddress( hLibrary, "DrvDocumentPropertySheets" );
916 
918  {
919  FIXME("DPS : fpDocumentPropertySheets(%p, 0x%lx) pdmOut %p\n", pCPSUIInfo, lparam, pdphdr->pdmOut);
920  Result = fpDocumentPropertySheets( pCPSUIInfo, lparam );
921  FIXME("DPS : fpDocumentPropertySheets result %d cbOut %d\n",Result, pdphdr->cbOut);
922  }
923  else
924  {
925  //
926  // ReactOS backup!!! Currently no supporting UI driver.
927  //
928  PRINTER_INFO_9W * pi9 = get_devmodeW( pdphdr->hPrinter );
929  if ( pi9 )
930  {
931  Result = pi9->pDevMode->dmSize + pi9->pDevMode->dmDriverExtra;
932  FIXME("IDPS : Using ReactOS backup!!! DevMode Size %d\n",Result);
933  HeapFree(hProcessHeap, 0, pi9);
934  }
935  }
936 
938 
939  if ( Result > 0 )
940  {
941  IntFixUpDevModeNames( pdphdr );
942  }
943 
944  return Result;
945  }
946  else
947  {
949  }
950  }
951  else
952  {
954  }
955  return Result;
956  }
957 
958  Result = 0;
959 
960  if ( pCPSUIInfo )
961  {
962  PSETRESULT_INFO psri;
963  PPROPSHEETUI_INFO_HEADER ppsuiihdr;
964  PCOMPUI_USERDATA pcui_ud;
965  pdphdr = (PDOCUMENTPROPERTYHEADER)pCPSUIInfo->lParamInit;
966 
967  if ( pdphdr->cbSize < sizeof(PDOCUMENTPROPERTYHEADER) )
968  {
970  return Result;
971  }
972 
973  switch ( pCPSUIInfo->Reason )
974  {
976  {
977  FIXME("DocPS : PROPSHEETUI_REASON_INIT\n");
978  if ( CreateUIUserData( &pCPSUIInfo->UserData, pdphdr->hPrinter ) )
979  {
980  pcui_ud = (PCOMPUI_USERDATA)pCPSUIInfo->UserData;
981 
982  fpDocumentPropertySheets = (PVOID)GetProcAddress( pcui_ud->hModule, "DrvDocumentPropertySheets" );
983 
985  {
986  pCPSUIInfo->pfnComPropSheet( pCPSUIInfo->hComPropSheet,
988  -3, // What type of handle is this?
989  0 ); // Not used, must be zero.
990 
991  Result = pCPSUIInfo->pfnComPropSheet( pCPSUIInfo->hComPropSheet,
994  pCPSUIInfo->lParamInit );
995  break;
996  }
997  FIXME("DocPS : PROPSHEETUI_REASON_INIT Fail\n");
998  DestroyUIUserData( &pCPSUIInfo->UserData );
999  }
1000  }
1001  break;
1002 
1004  FIXME("DocPS : PROPSHEETUI_REASON_GET_INFO_HEADER\n");
1005 
1006  ppsuiihdr = (PPROPSHEETUI_INFO_HEADER)lparam;
1007 
1008  pcui_ud = (PCOMPUI_USERDATA)pCPSUIInfo->UserData;
1009 
1010  CreatePrinterFriendlyName( pcui_ud, pdphdr->pszPrinterName );
1011 
1013  ppsuiihdr->pTitle = pcui_ud->pszPrinterName;
1014  ppsuiihdr->hInst = hinstWinSpool;
1015  ppsuiihdr->IconID = IDI_CPSUI_DOCUMENT;
1016 
1017  Result = CPSUI_OK;
1018  break;
1019 
1021  FIXME("DocPS : PROPSHEETUI_REASON_DESTROY\n");
1022  DestroyUIUserData( &pCPSUIInfo->UserData );
1023  Result = CPSUI_OK;
1024  break;
1025 
1027  FIXME("DocPS : PROPSHEETUI_REASON_SET_RESULT\n");
1028 
1029  psri = (PSETRESULT_INFO)lparam;
1030 
1031  pCPSUIInfo->Result = psri->Result;
1032  if ( pCPSUIInfo->Result > 0 )
1033  {
1034  IntFixUpDevModeNames( pdphdr );
1035  }
1036  Result = CPSUI_OK;
1037  break;
1038  }
1039  }
1040  return Result;
1041 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define IDI_CPSUI_DOCUMENT
Definition: compstui.h:88
struct _PROPSHEETUI_INFO_HEADER * PPROPSHEETUI_INFO_HEADER
HANDLE hComPropSheet
Definition: compstui.h:889
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define PSUIHDRF_PROPTITLE
Definition: compstui.h:693
WORD dmDriverExtra
Definition: wingdi.h:1620
#define CPSUI_OK
Definition: compstui.h:640
LPDEVMODEW pDevMode
Definition: winspool.h:170
#define PROPSHEETUI_REASON_GET_INFO_HEADER
Definition: compstui.h:628
BOOL FASTCALL IntFixUpDevModeNames(PDOCUMENTPROPERTYHEADER pdphdr)
Definition: printers.c:815
long LONG
Definition: pedump.c:60
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
PRINTER_INFO_9W * get_devmodeW(HANDLE hprn)
Definition: printers.c:746
#define FIXME(fmt,...)
Definition: debug.h:111
PFNCOMPROPSHEET pfnComPropSheet
Definition: compstui.h:890
LPWSTR pszPrinterName
Definition: printers.c:54
struct _DOCUMENTPROPERTYHEADER * PDOCUMENTPROPERTYHEADER
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
void * PVOID
Definition: retypes.h:9
ULONG_PTR Result
Definition: compstui.h:893
HMODULE hModule
Definition: printers.c:53
#define FreeLibrary(x)
Definition: compat.h:496
struct _COMPUI_USERDATA * PCOMPUI_USERDATA
if(!(yy_init))
Definition: macro.lex.yy.c:714
WORD dmSize
Definition: wingdi.h:1619
#define SetLastError(x)
Definition: compat.h:500
LPARAM lParamInit
Definition: compstui.h:891
#define DM_PROMPT
Definition: windef.h:354
HMODULE WINAPI LoadPrinterDriver(HANDLE hspool)
Definition: printers.c:488
HMODULE hLibrary
Definition: odbccp32.c:12
HINSTANCE hinstWinSpool
Definition: main.c:12
#define PSUIHDRF_NOAPPLYNOW
Definition: compstui.h:692
struct _SETRESULT_INFO * PSETRESULT_INFO
#define PROPSHEETUI_REASON_INIT
Definition: compstui.h:627
#define PROPSHEETUI_REASON_DESTROY
Definition: compstui.h:629
LONG WINAPI CreatePrinterFriendlyName(PCOMPUI_USERDATA pcui_ud, LPWSTR pszPrinterName)
Definition: printers.c:851
static DOCUMENTPROPERTYSHEETS fpDocumentPropertySheets
Definition: printers.c:24
BOOL FASTCALL CreateUIUserData(ULONG_PTR *puserdata, HANDLE hPrinter)
Definition: printers.c:769
#define PROPSHEETUI_REASON_SET_RESULT
Definition: compstui.h:630
ULONG_PTR UserData
Definition: compstui.h:892
#define GetProcAddress(x, y)
Definition: compat.h:501
VOID FASTCALL DestroyUIUserData(ULONG_PTR *puserdata)
Definition: printers.c:790
LRESULT Result
Definition: compstui.h:849
#define CPSFUNC_ADD_PFNPROPSHEETUIW
Definition: compstui.h:552
#define CPSFUNC_SET_FUSION_CONTEXT
Definition: compstui.h:575
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by DocumentPropertiesW().

◆ EndDocPrinter()

BOOL WINAPI EndDocPrinter ( HANDLE  hPrinter)

Definition at line 1291 of file printers.c.

1292 {
1293  DWORD dwErrorCode;
1294  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
1295 
1296  TRACE("EndDocPrinter(%p)\n", hPrinter);
1297 
1298  // Sanity checks.
1299  if (!pHandle)
1300  {
1301  dwErrorCode = ERROR_INVALID_HANDLE;
1302  goto Cleanup;
1303  }
1304 
1305  if (pHandle->hSPLFile != INVALID_HANDLE_VALUE)
1306  {
1307  // For spooled jobs, the document is finished by calling _RpcScheduleJob.
1308  RpcTryExcept
1309  {
1310  dwErrorCode = _RpcScheduleJob(pHandle->hPrinter, pHandle->dwJobID);
1311  }
1313  {
1314  dwErrorCode = RpcExceptionCode();
1315  ERR("_RpcScheduleJob failed with exception code %lu!\n", dwErrorCode);
1316  }
1317  RpcEndExcept;
1318 
1319  // Close the spool file handle.
1320  CloseHandle(pHandle->hSPLFile);
1321  }
1322  else
1323  {
1324  // In all other cases, just call _RpcEndDocPrinter.
1325  RpcTryExcept
1326  {
1327  dwErrorCode = _RpcEndDocPrinter(pHandle->hPrinter);
1328  }
1330  {
1331  dwErrorCode = RpcExceptionCode();
1332  ERR("_RpcEndDocPrinter failed with exception code %lu!\n", dwErrorCode);
1333  }
1334  RpcEndExcept;
1335  }
1336 
1337  // A new document can now be started again.
1338  pHandle->bTrayIcon = pHandle->bJob = pHandle->bStartedDoc = FALSE;
1339 
1340 Cleanup:
1341  SetLastError(dwErrorCode);
1342  return (dwErrorCode == ERROR_SUCCESS);
1343 }
#define RpcEndExcept
Definition: rpc.h:128
#define CloseHandle
Definition: compat.h:487
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD _RpcEndDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: printers.c:85
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
BOOL bStartedDoc
Definition: precomp.h:41
DWORD dwJobID
Definition: precomp.h:49
#define FALSE
Definition: types.h:117
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE hSPLFile
Definition: precomp.h:51
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
DWORD _RpcScheduleJob(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD JobId)
Definition: jobs.c:110
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
BOOL bTrayIcon
Definition: precomp.h:45
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

Referenced by PrintRawJob(), and wmain().

◆ EndPagePrinter()

BOOL WINAPI EndPagePrinter ( HANDLE  hPrinter)

Definition at line 1346 of file printers.c.

1347 {
1348  DWORD dwErrorCode;
1349  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
1350 
1351  TRACE("EndPagePrinter(%p)\n", hPrinter);
1352 
1353  // Sanity checks.
1354  if (!pHandle)
1355  {
1356  dwErrorCode = ERROR_INVALID_HANDLE;
1357  goto Cleanup;
1358  }
1359 
1360  if (pHandle->hSPLFile != INVALID_HANDLE_VALUE)
1361  {
1362  // For spooled jobs, we don't need to do anything.
1363  dwErrorCode = ERROR_SUCCESS;
1364  }
1365  else
1366  {
1367  // In all other cases, just call _RpcEndPagePrinter.
1368  RpcTryExcept
1369  {
1370  dwErrorCode = _RpcEndPagePrinter(pHandle->hPrinter);
1371  }
1373  {
1374  dwErrorCode = RpcExceptionCode();
1375  ERR("_RpcEndPagePrinter failed with exception code %lu!\n", dwErrorCode);
1376  }
1377  RpcEndExcept;
1378  }
1379 
1380 Cleanup:
1381  SetLastError(dwErrorCode);
1382  return (dwErrorCode == ERROR_SUCCESS);
1383 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define RpcTryExcept
Definition: rpc.h:126
DWORD _RpcEndPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: printers.c:104
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE hSPLFile
Definition: precomp.h:51
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

Referenced by wmain().

◆ EnumPrintersA()

BOOL WINAPI EnumPrintersA ( DWORD  Flags,
PSTR  Name,
DWORD  Level,
PBYTE  pPrinterEnum,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 1386 of file printers.c.

1387 {
1388  DWORD dwErrorCode;
1389  DWORD cch;
1390  PWSTR pwszName = NULL;
1391  PSTR pszPrinterName = NULL;
1392  PSTR pszServerName = NULL;
1393  PSTR pszDescription = NULL;
1394  PSTR pszName = NULL;
1395  PSTR pszComment = NULL;
1396  PSTR pszShareName = NULL;
1397  PSTR pszPortName = NULL;
1398  PSTR pszDriverName = NULL;
1399  PSTR pszLocation = NULL;
1400  PSTR pszSepFile = NULL;
1401  PSTR pszPrintProcessor = NULL;
1402  PSTR pszDatatype = NULL;
1403  PSTR pszParameters = NULL;
1404  DWORD i;
1405  PPRINTER_INFO_1W ppi1w = NULL;
1406  PPRINTER_INFO_1A ppi1a = NULL;
1407  PPRINTER_INFO_2W ppi2w = NULL;
1408  PPRINTER_INFO_2A ppi2a = NULL;
1409  PPRINTER_INFO_4W ppi4w = NULL;
1410  PPRINTER_INFO_4A ppi4a = NULL;
1411  PPRINTER_INFO_5W ppi5w = NULL;
1412  PPRINTER_INFO_5A ppi5a = NULL;
1413 
1414  TRACE("EnumPrintersA(%lu, %s, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
1415 
1416  // Check for invalid levels here for early error return. MSDN says that only 1, 2, 4, and 5 are allowable.
1417  if (Level != 1 && Level != 2 && Level != 4 && Level != 5)
1418  {
1419  dwErrorCode = ERROR_INVALID_LEVEL;
1420  ERR("Invalid Level!\n");
1421  goto Cleanup;
1422  }
1423 
1424  if (Name)
1425  {
1426  // Convert pName to a Unicode string pwszName.
1427  cch = strlen(Name);
1428 
1429  pwszName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(WCHAR));
1430  if (!pwszName)
1431  {
1432  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1433  ERR("HeapAlloc failed!\n");
1434  goto Cleanup;
1435  }
1436 
1437  MultiByteToWideChar(CP_ACP, 0, Name, -1, pwszName, cch + 1);
1438  }
1439 
1440  /* Ref: https://stackoverflow.com/questions/41147180/why-enumprintersa-and-enumprintersw-request-the-same-amount-of-memory */
1441  if (!EnumPrintersW(Flags, pwszName, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned))
1442  {
1443  dwErrorCode = GetLastError();
1444  goto Cleanup;
1445  }
1446 
1447  /* We are mapping multiple different pointers to the same pPrinterEnum pointer here so that */
1448  /* we can do in-place conversion. We read the Unicode response from the EnumPrintersW and */
1449  /* then we write back the ANSI conversion into the same buffer for our EnumPrintersA output */
1450 
1451  /* mapping to pPrinterEnum for Unicode (w) characters for Levels 1, 2, 4, and 5 */
1452  ppi1w = (PPRINTER_INFO_1W)pPrinterEnum;
1453  ppi2w = (PPRINTER_INFO_2W)pPrinterEnum;
1454  ppi4w = (PPRINTER_INFO_4W)pPrinterEnum;
1455  ppi5w = (PPRINTER_INFO_5W)pPrinterEnum;
1456  /* mapping to pPrinterEnum for ANSI (a) characters for Levels 1, 2, 4, and 5 */
1457  ppi1a = (PPRINTER_INFO_1A)pPrinterEnum;
1458  ppi2a = (PPRINTER_INFO_2A)pPrinterEnum;
1459  ppi4a = (PPRINTER_INFO_4A)pPrinterEnum;
1460  ppi5a = (PPRINTER_INFO_5A)pPrinterEnum;
1461 
1462  for (i = 0; i < *pcReturned; i++)
1463  {
1464  switch (Level)
1465  {
1466  case 1:
1467  {
1468  if (ppi1w[i].pDescription)
1469  {
1470  // Convert Unicode pDescription to a ANSI string pszDescription.
1471  cch = wcslen(ppi1w[i].pDescription);
1472 
1473  pszDescription = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1474  if (!pszDescription)
1475  {
1476  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1477  ERR("HeapAlloc failed!\n");
1478  goto Cleanup;
1479  }
1480 
1481  WideCharToMultiByte(CP_ACP, 0, ppi1w[i].pDescription, -1, pszDescription, cch + 1, NULL, NULL);
1482  StringCchCopyA(ppi1a[i].pDescription, cch + 1, pszDescription);
1483 
1484  HeapFree(hProcessHeap, 0, pszDescription);
1485  }
1486 
1487  if (ppi1w[i].pName)
1488  {
1489  // Convert Unicode pName to a ANSI string pszName.
1490  cch = wcslen(ppi1w[i].pName);
1491 
1492  pszName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1493  if (!pszName)
1494  {
1495  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1496  ERR("HeapAlloc failed!\n");
1497  goto Cleanup;
1498  }
1499 
1500  WideCharToMultiByte(CP_ACP, 0, ppi1w[i].pName, -1, pszName, cch + 1, NULL, NULL);
1501  StringCchCopyA(ppi1a[i].pName, cch + 1, pszName);
1502 
1503  HeapFree(hProcessHeap, 0, pszName);
1504  }
1505 
1506  if (ppi1w[i].pComment)
1507  {
1508  // Convert Unicode pComment to a ANSI string pszComment.
1509  cch = wcslen(ppi1w[i].pComment);
1510 
1511  pszComment = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1512  if (!pszComment)
1513  {
1514  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1515  ERR("HeapAlloc failed!\n");
1516  goto Cleanup;
1517  }
1518 
1519  WideCharToMultiByte(CP_ACP, 0, ppi1w[i].pComment, -1, pszComment, cch + 1, NULL, NULL);
1520  StringCchCopyA(ppi1a[i].pComment, cch + 1, pszComment);
1521 
1522  HeapFree(hProcessHeap, 0, pszComment);
1523  }
1524  break;
1525  }
1526 
1527 
1528  case 2:
1529  {
1530  if (ppi2w[i].pServerName)
1531  {
1532  // Convert Unicode pServerName to a ANSI string pszServerName.
1533  cch = wcslen(ppi2w[i].pServerName);
1534 
1535  pszServerName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1536  if (!pszServerName)
1537  {
1538  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1539  ERR("HeapAlloc failed!\n");
1540  goto Cleanup;
1541  }
1542 
1543  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pServerName, -1, pszServerName, cch + 1, NULL, NULL);
1544  StringCchCopyA(ppi2a[i].pServerName, cch + 1, pszServerName);
1545 
1546  HeapFree(hProcessHeap, 0, pszServerName);
1547  }
1548 
1549  if (ppi2w[i].pPrinterName)
1550  {
1551  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
1552  cch = wcslen(ppi2w[i].pPrinterName);
1553 
1554  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1555  if (!pszPrinterName)
1556  {
1557  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1558  ERR("HeapAlloc failed!\n");
1559  goto Cleanup;
1560  }
1561 
1562  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
1563  StringCchCopyA(ppi2a[i].pPrinterName, cch + 1, pszPrinterName);
1564 
1565  HeapFree(hProcessHeap, 0, pszPrinterName);
1566  }
1567 
1568  if (ppi2w[i].pShareName)
1569  {
1570  // Convert Unicode pShareName to a ANSI string pszShareName.
1571  cch = wcslen(ppi2w[i].pShareName);
1572 
1573  pszShareName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1574  if (!pszShareName)
1575  {
1576  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1577  ERR("HeapAlloc failed!\n");
1578  goto Cleanup;
1579  }
1580 
1581  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pShareName, -1, pszShareName, cch + 1, NULL, NULL);
1582  StringCchCopyA(ppi2a[i].pShareName, cch + 1, pszShareName);
1583 
1584  HeapFree(hProcessHeap, 0, pszShareName);
1585  }
1586 
1587  if (ppi2w[i].pPortName)
1588  {
1589  // Convert Unicode pPortName to a ANSI string pszPortName.
1590  cch = wcslen(ppi2w[i].pPortName);
1591 
1592  pszPortName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1593  if (!pszPortName)
1594  {
1595  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1596  ERR("HeapAlloc failed!\n");
1597  goto Cleanup;
1598  }
1599 
1600  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pPortName, -1, pszPortName, cch + 1, NULL, NULL);
1601  StringCchCopyA(ppi2a[i].pPortName, cch + 1, pszPortName);
1602 
1603  HeapFree(hProcessHeap, 0, pszPortName);
1604  }
1605 
1606  if (ppi2w[i].pDriverName)
1607  {
1608  // Convert Unicode pDriverName to a ANSI string pszDriverName.
1609  cch = wcslen(ppi2w[i].pDriverName);
1610 
1611  pszDriverName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1612  if (!pszDriverName)
1613  {
1614  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1615  ERR("HeapAlloc failed!\n");
1616  goto Cleanup;
1617  }
1618 
1619  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pDriverName, -1, pszDriverName, cch + 1, NULL, NULL);
1620  StringCchCopyA(ppi2a[i].pDriverName, cch + 1, pszDriverName);
1621 
1622  HeapFree(hProcessHeap, 0, pszDriverName);
1623  }
1624 
1625  if (ppi2w[i].pComment)
1626  {
1627  // Convert Unicode pComment to a ANSI string pszComment.
1628  cch = wcslen(ppi2w[i].pComment);
1629 
1630  pszComment = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1631  if (!pszComment)
1632  {
1633  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1634  ERR("HeapAlloc failed!\n");
1635  goto Cleanup;
1636  }
1637 
1638  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pComment, -1, pszComment, cch + 1, NULL, NULL);
1639  StringCchCopyA(ppi2a[i].pComment, cch + 1, pszComment);
1640 
1641  HeapFree(hProcessHeap, 0, pszComment);
1642  }
1643 
1644  if (ppi2w[i].pLocation)
1645  {
1646  // Convert Unicode pLocation to a ANSI string pszLocation.
1647  cch = wcslen(ppi2w[i].pLocation);
1648 
1649  pszLocation = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1650  if (!pszLocation)
1651  {
1652  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1653  ERR("HeapAlloc failed!\n");
1654  goto Cleanup;
1655  }
1656 
1657  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pLocation, -1, pszLocation, cch + 1, NULL, NULL);
1658  StringCchCopyA(ppi2a[i].pLocation, cch + 1, pszLocation);
1659 
1660  HeapFree(hProcessHeap, 0, pszLocation);
1661  }
1662 
1663 
1664  if (ppi2w[i].pSepFile)
1665  {
1666  // Convert Unicode pSepFile to a ANSI string pszSepFile.
1667  cch = wcslen(ppi2w[i].pSepFile);
1668 
1669  pszSepFile = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1670  if (!pszSepFile)
1671  {
1672  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1673  ERR("HeapAlloc failed!\n");
1674  goto Cleanup;
1675  }
1676 
1677  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pSepFile, -1, pszSepFile, cch + 1, NULL, NULL);
1678  StringCchCopyA(ppi2a[i].pSepFile, cch + 1, pszSepFile);
1679 
1680  HeapFree(hProcessHeap, 0, pszSepFile);
1681  }
1682 
1683  if (ppi2w[i].pPrintProcessor)
1684  {
1685  // Convert Unicode pPrintProcessor to a ANSI string pszPrintProcessor.
1686  cch = wcslen(ppi2w[i].pPrintProcessor);
1687 
1688  pszPrintProcessor = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1689  if (!pszPrintProcessor)
1690  {
1691  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1692  ERR("HeapAlloc failed!\n");
1693  goto Cleanup;
1694  }
1695 
1696  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pPrintProcessor, -1, pszPrintProcessor, cch + 1, NULL, NULL);
1697  StringCchCopyA(ppi2a[i].pPrintProcessor, cch + 1, pszPrintProcessor);
1698 
1699  HeapFree(hProcessHeap, 0, pszPrintProcessor);
1700  }
1701 
1702 
1703  if (ppi2w[i].pDatatype)
1704  {
1705  // Convert Unicode pDatatype to a ANSI string pszDatatype.
1706  cch = wcslen(ppi2w[i].pDatatype);
1707 
1708  pszDatatype = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1709  if (!pszDatatype)
1710  {
1711  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1712  ERR("HeapAlloc failed!\n");
1713  goto Cleanup;
1714  }
1715 
1716  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pDatatype, -1, pszDatatype, cch + 1, NULL, NULL);
1717  StringCchCopyA(ppi2a[i].pDatatype, cch + 1, pszDatatype);
1718 
1719  HeapFree(hProcessHeap, 0, pszDatatype);
1720  }
1721 
1722  if (ppi2w[i].pParameters)
1723  {
1724  // Convert Unicode pParameters to a ANSI string pszParameters.
1725  cch = wcslen(ppi2w[i].pParameters);
1726 
1727  pszParameters = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1728  if (!pszParameters)
1729  {
1730  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1731  ERR("HeapAlloc failed!\n");
1732  goto Cleanup;
1733  }
1734 
1735  WideCharToMultiByte(CP_ACP, 0, ppi2w[i].pParameters, -1, pszParameters, cch + 1, NULL, NULL);
1736  StringCchCopyA(ppi2a[i].pParameters, cch + 1, pszParameters);
1737 
1738  HeapFree(hProcessHeap, 0, pszParameters);
1739  }
1740  if ( ppi2w[i].pDevMode )
1741  {
1742  RosConvertUnicodeDevModeToAnsiDevmode( ppi2w[i].pDevMode, ppi2a[i].pDevMode );
1743  }
1744  break;
1745  }
1746 
1747  case 4:
1748  {
1749  if (ppi4w[i].pPrinterName)
1750  {
1751  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
1752  cch = wcslen(ppi4w[i].pPrinterName);
1753 
1754  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1755  if (!pszPrinterName)
1756  {
1757  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1758  ERR("HeapAlloc failed!\n");
1759  goto Cleanup;
1760  }
1761 
1762  WideCharToMultiByte(CP_ACP, 0, ppi4w[i].pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
1763  StringCchCopyA(ppi4a[i].pPrinterName, cch + 1, pszPrinterName);
1764 
1765  HeapFree(hProcessHeap, 0, pszPrinterName);
1766  }
1767 
1768  if (ppi4w[i].pServerName)
1769  {
1770  // Convert Unicode pServerName to a ANSI string pszServerName.
1771  cch = wcslen(ppi4w[i].pServerName);
1772 
1773  pszServerName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1774  if (!pszServerName)
1775  {
1776  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1777  ERR("HeapAlloc failed!\n");
1778  goto Cleanup;
1779  }
1780 
1781  WideCharToMultiByte(CP_ACP, 0, ppi4w[i].pServerName, -1, pszServerName, cch + 1, NULL, NULL);
1782  StringCchCopyA(ppi4a[i].pServerName, cch + 1, pszServerName);
1783 
1784  HeapFree(hProcessHeap, 0, pszServerName);
1785  }
1786  break;
1787  }
1788 
1789  case 5:
1790  {
1791  if (ppi5w[i].pPrinterName)
1792  {
1793  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
1794  cch = wcslen(ppi5w[i].pPrinterName);
1795 
1796  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1797  if (!pszPrinterName)
1798  {
1799  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1800  ERR("HeapAlloc failed!\n");
1801  goto Cleanup;
1802  }
1803 
1804  WideCharToMultiByte(CP_ACP, 0, ppi5w[i].pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
1805  StringCchCopyA(ppi5a[i].pPrinterName, cch + 1, pszPrinterName);
1806 
1807  HeapFree(hProcessHeap, 0, pszPrinterName);
1808  }
1809 
1810  if (ppi5w[i].pPortName)
1811  {
1812  // Convert Unicode pPortName to a ANSI string pszPortName.
1813  cch = wcslen(ppi5w[i].pPortName);
1814 
1815  pszPortName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
1816  if (!pszPortName)
1817  {
1818  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1819  ERR("HeapAlloc failed!\n");
1820  goto Cleanup;
1821  }
1822 
1823  WideCharToMultiByte(CP_ACP, 0, ppi5w[i].pPortName, -1, pszPortName, cch + 1, NULL, NULL);
1824  StringCchCopyA(ppi5a[i].pPortName, cch + 1, pszPortName);
1825 
1826  HeapFree(hProcessHeap, 0, pszPortName);
1827  }
1828  break;
1829  }
1830 
1831  } // switch
1832  } // for
1833 
1834  dwErrorCode = ERROR_SUCCESS;
1835 
1836 Cleanup:
1837  if (pwszName)
1838  {
1839  HeapFree(hProcessHeap, 0, pwszName);
1840  }
1841 
1842  SetLastError(dwErrorCode);
1843  return (dwErrorCode == ERROR_SUCCESS);
1844 }
BOOL WINAPI EnumPrintersW(DWORD Flags, PWSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
Definition: printers.c:247
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:111
struct _PRINTER_INFO_2W * PPRINTER_INFO_2W
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
uint16_t * PWSTR
Definition: typedefs.h:56
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
struct _PRINTER_INFO_5A * PPRINTER_INFO_5A
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
struct _PRINTER_INFO_2A * PPRINTER_INFO_2A
struct _PRINTER_INFO_1W * PPRINTER_INFO_1W
void RosConvertUnicodeDevModeToAnsiDevmode(PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput)
Definition: devmode.c:353
#define TRACE(s)
Definition: solgame.cpp:4
static LPSTR pName
Definition: security.c:75
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _PRINTER_INFO_1A * PPRINTER_INFO_1A
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
struct _PRINTER_INFO_4W * PPRINTER_INFO_4W
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
signed char * PSTR
Definition: retypes.h:7
struct _PRINTER_INFO_5W * PPRINTER_INFO_5W
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
struct _PRINTER_INFO_4A * PPRINTER_INFO_4A
HANDLE hProcessHeap
Definition: kbswitch.c:25

◆ EnumPrintersW()

BOOL WINAPI EnumPrintersW ( DWORD  Flags,
PWSTR  Name,
DWORD  Level,
PBYTE  pPrinterEnum,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 1847 of file printers.c.

1848 {
1849  DWORD dwErrorCode;
1850 
1851  TRACE("EnumPrintersW(%lu, %S, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
1852 
1853  // Dismiss invalid levels already at this point.
1854  if (Level == 3 || Level > 5)
1855  {
1856  dwErrorCode = ERROR_INVALID_LEVEL;
1857  goto Cleanup;
1858  }
1859 
1860  if (cbBuf && pPrinterEnum)
1861  ZeroMemory(pPrinterEnum, cbBuf);
1862 
1863  // Do the RPC call
1864  RpcTryExcept
1865  {
1866  dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
1867  }
1869  {
1870  dwErrorCode = RpcExceptionCode();
1871  ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode);
1872  }
1873  RpcEndExcept;
1874 
1875  if (dwErrorCode == ERROR_SUCCESS)
1876  {
1877  // Replace relative offset addresses in the output by absolute pointers.
1878  ASSERT(Level <= 9);
1879  MarshallUpStructuresArray(cbBuf, pPrinterEnum, *pcReturned, pPrinterInfoMarshalling[Level]->pInfo, pPrinterInfoMarshalling[Level]->cbStructureSize, TRUE);
1880  }
1881 
1882 Cleanup:
1883  SetLastError(dwErrorCode);
1884  return (dwErrorCode == ERROR_SUCCESS);
1885 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
DWORD _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE *pPrinterEnum, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
Definition: printers.c:123
#define ZeroMemory
Definition: winbase.h:1648
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
static const MARSHALLING * pPrinterInfoMarshalling[]
Definition: printers.h:146
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define RpcExcept(expr)
Definition: rpc.h:127
BOOL WINAPI MarshallUpStructuresArray(DWORD cbSize, PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:202

◆ file_dlg_proc()

INT_PTR CALLBACK file_dlg_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)

Definition at line 3475 of file printers.c.

3476 {
3477  LPWSTR filename;
3478 
3479  switch(msg)
3480  {
3481  case WM_INITDIALOG:
3483  return TRUE;
3484 
3485  case WM_COMMAND:
3486  if(HIWORD(wparam) == BN_CLICKED)
3487  {
3488  if(LOWORD(wparam) == IDOK)
3489  {
3490  HANDLE hf;
3492  LPWSTR *output;
3493 
3494  filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
3496 
3498  {
3499  WCHAR caption[200], message[200];
3500  int mb_ret;
3501 
3502  LoadStringW(hinstWinSpool, IDS_CAPTION, caption, ARRAYSIZE(caption));
3504  mb_ret = MessageBoxW(hwnd, message, caption, MB_OKCANCEL | MB_ICONEXCLAMATION);
3505  if(mb_ret == IDCANCEL)
3506  {
3508  return TRUE;
3509  }
3510  }
3512  if(hf == INVALID_HANDLE_VALUE)
3513  {
3514  WCHAR caption[200], message[200];
3515 
3516  LoadStringW(hinstWinSpool, IDS_CAPTION, caption, ARRAYSIZE(caption));
3520  return TRUE;
3521  }
3522  CloseHandle(hf);
3525  *output = filename;
3526  EndDialog(hwnd, IDOK);
3527  return TRUE;
3528  }
3529  if(LOWORD(wparam) == IDCANCEL)
3530  {
3532  return TRUE;
3533  }
3534  }
3535  return FALSE;
3536  }
3537  return FALSE;
3538 }
#define WM_GETTEXTLENGTH
Definition: winuser.h:1601
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDS_CANNOT_OPEN
Definition: resource.h:5
Definition: tftpd.h:59
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:487
#define TRUE
Definition: types.h:120
#define EDITBOX
Definition: wspool.h:30
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define GetWindowLongPtrW
Definition: winuser.h:4804
const char * filename
Definition: ioapi.h:135
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define IDS_CAPTION
Definition: resource.h:93
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define IDS_FILE_EXISTS
Definition: wspool.h:26
#define FALSE
Definition: types.h:117
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
#define MB_OKCANCEL
Definition: winuser.h:798
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define DWLP_USER
Definition: winuser.h:866
GLenum GLsizei len
Definition: glext.h:6722
HINSTANCE hinstWinSpool
Definition: main.c:12
#define WM_COMMAND
Definition: winuser.h:1722
#define CREATE_ALWAYS
Definition: disk.h:72
#define MB_OK
Definition: winuser.h:784
#define CreateFileW
Definition: compat.h:489
#define msg(x)
Definition: auth_time.c:54
#define HIWORD(l)
Definition: typedefs.h:247
#define SetWindowLongPtrW
Definition: winuser.h:5321
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:483
static UINT WPARAM wparam
Definition: combo.c:716

Referenced by StartDocDlgW().

◆ FlushPrinter()

BOOL WINAPI FlushPrinter ( HANDLE  hPrinter,
PVOID  pBuf,
DWORD  cbBuf,
PDWORD  pcWritten,
DWORD  cSleep 
)

Definition at line 1888 of file printers.c.

1889 {
1890  TRACE("FlushPrinter(%p, %p, %lu, %p, %lu)\n", hPrinter, pBuf, cbBuf, pcWritten, cSleep);
1891  UNIMPLEMENTED;
1892  return FALSE;
1893 }
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define UNIMPLEMENTED
Definition: debug.h:115

◆ get_devmodeW()

PRINTER_INFO_9W* get_devmodeW ( HANDLE  hprn)

Definition at line 746 of file printers.c.

747 {
748  PRINTER_INFO_9W *pi9 = NULL;
749  DWORD needed = 0;
750  BOOL res;
751 
752  res = GetPrinterW(hprn, 9, NULL, 0, &needed);
754  {
755  pi9 = HeapAlloc(hProcessHeap, 0, needed);
756  res = GetPrinterW(hprn, 9, (LPBYTE)pi9, needed, &needed);
757  }
758 
759  if (res)
760  return pi9;
761 
762  ERR("GetPrinterW failed with %u\n", GetLastError());
763  HeapFree(hProcessHeap, 0, pi9);
764  return NULL;
765 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, PBYTE pPrinter, DWORD cbBuf, PDWORD pcbNeeded)
Definition: printers.c:312
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DocumentPropertySheets().

◆ GetDefaultPrinterA()

BOOL WINAPI GetDefaultPrinterA ( LPSTR  pszBuffer,
LPDWORD  pcchBuffer 
)

Definition at line 1896 of file printers.c.

1897 {
1898  DWORD dwErrorCode;
1899  PWSTR pwszBuffer = NULL;
1900 
1901  TRACE("GetDefaultPrinterA(%p, %p)\n", pszBuffer, pcchBuffer);
1902 
1903  // Sanity check.
1904  if (!pcchBuffer)
1905  {
1906  dwErrorCode = ERROR_INVALID_PARAMETER;
1907  goto Cleanup;
1908  }
1909 
1910  // Check if an ANSI buffer was given and if so, allocate a Unicode buffer of the same size.
1911  if (pszBuffer && *pcchBuffer)
1912  {
1913  pwszBuffer = HeapAlloc(hProcessHeap, 0, *pcchBuffer * sizeof(WCHAR));
1914  if (!pwszBuffer)
1915  {
1916  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1917  ERR("HeapAlloc failed!\n");
1918  goto Cleanup;
1919  }
1920  }
1921 
1922  if (!GetDefaultPrinterW(pwszBuffer, pcchBuffer))
1923  {
1924  dwErrorCode = GetLastError();
1925  goto Cleanup;
1926  }
1927 
1928  // We successfully got a string in pwszBuffer, so convert the Unicode string to ANSI.
1929  WideCharToMultiByte(CP_ACP, 0, pwszBuffer, -1, pszBuffer, *pcchBuffer, NULL, NULL);
1930 
1931  dwErrorCode = ERROR_SUCCESS;
1932 
1933 Cleanup:
1934  if (pwszBuffer)
1935  HeapFree(hProcessHeap, 0, pwszBuffer);
1936 
1937  SetLastError(dwErrorCode);
1938  return (dwErrorCode == ERROR_SUCCESS);
1939 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:111
uint16_t * PWSTR
Definition: typedefs.h:56
#define CP_ACP
Definition: compat.h:109
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetDefaultPrinterW(LPWSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:1942
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by PRINTDLG_CreateDevNames(), PRINTDLG_SetUpPrinterListComboA(), PRINTDLG_WMInitDialog(), and START_TEST().

◆ GetDefaultPrinterW()

BOOL WINAPI GetDefaultPrinterW ( LPWSTR  pszBuffer,
LPDWORD  pcchBuffer 
)

Definition at line 1942 of file printers.c.

1943 {
1944  DWORD cbNeeded;
1945  DWORD cchInputBuffer;
1946  DWORD dwErrorCode;
1947  HKEY hWindowsKey = NULL;
1948  PWSTR pwszDevice = NULL;
1949  PWSTR pwszComma;
1950 
1951  TRACE("GetDefaultPrinterW(%p, %p)\n", pszBuffer, pcchBuffer);
1952 
1953  // Sanity check.
1954  if (!pcchBuffer)
1955  {
1956  dwErrorCode = ERROR_INVALID_PARAMETER;
1957  goto Cleanup;
1958  }
1959 
1960  cchInputBuffer = *pcchBuffer;
1961 
1962  // Open the registry key where the default printer for the current user is stored.
1963  dwErrorCode = (DWORD)RegOpenKeyExW(HKEY_CURRENT_USER, wszWindowsKey, 0, KEY_READ, &hWindowsKey);
1964  if (dwErrorCode != ERROR_SUCCESS)
1965  {
1966  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
1967  goto Cleanup;
1968  }
1969 
1970  // Determine the size of the required buffer.
1971  dwErrorCode = (DWORD)RegQueryValueExW(hWindowsKey, wszDeviceValue, NULL, NULL, NULL, &cbNeeded);
1972  if (dwErrorCode != ERROR_SUCCESS)
1973  {
1974  ERR("RegQueryValueExW failed with status %lu!\n", dwErrorCode);
1975  goto Cleanup;
1976  }
1977 
1978  // Allocate it.
1979  pwszDevice = HeapAlloc(hProcessHeap, 0, cbNeeded);
1980  if (!pwszDevice)
1981  {
1982  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
1983  ERR("HeapAlloc failed!\n");
1984  goto Cleanup;
1985  }
1986 
1987  // Now get the actual value.
1988  dwErrorCode = RegQueryValueExW(hWindowsKey, wszDeviceValue, NULL, NULL, (PBYTE)pwszDevice, &cbNeeded);
1989  if (dwErrorCode != ERROR_SUCCESS)
1990  {
1991  ERR("RegQueryValueExW failed with status %lu!\n", dwErrorCode);
1992  goto Cleanup;
1993  }
1994 
1995  // We get a string "<Printer Name>,winspool,<Port>:".
1996  // Extract the printer name from it.
1997  pwszComma = wcschr(pwszDevice, L',');
1998  if (!pwszComma)
1999  {
2000  ERR("Found no or invalid default printer: %S!\n", pwszDevice);
2001  dwErrorCode = ERROR_INVALID_NAME;
2002  goto Cleanup;
2003  }
2004 
2005  // Store the length of the Printer Name (including the terminating NUL character!) in *pcchBuffer.
2006  *pcchBuffer = pwszComma - pwszDevice + 1;
2007 
2008  // Check if the supplied buffer is large enough.
2009  if ( !pszBuffer || cchInputBuffer < *pcchBuffer)
2010  {
2011  dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
2012  goto Cleanup;
2013  }
2014 
2015  // Copy the default printer.
2016  *pwszComma = 0;
2017  CopyMemory(pszBuffer, pwszDevice, *pcchBuffer * sizeof(WCHAR));
2018 
2019  dwErrorCode = ERROR_SUCCESS;
2020 
2021 Cleanup:
2022  if (hWindowsKey)
2023  RegCloseKey(hWindowsKey);
2024 
2025  if (pwszDevice)
2026  HeapFree(hProcessHeap, 0, pwszDevice);
2027 
2028  SetLastError(dwErrorCode);
2029  return (dwErrorCode == ERROR_SUCCESS);
2030 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:56
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
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 CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
static const WCHAR wszWindowsKey[]
Definition: printers.c:61
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:110
static const WCHAR wszDeviceValue[]
Definition: printers.c:62
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define ERROR_INVALID_NAME
Definition: compat.h:103
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by get_default_printer(), GetDefaultPrinterA(), pagesetup_set_devnames(), PRINTDLG_CreateDevNamesW(), PRINTDLG_OpenDefaultPrinter(), PRINTDLG_SetUpPrinterListComboW(), PRINTDLG_WMInitDialogW(), SetDefaultPrinterW(), and START_TEST().

◆ GetPrinterA()

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

Definition at line 2033 of file printers.c.

2034 {
2035  DWORD dwErrorCode;
2036  PPRINTER_INFO_1A ppi1a = (PPRINTER_INFO_1A)pPrinter;
2037  PPRINTER_INFO_1W ppi1w = (PPRINTER_INFO_1W)pPrinter;
2038  PPRINTER_INFO_2A ppi2a = (PPRINTER_INFO_2A)pPrinter;
2039  PPRINTER_INFO_2W ppi2w = (PPRINTER_INFO_2W)pPrinter;
2040  PPRINTER_INFO_4A ppi4a = (PPRINTER_INFO_4A)pPrinter;
2041  PPRINTER_INFO_4W ppi4w = (PPRINTER_INFO_4W)pPrinter;
2042  PPRINTER_INFO_5A ppi5a = (PPRINTER_INFO_5A)pPrinter;
2043  PPRINTER_INFO_5W ppi5w = (PPRINTER_INFO_5W)pPrinter;
2044  PPRINTER_INFO_7A ppi7a = (PPRINTER_INFO_7A)pPrinter;
2045  PPRINTER_INFO_7W ppi7w = (PPRINTER_INFO_7W)pPrinter;
2046  PPRINTER_INFO_9A ppi9a = (PPRINTER_INFO_9A)pPrinter;
2047  PPRINTER_INFO_9W ppi9w = (PPRINTER_INFO_9W)pPrinter;
2048  DWORD cch;
2049 
2050  TRACE("GetPrinterA(%p, %lu, %p, %lu, %p)\n", hPrinter, Level, pPrinter, cbBuf, pcbNeeded);
2051 
2052  // Check for invalid levels here for early error return. Should be 1-9.
2053  if (Level < 1 || Level > 9)
2054  {
2055  dwErrorCode = ERROR_INVALID_LEVEL;
2056  ERR("Invalid Level!\n");
2057  goto Cleanup;
2058  }
2059 
2060  if (!GetPrinterW(hPrinter, Level, pPrinter, cbBuf, pcbNeeded))
2061  {
2062  dwErrorCode = GetLastError();
2063  goto Cleanup;
2064  }
2065 
2066  switch (Level)
2067  {
2068  case 1:
2069  {
2070  if (ppi1w->pDescription)
2071  {
2072  PSTR pszDescription;
2073 
2074  // Convert Unicode pDescription to a ANSI string pszDescription.
2075  cch = wcslen(ppi1w->pDescription);
2076 
2077  pszDescription = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2078  if (!pszDescription)
2079  {
2080  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2081  ERR("HeapAlloc failed!\n");
2082  goto Cleanup;
2083  }
2084 
2085  WideCharToMultiByte(CP_ACP, 0, ppi1w->pDescription, -1, pszDescription, cch + 1, NULL, NULL);
2086  StringCchCopyA(ppi1a->pDescription, cch + 1, pszDescription);
2087 
2088  HeapFree(hProcessHeap, 0, pszDescription);
2089  }
2090 
2091  if (ppi1w->pName)
2092  {
2093  PSTR pszName;
2094 
2095  // Convert Unicode pName to a ANSI string pszName.
2096  cch = wcslen(ppi1w->pName);
2097 
2098  pszName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2099  if (!pszName)
2100  {
2101  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2102  ERR("HeapAlloc failed!\n");
2103  goto Cleanup;
2104  }
2105 
2106  WideCharToMultiByte(CP_ACP, 0, ppi1w->pName, -1, pszName, cch + 1, NULL, NULL);
2107  StringCchCopyA(ppi1a->pName, cch + 1, pszName);
2108 
2109  HeapFree(hProcessHeap, 0, pszName);
2110  }
2111 
2112  if (ppi1w->pComment)
2113  {
2114  PSTR pszComment;
2115 
2116  // Convert Unicode pComment to a ANSI string pszComment.
2117  cch = wcslen(ppi1w->pComment);
2118 
2119  pszComment = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2120  if (!pszComment)
2121  {
2122  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2123  ERR("HeapAlloc failed!\n");
2124  goto Cleanup;
2125  }
2126 
2127  WideCharToMultiByte(CP_ACP, 0, ppi1w->pComment, -1, pszComment, cch + 1, NULL, NULL);
2128  StringCchCopyA(ppi1a->pComment, cch + 1, pszComment);
2129 
2130  HeapFree(hProcessHeap, 0, pszComment);
2131  }
2132  break;
2133  }
2134 
2135  case 2:
2136  {
2137  if (ppi2w->pServerName)
2138  {
2139  PSTR pszServerName;
2140 
2141  // Convert Unicode pServerName to a ANSI string pszServerName.
2142  cch = wcslen(ppi2w->pServerName);
2143 
2144  pszServerName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2145  if (!pszServerName)
2146  {
2147  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2148  ERR("HeapAlloc failed!\n");
2149  goto Cleanup;
2150  }
2151 
2152  WideCharToMultiByte(CP_ACP, 0, ppi2w->pServerName, -1, pszServerName, cch + 1, NULL, NULL);
2153  StringCchCopyA(ppi2a->pServerName, cch + 1, pszServerName);
2154 
2155  HeapFree(hProcessHeap, 0, pszServerName);
2156  }
2157 
2158  if (ppi2w->pPrinterName)
2159  {
2160  PSTR pszPrinterName;
2161 
2162  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
2163  cch = wcslen(ppi2w->pPrinterName);
2164 
2165  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2166  if (!pszPrinterName)
2167  {
2168  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2169  ERR("HeapAlloc failed!\n");
2170  goto Cleanup;
2171  }
2172 
2173  WideCharToMultiByte(CP_ACP, 0, ppi2w->pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
2174  StringCchCopyA(ppi2a->pPrinterName, cch + 1, pszPrinterName);
2175 
2176  HeapFree(hProcessHeap, 0, pszPrinterName);
2177  }
2178 
2179  if (ppi2w->pShareName)
2180  {
2181  PSTR pszShareName;
2182 
2183  // Convert Unicode pShareName to a ANSI string pszShareName.
2184  cch = wcslen(ppi2w->pShareName);
2185 
2186  pszShareName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2187  if (!pszShareName)
2188  {
2189  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2190  ERR("HeapAlloc failed!\n");
2191  goto Cleanup;
2192  }
2193 
2194  WideCharToMultiByte(CP_ACP, 0, ppi2w->pShareName, -1, pszShareName, cch + 1, NULL, NULL);
2195  StringCchCopyA(ppi2a->pShareName, cch + 1, pszShareName);
2196 
2197  HeapFree(hProcessHeap, 0, pszShareName);
2198  }
2199 
2200  if (ppi2w->pPortName)
2201  {
2202  PSTR pszPortName;
2203 
2204  // Convert Unicode pPortName to a ANSI string pszPortName.
2205  cch = wcslen(ppi2w->pPortName);
2206 
2207  pszPortName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2208  if (!pszPortName)
2209  {
2210  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2211  ERR("HeapAlloc failed!\n");
2212  goto Cleanup;
2213  }
2214 
2215  WideCharToMultiByte(CP_ACP, 0, ppi2w->pPortName, -1, pszPortName, cch + 1, NULL, NULL);
2216  StringCchCopyA(ppi2a->pPortName, cch + 1, pszPortName);
2217 
2218  HeapFree(hProcessHeap, 0, pszPortName);
2219  }
2220 
2221  if (ppi2w->pDriverName)
2222  {
2223  PSTR pszDriverName;
2224 
2225  // Convert Unicode pDriverName to a ANSI string pszDriverName.
2226  cch = wcslen(ppi2w->pDriverName);
2227 
2228  pszDriverName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2229  if (!pszDriverName)
2230  {
2231  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2232  ERR("HeapAlloc failed!\n");
2233  goto Cleanup;
2234  }
2235 
2236  WideCharToMultiByte(CP_ACP, 0, ppi2w->pDriverName, -1, pszDriverName, cch + 1, NULL, NULL);
2237  StringCchCopyA(ppi2a->pDriverName, cch + 1, pszDriverName);
2238 
2239  HeapFree(hProcessHeap, 0, pszDriverName);
2240  }
2241 
2242  if (ppi2w->pComment)
2243  {
2244  PSTR pszComment;
2245 
2246  // Convert Unicode pComment to a ANSI string pszComment.
2247  cch = wcslen(ppi2w->pComment);
2248 
2249  pszComment = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2250  if (!pszComment)
2251  {
2252  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2253  ERR("HeapAlloc failed!\n");
2254  goto Cleanup;
2255  }
2256 
2257  WideCharToMultiByte(CP_ACP, 0, ppi2w->pComment, -1, pszComment, cch + 1, NULL, NULL);
2258  StringCchCopyA(ppi2a->pComment, cch + 1, pszComment);
2259 
2260  HeapFree(hProcessHeap, 0, pszComment);
2261  }
2262 
2263  if (ppi2w->pLocation)
2264  {
2265  PSTR pszLocation;
2266 
2267  // Convert Unicode pLocation to a ANSI string pszLocation.
2268  cch = wcslen(ppi2w->pLocation);
2269 
2270  pszLocation = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2271  if (!pszLocation)
2272  {
2273  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2274  ERR("HeapAlloc failed!\n");
2275  goto Cleanup;
2276  }
2277 
2278  WideCharToMultiByte(CP_ACP, 0, ppi2w->pLocation, -1, pszLocation, cch + 1, NULL, NULL);
2279  StringCchCopyA(ppi2a->pLocation, cch + 1, pszLocation);
2280 
2281  HeapFree(hProcessHeap, 0, pszLocation);
2282  }
2283 
2284  if (ppi2w->pSepFile)
2285  {
2286  PSTR pszSepFile;
2287 
2288  // Convert Unicode pSepFile to a ANSI string pszSepFile.
2289  cch = wcslen(ppi2w->pSepFile);
2290 
2291  pszSepFile = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2292  if (!pszSepFile)
2293  {
2294  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2295  ERR("HeapAlloc failed!\n");
2296  goto Cleanup;
2297  }
2298 
2299  WideCharToMultiByte(CP_ACP, 0, ppi2w->pSepFile, -1, pszSepFile, cch + 1, NULL, NULL);
2300  StringCchCopyA(ppi2a->pSepFile, cch + 1, pszSepFile);
2301 
2302  HeapFree(hProcessHeap, 0, pszSepFile);
2303  }
2304 
2305  if (ppi2w->pPrintProcessor)
2306  {
2307  PSTR pszPrintProcessor;
2308 
2309  // Convert Unicode pPrintProcessor to a ANSI string pszPrintProcessor.
2310  cch = wcslen(ppi2w->pPrintProcessor);
2311 
2312  pszPrintProcessor = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2313  if (!pszPrintProcessor)
2314  {
2315  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2316  ERR("HeapAlloc failed!\n");
2317  goto Cleanup;
2318  }
2319 
2320  WideCharToMultiByte(CP_ACP, 0, ppi2w->pPrintProcessor, -1, pszPrintProcessor, cch + 1, NULL, NULL);
2321  StringCchCopyA(ppi2a->pPrintProcessor, cch + 1, pszPrintProcessor);
2322 
2323  HeapFree(hProcessHeap, 0, pszPrintProcessor);
2324  }
2325 
2326  if (ppi2w->pDatatype)
2327  {
2328  PSTR pszDatatype;
2329 
2330  // Convert Unicode pDatatype to a ANSI string pszDatatype.
2331  cch = wcslen(ppi2w->pDatatype);
2332 
2333  pszDatatype = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2334  if (!pszDatatype)
2335  {
2336  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2337  ERR("HeapAlloc failed!\n");
2338  goto Cleanup;
2339  }
2340 
2341  WideCharToMultiByte(CP_ACP, 0, ppi2w->pDatatype, -1, pszDatatype, cch + 1, NULL, NULL);
2342  StringCchCopyA(ppi2a->pDatatype, cch + 1, pszDatatype);
2343 
2344  HeapFree(hProcessHeap, 0, pszDatatype);
2345  }
2346 
2347  if (ppi2w->pParameters)
2348  {
2349  PSTR pszParameters;
2350 
2351  // Convert Unicode pParameters to a ANSI string pszParameters.
2352  cch = wcslen(ppi2w->pParameters);
2353 
2354  pszParameters = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2355  if (!pszParameters)
2356  {
2357  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2358  ERR("HeapAlloc failed!\n");
2359  goto Cleanup;
2360  }
2361 
2362  WideCharToMultiByte(CP_ACP, 0, ppi2w->pParameters, -1, pszParameters, cch + 1, NULL, NULL);
2363  StringCchCopyA(ppi2a->pParameters, cch + 1, pszParameters);
2364 
2365  HeapFree(hProcessHeap, 0, pszParameters);
2366  }
2367  if ( ppi2w->pDevMode )
2368  {
2370  }
2371  break;
2372  }
2373 
2374  case 4:
2375  {
2376  if (ppi4w->pPrinterName)
2377  {
2378  PSTR pszPrinterName;
2379 
2380  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
2381  cch = wcslen(ppi4w->pPrinterName);
2382 
2383  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2384  if (!pszPrinterName)
2385  {
2386  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2387  ERR("HeapAlloc failed!\n");
2388  goto Cleanup;
2389  }
2390 
2391  WideCharToMultiByte(CP_ACP, 0, ppi4w->pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
2392  StringCchCopyA(ppi4a->pPrinterName, cch + 1, pszPrinterName);
2393 
2394  HeapFree(hProcessHeap, 0, pszPrinterName);
2395  }
2396 
2397  if (ppi4w->pServerName)
2398  {
2399  PSTR pszServerName;
2400 
2401  // Convert Unicode pServerName to a ANSI string pszServerName.
2402  cch = wcslen(ppi4w->pServerName);
2403 
2404  pszServerName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2405  if (!pszServerName)
2406  {
2407  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2408  ERR("HeapAlloc failed!\n");
2409  goto Cleanup;
2410  }
2411 
2412  WideCharToMultiByte(CP_ACP, 0, ppi4w->pServerName, -1, pszServerName, cch + 1, NULL, NULL);
2413  StringCchCopyA(ppi4a->pServerName, cch + 1, pszServerName);
2414 
2415  HeapFree(hProcessHeap, 0, pszServerName);
2416  }
2417  break;
2418  }
2419 
2420  case 5:
2421  {
2422  if (ppi5w->pPrinterName)
2423  {
2424  PSTR pszPrinterName;
2425 
2426  // Convert Unicode pPrinterName to a ANSI string pszPrinterName.
2427  cch = wcslen(ppi5w->pPrinterName);
2428 
2429  pszPrinterName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2430  if (!pszPrinterName)
2431  {
2432  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2433  ERR("HeapAlloc failed!\n");
2434  goto Cleanup;
2435  }
2436 
2437  WideCharToMultiByte(CP_ACP, 0, ppi5w->pPrinterName, -1, pszPrinterName, cch + 1, NULL, NULL);
2438  StringCchCopyA(ppi5a->pPrinterName, cch + 1, pszPrinterName);
2439 
2440  HeapFree(hProcessHeap, 0, pszPrinterName);
2441  }
2442 
2443  if (ppi5w->pPortName)
2444  {
2445  PSTR pszPortName;
2446 
2447  // Convert Unicode pPortName to a ANSI string pszPortName.
2448  cch = wcslen(ppi5w->pPortName);
2449 
2450  pszPortName = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2451  if (!pszPortName)
2452  {
2453  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2454  ERR("HeapAlloc failed!\n");
2455  goto Cleanup;
2456  }
2457 
2458  WideCharToMultiByte(CP_ACP, 0, ppi5w->pPortName, -1, pszPortName, cch + 1, NULL, NULL);
2459  StringCchCopyA(ppi5a->pPortName, cch + 1, pszPortName);
2460 
2461  HeapFree(hProcessHeap, 0, pszPortName);
2462  }
2463  break;
2464  }
2465 
2466  case 7:
2467  {
2468  if (ppi7w->pszObjectGUID)
2469  {
2470  PSTR pszaObjectGUID;
2471 
2472  // Convert Unicode pszObjectGUID to a ANSI string pszaObjectGUID.
2473  cch = wcslen(ppi7w->pszObjectGUID);
2474 
2475  pszaObjectGUID = HeapAlloc(hProcessHeap, 0, (cch + 1) * sizeof(CHAR));
2476  if (!pszaObjectGUID)
2477  {
2478  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
2479  ERR("HeapAlloc failed!\n");
2480  goto Cleanup;
2481  }
2482 
2483  WideCharToMultiByte(CP_ACP, 0, ppi7w->pszObjectGUID, -1, pszaObjectGUID, cch + 1, NULL, NULL);
2484  StringCchCopyA(ppi7a->pszObjectGUID, cch + 1, pszaObjectGUID);
2485 
2486  HeapFree(hProcessHeap, 0, pszaObjectGUID);
2487  }
2488  }
2489  break;
2490  case 8:
2491  case 9:
2493  break;
2494  } // switch
2495 
2496  dwErrorCode = ERROR_SUCCESS;
2497 
2498 Cleanup:
2499  SetLastError(dwErrorCode);
2500  return (dwErrorCode == ERROR_SUCCESS);
2501 }
struct _PRINTER_INFO_7A * PPRINTER_INFO_7A
LPSTR pPrinterName
Definition: winspool.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WideCharToMultiByte
Definition: compat.h:111
struct _PRINTER_INFO_2W * PPRINTER_INFO_2W
LPWSTR pDatatype
Definition: winspool.h:72
#define CP_ACP
Definition: compat.h:109
LPSTR pServerName
Definition: winspool.h:38
char CHAR
Definition: xmlstorage.h:175
LPDEVMODEA pDevMode
Definition: winspool.h:166
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
LPDEVMODEW pDevMode
Definition: winspool.h:170
struct _PRINTER_INFO_9W * PPRINTER_INFO_9W
struct _PRINTER_INFO_5A * PPRINTER_INFO_5A
LPSTR pSepFile
Definition: winspool.h:46
LPWSTR pDriverName
Definition: winspool.h:66
LPSTR pShareName
Definition: winspool.h:40
LPWSTR pLocation
Definition: winspool.h:68
struct _PRINTER_INFO_9A * PPRINTER_INFO_9A
LPSTR pComment
Definition: winspool.h:23
LPWSTR pPrinterName
Definition: winspool.h:100
LPWSTR pName
Definition: winspool.h:29
LPWSTR pShareName
Definition: winspool.h:64
LPSTR pServerName
Definition: winspool.h:95
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
LPSTR pDriverName
Definition: winspool.h:42
struct _PRINTER_INFO_2A * PPRINTER_INFO_2A
struct _PRINTER_INFO_1W * PPRINTER_INFO_1W
LPSTR pPrinterName
Definition: winspool.h:94
BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, PBYTE pPrinter, DWORD cbBuf, PDWORD pcbNeeded)
Definition: printers.c:312
LPSTR pPrinterName
Definition: winspool.h:39
void RosConvertUnicodeDevModeToAnsiDevmode(PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput)
Definition: devmode.c:353
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _PRINTER_INFO_1A * PPRINTER_INFO_1A
LPSTR pszObjectGUID
Definition: winspool.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
LPSTR pLocation
Definition: winspool.h:44
LPWSTR pSepFile
Definition: winspool.h:70
LPWSTR pServerName
Definition: winspool.h:62
LPSTR pPortName
Definition: winspool.h:41
LPSTR pDescription
Definition: winspool.h:21
LPWSTR pPrinterName
Definition: winspool.h:118
static const WCHAR Cleanup[]
Definition: register.c:80
LPWSTR pComment
Definition: winspool.h:30
LPDEVMODEW pDevMode
Definition: winspool.h:69
LPDEVMODEA pDevMode
Definition: winspool.h:45
#define ERR(fmt,...)
Definition: debug.h:110
LPWSTR pDescription
Definition: winspool.h:28
LPWSTR pszObjectGUID
Definition: winspool.h:139
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
struct _PRINTER_INFO_4W * PPRINTER_INFO_4W
LPWSTR pPortName
Definition: winspool.h:119
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
LPWSTR pServerName
Definition: winspool.h:101
signed char * PSTR
Definition: retypes.h:7
struct _PRINTER_INFO_5W * PPRINTER_INFO_5W
LPSTR pComment
Definition: winspool.h:43
LPWSTR pPortName
Definition: winspool.h:65
LPSTR pParameters
Definition: winspool.h:49
LPWSTR pPrinterName
Definition: winspool.h:63
LPWSTR pComment
Definition: winspool.h:67
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _PRINTER_INFO_7W * PPRINTER_INFO_7W
LPSTR pDatatype
Definition: winspool.h:48
LPWSTR pParameters
Definition: winspool.h:73
LPWSTR pPrintProcessor
Definition: winspool.h:71
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
struct _PRINTER_INFO_4A * PPRINTER_INFO_4A
LPSTR pPrintProcessor
Definition: winspool.h:47
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by get_printer_infoA(), PRINTDLG_ChangePrinterA(), PrintDlgA(), test_GetPrinter(), and test_OpenPrinter_defaults().

◆ GetPrinterW()

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

Definition at line 2504 of file printers.c.

2505 {
2506  DWORD dwErrorCode;
2507  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
2508 
2509  TRACE("GetPrinterW(%p, %lu, %p, %lu, %p)\n", hPrinter, Level, pPrinter, cbBuf, pcbNeeded);
2510 
2511  // Sanity checks.
2512  if (!pHandle)
2513  {
2514  dwErrorCode = ERROR_INVALID_HANDLE;
2515  goto Cleanup;
2516  }
2517 
2518  // Dismiss invalid levels already at this point.
2519  if (Level > 9)
2520  {
2521  dwErrorCode = ERROR_INVALID_LEVEL;
2522  goto Cleanup;
2523  }
2524 
2525  if (cbBuf && pPrinter)
2526  ZeroMemory(pPrinter, cbBuf);
2527 
2528  // Do the RPC call
2529  RpcTryExcept
2530  {
2531  dwErrorCode = _RpcGetPrinter(pHandle->hPrinter, Level, pPrinter, cbBuf, pcbNeeded);
2532  }
2534  {
2535  dwErrorCode = RpcExceptionCode();
2536  ERR("_RpcGetPrinter failed with exception code %lu!\n", dwErrorCode);
2537  }
2538  RpcEndExcept;
2539 
2540  if (dwErrorCode == ERROR_SUCCESS)
2541  {
2542  // Replace relative offset addresses in the output by absolute pointers.
2543  ASSERT(Level <= 9);
2544  MarshallUpStructure(cbBuf, pPrinter, pPrinterInfoMarshalling[Level]->pInfo, pPrinterInfoMarshalling[Level]->cbStructureSize, TRUE);
2545  }
2546 
2547 Cleanup:
2548  SetLastError(dwErrorCode);
2549  return (dwErrorCode == ERROR_SUCCESS);
2550 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ZeroMemory
Definition: winbase.h:1648
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR Cleanup[]
Definition: register.c:80
BOOL WINAPI MarshallUpStructure(DWORD cbSize, PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:137
#define ERR(fmt,...)
Definition: debug.h:110
static const MARSHALLING * pPrinterInfoMarshalling[]
Definition: printers.h:146
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
DWORD _RpcGetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pPrinter, DWORD cbBuf, DWORD *pcbNeeded)
Definition: printers.c:162
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

Referenced by get_printer_infoW(), pagesetup_change_printer(), PRINTDLG_ChangePrinterW(), PrintDlgW(), START_TEST(), and UpdateTrayIcon().

◆ IntFixUpDevModeNames()

BOOL FASTCALL IntFixUpDevModeNames ( PDOCUMENTPROPERTYHEADER  pdphdr)

Definition at line 815 of file printers.c.

816 {
817  PRINTER_INFO_2W *pi2 = NULL;
818  DWORD needed = 0;
819  BOOL res;
820 
821  if (!(pdphdr->fMode & DM_OUT_BUFFER) ||
822  pdphdr->fMode & DM_NOPERMISSION || // Do not allow the user to modify properties on the displayed property sheet pages.
823  !pdphdr->pdmOut )
824  {
825  return FALSE;
826  }
827 
828  res = GetPrinterW( pdphdr->hPrinter, 2, NULL, 0, &needed);
830  {
831  pi2 = HeapAlloc(hProcessHeap, 0, needed);
832  res = GetPrinterW( pdphdr->hPrinter, 2, (LPBYTE)pi2, needed, &needed);
833  }
834 
835  if (res)
836  {
837  FIXME("IFUDMN : Get Printer Name %S\n",pi2->pPrinterName);
839  pdphdr->pdmOut->dmDeviceName[CCHDEVICENAME-1] = 0;
840  }
841  else
842  {
843  ERR("IFUDMN : GetPrinterW failed with %u\n", GetLastError());
844  }
845  HeapFree(hProcessHeap, 0, pi2);
846  return res;
847 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DM_OUT_BUFFER
Definition: windef.h:359
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define DM_NOPERMISSION
Definition: winddiui.h:139
BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, PBYTE pPrinter, DWORD cbBuf, PDWORD pcbNeeded)
Definition: printers.c:312
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
#define CCHDEVICENAME
Definition: ddrawi.h:63
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1564
GLuint res
Definition: glext.h:9613
LPWSTR pPrinterName
Definition: winspool.h:63
#define HeapFree(x, y, z)
Definition: compat.h:483
HANDLE hProcessHeap
Definition: kbswitch.c:25
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DocumentPropertySheets().

◆ LoadPrinterDriver()

HMODULE WINAPI LoadPrinterDriver ( HANDLE  hspool)

Definition at line 488 of file printers.c.

489 {
490  INT iTries = 0;
491  DWORD Size = (sizeof(WCHAR) * MAX_PATH) * 2; // DRIVER_INFO_5W + plus strings.
494 
495  do
496  {
497  ++iTries;
498 
500 
501  if ( !pdi )
502  break;
503 
504  if ( GetPrinterDriverW(hspool, NULL, 5, (LPBYTE)pdi, Size, &Size) )
505  {
506  TRACE("Level 5 Size %d\n",Size);
507 
508  // Name and load configure library (for example, C:\DRIVERS\Pscrptui.dll). Not printui.dll!
509 
510  hLibrary = LoadLibrary(pdi->pConfigFile);
511 
512  FIXME("IGPD : Get Printer Driver Config File : %S\n",pdi->pConfigFile);
513 
515  return hLibrary;
516  }
517 
519  ++iTries;
520 
522  }
523  while ( iTries < 2 );