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.

153 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. pdevinfo.c
  5. Abstract:
  6. This module contains functions to get / validate the PDEV data structure.
  7. This structure, is initialized by the driver at DrvEnablePDEV time. The
  8. handle (or pointer) to is passed to most of the drivers DrvXXX exported
  9. functions. This is how a driver maintains state, about various items
  10. of interest in the rendering process.
  11. Author:
  12. 30-Nov-1993 Tue 20:37:26 created
  13. [Environment:]
  14. GDI Device Driver - Plotter.
  15. [Notes:]
  16. Revision History:
  17. --*/
  18. #include "precomp.h"
  19. #pragma hdrstop
  20. #define DBG_PLOTFILENAME DbgPDEVInfo
  21. #define DBG_VALIDATE_PDEV 0x00000001
  22. DEFINE_DBGVAR(0);
  23. PPDEV
  24. ValidatePDEVFromSurfObj(
  25. SURFOBJ *pso
  26. )
  27. /*++
  28. Routine Description:
  29. This function validates the PDEV to see if it belong to this driver and
  30. checks to see if it is still usable. It also moves the passed SURFOBJ
  31. in the data structure which is needed for the driver to occasionally call
  32. EngCheckAbort, to see if the job has been cancelled.
  33. Arguments:
  34. pPDev - Pointer to the PDEV data structure to be validate
  35. Return Value:
  36. return the passed in PDEV pointer if sucessful, return NULL if failed,
  37. if it return NULL it will also log the INVALID_HANDLE error code
  38. Author:
  39. 30-Nov-1993 Tue 20:39:12 created
  40. Revision History:
  41. --*/
  42. {
  43. PPDEV pPDev;
  44. pPDev = ((PPDEV)(((SURFOBJ *)pso)->dhpdev));
  45. if (pPDev) {
  46. //
  47. // Look for start marker, size of the data structure, and end marker.
  48. //
  49. if (pPDev->PDEVBegID == PDEV_BEG_ID) {
  50. if (pPDev->SizePDEV == sizeof(PDEV)) {
  51. if (pPDev->PDEVEndID == PDEV_END_ID) {
  52. //
  53. // Okay its valid so record the surfobj so we can call
  54. // EngCheckAbort() in our output functions
  55. //
  56. pPDev->pso = pso;
  57. //
  58. // Check to see if the app or the spooler has canceled
  59. // the job, if it has set our cancel bit and fail this
  60. // call.
  61. //
  62. if (EngCheckAbort(pso)) {
  63. pPDev->Flags |= PDEVF_CANCEL_JOB;
  64. PLOTDBG(DBG_VALIDATE_PDEV,
  65. ("ValidatePDEV: EngCheckAbort returns TRUE"));
  66. return(NULL);
  67. }
  68. return(pPDev);
  69. } else {
  70. PLOTRIP(("ValidatePDEV: Invalid PDEV End ID (%08lx)",
  71. pPDev->PDEVEndID));
  72. }
  73. } else {
  74. PLOTRIP(("ValidatePDEV: Invalid PDEV size (%ld)",
  75. pPDev->SizePDEV));
  76. }
  77. } else {
  78. PLOTRIP(("ValidatePDEV: Invalid PDEV Begin ID (%08lx)",
  79. pPDev->PDEVBegID));
  80. }
  81. } else {
  82. PLOTRIP(("ValidatePDEV: NULL pPDev"));
  83. }
  84. SetLastError(ERROR_INVALID_HANDLE);
  85. return(NULL);
  86. }