1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
//+--------------------------------------------------------------------------
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved.
//
// FILE: Intrface.cpp
//
// PURPOSE: Generic abstract base class useful for creating implementation
// of interface for Unidrv5 UI plug-ins. This base class
// implements all methods which have a standard implementation
// and / or are optional. Non-optional mathods are pure virtual
// in this base class.
//
//--------------------------------------------------------------------------
#include "precomp.h"
#include "debug.h"
#include "devmode.h"
#include "intrface.h"
// This indicates to Prefast that this is a usermode driver file.
_Analysis_mode_(_Analysis_code_type_user_driver_);
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::QueryInterface
//
// Synopsis:
// Standard COM IUnknown implementation.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::QueryInterface(
CONST IID& iid,
VOID** ppv
)
{
if (iid == IID_IUnknown)
{
*ppv = static_cast<IUnknown*>(this);
}
else if (iid == IID_IPrintOemUI2)
{
*ppv = static_cast<IPrintOemUI2*>(this);
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
reinterpret_cast<IUnknown*>(*ppv)->AddRef();
return S_OK;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::AddRef
//
// Synopsis:
// Standard COM IUnknown implementation.
//
//
//----------------------------------------------------------------------------
ULONG __stdcall
CAbstractOemUI2::AddRef()
{
return InterlockedIncrement(&m_cRef);
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::Release
//
// Synopsis:
// Standard COM IUnknown implementation.
//
//
//----------------------------------------------------------------------------
_At_(this, __drv_freesMem(object))
ULONG __stdcall
CAbstractOemUI2::Release()
{
ASSERT(0 != m_cRef);
ULONG cRef = InterlockedDecrement(&m_cRef);
if (0 == cRef)
{
delete this;
return 0;
}
return cRef;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::HideStandardUI
//
// Synopsis:
// This routine is critical to supporting full UI replacement. This
// routine allows the plug-in to disable Unidrv's (or PScript's) standard
// UI panels. If this returns E_NOTIMPL, the panel isn't hidden. If
// this routine returns S_OK, Unidrv will not display any UI for the
// specified mode. If this returns E_NOTIMPL, Unidrv will display it's
// standard UI.
//
// Returns:
// S_OK to hide the indicated UI if desired, otherwise E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::HideStandardUI(
DWORD dwMode
// document property sheets, printer property sheets, or possibly
// something not yet defined.
)
{
UNREFERENCED_PARAMETER(dwMode);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DocumentPropertySheets
//
// Synopsis:
// A plug-in may optionally add property sheets. If the plug-in has
// chosen to hide the standard UI, then it would instead provide
// replacements for the standard property sheets.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DocumentPropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(pPSUIInfo);
UNREFERENCED_PARAMETER(lParam);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DevicePropertySheets
//
// Synopsis:
// A plug-in may optionally add property sheets. If the plug-in has
// chosen to hide the standard UI, then it would instead provide
// replacements for the standard property sheets.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DevicePropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(pPSUIInfo);
UNREFERENCED_PARAMETER(lParam);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::CommonUIProp
//
// Synopsis:
// This routine is used to interact with the Unidrv-supplied
// property sheet pages. Since this plug-in implements full-UI
// replacement, those property sheet pages are disabled, and this
// routine does not need to do anything.
//
// Returns:
// S_OK
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::CommonUIProp(
DWORD dwMode,
POEMCUIPPARAM pOemCUIPParam
)
{
UNREFERENCED_PARAMETER(dwMode);
UNREFERENCED_PARAMETER(pOemCUIPParam);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DeviceCapabilities
//
// Synopsis:
// This routine can be used to replace the Unidrv's device capabilities
// handling. In this implementation, no custom capabilities handling is
// provided.
//
// Returns:
// E_FAIL
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DeviceCapabilities(
_Inout_ POEMUIOBJ poemuiobj,
// OEM settings & information
_In_ HANDLE hPrinter,
// Handle to the printer that the capabilities are being requested for
_In_ PWSTR pDeviceName,
// Name of the device / driver
WORD wCapability,
// The DC_ ID indicating which capability was requested.
_Out_ PVOID pOutput,
// Buffer to write requested information to.
_In_ PDEVMODE pPublicDM,
// Pointer to the public DEVMODE representing the settings to get
// capabilities with respect to.
_In_ PVOID pOEMDM,
// OEM private DEVMODE settings.
DWORD dwOld,
// Result from previous plug-in call to this routine.
_Out_ DWORD *dwResult
// Result of this call. If there are multiple UI plug-ins, this
// result is passed to the next one as dwOld
)
{
UNREFERENCED_PARAMETER(poemuiobj);
UNREFERENCED_PARAMETER(hPrinter);
UNREFERENCED_PARAMETER(pDeviceName);
UNREFERENCED_PARAMETER(wCapability);
UNREFERENCED_PARAMETER(pOutput);
UNREFERENCED_PARAMETER(pPublicDM);
UNREFERENCED_PARAMETER(pOEMDM);
UNREFERENCED_PARAMETER(dwOld);
UNREFERENCED_PARAMETER(dwResult);
//
// Do nothing. Let Unidrv handle the device capabilities processing.
//
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DevQueryPrintEx
//
// Synopsis:
// This routine is used to determine print job compatibility with the
// current driver. The plug-in can supplement Unidrv's handling of this
// routine. If Unidrv determines that a job can be printed on the current
// printer it will call this routine to ask the plug-in whether it can
// also handle the current job. If Unidrv determines that the job cannot
// be printed, it will not call the plug-in. Additionally, XPS drivers
// built on the Unidrv and PScript UI modules may not recieve this call-
// back.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DevQueryPrintEx(
POEMUIOBJ poemuiobj,
PDEVQUERYPRINT_INFO pDQPInfo,
PDEVMODE pPublicDM,
PVOID pOEMDM
)
{
UNREFERENCED_PARAMETER(poemuiobj);
UNREFERENCED_PARAMETER(pDQPInfo);
UNREFERENCED_PARAMETER(pPublicDM);
UNREFERENCED_PARAMETER(pOEMDM);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::UpgradePrinter
//
// Synopsis:
// Use this callback to upgrade any settings from previous versions
// that are stored in the registry by the plug-in Not applicabe to
// this sample.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::UpgradePrinter(
DWORD dwLevel,
PBYTE pDriverUpgradeInfo
)
{
UNREFERENCED_PARAMETER(dwLevel);
UNREFERENCED_PARAMETER(pDriverUpgradeInfo);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::PrinterEvent
//
// Synopsis:
// Perform any special processing needed when various events occur to the
// print queue.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::PrinterEvent(
_In_ PWSTR pPrinterName,
INT iDriverEvent,
DWORD dwFlags,
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(pPrinterName);
UNREFERENCED_PARAMETER(iDriverEvent);
UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(lParam);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DriverEvent
//
// Synopsis:
// Notifies the plug-in of changes or events relevant to the driver,
// such as installing and upgrading.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DriverEvent(
DWORD dwDriverEvent,
DWORD dwLevel,
LPBYTE pDriverInfo,
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(dwDriverEvent);
UNREFERENCED_PARAMETER(dwLevel);
UNREFERENCED_PARAMETER(pDriverInfo);
UNREFERENCED_PARAMETER(lParam);
return E_NOTIMPL;
};
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::QueryColorProfile
//
// Synopsis:
// This routine can be implemented to provide a color profile from the
// driver.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::QueryColorProfile(
HANDLE hPrinter,
POEMUIOBJ poemuiobj,
PDEVMODE pPublicDM,
PVOID pOEMDM,
ULONG ulQueryMode,
VOID *pvProfileData,
ULONG *pcbProfileData,
FLONG *pflProfileData
)
{
UNREFERENCED_PARAMETER(hPrinter);
UNREFERENCED_PARAMETER(poemuiobj);
UNREFERENCED_PARAMETER(pPublicDM);
UNREFERENCED_PARAMETER(pOEMDM);
UNREFERENCED_PARAMETER(ulQueryMode);
UNREFERENCED_PARAMETER(pvProfileData);
UNREFERENCED_PARAMETER(pcbProfileData);
UNREFERENCED_PARAMETER(pflProfileData);
return E_NOTIMPL;
};
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::FontInstallerDlgProc
//
// Synopsis:
// Plug-ins can use this method to replace Unidrv's provided soft-font
// installer dialog.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::FontInstallerDlgProc(
HWND hWnd,
UINT usMsg,
WPARAM wParam,
LPARAM lParam
)
{
UNREFERENCED_PARAMETER(hWnd);
UNREFERENCED_PARAMETER(usMsg);
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
return E_NOTIMPL;
};
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::UpdateExternalFonts
//
// Synopsis:
// This routine is used to notify the UI of any changes to installed
// font cartridges, primarily for supporting soft-font UI replacement.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::UpdateExternalFonts(
_In_ HANDLE hPrinter,
_In_ HANDLE hHeap,
_In_ PWSTR pwstrCartridges
)
{
UNREFERENCED_PARAMETER(hPrinter);
UNREFERENCED_PARAMETER(hHeap);
UNREFERENCED_PARAMETER(pwstrCartridges);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::QueryJobAttributes
//
// Synopsis:
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::QueryJobAttributes(
HANDLE hPrinter,
PDEVMODE pDevmode,
DWORD dwLevel,
LPBYTE lpAttributeInfo
)
{
UNREFERENCED_PARAMETER(hPrinter);
UNREFERENCED_PARAMETER(pDevmode);
UNREFERENCED_PARAMETER(dwLevel);
UNREFERENCED_PARAMETER(lpAttributeInfo);
return E_NOTIMPL;
}
//+---------------------------------------------------------------------------
//
// Member:
// CAbstractOemUI2::DocumentEvent
//
// Synopsis:
// Perform any special processing needed at various points in time while
// a job is printing.
//
// Implementation of this routine is optional. To indicate that the
// plug-in does not support this call, return E_NOTIMPL.
//
//
//----------------------------------------------------------------------------
HRESULT __stdcall
CAbstractOemUI2::DocumentEvent(
HANDLE hPrinter,
HDC hdc,
INT iEsc,
ULONG cbIn,
PVOID pbIn,
ULONG cbOut,
PVOID pbOut,
PINT piResult
)
{
UNREFERENCED_PARAMETER(hPrinter);
UNREFERENCED_PARAMETER(hdc);
UNREFERENCED_PARAMETER(iEsc);
UNREFERENCED_PARAMETER(cbIn);
UNREFERENCED_PARAMETER(pbIn);
UNREFERENCED_PARAMETER(cbOut);
UNREFERENCED_PARAMETER(pbOut);
UNREFERENCED_PARAMETER(piResult);
return E_NOTIMPL;
}
|