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.

193 lines
5.5 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 "oemuni.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_DrvDitherColor, (PFN) OEMDitherColor },
  39. { INDEX_DrvCopyBits, (PFN) OEMCopyBits },
  40. { INDEX_DrvBitBlt, (PFN) OEMBitBlt },
  41. { INDEX_DrvStretchBlt, (PFN) OEMStretchBlt },
  42. { INDEX_DrvTextOut, (PFN) OEMTextOut },
  43. { INDEX_DrvStrokePath, (PFN) OEMStrokePath },
  44. { INDEX_DrvFillPath, (PFN) OEMFillPath },
  45. { INDEX_DrvStrokeAndFillPath, (PFN) OEMStrokeAndFillPath },
  46. { INDEX_DrvPaint, (PFN) OEMPaint },
  47. { INDEX_DrvLineTo, (PFN) OEMLineTo },
  48. { INDEX_DrvStartPage, (PFN) OEMStartPage },
  49. { INDEX_DrvSendPage, (PFN) OEMSendPage },
  50. { INDEX_DrvEscape, (PFN) OEMEscape },
  51. { INDEX_DrvStartDoc, (PFN) OEMStartDoc },
  52. { INDEX_DrvEndDoc, (PFN) OEMEndDoc },
  53. { INDEX_DrvNextBand, (PFN) OEMNextBand },
  54. { INDEX_DrvStartBanding, (PFN) OEMStartBanding },
  55. { INDEX_DrvQueryFont, (PFN) OEMQueryFont },
  56. { INDEX_DrvQueryFontTree, (PFN) OEMQueryFontTree },
  57. { INDEX_DrvQueryFontData, (PFN) OEMQueryFontData },
  58. { INDEX_DrvQueryAdvanceWidths, (PFN) OEMQueryAdvanceWidths },
  59. { INDEX_DrvFontManagement, (PFN) OEMFontManagement },
  60. { INDEX_DrvGetGlyphMode, (PFN) OEMGetGlyphMode },
  61. { INDEX_DrvStretchBltROP, (PFN) OEMStretchBltROP },
  62. { INDEX_DrvPlgBlt, (PFN) OEMPlgBlt },
  63. { INDEX_DrvTransparentBlt, (PFN) OEMTransparentBlt },
  64. { INDEX_DrvAlphaBlend, (PFN) OEMAlphaBlend },
  65. { INDEX_DrvGradientFill, (PFN) OEMGradientFill },
  66. };
  67. PDEVOEM APIENTRY OEMEnablePDEV(
  68. PDEVOBJ pdevobj,
  69. PWSTR pPrinterName,
  70. ULONG cPatterns,
  71. HSURF *phsurfPatterns,
  72. ULONG cjGdiInfo,
  73. GDIINFO *pGdiInfo,
  74. ULONG cjDevInfo,
  75. DEVINFO *pDevInfo,
  76. DRVENABLEDATA *pded // Unidrv's hook table
  77. )
  78. {
  79. POEMPDEV poempdev;
  80. INT i, j;
  81. DWORD dwDDIIndex;
  82. PDRVFN pdrvfn;
  83. VERBOSE(DLLTEXT("OEMEnablePDEV() entry.\r\n"));
  84. //
  85. // Allocate the OEMDev
  86. //
  87. poempdev = new OEMPDEV;
  88. if (NULL == poempdev)
  89. {
  90. return NULL;
  91. }
  92. //
  93. // Fill in OEMDEV as you need
  94. //
  95. //
  96. // Fill in OEMDEV
  97. //
  98. for (i = 0; i < MAX_DDI_HOOKS; i++)
  99. {
  100. //
  101. // search through Unidrv's hooks and locate the function ptr
  102. //
  103. dwDDIIndex = OEMHookFuncs[i].iFunc;
  104. for (j = pded->c, pdrvfn = pded->pdrvfn; j > 0; j--, pdrvfn++)
  105. {
  106. if (dwDDIIndex == pdrvfn->iFunc)
  107. {
  108. poempdev->pfnUnidrv[i] = pdrvfn->pfn;
  109. break;
  110. }
  111. }
  112. if (j == 0)
  113. {
  114. //
  115. // didn't find the Unidrv hook. Should happen only with DrvRealizeBrush
  116. //
  117. poempdev->pfnUnidrv[i] = NULL;
  118. }
  119. }
  120. return (POEMPDEV) poempdev;
  121. }
  122. VOID APIENTRY OEMDisablePDEV(
  123. PDEVOBJ pdevobj
  124. )
  125. {
  126. VERBOSE(DLLTEXT("OEMDisablePDEV() entry.\r\n"));
  127. //
  128. // Free memory for OEMPDEV and any memory block that hangs off OEMPDEV.
  129. //
  130. assert(NULL != pdevobj->pdevOEM);
  131. delete pdevobj->pdevOEM;
  132. }
  133. BOOL APIENTRY OEMResetPDEV(
  134. PDEVOBJ pdevobjOld,
  135. PDEVOBJ pdevobjNew
  136. )
  137. {
  138. VERBOSE(DLLTEXT("OEMResetPDEV() entry.\r\n"));
  139. //
  140. // If you want to carry over anything from old pdev to new pdev, do it here.
  141. //
  142. return TRUE;
  143. }
  144. VOID APIENTRY OEMDisableDriver()
  145. {
  146. VERBOSE(DLLTEXT("OEMDisableDriver() entry.\r\n"));
  147. }
  148. BOOL APIENTRY OEMEnableDriver(DWORD dwOEMintfVersion, DWORD dwSize, PDRVENABLEDATA pded)
  149. {
  150. VERBOSE(DLLTEXT("OEMEnableDriver() entry.\r\n"));
  151. // List DDI functions that are hooked.
  152. pded->iDriverVersion = PRINTER_OEMINTF_VERSION;
  153. pded->c = sizeof(OEMHookFuncs) / sizeof(DRVFN);
  154. pded->pdrvfn = (DRVFN *) OEMHookFuncs;
  155. return TRUE;
  156. }