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.

191 lines
5.7 KiB

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright 1998 -2003 Microsoft Corporation. All Rights Reserved.
  7. //
  8. // FILE: Enable.cpp
  9. //
  10. //
  11. // PURPOSE: Enable routines for User Mode COM Customization DLL.
  12. //
  13. //
  14. // Functions:
  15. //
  16. //
  17. //
  18. //
  19. // PLATFORMS: Windows 2000, Windows XP, Windows Server 2003
  20. //
  21. //
  22. #include "precomp.h"
  23. #include "debug.h"
  24. #include "oemps.h"
  25. // StrSafe.h needs to be included last
  26. // to disallow bad string functions.
  27. #include <STRSAFE.H>
  28. ////////////////////////////////////////////////////////
  29. // Internal Constants
  30. ////////////////////////////////////////////////////////
  31. ///////////////////////////////////////////////////////
  32. // Warning: the following array order must match the
  33. // order in enum ENUMHOOKS.
  34. ///////////////////////////////////////////////////////
  35. static const DRVFN OEMHookFuncs[] =
  36. {
  37. { INDEX_DrvRealizeBrush, (PFN) OEMRealizeBrush },
  38. { INDEX_DrvCopyBits, (PFN) OEMCopyBits },
  39. { INDEX_DrvBitBlt, (PFN) OEMBitBlt },
  40. { INDEX_DrvStretchBlt, (PFN) OEMStretchBlt },
  41. { INDEX_DrvTextOut, (PFN) OEMTextOut },
  42. { INDEX_DrvStrokePath, (PFN) OEMStrokePath },
  43. { INDEX_DrvFillPath, (PFN) OEMFillPath },
  44. { INDEX_DrvStrokeAndFillPath, (PFN) OEMStrokeAndFillPath },
  45. { INDEX_DrvStartPage, (PFN) OEMStartPage },
  46. { INDEX_DrvSendPage, (PFN) OEMSendPage },
  47. { INDEX_DrvEscape, (PFN) OEMEscape },
  48. { INDEX_DrvStartDoc, (PFN) OEMStartDoc },
  49. { INDEX_DrvEndDoc, (PFN) OEMEndDoc },
  50. { INDEX_DrvQueryFont, (PFN) OEMQueryFont },
  51. { INDEX_DrvQueryFontTree, (PFN) OEMQueryFontTree },
  52. { INDEX_DrvQueryFontData, (PFN) OEMQueryFontData },
  53. { INDEX_DrvQueryAdvanceWidths, (PFN) OEMQueryAdvanceWidths },
  54. { INDEX_DrvFontManagement, (PFN) OEMFontManagement },
  55. { INDEX_DrvGetGlyphMode, (PFN) OEMGetGlyphMode },
  56. { INDEX_DrvStretchBltROP, (PFN) OEMStretchBltROP },
  57. { INDEX_DrvPlgBlt, (PFN) OEMPlgBlt },
  58. { INDEX_DrvTransparentBlt, (PFN) OEMTransparentBlt },
  59. { INDEX_DrvAlphaBlend, (PFN) OEMAlphaBlend },
  60. { INDEX_DrvGradientFill, (PFN) OEMGradientFill },
  61. { INDEX_DrvIcmCreateColorTransform, (PFN) OEMIcmCreateColorTransform },
  62. { INDEX_DrvIcmDeleteColorTransform, (PFN) OEMIcmDeleteColorTransform },
  63. { INDEX_DrvQueryDeviceSupport, (PFN) OEMQueryDeviceSupport },
  64. };
  65. PDEVOEM APIENTRY OEMEnablePDEV(
  66. PDEVOBJ pdevobj,
  67. PWSTR pPrinterName,
  68. ULONG cPatterns,
  69. HSURF *phsurfPatterns,
  70. ULONG cjGdiInfo,
  71. GDIINFO *pGdiInfo,
  72. ULONG cjDevInfo,
  73. DEVINFO *pDevInfo,
  74. DRVENABLEDATA *pded // Unidrv's hook table
  75. )
  76. {
  77. POEMPDEV poempdev;
  78. INT i, j;
  79. DWORD dwDDIIndex;
  80. PDRVFN pdrvfn;
  81. VERBOSE(DLLTEXT("OEMEnablePDEV() entry.\r\n"));
  82. //
  83. // Allocate the OEMDev
  84. //
  85. poempdev = new OEMPDEV;
  86. if (NULL == poempdev)
  87. {
  88. return NULL;
  89. }
  90. //
  91. // Fill in OEMDEV as you need
  92. //
  93. //
  94. // Fill in OEMDEV
  95. //
  96. for (i = 0; i < MAX_DDI_HOOKS; i++)
  97. {
  98. //
  99. // search through Unidrv's hooks and locate the function ptr
  100. //
  101. dwDDIIndex = OEMHookFuncs[i].iFunc;
  102. for (j = pded->c, pdrvfn = pded->pdrvfn; j > 0; j--, pdrvfn++)
  103. {
  104. if (dwDDIIndex == pdrvfn->iFunc)
  105. {
  106. poempdev->pfnPS[i] = pdrvfn->pfn;
  107. break;
  108. }
  109. }
  110. if (j == 0)
  111. {
  112. //
  113. // didn't find the Unidrv hook. Should happen only with DrvRealizeBrush
  114. //
  115. poempdev->pfnPS[i] = NULL;
  116. }
  117. }
  118. return (POEMPDEV) poempdev;
  119. }
  120. VOID APIENTRY OEMDisablePDEV(
  121. PDEVOBJ pdevobj
  122. )
  123. {
  124. VERBOSE(DLLTEXT("OEMDisablePDEV() entry.\r\n"));
  125. //
  126. // Free memory for OEMPDEV and any memory block that hangs off OEMPDEV.
  127. //
  128. assert(NULL != pdevobj->pdevOEM);
  129. delete pdevobj->pdevOEM;
  130. }
  131. BOOL APIENTRY OEMResetPDEV(
  132. PDEVOBJ pdevobjOld,
  133. PDEVOBJ pdevobjNew
  134. )
  135. {
  136. VERBOSE(DLLTEXT("OEMResetPDEV() entry.\r\n"));
  137. //
  138. // If you want to carry over anything from old pdev to new pdev, do it here.
  139. //
  140. return TRUE;
  141. }
  142. VOID APIENTRY OEMDisableDriver()
  143. {
  144. VERBOSE(DLLTEXT("OEMDisableDriver() entry.\r\n"));
  145. }
  146. BOOL APIENTRY OEMEnableDriver(DWORD dwOEMintfVersion, DWORD dwSize, PDRVENABLEDATA pded)
  147. {
  148. VERBOSE(DLLTEXT("OEMEnableDriver() entry.\r\n"));
  149. // List DDI functions that are hooked.
  150. pded->iDriverVersion = PRINTER_OEMINTF_VERSION;
  151. pded->c = sizeof(OEMHookFuncs) / sizeof(DRVFN);
  152. pded->pdrvfn = (DRVFN *) OEMHookFuncs;
  153. return TRUE;
  154. }