Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1311 lines
21 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. comoem.cpp
  5. Abstract:
  6. Windows NT Universal Printer Driver OEM Plug-in Sample
  7. Environment:
  8. Windows NT Unidrv driver
  9. Revision History:
  10. Created it.
  11. --*/
  12. #include "pdev.h"
  13. #include "name.h"
  14. #include <initguid.h>
  15. #include <prcomoem.h>
  16. #include <assert.h>
  17. #include "comoem.h"
  18. ///////////////////////////////////////////////////////////
  19. //
  20. // Globals
  21. //
  22. static HANDLE ghInstance = NULL ;
  23. static long g_cComponents = 0 ;
  24. static long g_cServerLocks = 0 ;
  25. ///////////////////////////////////////////////////////////
  26. #include "code.c"
  27. //
  28. // Export functions
  29. //
  30. BOOL APIENTRY
  31. DllMain(
  32. HANDLE hInst,
  33. DWORD dwReason,
  34. void* lpReserved)
  35. /*++
  36. Routine Description:
  37. Dll entry point for initializatoin.
  38. Arguments:
  39. hInst - Dll instance handle
  40. wReason - The reason DllMain was called.
  41. Initialization or termination, for a process or a thread.
  42. lpreserved - Reserved for the system's use
  43. Return Value:
  44. TRUE if successful, FALSE if there is an error
  45. Note:
  46. --*/
  47. {
  48. switch(dwReason)
  49. {
  50. case DLL_PROCESS_ATTACH:
  51. DebugMsg(DLLTEXT("DLLMain: Process attach.\r\n"));
  52. //
  53. // Save DLL instance for use later.
  54. //
  55. ghInstance = hInst;
  56. break;
  57. case DLL_THREAD_ATTACH:
  58. DebugMsg(DLLTEXT("DLLMain: Thread attach.\r\n"));
  59. break;
  60. case DLL_PROCESS_DETACH:
  61. DebugMsg(DLLTEXT("DLLMain: Process detach.\r\n"));
  62. break;
  63. case DLL_THREAD_DETACH:
  64. DebugMsg(DLLTEXT("DLLMain: Thread detach.\r\n"));
  65. break;
  66. }
  67. return TRUE;
  68. }
  69. STDAPI
  70. DllCanUnloadNow()
  71. /*++
  72. Routine Description:
  73. Function to return the status that this dll can be unloaded.
  74. Arguments:
  75. Return Value:
  76. S_OK if it's ok to unload it, S_FALSE if it is used.
  77. Note:
  78. --*/
  79. {
  80. if ((g_cComponents == 0) && (g_cServerLocks == 0))
  81. {
  82. return S_OK ;
  83. }
  84. else
  85. {
  86. return S_FALSE ;
  87. }
  88. }
  89. STDAPI
  90. DllGetClassObject(
  91. const CLSID& clsid,
  92. const IID& iid,
  93. void** ppv)
  94. /*++
  95. Routine Description:
  96. Function to return class factory object
  97. Arguments:
  98. clsid - CLSID for the class object
  99. iid - Reference to the identifier of the interface that communic
  100. ppv - Indirect pointer to the communicating interface
  101. Note:
  102. --*/
  103. {
  104. DebugMsg(DLLTEXT("DllGetClassObject:\tCreate class factory.")) ;
  105. //
  106. // Can we create this component?
  107. //
  108. if (clsid != CLSID_OEMRENDER)
  109. {
  110. return CLASS_E_CLASSNOTAVAILABLE ;
  111. }
  112. //
  113. // Create class factory.
  114. //
  115. IOemCF* pClassFactory = new IOemCF ; // Reference count set to 1
  116. // in constructor
  117. if (pClassFactory == NULL)
  118. {
  119. return E_OUTOFMEMORY ;
  120. }
  121. //
  122. // Get requested interface.
  123. //
  124. HRESULT hr = pClassFactory->QueryInterface(iid, ppv) ;
  125. pClassFactory->Release() ;
  126. return hr ;
  127. }
  128. ////////////////////////////////////////////////////////////////////////////////
  129. //
  130. // Interface Oem CallBack (IPrintOemUNI) body
  131. //
  132. STDMETHODIMP
  133. IOemCB::QueryInterface(
  134. const IID& iid,
  135. void** ppv)
  136. /*++
  137. Routine Description:
  138. IUnknow QueryInterface
  139. Arguments:
  140. iid - Reference to the identifier of the interface that communic
  141. ppv - Indirect pointer to the communicating interface
  142. Note:
  143. --*/
  144. {
  145. DebugMsg(DLLTEXT("IOemCB: QueryInterface entry\n"));
  146. if (iid == IID_IUnknown)
  147. {
  148. *ppv = static_cast<IUnknown*>(this);
  149. DebugMsg(DLLTEXT("IOemCB:Return pointer to IUnknown.\n")) ;
  150. }
  151. else if (iid == IID_IPrintOemUni)
  152. {
  153. *ppv = static_cast<IPrintOemUni*>(this) ;
  154. DebugMsg(DLLTEXT("IOemCB:Return pointer to IPrintOemUni.\n")) ;
  155. }
  156. else
  157. {
  158. *ppv = NULL ;
  159. DebugMsg(DLLTEXT("IOemCB:Return NULL.\n")) ;
  160. return E_NOINTERFACE ;
  161. }
  162. reinterpret_cast<IUnknown*>(*ppv)->AddRef() ;
  163. return S_OK ;
  164. }
  165. STDMETHODIMP_(ULONG)
  166. IOemCB::AddRef()
  167. /*++
  168. Routine Description:
  169. IUnknow AddRef interface
  170. Arguments:
  171. Increment a reference count
  172. Return Value:
  173. Reference count
  174. Note:
  175. --*/
  176. {
  177. DebugMsg(DLLTEXT("IOemCB::AddRef() entry.\r\n"));
  178. return InterlockedIncrement(&m_cRef) ;
  179. }
  180. STDMETHODIMP_(ULONG)
  181. IOemCB::Release()
  182. /*++
  183. Routine Description:
  184. IUnknown Release interface
  185. Arguments:
  186. Decrement a reference count
  187. Return Value:
  188. Reference count
  189. Note:
  190. --*/
  191. {
  192. DebugMsg(DLLTEXT("IOemCB::Release() entry.\r\n"));
  193. if (InterlockedDecrement(&m_cRef) == 0)
  194. {
  195. delete this ;
  196. return 0 ;
  197. }
  198. return m_cRef ;
  199. }
  200. STDMETHODIMP
  201. IOemCB::EnableDriver(
  202. DWORD dwDriverVersion,
  203. DWORD cbSize,
  204. PDRVENABLEDATA pded)
  205. /*++
  206. Routine Description:
  207. Arguments:
  208. Return Value:
  209. Note:
  210. --*/
  211. {
  212. DebugMsg(DLLTEXT("IOemCB::EnableDriver() entry.\r\n"));
  213. return E_NOTIMPL;
  214. }
  215. STDMETHODIMP
  216. IOemCB::DisableDriver(VOID)
  217. /*++
  218. Routine Description:
  219. IPrintOemUni DisableDriver interface
  220. Free all resources, and get prepared to be unloaded.
  221. Arguments:
  222. Return Value:
  223. Note:
  224. --*/
  225. {
  226. DebugMsg(DLLTEXT("IOemCB::DisaleDriver() entry.\r\n"));
  227. return E_NOTIMPL;
  228. }
  229. STDMETHODIMP IOemCB::PublishDriverInterface(
  230. IUnknown *pIUnknown)
  231. /*++
  232. Routine Description:
  233. IPrintOemUni PublishDriverInterface interface
  234. Arguments:
  235. Return Value:
  236. Note:
  237. --*/
  238. {
  239. DebugMsg(DLLTEXT("IOemCB::PublishDriverInterface() entry.\r\n"));
  240. // Need to store pointer to Driver Helper functions, if we already haven't.
  241. if (this->pOEMHelp == NULL)
  242. {
  243. HRESULT hResult;
  244. // Get Interface to Helper Functions.
  245. hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->pOEMHelp));
  246. if(!SUCCEEDED(hResult))
  247. {
  248. // Make sure that interface pointer reflects interface query failure.
  249. this->pOEMHelp = NULL;
  250. return E_FAIL;
  251. }
  252. }
  253. return S_OK;
  254. }
  255. STDMETHODIMP
  256. IOemCB::EnablePDEV(
  257. PDEVOBJ pdevobj,
  258. PWSTR pPrinterName,
  259. ULONG cPatterns,
  260. HSURF *phsurfPatterns,
  261. ULONG cjGdiInfo,
  262. GDIINFO *pGdiInfo,
  263. ULONG cjDevInfo,
  264. DEVINFO *pDevInfo,
  265. DRVENABLEDATA *pded,
  266. OUT PDEVOEM *pDevOem)
  267. /*++
  268. Routine Description:
  269. IPrintOemUni EnablePDEV interface
  270. Construct its own PDEV. At this time, the driver also passes a function
  271. table which contains its own implementation of DDI entrypoints
  272. Arguments:
  273. pdevobj - pointer to a DEVOBJ structure. pdevobj->pdevOEM is undefined.
  274. pPrinterName - name of the current printer.
  275. Cpatterns -
  276. phsurfPatterns -
  277. cjGdiInfo - size of GDIINFO
  278. pGdiInfo - a pointer to GDIINFO
  279. cjDevInfo - size of DEVINFO
  280. pDevInfo - These parameters are identical to what39s passed into DrvEnablePDEV.
  281. pded: points to a function table which contains the system driver39s
  282. implementation of DDI entrypoints.
  283. Return Value:
  284. --*/
  285. {
  286. DebugMsg(DLLTEXT("IOemCB::EnablePDEV() entry.\r\n"));
  287. return E_NOTIMPL;
  288. }
  289. STDMETHODIMP
  290. IOemCB::ResetPDEV(
  291. PDEVOBJ pdevobjOld,
  292. PDEVOBJ pdevobjNew)
  293. /*++
  294. Routine Description:
  295. IPrintOemUni ResetPDEV interface
  296. OEMResetPDEV transfers the state of the driver from the old PDEVOBJ to the
  297. new PDEVOBJ when an application calls ResetDC.
  298. Arguments:
  299. pdevobjOld - pdevobj containing Old PDEV
  300. pdevobjNew - pdevobj containing New PDEV
  301. Return Value:
  302. Note:
  303. --*/
  304. {
  305. DebugMsg(DLLTEXT("IOemCB::ResetPDEV entry.\r\n"));
  306. return E_NOTIMPL;
  307. }
  308. STDMETHODIMP
  309. IOemCB::DisablePDEV(
  310. PDEVOBJ pdevobj)
  311. /*++
  312. Routine Description:
  313. IPrintOemUni DisablePDEV interface
  314. Free resources allocated for the PDEV.
  315. Arguments:
  316. pdevobj -
  317. Return Value:
  318. Note:
  319. --*/
  320. {
  321. DebugMsg(DLLTEXT("IOemCB::DisablePDEV() entry.\r\n"));
  322. return E_NOTIMPL;
  323. };
  324. STDMETHODIMP
  325. IOemCB::GetInfo (
  326. DWORD dwMode,
  327. PVOID pBuffer,
  328. DWORD cbSize,
  329. PDWORD pcbNeeded)
  330. /*++
  331. Routine Description:
  332. IPrintOemUni GetInfo interface
  333. Arguments:
  334. Return Value:
  335. Note:
  336. --*/
  337. {
  338. LPTSTR OEM_INFO[] = { __TEXT("Bad Index"),
  339. __TEXT("OEMGI_GETSIGNATURE"),
  340. __TEXT("OEMGI_GETINTERFACEVERSION"),
  341. __TEXT("OEMGI_GETVERSION"),
  342. };
  343. DebugMsg(DLLTEXT("IOemCB::GetInfo(%s) entry.\r\n"), OEM_INFO[dwMode]);
  344. //
  345. // Validate parameters.
  346. //
  347. if( ( (OEMGI_GETSIGNATURE != dwMode) &&
  348. (OEMGI_GETINTERFACEVERSION != dwMode) &&
  349. (OEMGI_GETVERSION != dwMode) ) ||
  350. (NULL == pcbNeeded)
  351. )
  352. {
  353. DebugMsg(ERRORTEXT("OEMGetInfo() ERROR_INVALID_PARAMETER.\r\n"));
  354. //
  355. // Did not write any bytes.
  356. //
  357. if(NULL != pcbNeeded)
  358. *pcbNeeded = 0;
  359. return E_FAIL;
  360. }
  361. //
  362. // Need/wrote 4 bytes.
  363. //
  364. *pcbNeeded = 4;
  365. //
  366. // Validate buffer size. Minimum size is four bytes.
  367. //
  368. if( (NULL == pBuffer) || (4 > cbSize) )
  369. {
  370. DebugMsg(ERRORTEXT("OEMGetInfo() ERROR_INSUFFICIENT_BUFFER.\r\n"));
  371. return E_FAIL;
  372. }
  373. //
  374. // Write information to buffer.
  375. //
  376. switch(dwMode)
  377. {
  378. case OEMGI_GETSIGNATURE:
  379. *(LPDWORD)pBuffer = OEM_SIGNATURE;
  380. break;
  381. case OEMGI_GETINTERFACEVERSION:
  382. *(LPDWORD)pBuffer = PRINTER_OEMINTF_VERSION;
  383. break;
  384. case OEMGI_GETVERSION:
  385. *(LPDWORD)pBuffer = OEM_VERSION;
  386. break;
  387. }
  388. return S_OK;
  389. }
  390. STDMETHODIMP
  391. IOemCB::GetImplementedMethod(
  392. PSTR pMethodName)
  393. /*++
  394. Routine Description:
  395. IPrintOemUni GetImplementedMethod interface
  396. Arguments:
  397. Return Value:
  398. Note:
  399. --*/
  400. {
  401. LONG lReturn;
  402. DebugMsg(DLLTEXT("IOemCB::GetImplementedMethod() entry.\r\n"));
  403. DebugMsg(DLLTEXT(" Function:%s:"),pMethodName);
  404. lReturn = FALSE;
  405. if (pMethodName != NULL)
  406. {
  407. switch (*pMethodName)
  408. {
  409. case (WCHAR)'F':
  410. if (!strcmp(pstrFilterGraphics, pMethodName))
  411. lReturn = TRUE;
  412. break;
  413. case (WCHAR)'G':
  414. if (!strcmp(pstrGetInfo, pMethodName))
  415. lReturn = TRUE;
  416. break;
  417. }
  418. }
  419. if (lReturn)
  420. {
  421. DebugMsg(__TEXT("Supported\r\n"));
  422. return S_OK;
  423. }
  424. else
  425. {
  426. DebugMsg(__TEXT("NOT supported\r\n"));
  427. return E_FAIL;
  428. }
  429. }
  430. STDMETHODIMP
  431. IOemCB::DevMode(
  432. DWORD dwMode,
  433. POEMDMPARAM pOemDMParam)
  434. /*++
  435. Routine Description:
  436. IPrintOemUni DevMode interface
  437. Arguments:
  438. Return Value:
  439. Note:
  440. --*/
  441. {
  442. DebugMsg(DLLTEXT("IOemCB::DevMode() entry.\r\n"));
  443. return E_NOTIMPL;
  444. }
  445. STDMETHODIMP
  446. IOemCB::CommandCallback(
  447. PDEVOBJ pdevobj,
  448. DWORD dwCallbackID,
  449. DWORD dwCount,
  450. PDWORD pdwParams,
  451. OUT INT *piResult)
  452. /*++
  453. Routine Description:
  454. IPrintOemUni CommandCallback interface
  455. Arguments:
  456. Return Value:
  457. Note:
  458. --*/
  459. {
  460. DebugMsg(DLLTEXT("IOemCB::CommandCallback() entry.\r\n"));
  461. DebugMsg(DLLTEXT(" dwCallbackID = %d\r\n"), dwCallbackID);
  462. DebugMsg(DLLTEXT(" dwCount = %d\r\n"), dwCount);
  463. return E_NOTIMPL;
  464. }
  465. STDMETHODIMP
  466. IOemCB::ImageProcessing(
  467. PDEVOBJ pdevobj,
  468. PBYTE pSrcBitmap,
  469. PBITMAPINFOHEADER pBitmapInfoHeader,
  470. PBYTE pColorTable,
  471. DWORD dwCallbackID,
  472. PIPPARAMS pIPParams,
  473. OUT PBYTE *ppbResult)
  474. /*++
  475. Routine Description:
  476. IPrintOemUni ImageProcessing interface
  477. Arguments:
  478. Return Value:
  479. Note:
  480. --*/
  481. {
  482. DebugMsg(DLLTEXT("IOemCB::ImageProcessing() entry.\r\n"));
  483. return E_NOTIMPL;
  484. }
  485. /********************** Module Header **************************************
  486. * code.c
  487. * Code required for OKI 9 pin printers. The bit order needs
  488. * swapping, and any ETX char needs to be sent twice.
  489. *
  490. * HISTORY:
  491. * 15:26 on Fri 10 Jan 1992 -by- Lindsay Harris [lindsayh]
  492. * Created it.
  493. *
  494. * Ported to NT5 on Weds 29 Oct 1997 -by- Philip Lee [philipl]
  495. *
  496. * Copyright (C) 1999 Microsoft Corporation.
  497. *
  498. **************************************************************************/
  499. STDMETHODIMP
  500. IOemCB::FilterGraphics(
  501. PDEVOBJ pdevobj,
  502. PBYTE pBuf,
  503. DWORD dwLen)
  504. /*++
  505. Routine Description:
  506. IPrintOemUni FilterGraphics interface
  507. Arguments:
  508. Return Value:
  509. Note:
  510. --*/
  511. /*++
  512. Copyright (c) 1996-1999 Microsoft Corporation
  513. Module Name:
  514. citohres.c
  515. Abstract:
  516. Implementation of OEMFilterGraphics callback
  517. Environment:
  518. Windows NT Unidrv driver
  519. Revision History:
  520. 10/09/97 -patryan-
  521. Port code to NT5.0
  522. --*/
  523. {
  524. /*
  525. * Easy to do - translate the input using FlipTable, then call the
  526. * RasDD function WriteSpoolBuf. Also must follow any \003 with
  527. * another one.
  528. */
  529. DWORD dwResult, dwBufLen;
  530. register int iLoop; /* Inner loop counter */
  531. register BYTE *pbOut; /* Destination address */
  532. int iLeft; /* Outer loop counter */
  533. BYTE bLocal[ SZ_LBUF ]; /* For local manipulations */
  534. HRESULT hr;
  535. DebugMsg(DLLTEXT("IOemCB::FilterGraphis() entry.\r\n"));
  536. iLeft = dwLen;
  537. while( iLeft > 0 )
  538. {
  539. iLoop = iLeft > (SZ_LBUF / 2) ? SZ_LBUF / 2 : iLeft;
  540. iLeft -= iLoop;
  541. pbOut = bLocal;
  542. while( --iLoop >= 0 )
  543. {
  544. if( (*pbOut++ = FlipTable[ *pBuf++ ]) == RPT_CHAR )
  545. *pbOut++ = RPT_CHAR;
  546. }
  547. dwBufLen = (DWORD)(pbOut - bLocal);
  548. hr = pOEMHelp->DrvWriteSpoolBuf( pdevobj, bLocal, dwBufLen, &dwResult );
  549. if ( !SUCCEEDED(hr) || (dwResult != dwBufLen) )
  550. return E_FAIL;
  551. }
  552. return S_OK;
  553. }
  554. STDMETHODIMP
  555. IOemCB::Compression(
  556. PDEVOBJ pdevobj,
  557. PBYTE pInBuf,
  558. PBYTE pOutBuf,
  559. DWORD dwInLen,
  560. DWORD dwOutLen,
  561. OUT INT *piResult)
  562. /*++
  563. Routine Description:
  564. IPrintOemUni Compression interface
  565. Arguments:
  566. Return Value:
  567. Note:
  568. --*/
  569. {
  570. DebugMsg(DLLTEXT("IOemCB::Compression() entry.\r\n"));
  571. return E_NOTIMPL;
  572. }
  573. STDMETHODIMP
  574. IOemCB::HalftonePattern(
  575. PDEVOBJ pdevobj,
  576. PBYTE pHTPattern,
  577. DWORD dwHTPatternX,
  578. DWORD dwHTPatternY,
  579. DWORD dwHTNumPatterns,
  580. DWORD dwCallbackID,
  581. PBYTE pResource,
  582. DWORD dwResourceSize)
  583. /*++
  584. Routine Description:
  585. IPrintOemUni HalftonePattern interface
  586. Arguments:
  587. Return Value:
  588. Note:
  589. --*/
  590. {
  591. DebugMsg(DLLTEXT("IOemCB::HalftonePattern() entry.\r\n"));
  592. return E_NOTIMPL;
  593. }
  594. STDMETHODIMP
  595. IOemCB::MemoryUsage(
  596. PDEVOBJ pdevobj,
  597. POEMMEMORYUSAGE pMemoryUsage)
  598. /*++
  599. Routine Description:
  600. IPrintOemUni MemoryUsage interface
  601. Arguments:
  602. Return Value:
  603. Note:
  604. --*/
  605. {
  606. DebugMsg(DLLTEXT("IOemCB::MemoryUsage() entry.\r\n"));
  607. return E_NOTIMPL;
  608. }
  609. STDMETHODIMP
  610. IOemCB::DownloadFontHeader(
  611. PDEVOBJ pdevobj,
  612. PUNIFONTOBJ pUFObj,
  613. OUT DWORD *pdwResult)
  614. /*++
  615. Routine Description:
  616. IPrintOemUni DownloadFontHeader interface
  617. Arguments:
  618. Return Value:
  619. Note:
  620. --*/
  621. {
  622. DebugMsg(DLLTEXT("IOemCB::DownloadFontHeader() entry.\r\n"));
  623. return E_NOTIMPL;
  624. }
  625. STDMETHODIMP
  626. IOemCB::DownloadCharGlyph(
  627. PDEVOBJ pdevobj,
  628. PUNIFONTOBJ pUFObj,
  629. HGLYPH hGlyph,
  630. PDWORD pdwWidth,
  631. OUT DWORD *pdwResult)
  632. /*++
  633. Routine Description:
  634. IPrintOemUni DownloadCharGlyph interface
  635. Arguments:
  636. Return Value:
  637. Note:
  638. --*/
  639. {
  640. DebugMsg(DLLTEXT("IOemCB::DownloadCharGlyph() entry.\r\n"));
  641. return E_NOTIMPL;
  642. }
  643. STDMETHODIMP
  644. IOemCB::TTDownloadMethod(
  645. PDEVOBJ pdevobj,
  646. PUNIFONTOBJ pUFObj,
  647. OUT DWORD *pdwResult)
  648. /*++
  649. Routine Description:
  650. IPrintOemUni TTDownloadMethod interface
  651. Arguments:
  652. Return Value:
  653. Note:
  654. --*/
  655. {
  656. DebugMsg(DLLTEXT("IOemCB::TTDownloadMethod() entry.\r\n"));
  657. return E_NOTIMPL;
  658. }
  659. STDMETHODIMP
  660. IOemCB::OutputCharStr(
  661. PDEVOBJ pdevobj,
  662. PUNIFONTOBJ pUFObj,
  663. DWORD dwType,
  664. DWORD dwCount,
  665. PVOID pGlyph)
  666. /*++
  667. Routine Description:
  668. IPrintOemUni OutputCharStr interface
  669. Arguments:
  670. Return Value:
  671. Note:
  672. --*/
  673. {
  674. DebugMsg(DLLTEXT("IOemCB::OutputCharStr() entry.\r\n"));
  675. return E_NOTIMPL;
  676. }
  677. STDMETHODIMP
  678. IOemCB::SendFontCmd(
  679. PDEVOBJ pdevobj,
  680. PUNIFONTOBJ pUFObj,
  681. PFINVOCATION pFInv)
  682. /*++
  683. Routine Description:
  684. IPrintOemUni SendFontCmd interface
  685. Arguments:
  686. Return Value:
  687. Note:
  688. --*/
  689. {
  690. DebugMsg(DLLTEXT("IOemCB::SendFontCmd() entry.\r\n"));
  691. return E_NOTIMPL;
  692. }
  693. STDMETHODIMP
  694. IOemCB::DriverDMS(
  695. PVOID pDevObj,
  696. PVOID pBuffer,
  697. DWORD cbSize,
  698. PDWORD pcbNeeded)
  699. /*++
  700. Routine Description:
  701. IPrintOemUni DriverDMS interface
  702. Arguments:
  703. Return Value:
  704. Note:
  705. --*/
  706. {
  707. DebugMsg(DLLTEXT("IOemCB::DriverDMS() entry.\r\n"));
  708. return E_NOTIMPL;
  709. }
  710. STDMETHODIMP
  711. IOemCB::TextOutAsBitmap(
  712. SURFOBJ *pso,
  713. STROBJ *pstro,
  714. FONTOBJ *pfo,
  715. CLIPOBJ *pco,
  716. RECTL *prclExtra,
  717. RECTL *prclOpaque,
  718. BRUSHOBJ *pboFore,
  719. BRUSHOBJ *pboOpaque,
  720. POINTL *pptlOrg,
  721. MIX mix)
  722. /*++
  723. Routine Description:
  724. IPrintOemUni TextOutAsBitmap interface
  725. Arguments:
  726. Return Value:
  727. Note:
  728. --*/
  729. {
  730. DebugMsg(DLLTEXT("IOemCB::TextOutAsBitmap() entry.\r\n"));
  731. return E_NOTIMPL;
  732. }
  733. STDMETHODIMP
  734. IOemCB::TTYGetInfo(
  735. PDEVOBJ pdevobj,
  736. DWORD dwInfoIndex,
  737. PVOID pOutputBuf,
  738. DWORD dwSize,
  739. DWORD *pcbcNeeded)
  740. /*++
  741. Routine Description:
  742. IPrintOemUni TTYGetInfo interface
  743. Arguments:
  744. Return Value:
  745. Note:
  746. --*/
  747. {
  748. DebugMsg(DLLTEXT("IOemCB::TTYGetInfo() entry.\r\n"));
  749. return E_NOTIMPL;
  750. }
  751. ///////////////////////////////////////////////////////////
  752. //
  753. // Interface Oem Class factory body
  754. //
  755. STDMETHODIMP
  756. IOemCF::QueryInterface(
  757. const IID& iid,
  758. void** ppv)
  759. /*++
  760. Routine Description:
  761. Class Factory QueryInterface interface
  762. Arguments:
  763. Return Value:
  764. Note:
  765. --*/
  766. {
  767. if ((iid == IID_IUnknown) || (iid == IID_IClassFactory))
  768. {
  769. *ppv = static_cast<IOemCF*>(this) ;
  770. }
  771. else
  772. {
  773. *ppv = NULL ;
  774. return E_NOINTERFACE ;
  775. }
  776. reinterpret_cast<IUnknown*>(*ppv)->AddRef() ;
  777. return S_OK ;
  778. }
  779. STDMETHODIMP_(ULONG)
  780. IOemCF::AddRef()
  781. /*++
  782. Routine Description:
  783. IPrintOemUni AddRef interface
  784. Arguments:
  785. Return Value:
  786. Note:
  787. --*/
  788. {
  789. return InterlockedIncrement(&m_cRef) ;
  790. }
  791. STDMETHODIMP_(ULONG)
  792. IOemCF::Release()
  793. /*++
  794. Routine Description:
  795. IPrintOemUni Release interface
  796. Arguments:
  797. Return Value:
  798. Note:
  799. --*/
  800. {
  801. if (InterlockedDecrement(&m_cRef) == 0)
  802. {
  803. delete this ;
  804. return 0 ;
  805. }
  806. return m_cRef ;
  807. }
  808. STDMETHODIMP
  809. IOemCF::CreateInstance(
  810. IUnknown* pUnknownOuter,
  811. const IID& iid,
  812. void** ppv)
  813. /*++
  814. Routine Description:
  815. IPrintOemUni CreateInstance interface
  816. Arguments:
  817. Return Value:
  818. Note:
  819. --*/
  820. {
  821. DebugMsg(DLLTEXT("Class factory:\t\tCreate component.")) ;
  822. //
  823. // Cannot aggregate.
  824. //
  825. if (pUnknownOuter != NULL)
  826. {
  827. return CLASS_E_NOAGGREGATION ;
  828. }
  829. //
  830. // Create component.
  831. //
  832. IOemCB* pOemCB = new IOemCB ;
  833. if (pOemCB == NULL)
  834. {
  835. return E_OUTOFMEMORY ;
  836. }
  837. //
  838. // Get the requested interface.
  839. //
  840. HRESULT hr = pOemCB->QueryInterface(iid, ppv) ;
  841. //
  842. // Release the IUnknown pointer.
  843. // (If QueryInterface failed, component will delete itself.)
  844. //
  845. pOemCB->Release() ;
  846. return hr ;
  847. }
  848. STDMETHODIMP
  849. IOemCF::LockServer(
  850. BOOL bLock)
  851. /*++
  852. Routine Description:
  853. Class Factory LockServer interface
  854. Arguments:
  855. Return Value:
  856. Note:
  857. --*/
  858. {
  859. if (bLock)
  860. {
  861. InterlockedIncrement(&g_cServerLocks) ;
  862. }
  863. else
  864. {
  865. InterlockedDecrement(&g_cServerLocks) ;
  866. }
  867. return S_OK ;
  868. }
  869. IOemCB::~IOemCB()
  870. {
  871. // Make sure that driver's helper function interface is released.
  872. if(NULL != pOEMHelp)
  873. {
  874. pOEMHelp->Release();
  875. pOEMHelp = NULL;
  876. }
  877. // If this instance of the object is being deleted, then the reference
  878. // count should be zero.
  879. assert(0 == m_cRef);
  880. }