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.

83 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. EmulateGetDeviceCaps.cpp
  5. Abstract:
  6. Fix known incompatibilities in GetDeviceCaps.
  7. Currently we know of:
  8. 1. NUMRESERVED always returns 20 on NT, but on win9x returns 0 in non-
  9. palettized modes. This was considered too great a regression risk to
  10. change the behavior of NT.
  11. Notes:
  12. This is a general purpose shim.
  13. (t-adams) MSDN states that along with NUMRESERVED, both SIZEPALETTE and
  14. COLORRES are valid only if the display is in paletted mode. I've
  15. experimentally determined that SIZEPALETTE always returns 0 in non-paletted
  16. modes, and that COLORRES seems to follow BITSPIXEL. These behaviors don't
  17. seem like they will present any problems since SIZEPALETTE * COLORRES will
  18. be 0.
  19. History:
  20. 02/17/2000 linstev Created
  21. 09/13/2000 t-adams Added to Notes
  22. --*/
  23. #include "precomp.h"
  24. IMPLEMENT_SHIM_BEGIN(EmulateGetDeviceCaps)
  25. #include "ShimHookMacro.h"
  26. APIHOOK_ENUM_BEGIN
  27. APIHOOK_ENUM_ENTRY(GetDeviceCaps)
  28. APIHOOK_ENUM_END
  29. /*++
  30. Check for known problems.
  31. --*/
  32. int
  33. APIHOOK(GetDeviceCaps)(
  34. HDC hdc,
  35. int nIndex
  36. )
  37. {
  38. int iRet = ORIGINAL_API(GetDeviceCaps)(hdc, nIndex);
  39. switch (nIndex)
  40. {
  41. case NUMRESERVED:
  42. if (ORIGINAL_API(GetDeviceCaps)(hdc, BITSPIXEL) > 8) {
  43. iRet = 0;
  44. }
  45. }
  46. return iRet;
  47. }
  48. /*++
  49. Register hooked functions
  50. --*/
  51. HOOK_BEGIN
  52. APIHOOK_ENTRY(GDI32.DLL, GetDeviceCaps)
  53. HOOK_END
  54. IMPLEMENT_SHIM_END